Skip to content

Commit

Permalink
Fix synchronisation of City elevators
Browse files Browse the repository at this point in the history
  • Loading branch information
Extremelyd1 committed Jul 26, 2024
1 parent 6ed94bb commit 1844e06
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 5 deletions.
64 changes: 64 additions & 0 deletions HKMP/Game/Client/Entity/Action/EntityFsmActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3063,6 +3063,70 @@ private static void ApplyNetworkDataFromAction(EntityNetworkData data, PreSpawnG
}
}

#endregion

#region SetSpriteRenderer

private static bool GetNetworkDataFromAction(EntityNetworkData data, SetSpriteRenderer action) {
return action.gameObject != null;
}

private static void ApplyNetworkDataFromAction(EntityNetworkData data, SetSpriteRenderer action) {
var gameObject = action.Fsm.GetOwnerDefaultTarget(action.gameObject);
if (gameObject == null) {
return;
}

var spriteRenderer = gameObject.GetComponent<SpriteRenderer>();
if (spriteRenderer != null) {
spriteRenderer.enabled = action.active.Value;
}
}

#endregion

#region MoveLiftChain

private static bool GetNetworkDataFromAction(EntityNetworkData data, MoveLiftChain action) {
return true;
}

private static void ApplyNetworkDataFromAction(EntityNetworkData data, MoveLiftChain action) {
var go = action.target.GetSafe(action);
if (go == null) {
return;
}

var liftChain = go.GetComponent<LiftChain>();
if (liftChain == null) {
return;
}

ReflectionHelper.CallMethod(action, "Apply", [liftChain]);
}

#endregion

#region StopLiftChain

private static bool GetNetworkDataFromAction(EntityNetworkData data, StopLiftChain action) {
return true;
}

private static void ApplyNetworkDataFromAction(EntityNetworkData data, StopLiftChain action) {
var go = action.target.GetSafe(action);
if (go == null) {
return;
}

var liftChain = go.GetComponent<LiftChain>();
if (liftChain == null) {
return;
}

ReflectionHelper.CallMethod(action, "Apply", [liftChain]);
}

#endregion

/// <summary>
Expand Down
5 changes: 0 additions & 5 deletions HKMP/Game/Client/Entity/EntityManager.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Hkmp.Game.Client.Entity.Action;
using Hkmp.Game.Client.Entity.Component;
using Hkmp.Networking.Client;
using Hkmp.Networking.Packet.Data;
using Hkmp.Util;
using HutongGames.PlayMaker.Actions;
using Modding;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using UnityEngine;
using UnityEngine.SceneManagement;
using FindGameObject = On.HutongGames.PlayMaker.Actions.FindGameObject;
using Logger = Hkmp.Logging.Logger;
using Object = UnityEngine.Object;
using OpCodes = Mono.Cecil.Cil.OpCodes;

namespace Hkmp.Game.Client.Entity;

Expand Down
1 change: 1 addition & 0 deletions HKMP/Game/Client/Entity/EntityType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace Hkmp.Game.Client.Entity;
internal enum EntityType {
BattleGate = 0,
CameraLockArea,
CityElevator,
Crawlid,
Tiktik,
Vengefly,
Expand Down
5 changes: 5 additions & 0 deletions HKMP/Resource/entity-registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
"base_object_name": "CameraLockArea",
"type": "CameraLockArea"
},
{
"base_object_name": "Ruins Lift",
"type": "CityElevator",
"fsm_name": "Lift Control"
},
{
"base_object_name": "Crawler",
"type": "Crawlid",
Expand Down

0 comments on commit 1844e06

Please sign in to comment.