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:
committed by
Pieter-Jan Briers
parent
842cb44cd2
commit
c5e077efc1
@@ -111,6 +111,7 @@
|
||||
<Compile Include="UserInterface\LobbyGui.cs" />
|
||||
<Compile Include="UserInterface\NanoStyle.cs" />
|
||||
<Compile Include="Utility\ResourceCacheExtensions.cs" />
|
||||
<Compile Include="GameObjects\Components\Mobs\SpeciesVisualizer2D.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Content.Shared\Content.Shared.csproj">
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -10,9 +11,9 @@ namespace Content.Server.GameObjects
|
||||
/// </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()
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@
|
||||
<Compile Include="GameObjects\Components\Items\SharedHandsComponent.cs" />
|
||||
<Compile Include="GameObjects\Components\Power\SharedPowerDebugTool.cs" />
|
||||
<Compile Include="Maths\PhysicalConstants.cs" />
|
||||
<Compile Include="GameObjects\Components\Mobs\SharedSpeciesComponent.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\engine\Lidgren.Network\Lidgren.Network.csproj">
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,9 @@
|
||||
zoom: 0.5, 0.5
|
||||
|
||||
- type: CameraRecoil
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: SpeciesVisualizer2D
|
||||
|
||||
- type: entity
|
||||
id: MobObserver
|
||||
|
||||
@@ -4,9 +4,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
VisualStudioVersion = 15.0.26730.16
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
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
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SS14.Shared", "engine\SS14.Shared\SS14.Shared.csproj", "{0529F740-0000-0000-0000-000000000000}"
|
||||
EndProject
|
||||
@@ -22,11 +19,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Content.Server", "Content.S
|
||||
EndProjectSection
|
||||
EndProject
|
||||
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
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lidgren.Network", "engine\Lidgren.Network\Lidgren.Network.csproj", "{59250BAF-0000-0000-0000-000000000000}"
|
||||
EndProject
|
||||
|
||||
Reference in New Issue
Block a user