28 lines
807 B
C#
28 lines
807 B
C#
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Log;
|
|
using Robust.Shared.Random;
|
|
using Robust.Shared.Reflection;
|
|
|
|
namespace Content.Server.RandomAppearance;
|
|
|
|
public sealed class RandomAppearanceSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<RandomAppearanceComponent, ComponentInit>(OnComponentInit);
|
|
}
|
|
|
|
private void OnComponentInit(EntityUid uid, RandomAppearanceComponent component, ComponentInit args)
|
|
{
|
|
if (TryComp(uid, out AppearanceComponent? appearance) && component.EnumKey != null)
|
|
{
|
|
appearance.SetData(component.EnumKey, _random.Pick(component.SpriteStates));
|
|
}
|
|
}
|
|
}
|