using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Robust.Shared.GameStates;
using Robust.Shared.IoC;
using Robust.Shared.ViewVariables;
namespace Robust.Shared.GameObjects;
///
/// The appearance component allows game logic to be more detached from the actual visuals of an entity such as 2D
/// sprites, 3D, particles, lights...
/// It does this with a "data" system. Basically, code writes data to the component, and the component will use
/// prototype-based configuration to change the actual visuals.
/// The data works using a simple key/value system. It is recommended to use enum keys to prevent errors.
/// Visualization works client side with derivatives of the VisualizerSystem class and corresponding components.
///
[RegisterComponent, NetworkedComponent]
public sealed partial class AppearanceComponent : Component
{
///
/// Whether or not the appearance needs to be updated.
///
[ViewVariables] internal bool AppearanceDirty;
///
/// If true, this entity will have its appearance updated in the next frame update.
///
///
/// If an entity is outside of PVS range, this may be false while is true.
///
[ViewVariables] internal bool UpdateQueued;
[ViewVariables] internal Dictionary AppearanceData = new();
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
[Obsolete("Use SharedAppearanceSystem instead")]
public void SetData(Enum key, object value)
{
_sysMan.GetEntitySystem().SetData(Owner, key, value, this);
}
[Obsolete("Use SharedAppearanceSystem instead")]
public bool TryGetData(Enum key, [NotNullWhen(true)] out T data)
{
if (AppearanceData.TryGetValue(key, out var dat) && dat is T)
{
data = (T)dat;
return true;
}
data = default!;
return false;
}
}