2022-05-13 00:59:03 -07:00
|
|
|
|
using Robust.Shared.Random;
|
2022-01-11 19:12:08 -07:00
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.RandomAppearance;
|
|
|
|
|
|
|
2022-02-16 00:23:23 -07:00
|
|
|
|
public sealed class RandomAppearanceSystem : EntitySystem
|
2022-01-11 19:12:08 -07:00
|
|
|
|
{
|
|
|
|
|
|
[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));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|