Skip to content

Commit

Permalink
Fix Dung Defender, Broken Vessel, and Lost Kin
Browse files Browse the repository at this point in the history
  • Loading branch information
Extremelyd1 committed Jul 27, 2024
1 parent e6eaa71 commit 5b0b2fb
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 7 deletions.
56 changes: 53 additions & 3 deletions HKMP/Game/Client/Entity/Action/EntityFsmActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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<Rigidbody2D>();
if (rigidbody == null) {
return;
}

rigidbody.isKinematic = action.isKinematic.Value;
}

#endregion

/// <summary>
/// Class that keeps track of an action that executes while in a certain state of the FSM.
/// </summary>
Expand Down
19 changes: 15 additions & 4 deletions HKMP/Game/Client/Entity/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<EnemyDeathEffects>();
if (enemyDeathEffects == null) {
Expand All @@ -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);
}

/// <summary>
Expand Down
4 changes: 4 additions & 0 deletions HKMP/Game/Client/Entity/EntitySpawner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ List<PlayMakerFSM> 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]);
}
Expand Down
4 changes: 4 additions & 0 deletions HKMP/Game/Client/Entity/EntityType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ internal enum EntityType {
LargeDungBall,
SmallDungBall,
DungDefenderBurrow,
DungDefenderCorpse,
Flukemarm,
Shardmite,
Glimback,
Expand Down Expand Up @@ -137,6 +138,9 @@ internal enum EntityType {
Mawlurk,
InfectedBalloon,
BrokenVessel,
BrokenVesselCorpse,
LostKin,
LostKinCorpse,
Boofly,
PrimalAspid,
Hopper,
Expand Down
23 changes: 23 additions & 0 deletions HKMP/Resource/entity-registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -846,6 +864,11 @@
"Music"
]
},
{
"base_object_name": "Corpse Infected Knight",
"type": "BrokenVesselCorpse",
"fsm_name": "corpse"
},
{
"base_object_name": "Blow Fly",
"type": "Boofly",
Expand Down

0 comments on commit 5b0b2fb

Please sign in to comment.