Fix various IC states not counting as dead (#19049)

This commit is contained in:
Nemanja
2023-08-13 23:34:18 -04:00
committed by GitHub
parent 494a8cd6b4
commit 6a125b55df
5 changed files with 31 additions and 7 deletions

View File

@@ -650,6 +650,15 @@ public sealed class MindSystem : EntitySystem
/// </summary> /// </summary>
public bool IsCharacterDeadIc(Mind mind) public bool IsCharacterDeadIc(Mind mind)
{ {
if (mind.OwnedEntity is { } owned)
{
var ev = new GetCharactedDeadIcEvent(null);
RaiseLocalEvent(owned, ref ev);
if (ev.Dead != null)
return ev.Dead.Value;
}
return IsCharacterDeadPhysically(mind); return IsCharacterDeadPhysically(mind);
} }
@@ -665,3 +674,11 @@ public sealed class MindSystem : EntitySystem
return "(originally " + mind.OriginalOwnerUserId + ")"; return "(originally " + mind.OriginalOwnerUserId + ")";
} }
} }
/// <summary>
/// Raised on an entity to determine whether or not they are "dead" in IC-logic.
/// If not handled, then it will simply check if they are dead physically.
/// </summary>
/// <param name="Dead"></param>
[ByRefEvent]
public record struct GetCharactedDeadIcEvent(bool? Dead);

View File

@@ -24,15 +24,12 @@ namespace Content.Server.Objectives.Conditions
{ {
get get
{ {
var targetName = string.Empty; var targetName = Target?.CharacterName ?? "Unknown";
var jobName = Target?.CurrentJob?.Name ?? "Unknown"; var jobName = Target?.CurrentJob?.Name ?? "Unknown";
if (Target == null) if (Target == null)
return Loc.GetString("objective-condition-kill-person-title", ("targetName", targetName), ("job", jobName)); return Loc.GetString("objective-condition-kill-person-title", ("targetName", targetName), ("job", jobName));
if (Target.OwnedEntity is {Valid: true} owned)
targetName = EntityManager.GetComponent<MetaDataComponent>(owned).EntityName;
return Loc.GetString("objective-condition-kill-person-title", ("targetName", targetName), ("job", jobName)); return Loc.GetString("objective-condition-kill-person-title", ("targetName", targetName), ("job", jobName));
} }
} }

View File

@@ -53,6 +53,7 @@ public sealed partial class BorgSystem : SharedBorgSystem
SubscribeLocalEvent<BorgChassisComponent, PowerCellChangedEvent>(OnPowerCellChanged); SubscribeLocalEvent<BorgChassisComponent, PowerCellChangedEvent>(OnPowerCellChanged);
SubscribeLocalEvent<BorgChassisComponent, PowerCellSlotEmptyEvent>(OnPowerCellSlotEmpty); SubscribeLocalEvent<BorgChassisComponent, PowerCellSlotEmptyEvent>(OnPowerCellSlotEmpty);
SubscribeLocalEvent<BorgChassisComponent, ActivatableUIOpenAttemptEvent>(OnUIOpenAttempt); SubscribeLocalEvent<BorgChassisComponent, ActivatableUIOpenAttemptEvent>(OnUIOpenAttempt);
SubscribeLocalEvent<BorgChassisComponent, GetCharactedDeadIcEvent>(OnGetDeadIC);
SubscribeLocalEvent<BorgBrainComponent, MindAddedMessage>(OnBrainMindAdded); SubscribeLocalEvent<BorgBrainComponent, MindAddedMessage>(OnBrainMindAdded);
@@ -198,6 +199,11 @@ public sealed partial class BorgSystem : SharedBorgSystem
args.Cancel(); args.Cancel();
} }
private void OnGetDeadIC(EntityUid uid, BorgChassisComponent component, ref GetCharactedDeadIcEvent args)
{
args.Dead = true;
}
private void OnBrainMindAdded(EntityUid uid, BorgBrainComponent component, MindAddedMessage args) private void OnBrainMindAdded(EntityUid uid, BorgBrainComponent component, MindAddedMessage args)
{ {
if (!Container.TryGetOuterContainer(uid, Transform(uid), out var container)) if (!Container.TryGetOuterContainer(uid, Transform(uid), out var container))

View File

@@ -7,6 +7,7 @@ using Content.Server.Drone.Components;
using Content.Server.Inventory; using Content.Server.Inventory;
using Content.Shared.Bed.Sleep; using Content.Shared.Bed.Sleep;
using Content.Server.Emoting.Systems; using Content.Server.Emoting.Systems;
using Content.Server.Mind;
using Content.Server.Speech.EntitySystems; using Content.Server.Speech.EntitySystems;
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.Inventory; using Content.Shared.Inventory;
@@ -49,6 +50,7 @@ namespace Content.Server.Zombies
SubscribeLocalEvent<ZombieComponent, MobStateChangedEvent>(OnMobState); SubscribeLocalEvent<ZombieComponent, MobStateChangedEvent>(OnMobState);
SubscribeLocalEvent<ZombieComponent, CloningEvent>(OnZombieCloning); SubscribeLocalEvent<ZombieComponent, CloningEvent>(OnZombieCloning);
SubscribeLocalEvent<ZombieComponent, TryingToSleepEvent>(OnSleepAttempt); SubscribeLocalEvent<ZombieComponent, TryingToSleepEvent>(OnSleepAttempt);
SubscribeLocalEvent<ZombieComponent, GetCharactedDeadIcEvent>(OnGetCharacterDeadIC);
SubscribeLocalEvent<PendingZombieComponent, MapInitEvent>(OnPendingMapInit); SubscribeLocalEvent<PendingZombieComponent, MapInitEvent>(OnPendingMapInit);
@@ -116,6 +118,11 @@ namespace Content.Server.Zombies
args.Cancelled = true; args.Cancelled = true;
} }
private void OnGetCharacterDeadIC(EntityUid uid, ZombieComponent component, ref GetCharactedDeadIcEvent args)
{
args.Dead = true;
}
private void OnStartup(EntityUid uid, ZombieComponent component, ComponentStartup args) private void OnStartup(EntityUid uid, ZombieComponent component, ComponentStartup args)
{ {
if (component.EmoteSoundsId == null) if (component.EmoteSoundsId == null)

View File

@@ -34,9 +34,6 @@
proto: robot proto: robot
- type: Speech - type: Speech
speechSounds: Pai speechSounds: Pai
- type: MobState
allowedStates:
- Alive
- type: ItemSlots - type: ItemSlots
slots: slots:
brain_slot: brain_slot: