Refactor actions to be entities with components (#19900)
This commit is contained in:
@@ -2,9 +2,9 @@ using Content.Server.Actions;
|
||||
using Content.Server.Bed.Components;
|
||||
using Content.Server.Bed.Sleep;
|
||||
using Content.Server.Body.Systems;
|
||||
using Content.Server.Construction;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Content.Shared.Bed;
|
||||
using Content.Shared.Bed.Sleep;
|
||||
using Content.Shared.Body.Components;
|
||||
@@ -12,9 +12,7 @@ using Content.Shared.Buckle.Components;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Emag.Components;
|
||||
using Content.Shared.Emag.Systems;
|
||||
using Content.Server.Construction;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server.Bed
|
||||
@@ -23,7 +21,6 @@ namespace Content.Server.Bed
|
||||
{
|
||||
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
|
||||
[Dependency] private readonly ActionsSystem _actionsSystem = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly SleepingSystem _sleepingSystem = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
|
||||
@@ -42,18 +39,17 @@ namespace Content.Server.Bed
|
||||
|
||||
private void ManageUpdateList(EntityUid uid, HealOnBuckleComponent component, ref BuckleChangeEvent args)
|
||||
{
|
||||
_prototypeManager.TryIndex<InstantActionPrototype>("Sleep", out var sleepAction);
|
||||
if (args.Buckling)
|
||||
{
|
||||
AddComp<HealOnBuckleHealingComponent>(uid);
|
||||
component.NextHealTime = _timing.CurTime + TimeSpan.FromSeconds(component.HealTime);
|
||||
if (sleepAction != null)
|
||||
_actionsSystem.AddAction(args.BuckledEntity, new InstantAction(sleepAction), null);
|
||||
component.SleepAction = Spawn(SleepingSystem.SleepActionId);
|
||||
_actionsSystem.AddAction(args.BuckledEntity, component.SleepAction.Value, null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (sleepAction != null)
|
||||
_actionsSystem.RemoveAction(args.BuckledEntity, sleepAction);
|
||||
if (component.SleepAction != null)
|
||||
_actionsSystem.RemoveAction(args.BuckledEntity, component.SleepAction.Value);
|
||||
|
||||
_sleepingSystem.TryWaking(args.BuckledEntity);
|
||||
RemComp<HealOnBuckleHealingComponent>(uid);
|
||||
|
||||
Reference in New Issue
Block a user