Prevent non-inital infected from getting the succumb to zombie action (#27820)

* b

* Update ZombieRuleSystem.cs

* hi
This commit is contained in:
Mr. 27
2024-05-09 17:45:23 -04:00
committed by GitHub
parent 4231efc780
commit fe5f4162ac
4 changed files with 17 additions and 11 deletions

View File

@@ -35,7 +35,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem<ZombieRuleComponent>
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<PendingZombieComponent, ZombifySelfActionEvent>(OnZombifySelf); SubscribeLocalEvent<IncurableZombieComponent, ZombifySelfActionEvent>(OnZombifySelf);
} }
protected override void AppendRoundEndText(EntityUid uid, ZombieRuleComponent component, GameRuleComponent gameRule, protected override void AppendRoundEndText(EntityUid uid, ZombieRuleComponent component, GameRuleComponent gameRule,
@@ -128,7 +128,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem<ZombieRuleComponent>
component.NextRoundEndCheck = _timing.CurTime + component.EndCheckDelay; component.NextRoundEndCheck = _timing.CurTime + component.EndCheckDelay;
} }
private void OnZombifySelf(EntityUid uid, PendingZombieComponent component, ZombifySelfActionEvent args) private void OnZombifySelf(EntityUid uid, IncurableZombieComponent component, ZombifySelfActionEvent args)
{ {
_zombie.ZombifyEntity(uid); _zombie.ZombifyEntity(uid);
if (component.Action != null) if (component.Action != null)

View File

@@ -1,10 +1,16 @@
namespace Content.Server.Zombies; using Robust.Shared.Prototypes;
namespace Content.Server.Zombies;
/// <summary> /// <summary>
/// This is used for a zombie that cannot be cured by any methods. /// This is used for a zombie that cannot be cured by any methods. Gives a succumb to zombie infection action.
/// </summary> /// </summary>
[RegisterComponent] [RegisterComponent]
public sealed partial class IncurableZombieComponent : Component public sealed partial class IncurableZombieComponent : Component
{ {
[DataField]
public EntProtoId ZombifySelfActionPrototype = "ActionTurnUndead";
[DataField]
public EntityUid? Action;
} }

View File

@@ -1,5 +1,4 @@
using Content.Shared.Damage; using Content.Shared.Damage;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Server.Zombies; namespace Content.Server.Zombies;
@@ -48,9 +47,6 @@ public sealed partial class PendingZombieComponent : Component
[DataField] [DataField]
public TimeSpan MaxInitialInfectedGrace = TimeSpan.FromMinutes(15f); public TimeSpan MaxInitialInfectedGrace = TimeSpan.FromMinutes(15f);
[DataField]
public EntProtoId ZombifySelfActionPrototype = "ActionTurnUndead";
/// <summary> /// <summary>
/// The chance each second that a warning will be shown. /// The chance each second that a warning will be shown.
/// </summary> /// </summary>
@@ -66,6 +62,4 @@ public sealed partial class PendingZombieComponent : Component
"zombie-infection-warning", "zombie-infection-warning",
"zombie-infection-underway" "zombie-infection-underway"
}; };
[DataField] public EntityUid? Action;
} }

View File

@@ -64,9 +64,16 @@ namespace Content.Server.Zombies
SubscribeLocalEvent<PendingZombieComponent, MapInitEvent>(OnPendingMapInit); SubscribeLocalEvent<PendingZombieComponent, MapInitEvent>(OnPendingMapInit);
SubscribeLocalEvent<IncurableZombieComponent, MapInitEvent>(OnPendingMapInit);
SubscribeLocalEvent<ZombifyOnDeathComponent, MobStateChangedEvent>(OnDamageChanged); SubscribeLocalEvent<ZombifyOnDeathComponent, MobStateChangedEvent>(OnDamageChanged);
} }
private void OnPendingMapInit(EntityUid uid, IncurableZombieComponent component, MapInitEvent args)
{
_actions.AddAction(uid, ref component.Action, component.ZombifySelfActionPrototype);
}
private void OnPendingMapInit(EntityUid uid, PendingZombieComponent component, MapInitEvent args) private void OnPendingMapInit(EntityUid uid, PendingZombieComponent component, MapInitEvent args)
{ {
if (_mobState.IsDead(uid)) if (_mobState.IsDead(uid))
@@ -77,7 +84,6 @@ namespace Content.Server.Zombies
component.NextTick = _timing.CurTime + TimeSpan.FromSeconds(1f); component.NextTick = _timing.CurTime + TimeSpan.FromSeconds(1f);
component.GracePeriod = _random.Next(component.MinInitialInfectedGrace, component.MaxInitialInfectedGrace); component.GracePeriod = _random.Next(component.MinInitialInfectedGrace, component.MaxInitialInfectedGrace);
_actions.AddAction(uid, ref component.Action, component.ZombifySelfActionPrototype);
} }
public override void Update(float frameTime) public override void Update(float frameTime)