Damage visualizer for simple mobs (#1332)

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
metalgearsloth
2020-07-23 10:04:03 +10:00
committed by GitHub
parent 9585c7b82d
commit 56737b635f
11 changed files with 146 additions and 16 deletions

View File

@@ -116,7 +116,7 @@ namespace Content.Server.AI.Utility.AiLogic
_planner = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AiActionSystem>();
if (SelfEntity.TryGetComponent(out DamageableComponent damageableComponent))
{
damageableComponent.DamageThresholdPassed += DeathHandle;
damageableComponent.DamageThresholdPassed += DamageThresholdHandle;
}
}
@@ -125,22 +125,25 @@ namespace Content.Server.AI.Utility.AiLogic
// TODO: If DamageableComponent removed still need to unsubscribe?
if (SelfEntity.TryGetComponent(out DamageableComponent damageableComponent))
{
damageableComponent.DamageThresholdPassed -= DeathHandle;
damageableComponent.DamageThresholdPassed -= DamageThresholdHandle;
}
var currentOp = CurrentAction?.ActionOperators.Peek();
currentOp?.Shutdown(Outcome.Failed);
}
private void DeathHandle(object sender, DamageThresholdPassedEventArgs eventArgs)
private void DamageThresholdHandle(object sender, DamageThresholdPassedEventArgs eventArgs)
{
if (eventArgs.DamageThreshold.ThresholdType == ThresholdType.Death)
if (!SelfEntity.TryGetComponent(out SpeciesComponent speciesComponent))
{
return;
}
if (speciesComponent.CurrentDamageState is DeadState)
{
_isDead = true;
}
// TODO: If we get healed - double-check what it should be
if (eventArgs.DamageThreshold.ThresholdType == ThresholdType.None)
else
{
_isDead = false;
}