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

@@ -111,6 +111,7 @@
<Compile Include="UserInterface\LobbyGui.cs" /> <Compile Include="UserInterface\LobbyGui.cs" />
<Compile Include="UserInterface\NanoStyle.cs" /> <Compile Include="UserInterface\NanoStyle.cs" />
<Compile Include="Utility\ResourceCacheExtensions.cs" /> <Compile Include="Utility\ResourceCacheExtensions.cs" />
<Compile Include="GameObjects\Components\Mobs\SpeciesVisualizer2D.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Content.Shared\Content.Shared.csproj"> <ProjectReference Include="..\Content.Shared\Content.Shared.csproj">

View File

@@ -0,0 +1,35 @@
using Content.Shared.GameObjects.Components.Mobs;
using SS14.Client.GameObjects;
using SS14.Client.Interfaces.GameObjects.Components;
using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.Maths;
namespace Content.Client.GameObjects.Components.Mobs
{
public class SpeciesVisualizer2D : AppearanceVisualizer
{
public override void InitializeEntity(IEntity entity)
{
base.InitializeEntity(entity);
}
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
var sprite = component.Owner.GetComponent<ISpriteComponent>();
if (component.TryGetData<SharedSpeciesComponent.MobState>(SharedSpeciesComponent.MobVisuals.RotationState, out var state))
{
switch (state)
{
case SharedSpeciesComponent.MobState.Stand:
sprite.Rotation = 0;
break;
case SharedSpeciesComponent.MobState.Down:
sprite.Rotation = Angle.FromDegrees(90);
break;
}
}
}
}
}

View File

@@ -1,4 +1,5 @@
using Content.Server.GameObjects.EntitySystems; using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects.Components.Mobs;
using SS14.Server.GameObjects; using SS14.Server.GameObjects;
using SS14.Shared.Interfaces.GameObjects; using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.Maths; 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 /// Defines the blocking effect of each damage state, and what effects to apply upon entering or exiting the state
/// </summary> /// </summary>
public interface DamageState : IActionBlocker 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> /// <summary>
@@ -20,9 +21,9 @@ namespace Content.Server.GameObjects
/// </summary> /// </summary>
public struct NormalState : DamageState 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() bool IActionBlocker.CanInteract()
{ {
@@ -45,9 +46,21 @@ namespace Content.Server.GameObjects
/// </summary> /// </summary>
public struct CriticalState : DamageState 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() bool IActionBlocker.CanInteract()
{ {
@@ -70,20 +83,26 @@ namespace Content.Server.GameObjects
/// </summary> /// </summary>
public struct DeadState : DamageState 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() bool IActionBlocker.CanInteract()

View File

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

View File

@@ -87,6 +87,7 @@
<Compile Include="GameObjects\Components\Items\SharedHandsComponent.cs" /> <Compile Include="GameObjects\Components\Items\SharedHandsComponent.cs" />
<Compile Include="GameObjects\Components\Power\SharedPowerDebugTool.cs" /> <Compile Include="GameObjects\Components\Power\SharedPowerDebugTool.cs" />
<Compile Include="Maths\PhysicalConstants.cs" /> <Compile Include="Maths\PhysicalConstants.cs" />
<Compile Include="GameObjects\Components\Mobs\SharedSpeciesComponent.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\engine\Lidgren.Network\Lidgren.Network.csproj"> <ProjectReference Include="..\engine\Lidgren.Network\Lidgren.Network.csproj">

View File

@@ -0,0 +1,34 @@
using System;
using SS14.Shared.GameObjects;
using SS14.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Mobs
{
public abstract class SharedSpeciesComponent : Component
{
public sealed override string Name => "Species";
public override uint? NetID => ContentNetIDs.SPECIES;
[Serializable, NetSerializable]
public enum MobVisuals
{
RotationState
}
[Serializable, NetSerializable]
public enum MobState
{
/// <summary>
/// Mob is standing up
/// </summary>
Stand,
/// <summary>
/// Mob is laying down
/// </summary>
Down,
}
}
}

View File

@@ -56,6 +56,9 @@
zoom: 0.5, 0.5 zoom: 0.5, 0.5
- type: CameraRecoil - type: CameraRecoil
- type: Appearance
visuals:
- type: SpeciesVisualizer2D
- type: entity - type: entity
id: MobObserver id: MobObserver

View File

@@ -4,9 +4,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 15.0.26730.16 VisualStudioVersion = 15.0.26730.16
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Content.Shared", "Content.Shared\Content.Shared.csproj", "{26AEEBB3-DDE7-443A-9F43-7BC7F4ACF6B5}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Content.Shared", "Content.Shared\Content.Shared.csproj", "{26AEEBB3-DDE7-443A-9F43-7BC7F4ACF6B5}"
ProjectSection(ProjectDependencies) = postProject
{0529F740-0000-0000-0000-000000000000} = {0529F740-0000-0000-0000-000000000000}
EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SS14.Shared", "engine\SS14.Shared\SS14.Shared.csproj", "{0529F740-0000-0000-0000-000000000000}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SS14.Shared", "engine\SS14.Shared\SS14.Shared.csproj", "{0529F740-0000-0000-0000-000000000000}"
EndProject EndProject
@@ -22,11 +19,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Content.Server", "Content.S
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Content.Client", "Content.Client\Content.Client.csproj", "{A2E5F175-78AF-4DDD-8F97-E2D2552372ED}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Content.Client", "Content.Client\Content.Client.csproj", "{A2E5F175-78AF-4DDD-8F97-E2D2552372ED}"
ProjectSection(ProjectDependencies) = postProject
{0529F740-0000-0000-0000-000000000000} = {0529F740-0000-0000-0000-000000000000}
{26AEEBB3-DDE7-443A-9F43-7BC7F4ACF6B5} = {26AEEBB3-DDE7-443A-9F43-7BC7F4ACF6B5}
{83429BD6-6358-4B18-BE51-401DF8EA2673} = {83429BD6-6358-4B18-BE51-401DF8EA2673}
EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lidgren.Network", "engine\Lidgren.Network\Lidgren.Network.csproj", "{59250BAF-0000-0000-0000-000000000000}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lidgren.Network", "engine\Lidgren.Network\Lidgren.Network.csproj", "{59250BAF-0000-0000-0000-000000000000}"
EndProject EndProject