Action container rejig (#20260)

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
Leon Friedrich
2023-09-23 04:49:39 -04:00
committed by GitHub
parent c80c90ed65
commit 684b334806
50 changed files with 889 additions and 740 deletions

View File

@@ -20,7 +20,7 @@ namespace Content.Server.Bed.Sleep
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<SleepingComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<SleepingComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<SleepingComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<SleepingComponent, SpeakAttemptEvent>(OnSpeakAttempt);
SubscribeLocalEvent<SleepingComponent, CanSeeAttemptEvent>(OnSeeAttempt);
@@ -33,24 +33,20 @@ namespace Content.Server.Bed.Sleep
Dirty(uid, component);
}
private void OnStartup(EntityUid uid, SleepingComponent component, ComponentStartup args)
private void OnMapInit(EntityUid uid, SleepingComponent component, MapInitEvent args)
{
var ev = new SleepStateChangedEvent(true);
RaiseLocalEvent(uid, ev);
_blindableSystem.UpdateIsBlind(uid);
_actionsSystem.AddAction(uid, ref component.WakeAction, WakeActionId, uid);
if (_net.IsClient)
return;
component.WakeAction = Spawn(WakeActionId);
// TODO remove hardcoded time.
_actionsSystem.SetCooldown(component.WakeAction, _gameTiming.CurTime, _gameTiming.CurTime + TimeSpan.FromSeconds(15));
_actionsSystem.AddAction(uid, component.WakeAction.Value, null);
}
private void OnShutdown(EntityUid uid, SleepingComponent component, ComponentShutdown args)
{
_actionsSystem.RemoveAction(uid, component.WakeAction);
var ev = new SleepStateChangedEvent(false);
RaiseLocalEvent(uid, ev);
_blindableSystem.UpdateIsBlind(uid);