Files
OldThink/Content.Server/GameObjects/Components/Mobs/DamageStates.cs

275 lines
5.5 KiB
C#
Raw Normal View History

2020-05-13 19:04:50 +02:00
using Content.Server.GameObjects.Components.Mobs;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Mobs;
using Content.Shared.Audio;
using Content.Shared.GameObjects.Components.Mobs;
2020-05-13 19:04:50 +02:00
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Robust.Server.GameObjects;
2020-05-13 19:04:50 +02:00
using Robust.Server.GameObjects.EntitySystems;
using Robust.Shared.GameObjects.Components;
using Robust.Shared.Interfaces.GameObjects;
2020-05-13 19:04:50 +02:00
using Robust.Shared.IoC;
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 IDamageState : IActionBlocker
{
void EnterState(IEntity entity);
void ExitState(IEntity entity);
bool IsConscious { get; }
}
/// <summary>
/// Standard state that a species is at with no damage or negative effect
/// </summary>
public struct NormalState : IDamageState
{
public void EnterState(IEntity entity)
{
}
public void ExitState(IEntity entity)
{
}
public bool IsConscious => true;
bool IActionBlocker.CanInteract()
{
return true;
}
bool IActionBlocker.CanMove()
{
return true;
}
bool IActionBlocker.CanUse()
{
return true;
}
bool IActionBlocker.CanThrow()
{
return true;
}
bool IActionBlocker.CanSpeak()
{
return true;
}
bool IActionBlocker.CanDrop()
{
return true;
}
bool IActionBlocker.CanPickup()
{
return true;
}
bool IActionBlocker.CanEmote()
{
return true;
}
bool IActionBlocker.CanAttack()
{
return true;
}
2020-05-13 16:53:01 +02:00
bool IActionBlocker.CanEquip()
{
return true;
}
bool IActionBlocker.CanUnequip()
{
return true;
}
2020-05-13 19:26:39 +02:00
bool IActionBlocker.CanChangeDirection()
{
return true;
}
}
/// <summary>
/// A state in which you are disabled from acting due to damage
/// </summary>
public struct CriticalState : IDamageState
{
public void EnterState(IEntity entity)
{
2020-05-13 19:04:50 +02:00
if(entity.TryGetComponent(out StunnableComponent stun))
stun.CancelAll();
StandingStateHelper.Down(entity);
}
public void ExitState(IEntity entity)
{
2020-05-13 19:04:50 +02:00
StandingStateHelper.Standing(entity);
}
public bool IsConscious => false;
bool IActionBlocker.CanInteract()
{
return false;
}
bool IActionBlocker.CanMove()
{
return false;
}
bool IActionBlocker.CanUse()
{
return false;
}
bool IActionBlocker.CanThrow()
{
return false;
}
bool IActionBlocker.CanSpeak()
{
return false;
}
bool IActionBlocker.CanDrop()
{
return false;
}
bool IActionBlocker.CanPickup()
{
return false;
}
bool IActionBlocker.CanEmote()
{
return false;
}
bool IActionBlocker.CanAttack()
{
return false;
}
2020-05-13 16:53:01 +02:00
bool IActionBlocker.CanEquip()
{
return false;
}
bool IActionBlocker.CanUnequip()
{
return false;
}
2020-05-13 19:26:39 +02:00
bool IActionBlocker.CanChangeDirection()
{
return true;
}
}
/// <summary>
/// A damage state which will allow ghosting out of mobs
/// </summary>
public struct DeadState : IDamageState
{
public void EnterState(IEntity entity)
{
2020-05-13 19:04:50 +02:00
if(entity.TryGetComponent(out StunnableComponent stun))
stun.CancelAll();
StandingStateHelper.Down(entity);
2019-10-30 16:27:49 +01:00
if (entity.TryGetComponent(out CollidableComponent collidable))
{
2020-05-23 01:23:36 +02:00
collidable.CanCollide = false;
2019-10-30 16:27:49 +01:00
}
}
public void ExitState(IEntity entity)
{
2020-05-13 19:04:50 +02:00
StandingStateHelper.Standing(entity);
2019-10-30 16:27:49 +01:00
if (entity.TryGetComponent(out CollidableComponent collidable))
{
2020-05-23 01:23:36 +02:00
collidable.CanCollide = true;
2019-10-30 16:27:49 +01:00
}
}
public bool IsConscious => false;
bool IActionBlocker.CanInteract()
{
return false;
}
bool IActionBlocker.CanMove()
{
return false;
}
bool IActionBlocker.CanUse()
{
return false;
}
bool IActionBlocker.CanThrow()
{
return false;
}
bool IActionBlocker.CanSpeak()
{
return false;
}
bool IActionBlocker.CanDrop()
{
return false;
}
bool IActionBlocker.CanPickup()
{
return false;
}
bool IActionBlocker.CanEmote()
{
return false;
}
bool IActionBlocker.CanAttack()
{
return false;
}
2020-05-13 16:53:01 +02:00
bool IActionBlocker.CanEquip()
{
return false;
}
bool IActionBlocker.CanUnequip()
{
return false;
}
2020-05-13 19:26:39 +02:00
bool IActionBlocker.CanChangeDirection()
{
return false;
}
}
}