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
This commit is contained in:
Injazz
2019-03-27 17:29:06 +05:00
committed by Pieter-Jan Briers
parent 842cb44cd2
commit c5e077efc1
8 changed files with 118 additions and 29 deletions

View File

@@ -1,4 +1,5 @@
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects.Components.Mobs;
using SS14.Server.GameObjects;
using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.Maths;
@@ -9,10 +10,10 @@ namespace Content.Server.GameObjects
/// 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);
{
void EnterState(IEntity entity, AppearanceComponent appearance);
void ExitState(IEntity entity);
void ExitState(IEntity entity, AppearanceComponent appearance);
}
/// <summary>
@@ -20,9 +21,9 @@ namespace Content.Server.GameObjects
/// </summary>
public struct NormalState : DamageState
{
public void EnterState(IEntity entity){}
public void EnterState(IEntity entity, AppearanceComponent appearance) {}
public void ExitState(IEntity entity){}
public void ExitState(IEntity entity, AppearanceComponent appearance) {}
bool IActionBlocker.CanInteract()
{
@@ -45,9 +46,21 @@ namespace Content.Server.GameObjects
/// </summary>
public struct CriticalState : DamageState
{
public void EnterState(IEntity entity) { }
public void EnterState(IEntity entity, AppearanceComponent appearance) {
if (!entity.TryGetComponent<PlayerInputMoverComponent>(out var mover))
{
return;
}
mover.Disabled = true;
}
public void ExitState(IEntity entity) { }
public void ExitState(IEntity entity, AppearanceComponent appearance) {
if (!entity.TryGetComponent<PlayerInputMoverComponent>(out var mover))
{
return;
}
mover.Disabled = false;
}
bool IActionBlocker.CanInteract()
{
@@ -70,20 +83,26 @@ namespace Content.Server.GameObjects
/// </summary>
public struct DeadState : DamageState
{
public void EnterState(IEntity entity)
public void EnterState(IEntity entity, AppearanceComponent appearance)
{
if(entity.TryGetComponent(out SpriteComponent sprite))
var newstate = SpeciesComponent.MobState.Down;
appearance.SetData(SpeciesComponent.MobVisuals.RotationState, newstate);
if (!entity.TryGetComponent<PlayerInputMoverComponent>(out var mover))
{
sprite.Rotation = sprite.Rotation + Angle.FromDegrees(90);
return;
}
mover.Disabled = true;
}
public void ExitState(IEntity entity)
public void ExitState(IEntity entity, AppearanceComponent appearance)
{
if (entity.TryGetComponent(out SpriteComponent sprite))
var newstate = SpeciesComponent.MobState.Stand;
appearance.SetData(SpeciesComponent.MobVisuals.RotationState, newstate);
if (!entity.TryGetComponent<PlayerInputMoverComponent>(out var mover))
{
sprite.Rotation = sprite.Rotation - Angle.FromDegrees(90);
return;
}
mover.Disabled = false;
}
bool IActionBlocker.CanInteract()

View File

@@ -2,7 +2,7 @@
using System.Collections.Generic;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Mobs;
using SS14.Server.GameObjects;
using SS14.Shared.ContentPack;
using SS14.Shared.GameObjects;
@@ -12,12 +12,8 @@ using SS14.Shared.Serialization;
namespace Content.Server.GameObjects
{
public class SpeciesComponent : Component, IActionBlocker, IOnDamageBehavior
public class SpeciesComponent : SharedSpeciesComponent, IActionBlocker, IOnDamageBehavior
{
public override string Name => "Species";
public override uint? NetID => ContentNetIDs.SPECIES;
/// <summary>
/// Damagestates are reached by reaching a certain damage threshold, they will block actions after being reached
/// </summary>
@@ -33,11 +29,19 @@ namespace Content.Server.GameObjects
/// </summary>
private DamageTemplates DamageTemplate;
AppearanceComponent Appearance;
/// <summary>
/// Variable for serialization
/// </summary>
private string templatename;
public override void Initialize()
{
base.Initialize();
Appearance = Owner.GetComponent<AppearanceComponent>();
}
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
@@ -104,9 +108,9 @@ namespace Content.Server.GameObjects
return;
}
CurrentDamageState.ExitState(Owner);
CurrentDamageState.ExitState(Owner, Appearance);
CurrentDamageState = DamageTemplates.StateThresholdMap[threshold];
CurrentDamageState.EnterState(Owner);
CurrentDamageState.EnterState(Owner, Appearance);
currentstate = threshold;
}