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

@@ -16,7 +16,6 @@ using Content.Shared.Mind.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Movement.Events;
using Content.Shared.Roles.Jobs;
using Content.Shared.Storage.Components;
using Robust.Server.GameObjects;
using Robust.Server.Player;
@@ -48,6 +47,7 @@ namespace Content.Server.Ghost
SubscribeLocalEvent<GhostComponent, ComponentStartup>(OnGhostStartup);
SubscribeLocalEvent<GhostComponent, ComponentShutdown>(OnGhostShutdown);
SubscribeLocalEvent<GhostComponent, MapInitEvent>(OnGhostMapInit);
SubscribeLocalEvent<GhostComponent, ExaminedEvent>(OnGhostExamine);
@@ -121,13 +121,7 @@ namespace Content.Server.Ghost
eye.VisibilityMask |= (uint) VisibilityFlags.Ghost;
}
var time = _gameTiming.CurTime;
component.TimeOfDeath = time;
// TODO ghost: remove once ghosts are persistent and aren't deleted when returning to body
if (component.Action.UseDelay != null)
component.Action.Cooldown = (time, time + component.Action.UseDelay.Value);
_actions.AddAction(uid, component.Action, null);
component.TimeOfDeath = _gameTiming.CurTime;
}
private void OnGhostShutdown(EntityUid uid, GhostComponent component, ComponentShutdown args)
@@ -149,10 +143,26 @@ namespace Content.Server.Ghost
eye.VisibilityMask &= ~(uint) VisibilityFlags.Ghost;
}
_actions.RemoveAction(uid, component.Action);
_actions.RemoveAction(uid, component.ActionEntity);
}
}
private void OnGhostMapInit(EntityUid uid, GhostComponent component, MapInitEvent args)
{
// TODO ghost: remove once ghosts are persistent and aren't deleted when returning to body
var time = _gameTiming.CurTime;
var action = _actions.AddAction(uid, ref component.ActionEntity, component.Action);
if (action?.UseDelay != null)
{
action.Cooldown = (time, time + action.UseDelay.Value);
Dirty(component.ActionEntity!.Value, action);
}
_actions.AddAction(uid, ref component.ToggleLightingActionEntity, component.ToggleLightingAction);
_actions.AddAction(uid, ref component.ToggleFoVActionEntity, component.ToggleFoVAction);
_actions.AddAction(uid, ref component.ToggleGhostsActionEntity, component.ToggleGhostsAction);
}
private void OnGhostExamine(EntityUid uid, GhostComponent component, ExaminedEvent args)
{
var timeSinceDeath = _gameTiming.RealTime.Subtract(component.TimeOfDeath);