From b85416b9a54b52cc11fd5b9e57f800ff5c3c6bce Mon Sep 17 00:00:00 2001 From: starfish <50672801+starfi5h@users.noreply.github.com> Date: Sun, 9 Jul 2023 10:09:29 +0800 Subject: [PATCH 1/6] Allow reform brush to have size over 10 --- .../Factory/Foundation/FoundationBuildUpdateProcessor.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/NebulaNetwork/PacketProcessors/Factory/Foundation/FoundationBuildUpdateProcessor.cs b/NebulaNetwork/PacketProcessors/Factory/Foundation/FoundationBuildUpdateProcessor.cs index 84d9c8b83..f081bc0f9 100644 --- a/NebulaNetwork/PacketProcessors/Factory/Foundation/FoundationBuildUpdateProcessor.cs +++ b/NebulaNetwork/PacketProcessors/Factory/Foundation/FoundationBuildUpdateProcessor.cs @@ -11,7 +11,7 @@ namespace NebulaNetwork.PacketProcessors.Factory.Foundation [RegisterPacketProcessor] internal class FoundationBuildUpdateProcessor : PacketProcessor { - private readonly Vector3[] reformPoints = new Vector3[100]; + private Vector3[] reformPoints = new Vector3[100]; public override void ProcessPacket(FoundationBuildUpdatePacket packet, NebulaConnection conn) { @@ -19,6 +19,11 @@ public override void ProcessPacket(FoundationBuildUpdatePacket packet, NebulaCon PlanetFactory factory = IsHost ? GameMain.data.GetOrCreateFactory(planet) : planet?.factory; if (factory != null) { + // Increase reformPoints for mods that increase brush size over 10 + if (packet.ReformSize * packet.ReformSize > reformPoints.Length) + { + reformPoints = new Vector3[packet.ReformSize * packet.ReformSize]; + } Array.Clear(reformPoints, 0, reformPoints.Length); //Check if some mandatory variables are missing From 1a42ee330a12e2889f47f1501631796e02867811 Mon Sep 17 00:00:00 2001 From: starfish <50672801+starfi5h@users.noreply.github.com> Date: Sun, 9 Jul 2023 10:24:35 +0800 Subject: [PATCH 2/6] Fix mecha animation when player count > 2 --- .../Remote/RemotePlayerAnimation.cs | 36 ++++++++++++++++--- .../Remote/RemotePlayerEffects.cs | 6 ++-- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/NebulaWorld/MonoBehaviours/Remote/RemotePlayerAnimation.cs b/NebulaWorld/MonoBehaviours/Remote/RemotePlayerAnimation.cs index a15a10f57..89840c645 100644 --- a/NebulaWorld/MonoBehaviours/Remote/RemotePlayerAnimation.cs +++ b/NebulaWorld/MonoBehaviours/Remote/RemotePlayerAnimation.cs @@ -6,11 +6,25 @@ namespace NebulaWorld.MonoBehaviours.Remote // TODO: Missing client side interpolation public class RemotePlayerAnimation : MonoBehaviour { + public struct Snapshot + { + public EMovementState MovementState { get; set; } + public float HorzSpeed { get; set; } + public float VertSpeed { get; set; } + public float Turning { get; set; } + public float JumpWeight { get; set; } + public float JumpNormalizedTime { get; set; } + public byte IdleAnimIndex { get; set; } + public byte MiningAnimIndex { get; set; } + public float MiningWeight { get; set; } + public PlayerMovement.EFlags Flags { get; set; } + } + public PlayerAnimator PlayerAnimator; private RemotePlayerMovement rootMovement; private RemotePlayerEffects remotePlayerEffects; private float altitudeFactor; - private readonly PlayerMovement[] packetBuffer = new PlayerMovement[3]; + private readonly Snapshot[] packetBuffer = new Snapshot[3]; private void Awake() { @@ -26,13 +40,25 @@ public void UpdateState(PlayerMovement packet) { packetBuffer[i] = packetBuffer[i + 1]; } - packetBuffer[packetBuffer.Length - 1] = packet; + packetBuffer[packetBuffer.Length - 1] = new Snapshot() + { + MovementState = packet.MovementState, + HorzSpeed = packet.HorzSpeed, + VertSpeed = packet.VertSpeed, + Turning = packet.Turning, + JumpWeight = packet.JumpWeight, + JumpNormalizedTime = packet.JumpNormalizedTime, + IdleAnimIndex = packet.IdleAnimIndex, + MiningAnimIndex = packet.MiningAnimIndex, + MiningWeight = packet.MiningWeight, + Flags = packet.Flags + }; } private void Update() { - PlayerMovement packet = packetBuffer[0]; - if (packet == null || PlayerAnimator == null) + ref Snapshot packet = ref packetBuffer[0]; + if (PlayerAnimator == null) { return; } @@ -72,7 +98,7 @@ private void Update() PlayerAnimator.AnimateSkills(deltaTime); AnimateRenderers(PlayerAnimator); - remotePlayerEffects.UpdateState(packet); + remotePlayerEffects.UpdateState(ref packet); } private void CalculateMovementStateWeights(PlayerAnimator animator, float dt) diff --git a/NebulaWorld/MonoBehaviours/Remote/RemotePlayerEffects.cs b/NebulaWorld/MonoBehaviours/Remote/RemotePlayerEffects.cs index ed389a12c..b814f5acf 100644 --- a/NebulaWorld/MonoBehaviours/Remote/RemotePlayerEffects.cs +++ b/NebulaWorld/MonoBehaviours/Remote/RemotePlayerEffects.cs @@ -474,7 +474,7 @@ private bool CheckPlayerInReform() } // collision with vegetation, landing sound effect - private void UpdateExtraSoundEffects(PlayerMovement packet) + private void UpdateExtraSoundEffects(ref RemotePlayerAnimation.Snapshot packet) { if (rootMovement.localPlanetId < 0) { @@ -550,7 +550,7 @@ private void UpdateExtraSoundEffects(PlayerMovement packet) vegeCollideColdTime = (vegeCollideColdTime > 0) ? vegeCollideColdTime - Time.deltaTime * 2 : 0; } - public void UpdateState(PlayerMovement packet) + public void UpdateState(ref RemotePlayerAnimation.Snapshot packet) { bool runActive = rootAnimation.runWeight > 0.001f; bool driftActive = rootAnimation.driftWeight > 0.001f; @@ -562,7 +562,7 @@ public void UpdateState(PlayerMovement packet) if (runActive || !isGrounded || maxAltitude > 0) { - UpdateExtraSoundEffects(packet); + UpdateExtraSoundEffects(ref packet); } if (runActive && isGrounded) { From edbb775d412840695ec1513b002f42b197a546b9 Mon Sep 17 00:00:00 2001 From: starfish <50672801+starfi5h@users.noreply.github.com> Date: Sun, 9 Jul 2023 11:12:59 +0800 Subject: [PATCH 3/6] Fix UIPerformance savetest in multiplayer --- .../Patches/Dynamic/GameSave_Patch.cs | 2 +- .../Dynamic/UIPerformancePanel_Patch.cs | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 NebulaPatcher/Patches/Dynamic/UIPerformancePanel_Patch.cs diff --git a/NebulaPatcher/Patches/Dynamic/GameSave_Patch.cs b/NebulaPatcher/Patches/Dynamic/GameSave_Patch.cs index 7160d477d..820d49dad 100644 --- a/NebulaPatcher/Patches/Dynamic/GameSave_Patch.cs +++ b/NebulaPatcher/Patches/Dynamic/GameSave_Patch.cs @@ -25,7 +25,7 @@ public static bool SaveCurrentGame_Prefix(string saveName) } // Only save if in single player or if you are the host - return (!Multiplayer.IsActive && !Multiplayer.IsLeavingGame) || Multiplayer.Session.LocalPlayer.IsHost; + return !Multiplayer.IsActive || Multiplayer.Session.LocalPlayer.IsHost; } [HarmonyPostfix] diff --git a/NebulaPatcher/Patches/Dynamic/UIPerformancePanel_Patch.cs b/NebulaPatcher/Patches/Dynamic/UIPerformancePanel_Patch.cs new file mode 100644 index 000000000..83d0860cc --- /dev/null +++ b/NebulaPatcher/Patches/Dynamic/UIPerformancePanel_Patch.cs @@ -0,0 +1,23 @@ +using HarmonyLib; +using NebulaWorld; + +namespace NebulaPatcher.Patches.Dynamic +{ + [HarmonyPatch(typeof(UIPerformancePanel))] + internal class UIPerformancePanel_Patch + { + [HarmonyPrefix] + [HarmonyPatch(nameof(UIPerformancePanel.OnDataActiveButtonClick))] + public static bool OnDataActiveButtonClick_Prefix(UIPerformancePanel __instance) + { + if (Multiplayer.IsActive && Multiplayer.Session.LocalPlayer.IsHost) + { + // Replace SaveAsLastExit() because it only triggers on UI exit in multiplayer mode + GameSave.SaveCurrentGame(GameSave.LastExit); + __instance.RefreshDataStatTexts(); + return false; + } + return true; + } + } +} From 5a091ac233662aa7f7db72db4e39a4e67db562af Mon Sep 17 00:00:00 2001 From: starfish <50672801+starfi5h@users.noreply.github.com> Date: Sun, 9 Jul 2023 13:10:14 +0800 Subject: [PATCH 4/6] Disable OnEntityBuild & OnEntityDismantle audio when entity is too far from player --- .../Patches/Dynamic/FactoryAudio_Patch.cs | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 NebulaPatcher/Patches/Dynamic/FactoryAudio_Patch.cs diff --git a/NebulaPatcher/Patches/Dynamic/FactoryAudio_Patch.cs b/NebulaPatcher/Patches/Dynamic/FactoryAudio_Patch.cs new file mode 100644 index 000000000..ed0921280 --- /dev/null +++ b/NebulaPatcher/Patches/Dynamic/FactoryAudio_Patch.cs @@ -0,0 +1,51 @@ +using HarmonyLib; +using NebulaWorld; +using UnityEngine; + +namespace NebulaPatcher.Patches.Dynamic +{ + [HarmonyPatch(typeof(FactoryAudio))] + class FactoryAudio_Patch + { + [HarmonyPrefix] + [HarmonyPatch(nameof(FactoryAudio.OnEntityBuild))] + public static bool OnEntityBuild_Prefix(FactoryAudio __instance, int objId) + { + if (Multiplayer.IsActive && Multiplayer.Session.Factories.IsIncomingRequest.Value && objId > 0) + { + Vector3 pos = __instance.planet.factory.entityPool[objId].pos; + NebulaModel.Logger.Log.Debug((pos - GameMain.mainPlayer.position).sqrMagnitude + " " + (__instance.planet.radius * __instance.planet.radius / 4)); + if ((pos - GameMain.mainPlayer.position).sqrMagnitude > (__instance.planet.radius * __instance.planet.radius / 4)) + { + // Don't make sounds if distance is over half of the planet radius + return false; + } + } + return true; + } + + [HarmonyPrefix] + [HarmonyPatch(nameof(FactoryAudio.OnEntityDismantle))] + public static bool OnEntityDismantle_Prefix(FactoryAudio __instance, int objId) + { + if (Multiplayer.IsActive && Multiplayer.Session.Factories.IsIncomingRequest.Value) + { + Vector3 pos; + if (objId > 0) + { + pos = __instance.planet.factory.entityPool[objId].pos; + } + else + { + pos = __instance.planet.factory.prebuildPool[-objId].pos; + } + if ((pos - GameMain.mainPlayer.position).sqrMagnitude > (__instance.planet.radius * __instance.planet.radius / 4)) + { + // Don't make sounds if distance is over half of the planet radius + return false; + } + } + return true; + } + } +} From a4eb50d23962df67d0e021985c5542f62670aaf0 Mon Sep 17 00:00:00 2001 From: starfish <50672801+starfi5h@users.noreply.github.com> Date: Sun, 9 Jul 2023 14:29:53 +0800 Subject: [PATCH 5/6] 0.8.14 version + changelog --- CHANGELOG.md | 12 +++++++++--- version.json | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9414972c0..9e1c79c57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,19 @@ ## Changelog +0.8.14: +- @starfi5h: Fix mecha animation when player count > 2 +- @starfi5h: Fix UIPerformance save test in multiplayer +- @starfi5h: Disable build/dismantle sounds when too far away +- @starfi5h: Convert strings to string.Translate() to enable translation + +
+All changes + 0.8.13: - @starfi5h: Fix compilation with 0.9.27.15466 - @starfi5h: Add -newgame launch option for dedicated server -
-All changes - 0.8.12: - @PhantomGamers: Remove exe targeting to support game pass version diff --git a/version.json b/version.json index df3ea78ac..04f2113df 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "0.8.13", + "version": "0.8.14", "assemblyVersion": { "precision": "build" }, From 0c4d446d1cdc5fb44b570b736461b9ab53d6e171 Mon Sep 17 00:00:00 2001 From: starfish <50672801+starfi5h@users.noreply.github.com> Date: Sun, 9 Jul 2023 14:48:15 +0800 Subject: [PATCH 6/6] Remove debug log --- NebulaPatcher/Patches/Dynamic/FactoryAudio_Patch.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/NebulaPatcher/Patches/Dynamic/FactoryAudio_Patch.cs b/NebulaPatcher/Patches/Dynamic/FactoryAudio_Patch.cs index ed0921280..6151b7093 100644 --- a/NebulaPatcher/Patches/Dynamic/FactoryAudio_Patch.cs +++ b/NebulaPatcher/Patches/Dynamic/FactoryAudio_Patch.cs @@ -14,7 +14,6 @@ public static bool OnEntityBuild_Prefix(FactoryAudio __instance, int objId) if (Multiplayer.IsActive && Multiplayer.Session.Factories.IsIncomingRequest.Value && objId > 0) { Vector3 pos = __instance.planet.factory.entityPool[objId].pos; - NebulaModel.Logger.Log.Debug((pos - GameMain.mainPlayer.position).sqrMagnitude + " " + (__instance.planet.radius * __instance.planet.radius / 4)); if ((pos - GameMain.mainPlayer.position).sqrMagnitude > (__instance.planet.radius * __instance.planet.radius / 4)) { // Don't make sounds if distance is over half of the planet radius