2021-06-27 19:02:46 +10:00
|
|
|
|
using Content.Shared.Hands;
|
|
|
|
|
|
using Content.Shared.Standing;
|
|
|
|
|
|
using Robust.Shared.GameObjects;
|
2021-06-05 17:23:24 +10:00
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Shared.MobState.State
|
2020-12-07 14:52:55 +01:00
|
|
|
|
{
|
|
|
|
|
|
public abstract class SharedDeadMobState : BaseMobState
|
|
|
|
|
|
{
|
|
|
|
|
|
protected override DamageState DamageState => DamageState.Dead;
|
|
|
|
|
|
|
2021-11-09 12:15:12 +01:00
|
|
|
|
public override void EnterState(EntityUid uid, IEntityManager entityManager)
|
2021-06-05 17:23:24 +10:00
|
|
|
|
{
|
2021-11-09 12:15:12 +01:00
|
|
|
|
base.EnterState(uid, entityManager);
|
|
|
|
|
|
var wake = entityManager.EnsureComponent<CollisionWakeComponent>(uid);
|
2021-06-05 17:23:24 +10:00
|
|
|
|
wake.Enabled = true;
|
2021-06-27 19:02:46 +10:00
|
|
|
|
var standingState = EntitySystem.Get<StandingStateSystem>();
|
2021-11-09 12:15:12 +01:00
|
|
|
|
standingState.Down(uid);
|
2021-06-27 19:02:46 +10:00
|
|
|
|
|
2021-11-09 12:15:12 +01:00
|
|
|
|
if (standingState.IsDown(uid) && entityManager.TryGetComponent(uid, out PhysicsComponent? physics))
|
2021-06-27 19:02:46 +10:00
|
|
|
|
{
|
|
|
|
|
|
physics.CanCollide = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-22 23:22:59 -08:00
|
|
|
|
if (entityManager.TryGetComponent(uid, out AppearanceComponent? appearance))
|
2021-06-27 19:02:46 +10:00
|
|
|
|
{
|
|
|
|
|
|
appearance.SetData(DamageStateVisuals.State, DamageState.Dead);
|
|
|
|
|
|
}
|
2021-06-05 17:23:24 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-11-09 12:15:12 +01:00
|
|
|
|
public override void ExitState(EntityUid uid, IEntityManager entityManager)
|
2021-06-05 17:23:24 +10:00
|
|
|
|
{
|
2021-11-09 12:15:12 +01:00
|
|
|
|
base.ExitState(uid, entityManager);
|
|
|
|
|
|
if (entityManager.HasComponent<CollisionWakeComponent>(uid))
|
2021-06-05 17:23:24 +10:00
|
|
|
|
{
|
2021-11-09 12:15:12 +01:00
|
|
|
|
entityManager.RemoveComponent<CollisionWakeComponent>(uid);
|
2021-06-05 17:23:24 +10:00
|
|
|
|
}
|
2021-06-27 19:02:46 +10:00
|
|
|
|
|
|
|
|
|
|
var standingState = EntitySystem.Get<StandingStateSystem>();
|
2021-11-09 12:15:12 +01:00
|
|
|
|
standingState.Stand(uid);
|
2021-06-27 19:02:46 +10:00
|
|
|
|
|
2021-11-09 12:15:12 +01:00
|
|
|
|
if (!standingState.IsDown(uid) && entityManager.TryGetComponent(uid, out PhysicsComponent? physics))
|
2021-06-27 19:02:46 +10:00
|
|
|
|
{
|
|
|
|
|
|
physics.CanCollide = true;
|
|
|
|
|
|
}
|
2021-06-05 17:23:24 +10:00
|
|
|
|
}
|
2020-12-07 14:52:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|