35 lines
1.1 KiB
C#
35 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 INetManager _net = default!;
|
|
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<SpiderComponent, ComponentStartup>(OnSpiderStartup);
|
|
SubscribeLocalEvent<SpiderWebObjectComponent, ComponentStartup>(OnWebStartup);
|
|
}
|
|
|
|
private void OnSpiderStartup(EntityUid uid, SpiderComponent component, ComponentStartup args)
|
|
{
|
|
if (_net.IsClient)
|
|
return;
|
|
|
|
_action.AddAction(uid, Spawn(component.WebAction), null);
|
|
}
|
|
|
|
private void OnWebStartup(EntityUid uid, SpiderWebObjectComponent component, ComponentStartup args)
|
|
{
|
|
_appearance.SetData(uid, SpiderWebVisuals.Variant, _robustRandom.Next(1, 3));
|
|
}
|
|
}
|