diff --git a/Content.Server/Mobs/Mind.cs b/Content.Server/Mobs/Mind.cs index c2cc2358e5..3ffc1afe56 100644 --- a/Content.Server/Mobs/Mind.cs +++ b/Content.Server/Mobs/Mind.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; +using Content.Shared.GameObjects.Components.Mobs.State; using Content.Server.GameObjects.Components.Mobs; using Content.Server.GameObjects.Components.Observer; using Content.Server.Mobs.Roles; @@ -106,6 +107,41 @@ namespace Content.Server.Mobs } } + /// + /// True if this Mind is 'sufficiently dead' IC (objectives, endtext). + /// Note that this is *IC logic*, it's not necessarily tied to any specific truth. + /// "If administrators decide that zombies are dead, this returns true for zombies." + /// (Maybe you were looking for the action blocker system?) + /// + [ViewVariables] + public bool CharacterDeadIC + { + get + { + // This is written explicitly so that the logic can be understood. + // But it's also weird and potentially situational. + // Specific considerations when updating this: + // + Does being turned into a borg (if/when implemented) count as dead? + // *If not, add specific conditions to users of this property where applicable.* + // + Is being transformed into a donut 'dead'? + // TODO: Consider changing the way ghost roles work. + // Mind is an *IC* mind, therefore ghost takeover is IC revival right now. + // + Is it necessary to have a reference to a specific 'mind iteration' to cycle when certain events happen? + // (If being a borg or AI counts as dead, then this is highly likely, as it's still the same Mind for practical purposes.) + + // This can be null if they're deleted (spike / brain nom) + if (OwnedEntity == null) + return true; + var targetMobState = OwnedEntity.GetComponentOrNull(); + // This can be null if it's a brain (this happens very often) + // Brains are the result of gibbing so should definitely count as dead + if (targetMobState == null) + return true; + // They might actually be alive. + return targetMobState.IsDead(); + } + } + /// /// Gives this mind a new role. /// diff --git a/Content.Server/Objectives/Conditions/DieCondition.cs b/Content.Server/Objectives/Conditions/DieCondition.cs index 46562820e5..7883f77557 100644 --- a/Content.Server/Objectives/Conditions/DieCondition.cs +++ b/Content.Server/Objectives/Conditions/DieCondition.cs @@ -20,18 +20,13 @@ namespace Content.Server.Objectives.Conditions return new DieCondition {_mind = mind}; } - public string Title => Loc.GetString("Die a glorius death"); + public string Title => Loc.GetString("Die a glorious death"); public string Description => Loc.GetString("Die."); public SpriteSpecifier Icon => new SpriteSpecifier.Rsi(new ResourcePath("Mobs/Ghosts/ghost_human.rsi"), "icon"); - public float Progress => _mind? - .OwnedEntity? - .GetComponentOrNull()? - .IsDead() ?? false - ? 0f - : 1f; + public float Progress => (_mind?.CharacterDeadIC ?? true) ? 1f : 0f; public float Difficulty => 1f; diff --git a/Content.Server/Objectives/Conditions/KillPersonCondition.cs b/Content.Server/Objectives/Conditions/KillPersonCondition.cs index 3ab9e13813..fd2e76d5e4 100644 --- a/Content.Server/Objectives/Conditions/KillPersonCondition.cs +++ b/Content.Server/Objectives/Conditions/KillPersonCondition.cs @@ -18,37 +18,7 @@ namespace Content.Server.Objectives.Conditions public SpriteSpecifier Icon => new SpriteSpecifier.Rsi(new ResourcePath("Objects/Weapons/Guns/Pistols/mk58_wood.rsi"), "icon"); - public float Progress - { - get - { - // This is written explicitly so that the logic can be understood. - // The previous form was "cleaner" but also didn't work because any failure meant the person was "not dead". - // It may be an idea to move all this logic to Mind, as, say, "Mind.CharacterDead". - // But it's also weird and potentially situational. - // Specific considerations when updating this: - // + Does being turned into a borg (if/when implemented) count as dead? - // + Is being transformed into a donut 'dead'? - // + *Ghost roles definitely shouldn't count as alive.* - // + Is it necessary to have a reference to a specific 'mind iteration' to cycle when certain events happen? - // (If being a borg or AI counts as dead, then this is highly likely, as it's still the same Mind for practical purposes.) - - // This shouldn't be possible but assume dead just so the invalid goal doesn't do anything annoying. - if (Target == null) - return 1f; - var targetOwnedEntity = Target.OwnedEntity; - // This can be null if they're deleted (spike / brain nom) - if (targetOwnedEntity == null) - return 1f; - var targetMobState = targetOwnedEntity.GetComponentOrNull(); - // This can be null if it's a brain (this happens very often) - // Brains are the result of gibbing so should definitely count as dead - if (targetMobState == null) - return 1f; - // They might actually be alive. - return targetMobState.IsDead() ? 1f : 0f; - } - } + public float Progress => (Target?.CharacterDeadIC ?? true) ? 1f : 0f; public float Difficulty => 2f; diff --git a/Content.Server/Objectives/Conditions/StayAliveCondition.cs b/Content.Server/Objectives/Conditions/StayAliveCondition.cs index 953d87a281..05be5ba368 100644 --- a/Content.Server/Objectives/Conditions/StayAliveCondition.cs +++ b/Content.Server/Objectives/Conditions/StayAliveCondition.cs @@ -26,12 +26,7 @@ namespace Content.Server.Objectives.Conditions public SpriteSpecifier Icon => new SpriteSpecifier.Rsi(new ResourcePath("Objects/Misc/skub.rsi"), "icon"); //didn't know what else would have been a good icon for staying alive - public float Progress => _mind? - .OwnedEntity? - .GetComponentOrNull()? - .IsDead() ?? false - ? 0f - : 1f; + public float Progress => (_mind?.CharacterDeadIC ?? false) ? 0f : 1f; public float Difficulty => 1f;