Skip to content

Commit

Permalink
Add all ComponentStart features to OnMapInit function
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepyyapril committed Dec 30, 2024
1 parent 60382e2 commit 2d2bfec
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions Content.Server/Ghost/GhostSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public override void Initialize()
_ghostQuery = GetEntityQuery<GhostComponent>();
_physicsQuery = GetEntityQuery<PhysicsComponent>();

SubscribeLocalEvent<GhostComponent, ComponentStartup>(OnGhostStartup);
SubscribeLocalEvent<GhostComponent, MapInitEvent>(OnMapInit);
SubscribeLocalEvent<GhostComponent, ComponentShutdown>(OnGhostShutdown);

Expand Down Expand Up @@ -147,24 +146,6 @@ private void OnRelayMoveInput(EntityUid uid, GhostOnMoveComponent component, ref
_ticker.OnGhostAttempt(mindId, component.CanReturn, mind: mind);
}

private void OnGhostStartup(EntityUid uid, GhostComponent component, ComponentStartup args)
{
// Allow this entity to be seen by other ghosts.
var visibility = EnsureComp<VisibilityComponent>(uid);

if (_ticker.RunLevel != GameRunLevel.PostRound)
{
_visibilitySystem.AddLayer((uid, visibility), (int) VisibilityFlags.Ghost, false);
_visibilitySystem.RemoveLayer((uid, visibility), (int) VisibilityFlags.Normal, false);
_visibilitySystem.RefreshVisibility(uid, visibilityComponent: visibility);
}

SetCanSeeGhosts(uid, true);

var time = _gameTiming.CurTime;
component.TimeOfDeath = time;
}

private void OnGhostShutdown(EntityUid uid, GhostComponent component, ComponentShutdown args)
{
// Perf: If the entity is deleting itself, no reason to change these back.
Expand Down Expand Up @@ -197,6 +178,21 @@ private void SetCanSeeGhosts(EntityUid uid, bool canSee, EyeComponent? eyeCompon

private void OnMapInit(EntityUid uid, GhostComponent component, MapInitEvent args)
{
// Allow this entity to be seen by other ghosts.
var visibility = EnsureComp<VisibilityComponent>(uid);

if (_ticker.RunLevel != GameRunLevel.PostRound)
{
_visibilitySystem.AddLayer((uid, visibility), (int) VisibilityFlags.Ghost, false);
_visibilitySystem.RemoveLayer((uid, visibility), (int) VisibilityFlags.Normal, false);
_visibilitySystem.RefreshVisibility(uid, visibilityComponent: visibility);
}

SetCanSeeGhosts(uid, true);

var time = _gameTiming.CurTime;
component.TimeOfDeath = time;

_actions.AddAction(uid, ref component.BooActionEntity, component.BooAction);
_actions.AddAction(uid, ref component.ToggleGhostHearingActionEntity, component.ToggleGhostHearingAction);
_actions.AddAction(uid, ref component.ToggleLightingActionEntity, component.ToggleLightingAction);
Expand Down

0 comments on commit 2d2bfec

Please sign in to comment.