Files
tbd-station-14/Content.Server/GameObjects/Components/RandomSpriteStateComponent.cs
Swept 29d02a3740 Attempts to fix all physics bugs at once (#3610)
* Fixed Rack/Shelf

* Fixes bookshelf, bed

* Placeable for beds for bedsheets

* Bunch of Physics changes, ask metalgearsloth about em'

* More modifications

* More

* Other stuff

* Organizes entities yaml a little bit

* Something new

* Fixed, happy with the state of this rn

* A

* A

* Ye

* E

* Done for now...

* Applied Reviws

* Changes

* Fix the robust commit

* Fixes tests?

* E

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
2021-03-26 12:51:26 +11:00

31 lines
949 B
C#

using System.Collections.Generic;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Random;
using Robust.Shared.Serialization.Manager.Attributes;
namespace Content.Server.GameObjects.Components
{
[RegisterComponent]
public class RandomSpriteStateComponent : Component
{
[Dependency] private readonly IRobustRandom _random = default!;
public override string Name => "RandomSpriteState";
[DataField("spriteStates")]
private List<string>? _spriteStates;
[DataField("spriteLayer")]
private int _spriteLayer;
public override void Initialize()
{
base.Initialize();
if (_spriteStates == null) return;
if (!Owner.TryGetComponent(out SpriteComponent? spriteComponent)) return;
spriteComponent.LayerSetState(_spriteLayer, _random.Pick(_spriteStates));
}
}
}