From 5b0b2fb27bf6d77d73ce2648a77c93324691ed42 Mon Sep 17 00:00:00 2001 From: Extremelyd1 <10898310+Extremelyd1@users.noreply.github.com> Date: Sat, 27 Jul 2024 11:00:37 +0200 Subject: [PATCH] Fix Dung Defender, Broken Vessel, and Lost Kin --- .../Client/Entity/Action/EntityFsmActions.cs | 56 ++++++++++++++++++- HKMP/Game/Client/Entity/Entity.cs | 19 +++++-- HKMP/Game/Client/Entity/EntitySpawner.cs | 4 ++ HKMP/Game/Client/Entity/EntityType.cs | 4 ++ HKMP/Resource/entity-registry.json | 23 ++++++++ 5 files changed, 99 insertions(+), 7 deletions(-) diff --git a/HKMP/Game/Client/Entity/Action/EntityFsmActions.cs b/HKMP/Game/Client/Entity/Action/EntityFsmActions.cs index 3440477..1ac143e 100644 --- a/HKMP/Game/Client/Entity/Action/EntityFsmActions.cs +++ b/HKMP/Game/Client/Entity/Action/EntityFsmActions.cs @@ -1130,10 +1130,24 @@ private static void ApplyNetworkDataFromAction(EntityNetworkData data, SetPartic if (particleSystem == null) { return; } - + + Action(); + + if (action.everyFrame) { + MonoBehaviourUtil.Instance.OnUpdateEvent += Action; + + new ActionInState { + Fsm = action.Fsm, + StateName = action.State.Name, + ExitAction = () => MonoBehaviourUtil.Instance.OnUpdateEvent -= Action + }.Register(); + } + + void Action() { #pragma warning disable CS0618 - particleSystem.emissionRate = action.emissionRate.Value; + particleSystem.emissionRate = action.emissionRate.Value; #pragma warning restore CS0618 + } } #endregion @@ -1159,9 +1173,23 @@ private static void ApplyNetworkDataFromAction(EntityNetworkData data, SetPartic return; } + Action(); + + if (action.everyFrame) { + MonoBehaviourUtil.Instance.OnUpdateEvent += Action; + + new ActionInState { + Fsm = action.Fsm, + StateName = action.State.Name, + ExitAction = () => MonoBehaviourUtil.Instance.OnUpdateEvent -= Action + }.Register(); + } + + void Action() { #pragma warning disable CS0618 - particleSystem.startSpeed = action.emissionSpeed.Value; + particleSystem.startSpeed = action.emissionSpeed.Value; #pragma warning restore CS0618 + } } #endregion @@ -3129,6 +3157,28 @@ private static void ApplyNetworkDataFromAction(EntityNetworkData data, StopLiftC #endregion + #region SetIsKinematic2d + + private static bool GetNetworkDataFromAction(EntityNetworkData data, SetIsKinematic2d action) { + return true; + } + + private static void ApplyNetworkDataFromAction(EntityNetworkData data, SetIsKinematic2d action) { + var go = action.Fsm.GetOwnerDefaultTarget(action.gameObject); + if (go == null) { + return; + } + + var rigidbody = go.GetComponent(); + if (rigidbody == null) { + return; + } + + rigidbody.isKinematic = action.isKinematic.Value; + } + + #endregion + /// /// Class that keeps track of an action that executes while in a certain state of the FSM. /// diff --git a/HKMP/Game/Client/Entity/Entity.cs b/HKMP/Game/Client/Entity/Entity.cs index 38c8260..a5cfffd 100644 --- a/HKMP/Game/Client/Entity/Entity.cs +++ b/HKMP/Game/Client/Entity/Entity.cs @@ -473,11 +473,20 @@ private void HandleEnemyDeathEffects() { case EntityType.WanderingHusk: corpseName = "Zombie Spider 1(Clone)"; break; + case EntityType.DungDefender: + corpseName = "Corpse Dung Defender(Clone)"; + break; + case EntityType.BrokenVessel: + corpseName = "Corpse Infected Knight(Clone)"; + break; + case EntityType.LostKin: + corpseName = "Corpse Infected Knight Dream(Clone)"; + break; default: return; } - Logger.Debug("Entity has corpse that is also enemy, deleting death effects and corpse from client entity"); + Logger.Debug($"Entity ({Id}, {Type}) has corpse that is also enemy, deleting death effects and corpse from client entity"); var enemyDeathEffects = Object.Client.GetComponent(); if (enemyDeathEffects == null) { @@ -486,10 +495,12 @@ private void HandleEnemyDeathEffects() { UnityEngine.Object.Destroy(enemyDeathEffects); var corpse = Object.Client.FindGameObjectInChildren(corpseName); - if (corpse == null) { - Logger.Debug(" Could not find corpse in children"); + if (corpse != null) { + Logger.Debug($" Destroying corpse of client object: {corpse.name}"); + UnityEngine.Object.Destroy(corpse); + } else { + Logger.Debug(" Could not find corpse of client object"); } - UnityEngine.Object.Destroy(corpse); } /// diff --git a/HKMP/Game/Client/Entity/EntitySpawner.cs b/HKMP/Game/Client/Entity/EntitySpawner.cs index 0fe2e9c..8f8f1ff 100644 --- a/HKMP/Game/Client/Entity/EntitySpawner.cs +++ b/HKMP/Game/Client/Entity/EntitySpawner.cs @@ -107,6 +107,10 @@ List clientFsms return SpawnBrokenVesselBalloonObject(clientFsms[7]); } + if (spawningType == EntityType.LostKin && spawnedType == EntityType.InfectedBalloon) { + return SpawnBrokenVesselBalloonObject(clientFsms[2]); + } + if (spawningType == EntityType.MantisPetra && spawnedType == EntityType.MantisPetraScythe) { return SpawnMantisPetraScytheObject(clientFsms[0]); } diff --git a/HKMP/Game/Client/Entity/EntityType.cs b/HKMP/Game/Client/Entity/EntityType.cs index 1157a75..63c3d5f 100644 --- a/HKMP/Game/Client/Entity/EntityType.cs +++ b/HKMP/Game/Client/Entity/EntityType.cs @@ -108,6 +108,7 @@ internal enum EntityType { LargeDungBall, SmallDungBall, DungDefenderBurrow, + DungDefenderCorpse, Flukemarm, Shardmite, Glimback, @@ -137,6 +138,9 @@ internal enum EntityType { Mawlurk, InfectedBalloon, BrokenVessel, + BrokenVesselCorpse, + LostKin, + LostKinCorpse, Boofly, PrimalAspid, Hopper, diff --git a/HKMP/Resource/entity-registry.json b/HKMP/Resource/entity-registry.json index 0c52ef7..f66cc96 100644 --- a/HKMP/Resource/entity-registry.json +++ b/HKMP/Resource/entity-registry.json @@ -667,6 +667,11 @@ "type": "DungDefenderBurrow", "fsm_name": "Burrow Effect" }, + { + "base_object_name": "Corpse Dung Defender", + "type": "DungDefenderCorpse", + "fsm_name": "Corpse" + }, { "base_object_name": "Fluke Mother", "type": "Flukemarm", @@ -838,6 +843,19 @@ "type": "InfectedBalloon", "fsm_name": "Control" }, + { + "base_object_name": "Lost Kin", + "type": "LostKin", + "fsm_name": "IK Control", + "components": [ + "Music" + ] + }, + { + "base_object_name": "Corpse Infected Knight Dream", + "type": "LostKinCorpse", + "fsm_name": "corpse" + }, { "base_object_name": "Infected Knight", "type": "BrokenVessel", @@ -846,6 +864,11 @@ "Music" ] }, + { + "base_object_name": "Corpse Infected Knight", + "type": "BrokenVesselCorpse", + "fsm_name": "corpse" + }, { "base_object_name": "Blow Fly", "type": "Boofly",