ECS AsteroidRock and add a doafter to mining (#6120)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
27
Content.Server/RandomAppearance/RandomAppearanceSystem.cs
Normal file
27
Content.Server/RandomAppearance/RandomAppearanceSystem.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
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 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user