Refactor actions to be entities with components (#19900)
This commit is contained in:
@@ -1,20 +1,18 @@
|
||||
using Content.Server.Actions;
|
||||
using Content.Server.Animals.Components;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Content.Shared.Actions.Events;
|
||||
using Content.Shared.Nutrition.Components;
|
||||
using Content.Shared.Nutrition.EntitySystems;
|
||||
using Content.Shared.Storage;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Animals.Systems;
|
||||
|
||||
public sealed class EggLayerSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly ActionsSystem _actions = default!;
|
||||
[Dependency] private readonly AudioSystem _audio = default!;
|
||||
@@ -54,10 +52,10 @@ public sealed class EggLayerSystem : EntitySystem
|
||||
|
||||
private void OnComponentInit(EntityUid uid, EggLayerComponent component, ComponentInit args)
|
||||
{
|
||||
if (!_prototype.TryIndex<InstantActionPrototype>(component.EggLayAction, out var action))
|
||||
if (string.IsNullOrWhiteSpace(component.EggLayAction))
|
||||
return;
|
||||
|
||||
_actions.AddAction(uid, new InstantAction(action), uid);
|
||||
_actions.AddAction(uid, Spawn(component.EggLayAction), uid);
|
||||
component.CurrentEggLayCooldown = _random.NextFloat(component.EggLayCooldownMin, component.EggLayCooldownMax);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user