From eaa489a10e29682676fe18987c52443694923261 Mon Sep 17 00:00:00 2001 From: killzoms Date: Sat, 21 Oct 2023 13:36:51 -0400 Subject: [PATCH] Reapply HighPrecisionPhysics --- .../GameLogic/Spawning/WorldEntitySpawner.cs | 49 +------------------ .../GroundMotor_UpdateFunction_Patch.cs | 28 ----------- ...ayer_RequiresHighPrecisionPhysics_Patch.cs | 2 +- 3 files changed, 3 insertions(+), 76 deletions(-) delete mode 100644 NitroxPatcher/Patches/Dynamic/GroundMotor_UpdateFunction_Patch.cs diff --git a/NitroxClient/GameLogic/Spawning/WorldEntitySpawner.cs b/NitroxClient/GameLogic/Spawning/WorldEntitySpawner.cs index 54afb5ed6d..5999e7c1af 100644 --- a/NitroxClient/GameLogic/Spawning/WorldEntitySpawner.cs +++ b/NitroxClient/GameLogic/Spawning/WorldEntitySpawner.cs @@ -22,54 +22,9 @@ public WorldEntitySpawner(PlayerManager playerManager, ILocalNitroxPlayer localP { worldEntitySpawnResolver = new WorldEntitySpawnerResolver(playerManager, localPlayer, simulationOwnership, entities); - if (NitroxEnvironment.IsNormal) - { - batchCellsById = (Dictionary)LargeWorldStreamer.main.cellManager.batch2cells; - } - } - - public override IEnumerator SpawnAsync(WorldEntity entity, TaskResult> result) + if (NitroxEnvironment.IsNormal) { - LargeWorldStreamer.main.cellManager.UnloadBatchCells(entity.AbsoluteEntityCell.CellId.ToUnity()); // Just in case - - EntityCell cellRoot = EnsureCell(entity); - - Optional parent = (entity.ParentId != null) ? NitroxEntity.GetObjectFrom(entity.ParentId) : Optional.Empty; - - IWorldEntitySpawner entitySpawner = worldEntitySpawnResolver.ResolveEntitySpawner(entity); - - return entitySpawner.SpawnAsync(entity, parent, cellRoot, result); - } - public override bool SpawnsOwnChildren(WorldEntity entity) - { - IWorldEntitySpawner entitySpawner = worldEntitySpawnResolver.ResolveEntitySpawner(entity); - return entitySpawner.SpawnsOwnChildren(); - } - - private EntityCell EnsureCell(WorldEntity entity) - { - EntityCell entityCell; - - Int3 batchId = entity.AbsoluteEntityCell.BatchId.ToUnity(); - Int3 cellId = entity.AbsoluteEntityCell.CellId.ToUnity(); - - if (!batchCellsById.TryGetValue(batchId, out BatchCells batchCells)) - { - batchCells = LargeWorldStreamer.main.cellManager.InitializeBatchCells(batchId); - } - - entityCell = batchCells.Get(cellId, entity.AbsoluteEntityCell.Level); - - if (entityCell == null) - { - entityCell = batchCells.Add(cellId, entity.AbsoluteEntityCell.Level); - entityCell.Initialize(); - } - - entityCell.EnsureRoot(); - - return entityCell; ->>>>>>> ddf37665 (first round of bug fixes) + batchCellsById = (Dictionary)LargeWorldStreamer.main.cellManager.batch2cells; } } diff --git a/NitroxPatcher/Patches/Dynamic/GroundMotor_UpdateFunction_Patch.cs b/NitroxPatcher/Patches/Dynamic/GroundMotor_UpdateFunction_Patch.cs deleted file mode 100644 index 1a093d3a0a..0000000000 --- a/NitroxPatcher/Patches/Dynamic/GroundMotor_UpdateFunction_Patch.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System.Reflection; -using NitroxClient.GameLogic; -using NitroxModel.DataStructures; -using NitroxModel.DataStructures.GameLogic.Entities.Metadata; -using NitroxModel.Helper; -using NitroxModel_Subnautica.DataStructures; -using UnityEngine; - -namespace NitroxPatcher.Patches.Dynamic; - -public sealed partial class GroundMotor_UpdateFunction_Patch : NitroxPatch, IDynamicPatch -{ - private static readonly MethodInfo TARGET_METHOD = Reflect.Method((GroundMotor t) => t.UpdateFunction()); - - public static void Postfix(GroundMotor __instance) - { - if (Physics.Raycast(__instance.transform.position + __instance.controller.center + Vector3.down * __instance.controller.height * 0.5f, Vector3.down, out RaycastHit hitInfo, __instance.controller.skinWidth + 0.01f) && hitInfo.transform.TryGetComponent(out Rigidbody rb)) - { - Vector3 platformPosition = hitInfo.transform.position; - Vector3 rbPosition = rb.position; - - Vector3 posRelativeToRigidbody = __instance.transform.position - rbPosition; - Vector3 posRelativeToPlatform = posRelativeToRigidbody + platformPosition; - - __instance.transform.position = posRelativeToPlatform; - } - } -} diff --git a/NitroxPatcher/Patches/Dynamic/Player_RequiresHighPrecisionPhysics_Patch.cs b/NitroxPatcher/Patches/Dynamic/Player_RequiresHighPrecisionPhysics_Patch.cs index c96ed54f16..56abb89188 100644 --- a/NitroxPatcher/Patches/Dynamic/Player_RequiresHighPrecisionPhysics_Patch.cs +++ b/NitroxPatcher/Patches/Dynamic/Player_RequiresHighPrecisionPhysics_Patch.cs @@ -22,7 +22,7 @@ public static bool Prefix(ref bool __result) if (movementController && movementController.Receiving) { - __result = false; + __result = true; return false; } }