2018-12-13 07:47:19 -06:00
|
|
|
|
using Content.Server.GameObjects.EntitySystems;
|
2019-03-27 17:29:06 +05:00
|
|
|
|
using Content.Shared.GameObjects.Components.Mobs;
|
2018-12-13 07:47:19 -06:00
|
|
|
|
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
|
2019-03-27 17:29:06 +05:00
|
|
|
|
{
|
|
|
|
|
|
void EnterState(IEntity entity, AppearanceComponent appearance);
|
2018-12-13 07:47:19 -06:00
|
|
|
|
|
2019-03-27 17:29:06 +05:00
|
|
|
|
void ExitState(IEntity entity, AppearanceComponent appearance);
|
2018-12-13 07:47:19 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Standard state that a species is at with no damage or negative effect
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public struct NormalState : DamageState
|
|
|
|
|
|
{
|
2019-03-27 17:29:06 +05:00
|
|
|
|
public void EnterState(IEntity entity, AppearanceComponent appearance) {}
|
2018-12-13 07:47:19 -06:00
|
|
|
|
|
2019-03-27 17:29:06 +05:00
|
|
|
|
public void ExitState(IEntity entity, AppearanceComponent appearance) {}
|
2018-12-13 07:47:19 -06:00
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
{
|
2019-03-27 17:29:06 +05:00
|
|
|
|
public void EnterState(IEntity entity, AppearanceComponent appearance) {
|
|
|
|
|
|
if (!entity.TryGetComponent<PlayerInputMoverComponent>(out var mover))
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
mover.Disabled = true;
|
|
|
|
|
|
}
|
2018-12-13 07:47:19 -06:00
|
|
|
|
|
2019-03-27 17:29:06 +05:00
|
|
|
|
public void ExitState(IEntity entity, AppearanceComponent appearance) {
|
|
|
|
|
|
if (!entity.TryGetComponent<PlayerInputMoverComponent>(out var mover))
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
mover.Disabled = false;
|
|
|
|
|
|
}
|
2018-12-13 07:47:19 -06:00
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
{
|
2019-03-27 17:29:06 +05:00
|
|
|
|
public void EnterState(IEntity entity, AppearanceComponent appearance)
|
2018-12-13 07:47:19 -06:00
|
|
|
|
{
|
2019-03-27 17:29:06 +05:00
|
|
|
|
var newstate = SpeciesComponent.MobState.Down;
|
|
|
|
|
|
appearance.SetData(SpeciesComponent.MobVisuals.RotationState, newstate);
|
|
|
|
|
|
if (!entity.TryGetComponent<PlayerInputMoverComponent>(out var mover))
|
2018-12-13 07:47:19 -06:00
|
|
|
|
{
|
2019-03-27 17:29:06 +05:00
|
|
|
|
return;
|
2018-12-13 07:47:19 -06:00
|
|
|
|
}
|
2019-03-27 17:29:06 +05:00
|
|
|
|
mover.Disabled = true;
|
2018-12-13 07:47:19 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-03-27 17:29:06 +05:00
|
|
|
|
public void ExitState(IEntity entity, AppearanceComponent appearance)
|
2018-12-13 07:47:19 -06:00
|
|
|
|
{
|
2019-03-27 17:29:06 +05:00
|
|
|
|
var newstate = SpeciesComponent.MobState.Stand;
|
|
|
|
|
|
appearance.SetData(SpeciesComponent.MobVisuals.RotationState, newstate);
|
|
|
|
|
|
if (!entity.TryGetComponent<PlayerInputMoverComponent>(out var mover))
|
2018-12-13 07:47:19 -06:00
|
|
|
|
{
|
2019-03-27 17:29:06 +05:00
|
|
|
|
return;
|
2018-12-13 07:47:19 -06:00
|
|
|
|
}
|
2019-03-27 17:29:06 +05:00
|
|
|
|
mover.Disabled = false;
|
2018-12-13 07:47:19 -06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool IActionBlocker.CanInteract()
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool IActionBlocker.CanMove()
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool IActionBlocker.CanUse()
|
|
|
|
|
|
{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|