Space cobra 1.1 (#20298)
* space cobra again * didn't see * fix * Dirty * space spider * license * component * sprite update * visibility * fix * fix visibility
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Mobs;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Content.Shared.Stealth.Components;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Timing;
|
||||
@@ -8,6 +10,7 @@ namespace Content.Shared.Stealth;
|
||||
public abstract class SharedStealthSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly MobStateSystem _mobState = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -22,6 +25,7 @@ public abstract class SharedStealthSystem : EntitySystem
|
||||
SubscribeLocalEvent<StealthComponent, ComponentInit>(OnInit);
|
||||
SubscribeLocalEvent<StealthComponent, ExamineAttemptEvent>(OnExamineAttempt);
|
||||
SubscribeLocalEvent<StealthComponent, ExaminedEvent>(OnExamined);
|
||||
SubscribeLocalEvent<StealthComponent, MobStateChangedEvent>(OnMobStateChanged);
|
||||
}
|
||||
|
||||
private void OnExamineAttempt(EntityUid uid, StealthComponent component, ExamineAttemptEvent args)
|
||||
@@ -55,20 +59,34 @@ public abstract class SharedStealthSystem : EntitySystem
|
||||
return;
|
||||
|
||||
component.Enabled = value;
|
||||
Dirty(component);
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
private void OnMobStateChanged(EntityUid uid, StealthComponent component, MobStateChangedEvent args)
|
||||
{
|
||||
if (args.NewMobState == MobState.Dead)
|
||||
{
|
||||
component.Enabled = component.EnabledOnDeath;
|
||||
}
|
||||
else
|
||||
{
|
||||
component.Enabled = true;
|
||||
}
|
||||
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
private void OnPaused(EntityUid uid, StealthComponent component, ref EntityPausedEvent args)
|
||||
{
|
||||
component.LastVisibility = GetVisibility(uid, component);
|
||||
component.LastUpdated = null;
|
||||
Dirty(component);
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
private void OnUnpaused(EntityUid uid, StealthComponent component, ref EntityUnpausedEvent args)
|
||||
{
|
||||
component.LastUpdated = _timing.CurTime;
|
||||
Dirty(component);
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
protected virtual void OnInit(EntityUid uid, StealthComponent component, ComponentInit args)
|
||||
@@ -128,7 +146,7 @@ public abstract class SharedStealthSystem : EntitySystem
|
||||
}
|
||||
|
||||
component.LastVisibility = Math.Clamp(component.LastVisibility + delta, component.MinVisibility, component.MaxVisibility);
|
||||
Dirty(component);
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -144,7 +162,7 @@ public abstract class SharedStealthSystem : EntitySystem
|
||||
if (component.LastUpdated != null)
|
||||
component.LastUpdated = _timing.CurTime;
|
||||
|
||||
Dirty(component);
|
||||
Dirty(uid, component);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user