Refactor standing to be ECS (#4142)
* Refactor standing to be ECS E C S B A B Y * DONE * FIX IT FIX IT FIX IT * IsDown event * Change to methods * Fixes * Address some reviews * Last of the Mohicans * Final fixes * Fix tests
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#nullable enable
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Standing;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
@@ -20,13 +21,20 @@ namespace Content.Shared.MobState.State
|
||||
{
|
||||
status.ShowAlert(AlertType.HumanCrit); // TODO: combine humancrit-0 and humancrit-1 into a gif and display it
|
||||
}
|
||||
|
||||
EntitySystem.Get<StandingStateSystem>().Down(entity);
|
||||
|
||||
if (entity.TryGetComponent(out SharedAppearanceComponent? appearance))
|
||||
{
|
||||
appearance.SetData(DamageStateVisuals.State, DamageState.Critical);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ExitState(IEntity entity)
|
||||
{
|
||||
base.ExitState(entity);
|
||||
|
||||
EntitySystem.Get<SharedStandingStateSystem>().Standing(entity);
|
||||
EntitySystem.Get<StandingStateSystem>().Stand(entity);
|
||||
}
|
||||
|
||||
public override bool CanInteract()
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Standing;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Shared.MobState.State
|
||||
{
|
||||
@@ -11,6 +13,18 @@ namespace Content.Shared.MobState.State
|
||||
base.EnterState(entity);
|
||||
var wake = entity.EnsureComponent<CollisionWakeComponent>();
|
||||
wake.Enabled = true;
|
||||
var standingState = EntitySystem.Get<StandingStateSystem>();
|
||||
standingState.Down(entity);
|
||||
|
||||
if (standingState.IsDown(entity) && entity.TryGetComponent(out PhysicsComponent? physics))
|
||||
{
|
||||
physics.CanCollide = false;
|
||||
}
|
||||
|
||||
if (entity.TryGetComponent(out SharedAppearanceComponent? appearance))
|
||||
{
|
||||
appearance.SetData(DamageStateVisuals.State, DamageState.Dead);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ExitState(IEntity entity)
|
||||
@@ -20,6 +34,14 @@ namespace Content.Shared.MobState.State
|
||||
{
|
||||
entity.RemoveComponent<CollisionWakeComponent>();
|
||||
}
|
||||
|
||||
var standingState = EntitySystem.Get<StandingStateSystem>();
|
||||
standingState.Stand(entity);
|
||||
|
||||
if (!standingState.IsDown(entity) && entity.TryGetComponent(out PhysicsComponent? physics))
|
||||
{
|
||||
physics.CanCollide = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanInteract()
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
#nullable enable
|
||||
using Content.Shared.Standing;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Content.Shared.MobState.State
|
||||
{
|
||||
@@ -9,6 +12,17 @@ namespace Content.Shared.MobState.State
|
||||
{
|
||||
protected override DamageState DamageState => DamageState.Alive;
|
||||
|
||||
public override void EnterState(IEntity entity)
|
||||
{
|
||||
base.EnterState(entity);
|
||||
EntitySystem.Get<StandingStateSystem>().Stand(entity);
|
||||
|
||||
if (entity.TryGetComponent(out SharedAppearanceComponent? appearance))
|
||||
{
|
||||
appearance.SetData(DamageStateVisuals.State, DamageState.Alive);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool CanInteract()
|
||||
{
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user