* Use new Subs.CVar helper Removes manual config OnValueChanged calls, removes need to remember to manually unsubscribe. This both reduces boilerplate and fixes many issues where subscriptions weren't removed on entity system shutdown. * Fix a bunch of warnings * More warning fixes * Use new DateTime serializer to get rid of ISerializationHooks in changelog code. * Get rid of some more ISerializationHooks for enums * And a little more * Apply suggestions from code review Co-authored-by: 0x6273 <0x40@keemail.me> --------- Co-authored-by: 0x6273 <0x40@keemail.me>
32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
using Content.Shared.Actions;
|
|
using Robust.Shared.Network;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Shared.Spider;
|
|
|
|
public abstract class SharedSpiderSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedActionsSystem _action = default!;
|
|
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<SpiderComponent, MapInitEvent>(OnInit);
|
|
SubscribeLocalEvent<SpiderWebObjectComponent, ComponentStartup>(OnWebStartup);
|
|
}
|
|
|
|
private void OnInit(EntityUid uid, SpiderComponent component, MapInitEvent args)
|
|
{
|
|
_action.AddAction(uid, ref component.Action, component.WebAction, uid);
|
|
}
|
|
|
|
private void OnWebStartup(EntityUid uid, SpiderWebObjectComponent component, ComponentStartup args)
|
|
{
|
|
// TODO dont use this. use some general random appearance system
|
|
_appearance.SetData(uid, SpiderWebVisuals.Variant, _robustRandom.Next(1, 3));
|
|
}
|
|
}
|