diff --git a/Robust.Client/Animations/AnimationTrackSpriteFlick.cs b/Robust.Client/Animations/AnimationTrackSpriteFlick.cs index f4f881757..b2cf39793 100644 --- a/Robust.Client/Animations/AnimationTrackSpriteFlick.cs +++ b/Robust.Client/Animations/AnimationTrackSpriteFlick.cs @@ -40,7 +40,7 @@ namespace Robust.Client.Animations DebugTools.AssertNotNull(LayerKey); var entity = (EntityUid) context; - var sprite = IoCManager.Resolve().GetComponent(entity); + var sprite = IoCManager.Resolve().GetComponent(entity); var playingTime = prevPlayingTime + frameTime; var keyFrameIndex = prevKeyFrameIndex; diff --git a/Robust.Client/GameObjects/Components/Renderable/ISpriteComponent.cs b/Robust.Client/GameObjects/Components/Renderable/ISpriteComponent.cs deleted file mode 100644 index 866c73473..000000000 --- a/Robust.Client/GameObjects/Components/Renderable/ISpriteComponent.cs +++ /dev/null @@ -1,227 +0,0 @@ -using System; -using System.Collections.Generic; -using Robust.Client.Graphics; -using Robust.Shared.Animations; -using Robust.Shared.GameObjects; -using Robust.Shared.Maths; -using Robust.Shared.Utility; - -namespace Robust.Client.GameObjects -{ - public interface ISpriteComponent : IComponent, IAnimationProperties - { - void FrameUpdate(float delta); - - bool Visible { get; set; } - - /// - /// Z-index for drawing. - /// - int DrawDepth { get; set; } - - /// - /// A scale applied to all layers. - /// - [Animatable] - Vector2 Scale { get; set; } - - Box2 Bounds { get; } - - /// - /// A rotation applied to all layers. - /// - [Animatable] - Angle Rotation { get; set; } - - /// - /// Offset applied to all layers. - /// - [Animatable] - Vector2 Offset { get; set; } - - /// - /// Color to multiply all layers with. - /// - [Animatable] - Color Color { get; set; } - - /// - /// All sprite rotation is locked, and will always be drawn upright on - /// the screen, regardless of world or view orientation. - /// - bool NoRotation {get; set; } - - /// - /// Enables overriding the calculated directional RSI state for this sprite. - /// The state to use is defined in . - /// - bool EnableDirectionOverride { get; set; } - - /// - /// The directional RSI state that will always be displayed, regardless of orientation. - /// - Direction DirectionOverride { get; set; } - - // NOTE: The below are ALL designed to NOT throw exceptions ever, - // instead making a bunch of noisy error logs. - - /// - /// The RSI that is currently used as "base". - /// Layers will fall back to this RSI if they do not have their own RSI set. - /// - RSI? BaseRSI { get; set; } - - ShaderInstance? PostShader { get; set; } - uint RenderOrder { get; set; } - bool IsInert { get; } - - Matrix3 GetLocalMatrix(); - - /// - /// Sets a layer key to the layer map, creating it if it does not exist. - /// - /// The key for this entry. - /// The layer this entry points to. - /// - /// Thrown if does not exist. - /// - /// - /// Thrown if is null. - /// - void LayerMapSet(object key, int layer); - - /// - /// Removes an entry from the layer map. - /// - /// The key to remove. - /// - /// Thrown if is null. - /// - void LayerMapRemove(object key); - - /// - /// Gets the index of a layer specified in the layer map. - /// - /// The key for the entry to look up. - /// - /// Thrown if is null. - /// - int LayerMapGet(object key); - - /// - /// Thrown if is null. - /// - bool LayerMapTryGet(object key, out int layer, bool logError = false); - - /// - /// Create a new blank layer and add it to the layer map, - /// only if the key does not already exist on the layer map. - /// - /// - /// This is useful to allow layer map configs to be defined in prototypes, - /// while still allowing code to create configs if they're absent. - /// - /// Index of the new layer. - int LayerMapReserveBlank(object key); - - /// - /// Adds a layer without texture (thus falling back to the error texture). - /// The layer defaults to invisible. - /// - /// If not null, the index of this new layer. - /// Index of the new layer. - int AddBlankLayer(int? newIndex = null); - - int AddLayer(Texture texture, int? newIndex = null); - int AddLayer(string texturePath, int? newIndex = null); - int AddLayer(ResourcePath texturePath, int? newIndex = null); - int AddLayer(RSI.StateId stateId, int? newIndex = null); - int AddLayerState(string stateId, int? newIndex = null); - int AddLayer(RSI.StateId stateId, RSI rsi, int? newIndex = null); - int AddLayerState(string stateId, RSI rsi, int? newIndex = null); - int AddLayer(RSI.StateId stateId, string rsiPath, int? newIndex = null); - int AddLayerState(string stateId, string rsiPath, int? newIndex = null); - int AddLayer(RSI.StateId stateId, ResourcePath rsiPath, int? newIndex = null); - int AddLayerState(string stateId, ResourcePath rsiPath, int? newIndex = null); - int AddLayer(SpriteSpecifier specifier, int? newIndex = null); - - void RemoveLayer(int layer); - void RemoveLayer(object layerKey); - - void LayerSetShader(int layer, ShaderInstance shader, string? prototype = null); - void LayerSetShader(object layerKey, ShaderInstance shader, string? prototype = null); - void LayerSetShader(int layer, string shaderName); - void LayerSetShader(object layerKey, string shaderName); - - void LayerSetSprite(int layer, SpriteSpecifier specifier); - void LayerSetSprite(object layerKey, SpriteSpecifier specifier); - - void LayerSetTexture(int layer, Texture texture); - void LayerSetTexture(object layerKey, Texture texture); - void LayerSetTexture(int layer, string texturePath); - void LayerSetTexture(object layerKey, string texturePath); - void LayerSetTexture(int layer, ResourcePath texturePath); - void LayerSetTexture(object layerKey, ResourcePath texturePath); - - void LayerSetState(int layer, RSI.StateId stateId); - void LayerSetState(object layerKey, RSI.StateId stateId); - void LayerSetState(int layer, RSI.StateId stateId, RSI rsi); - void LayerSetState(object layerKey, RSI.StateId stateId, RSI rsi); - void LayerSetState(int layer, RSI.StateId stateId, string rsiPath); - void LayerSetState(object layerKey, RSI.StateId stateId, string rsiPath); - void LayerSetState(int layer, RSI.StateId stateId, ResourcePath rsiPath); - void LayerSetState(object layerKey, RSI.StateId stateId, ResourcePath rsiPath); - - void LayerSetRSI(int layer, RSI rsi); - void LayerSetRSI(object layerKey, RSI rsi); - void LayerSetRSI(int layer, string rsiPath); - void LayerSetRSI(object layerKey, string rsiPath); - void LayerSetRSI(int layer, ResourcePath rsiPath); - void LayerSetRSI(object layerKey, ResourcePath rsiPath); - - void LayerSetScale(int layer, Vector2 scale); - void LayerSetScale(object layerKey, Vector2 scale); - void LayerSetRotation(int layer, Angle rotation); - void LayerSetRotation(object layerKey, Angle rotation); - void LayerSetVisible(int layer, bool visible); - void LayerSetVisible(object layerKey, bool visible); - void LayerSetColor(int layer, Color color); - - void LayerSetColor(object layerKey, Color color); - - // Yes, I realize how silly it is to reference an enum in the concrete implementation. - // I don't care. - void LayerSetDirOffset(int layer, SpriteComponent.DirectionOffset offset); - void LayerSetDirOffset(object layerKey, SpriteComponent.DirectionOffset offset); - - void LayerSetAnimationTime(int layer, float animationTime); - void LayerSetAnimationTime(object layerKey, float animationTime); - void LayerSetAutoAnimated(int layer, bool autoAnimated); - void LayerSetAutoAnimated(object layerKey, bool autoAnimated); - - RSI.StateId LayerGetState(int layer); - - /// - /// Get the RSI used by a layer. - /// - RSI? LayerGetActualRSI(int layer); - - /// - /// Get the RSI used by a layer. - /// - RSI? LayerGetActualRSI(object layerKey); - - ISpriteLayer this[int layer] { get; } - ISpriteLayer this[Index layer] { get; } - ISpriteLayer this[object layerKey] { get; } - - IEnumerable AllLayers { get; } - - int GetLayerDirectionCount(ISpriteLayer layer); - - /// - /// Calculate the rotated sprite bounding box in world-space coordinates. - /// - Box2Rotated CalculateRotatedBoundingBox(Vector2 worldPosition, Angle worldRotation, Angle eye); - } -} diff --git a/Robust.Client/GameObjects/Components/Renderable/SpriteComponent.cs b/Robust.Client/GameObjects/Components/Renderable/SpriteComponent.cs index 0b8fd3cf9..f8b9da330 100644 --- a/Robust.Client/GameObjects/Components/Renderable/SpriteComponent.cs +++ b/Robust.Client/GameObjects/Components/Renderable/SpriteComponent.cs @@ -30,9 +30,8 @@ using RSIDirection = Robust.Client.Graphics.RSI.State.Direction; namespace Robust.Client.GameObjects { [ComponentReference(typeof(SharedSpriteComponent))] - [RegisterComponent, ComponentReference(typeof(ISpriteComponent))] - public sealed class SpriteComponent : SharedSpriteComponent, ISpriteComponent, - IComponentDebug, ISerializationHooks, IComponentTreeEntry + [RegisterComponent] + public sealed class SpriteComponent : SharedSpriteComponent, IComponentDebug, ISerializationHooks, IComponentTreeEntry, IAnimationProperties { [Dependency] private readonly IResourceCache resourceCache = default!; [Dependency] private readonly IPrototypeManager prototypes = default!; diff --git a/Robust.Client/GameObjects/EntitySystems/SpriteSystem.cs b/Robust.Client/GameObjects/EntitySystems/SpriteSystem.cs index 6b56bea59..44157a0a1 100644 --- a/Robust.Client/GameObjects/EntitySystems/SpriteSystem.cs +++ b/Robust.Client/GameObjects/EntitySystems/SpriteSystem.cs @@ -24,7 +24,7 @@ namespace Robust.Client.GameObjects [Dependency] private readonly TransformSystem _transform = default!; private readonly Queue _inertUpdateQueue = new(); - private HashSet _manualUpdate = new(); + private HashSet _manualUpdate = new(); public override void Initialize() { @@ -84,7 +84,7 @@ namespace Robust.Client.GameObjects var spriteState = (frameTime, _manualUpdate); _treeSystem.QueryAabb( ref spriteState, static (ref (float frameTime, - HashSet _manualUpdate) tuple, in ComponentTreeEntry value) => + HashSet _manualUpdate) tuple, in ComponentTreeEntry value) => { if (value.Component.IsInert) return true; @@ -101,7 +101,7 @@ namespace Robust.Client.GameObjects /// /// Force update of the sprite component next frame /// - public void ForceUpdate(ISpriteComponent sprite) + public void ForceUpdate(SpriteComponent sprite) { _manualUpdate.Add(sprite); } diff --git a/Robust.Client/Placement/Modes/AlignSimilar.cs b/Robust.Client/Placement/Modes/AlignSimilar.cs index 42411cdce..72eb59671 100644 --- a/Robust.Client/Placement/Modes/AlignSimilar.cs +++ b/Robust.Client/Placement/Modes/AlignSimilar.cs @@ -43,7 +43,7 @@ namespace Robust.Client.Placement.Modes var closestEntity = snapToEntities[0]; var closestTransform = pManager.EntityManager.GetComponent(closestEntity); - if (!pManager.EntityManager.TryGetComponent(closestEntity, out var component) || component.BaseRSI == null) + if (!pManager.EntityManager.TryGetComponent(closestEntity, out var component) || component.BaseRSI == null) { return; } diff --git a/Robust.Client/UserInterface/Controls/SpriteView.cs b/Robust.Client/UserInterface/Controls/SpriteView.cs index b750ed294..2f044cf0d 100644 --- a/Robust.Client/UserInterface/Controls/SpriteView.cs +++ b/Robust.Client/UserInterface/Controls/SpriteView.cs @@ -25,7 +25,7 @@ namespace Robust.Client.UserInterface.Controls } [ViewVariables] - public ISpriteComponent? Sprite { get; set; } + public SpriteComponent? Sprite { get; set; } /// /// Overrides the direction used to render the sprite. diff --git a/Robust.Client/ViewVariables/Instances/ViewVariablesInstanceEntity.cs b/Robust.Client/ViewVariables/Instances/ViewVariablesInstanceEntity.cs index 41e8bd7ff..3e5d6ef3b 100644 --- a/Robust.Client/ViewVariables/Instances/ViewVariablesInstanceEntity.cs +++ b/Robust.Client/ViewVariables/Instances/ViewVariablesInstanceEntity.cs @@ -108,7 +108,7 @@ namespace Robust.Client.ViewVariables.Instances top = new Label {Text = stringified}; } - if (_entityManager.TryGetComponent(_entity, out ISpriteComponent? sprite)) + if (_entityManager.TryGetComponent(_entity, out SpriteComponent? sprite)) { var hBox = new BoxContainer {