Files
tbd-station-14/Content.Server/GameObjects/Components/Mobs/DamageStates.cs
Injazz c5e077efc1 mob dead state tweaks (#162)
~~well, it SHOULD make mob rotate on death, but it doesn't, i have no idea why~~

- Blocks character movement in crit/death
- rotates character ~~360noscope~~ 90 degrees to convince you it's lying down when dead

resolves #145
resolves #158
related to #115
2019-03-27 13:29:06 +01:00

124 lines
3.3 KiB
C#

using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects.Components.Mobs;
using SS14.Server.GameObjects;
using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.Maths;
namespace Content.Server.GameObjects
{
/// <summary>
/// Defines the blocking effect of each damage state, and what effects to apply upon entering or exiting the state
/// </summary>
public interface DamageState : IActionBlocker
{
void EnterState(IEntity entity, AppearanceComponent appearance);
void ExitState(IEntity entity, AppearanceComponent appearance);
}
/// <summary>
/// Standard state that a species is at with no damage or negative effect
/// </summary>
public struct NormalState : DamageState
{
public void EnterState(IEntity entity, AppearanceComponent appearance) {}
public void ExitState(IEntity entity, AppearanceComponent appearance) {}
bool IActionBlocker.CanInteract()
{
return true;
}
bool IActionBlocker.CanMove()
{
return true;
}
bool IActionBlocker.CanUse()
{
return true;
}
}
/// <summary>
/// A state in which you are disabled from acting due to damage
/// </summary>
public struct CriticalState : DamageState
{
public void EnterState(IEntity entity, AppearanceComponent appearance) {
if (!entity.TryGetComponent<PlayerInputMoverComponent>(out var mover))
{
return;
}
mover.Disabled = true;
}
public void ExitState(IEntity entity, AppearanceComponent appearance) {
if (!entity.TryGetComponent<PlayerInputMoverComponent>(out var mover))
{
return;
}
mover.Disabled = false;
}
bool IActionBlocker.CanInteract()
{
return false;
}
bool IActionBlocker.CanMove()
{
return false;
}
bool IActionBlocker.CanUse()
{
return false;
}
}
/// <summary>
/// A damage state which will allow ghosting out of mobs
/// </summary>
public struct DeadState : DamageState
{
public void EnterState(IEntity entity, AppearanceComponent appearance)
{
var newstate = SpeciesComponent.MobState.Down;
appearance.SetData(SpeciesComponent.MobVisuals.RotationState, newstate);
if (!entity.TryGetComponent<PlayerInputMoverComponent>(out var mover))
{
return;
}
mover.Disabled = true;
}
public void ExitState(IEntity entity, AppearanceComponent appearance)
{
var newstate = SpeciesComponent.MobState.Stand;
appearance.SetData(SpeciesComponent.MobVisuals.RotationState, newstate);
if (!entity.TryGetComponent<PlayerInputMoverComponent>(out var mover))
{
return;
}
mover.Disabled = false;
}
bool IActionBlocker.CanInteract()
{
return false;
}
bool IActionBlocker.CanMove()
{
return false;
}
bool IActionBlocker.CanUse()
{
return false;
}
}
}