Refactor actions to be entities with components (#19900)

This commit is contained in:
DrSmugleaf
2023-09-08 18:16:05 -07:00
committed by GitHub
parent e18f731b91
commit c71f97e3a2
210 changed files with 10693 additions and 11714 deletions

View File

@@ -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);
}