-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Sync base hull * Fix "entity was spawned" condition, fix ServerAutofac duplicate registering of a critical instance, fix base hull strength creating duplicate leaks, fix simulation not being acquired when creating a base * Fix a regression: all children added to bases were duplicated, improve LiveMixin metadata broadcast conditions
- Loading branch information
1 parent
06e114e
commit 5c48f8c
Showing
25 changed files
with
514 additions
and
65 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
Nitrox.Test/Patcher/Patches/Dynamic/BaseHullStrength_CrushDamageUpdate_PatchTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using FluentAssertions; | ||
using HarmonyLib; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using NitroxTest.Patcher; | ||
|
||
namespace NitroxPatcher.Patches.Dynamic; | ||
|
||
[TestClass] | ||
public class BaseHullStrength_CrushDamageUpdate_PatchTest | ||
{ | ||
[TestMethod] | ||
public void Sanity() | ||
{ | ||
IEnumerable<CodeInstruction> originalIl = PatchTestHelper.GetInstructionsFromMethod(BaseHullStrength_CrushDamageUpdate_Patch.TARGET_METHOD); | ||
IEnumerable<CodeInstruction> transformedIl = BaseHullStrength_CrushDamageUpdate_Patch.Transpiler(originalIl); | ||
transformedIl.Count().Should().Be(originalIl.Count() + 3); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
NitroxClient/Communication/Packets/Processors/LeakRepairedProcessor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using NitroxClient.Communication.Packets.Processors.Abstract; | ||
using NitroxClient.MonoBehaviours; | ||
using NitroxModel.Packets; | ||
using NitroxModel_Subnautica.DataStructures; | ||
|
||
namespace NitroxClient.Communication.Packets.Processors; | ||
|
||
public class LeakRepairedProcessor : ClientPacketProcessor<LeakRepaired> | ||
{ | ||
public override void Process(LeakRepaired packet) | ||
{ | ||
if (NitroxEntity.TryGetComponentFrom(packet.BaseId, out BaseLeakManager baseLeakManager)) | ||
{ | ||
baseLeakManager.HealLeakToMax(packet.RelativeCell.ToUnity()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
NitroxClient/GameLogic/Spawning/Bases/BaseLeakEntitySpawner.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System.Collections; | ||
using NitroxClient.GameLogic.Spawning.Abstract; | ||
using NitroxClient.MonoBehaviours; | ||
using NitroxModel.DataStructures.GameLogic.Entities.Bases; | ||
using NitroxModel.DataStructures.Util; | ||
using NitroxModel_Subnautica.DataStructures; | ||
using UnityEngine; | ||
|
||
namespace NitroxClient.GameLogic.Spawning.Bases; | ||
|
||
public class BaseLeakEntitySpawner : SyncEntitySpawner<BaseLeakEntity> | ||
{ | ||
private readonly LiveMixinManager liveMixinManager; | ||
|
||
public BaseLeakEntitySpawner(LiveMixinManager liveMixinManager) | ||
{ | ||
this.liveMixinManager = liveMixinManager; | ||
} | ||
|
||
protected override IEnumerator SpawnAsync(BaseLeakEntity entity, TaskResult<Optional<GameObject>> result) | ||
{ | ||
SpawnSync(entity, result); | ||
yield break; | ||
} | ||
|
||
protected override bool SpawnsOwnChildren(BaseLeakEntity entity) => false; | ||
|
||
protected override bool SpawnSync(BaseLeakEntity entity, TaskResult<Optional<GameObject>> result) | ||
{ | ||
if (!NitroxEntity.TryGetComponentFrom(entity.ParentId, out BaseHullStrength baseHullStrength)) | ||
{ | ||
Log.Error($"[{nameof(BaseLeakEntitySpawner)}] Couldn't find a {nameof(BaseHullStrength)} from id {entity.ParentId}"); | ||
return true; | ||
} | ||
|
||
BaseLeakManager baseLeakManager = baseHullStrength.gameObject.EnsureComponent<BaseLeakManager>(); | ||
baseLeakManager.EnsureLeak(entity.RelativeCell.ToUnity(), entity.Id, entity.Health); | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.