-
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.
- Loading branch information
1 parent
bad5975
commit c6f169c
Showing
29 changed files
with
493 additions
and
20 deletions.
There are no files selected for viewing
4 changes: 0 additions & 4 deletions
4
...Test/Patcher/Patches/Dynamic/AggressiveWhenSeeTarget_ScanForAggressionTarget_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
4 changes: 0 additions & 4 deletions
4
Nitrox.Test/Patcher/Patches/Dynamic/AttackCyclops_OnCollisionEnter_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
4 changes: 0 additions & 4 deletions
4
Nitrox.Test/Patcher/Patches/Dynamic/AttackCyclops_UpdateAggression_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
16 changes: 16 additions & 0 deletions
16
Nitrox.Test/Patcher/Patches/Dynamic/Poop_Perform_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,16 @@ | ||
using HarmonyLib; | ||
using NitroxTest.Patcher; | ||
|
||
namespace NitroxPatcher.Patches.Dynamic; | ||
|
||
[TestClass] | ||
public class Poop_Perform_PatchTest | ||
{ | ||
[TestMethod] | ||
public void Sanity() | ||
{ | ||
IEnumerable<CodeInstruction> originalIl = PatchTestHelper.GetInstructionsFromMethod(Poop_Perform_Patch.TARGET_METHOD); | ||
IEnumerable<CodeInstruction> transformedIl = Poop_Perform_Patch.Transpiler(originalIl); | ||
transformedIl.Count().Should().Be(originalIl.Count() + 1); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
Nitrox.Test/Patcher/Patches/Dynamic/SeaTreaderSounds_SpawnChunks_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,16 @@ | ||
using HarmonyLib; | ||
using NitroxTest.Patcher; | ||
|
||
namespace NitroxPatcher.Patches.Dynamic; | ||
|
||
[TestClass] | ||
public class SeaTreaderSounds_SpawnChunks_PatchTest | ||
{ | ||
[TestMethod] | ||
public void Sanity() | ||
{ | ||
IEnumerable<CodeInstruction> originalIl = PatchTestHelper.GetInstructionsFromMethod(SeaTreaderSounds_SpawnChunks_Patch.TARGET_METHOD); | ||
IEnumerable<CodeInstruction> transformedIl = SeaTreaderSounds_SpawnChunks_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
13 changes: 13 additions & 0 deletions
13
NitroxClient/Communication/Packets/Processors/CreaturePoopPerformedProcessor.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,13 @@ | ||
using NitroxClient.Communication.Packets.Processors.Abstract; | ||
using NitroxClient.GameLogic; | ||
using NitroxModel.Packets; | ||
|
||
namespace NitroxClient.Communication.Packets.Processors; | ||
|
||
public class CreaturePoopPerformedProcessor : ClientPacketProcessor<CreaturePoopPerformed> | ||
{ | ||
public override void Process(CreaturePoopPerformed packet) | ||
{ | ||
AI.CreaturePoopPerformed(packet.CreatureId); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
NitroxClient/Communication/Packets/Processors/SeaTreaderChunkPickedUpProcessor.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 UnityEngine; | ||
|
||
namespace NitroxClient.Communication.Packets.Processors; | ||
|
||
public class SeaTreaderChunkPickedUpProcessor : ClientPacketProcessor<SeaTreaderChunkPickedUp> | ||
{ | ||
public override void Process(SeaTreaderChunkPickedUp packet) | ||
{ | ||
if (NitroxEntity.TryGetComponentFrom(packet.ChunkId, out SinkingGroundChunk sinkingGroundChunk)) | ||
{ | ||
GameObject.Destroy(sinkingGroundChunk.gameObject); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
NitroxClient/Communication/Packets/Processors/SeaTreaderSpawnedChunkProcessor.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,22 @@ | ||
using NitroxClient.Communication.Packets.Processors.Abstract; | ||
using NitroxClient.MonoBehaviours; | ||
using NitroxClient.Unity.Helper; | ||
using NitroxModel.Packets; | ||
using NitroxModel_Subnautica.DataStructures; | ||
using UnityEngine; | ||
|
||
namespace NitroxClient.Communication.Packets.Processors; | ||
|
||
public class SeaTreaderSpawnedChunkProcessor : ClientPacketProcessor<SeaTreaderSpawnedChunk> | ||
{ | ||
public override void Process(SeaTreaderSpawnedChunk packet) | ||
{ | ||
if (NitroxEntity.TryGetComponentFrom(packet.CreatureId, out SeaTreader seaTreader) && | ||
seaTreader.TryGetComponentInChildren(out SeaTreaderSounds seaTreaderSounds)) | ||
{ | ||
GameObject chunkObject = GameObjectHelper.InstantiateWithId(seaTreaderSounds.stepChunkPrefab, packet.ChunkId); | ||
chunkObject.transform.position = packet.Position.ToUnity(); | ||
chunkObject.transform.rotation = packet.Rotation.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
18 changes: 18 additions & 0 deletions
18
NitroxClient/GameLogic/Spawning/Metadata/Extractor/SeaTreaderMetadataExtractor.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,18 @@ | ||
using NitroxClient.GameLogic.Spawning.Metadata.Extractor.Abstract; | ||
using NitroxModel.DataStructures.GameLogic.Entities.Metadata; | ||
using NitroxModel_Subnautica.DataStructures; | ||
|
||
namespace NitroxClient.GameLogic.Spawning.Metadata.Extractor; | ||
|
||
public class SeaTreaderMetadataExtractor : EntityMetadataExtractor<SeaTreader, SeaTreaderMetadata> | ||
{ | ||
public override SeaTreaderMetadata Extract(SeaTreader seaTreader) | ||
{ | ||
if (!DayNightCycle.main) | ||
{ | ||
return null; | ||
} | ||
float grazingEndTime = DayNightCycle.main.timePassedAsFloat + seaTreader.grazingTimeLeft; | ||
return new(seaTreader.reverseDirection, grazingEndTime, seaTreader.leashPosition.ToDto()); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
NitroxClient/GameLogic/Spawning/Metadata/Processor/SeaTreaderMetadataProcessor.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,37 @@ | ||
using System; | ||
using NitroxClient.GameLogic.Spawning.Metadata.Processor.Abstract; | ||
using NitroxModel.DataStructures.GameLogic.Entities.Metadata; | ||
using NitroxModel_Subnautica.DataStructures; | ||
using UnityEngine; | ||
|
||
namespace NitroxClient.GameLogic.Spawning.Metadata.Processor; | ||
|
||
public class SeaTreaderMetadataProcessor : EntityMetadataProcessor<SeaTreaderMetadata> | ||
{ | ||
public override void ProcessMetadata(GameObject gameObject, SeaTreaderMetadata metadata) | ||
{ | ||
if (gameObject.TryGetComponent(out SeaTreader seaTreader)) | ||
{ | ||
if (!seaTreader.isInitialized) | ||
{ | ||
seaTreader.InitializeOnce(); | ||
} | ||
|
||
seaTreader.reverseDirection = metadata.ReverseDirection; | ||
|
||
float grazingTimeLeft = Math.Max(0, metadata.GrazingEndTime - DayNightCycle.main.timePassedAsFloat); | ||
|
||
seaTreader.grazing = grazingTimeLeft > 0; | ||
seaTreader.grazingTimeLeft = grazingTimeLeft; | ||
|
||
seaTreader.leashPosition = metadata.LeashPosition.ToUnity(); | ||
seaTreader.leashPosition.y = gameObject.transform.position.y; | ||
seaTreader.isInitialized = true; | ||
seaTreader.InitializeAgain(); | ||
} | ||
else | ||
{ | ||
Log.Error($"Could not find {nameof(SeaTreader)} on {gameObject.name}"); | ||
} | ||
} | ||
} |
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
38 changes: 38 additions & 0 deletions
38
NitroxModel/DataStructures/GameLogic/Entities/Metadata/SeaTreaderMetadata.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,38 @@ | ||
using System; | ||
using System.Runtime.Serialization; | ||
using BinaryPack.Attributes; | ||
using NitroxModel.DataStructures.Unity; | ||
|
||
namespace NitroxModel.DataStructures.GameLogic.Entities.Metadata; | ||
|
||
[Serializable] | ||
[DataContract] | ||
public class SeaTreaderMetadata : EntityMetadata | ||
{ | ||
[DataMember(Order = 1)] | ||
public bool ReverseDirection { get; } | ||
|
||
[DataMember(Order = 2)] | ||
public float GrazingEndTime { get; } | ||
|
||
[DataMember(Order = 3)] | ||
public NitroxVector3 LeashPosition { get; } | ||
|
||
[IgnoreConstructor] | ||
protected SeaTreaderMetadata() | ||
{ | ||
// Constructor for serialization. Has to be "protected" for json serialization. | ||
} | ||
|
||
public SeaTreaderMetadata(bool reverseDirection, float grazingEndTime, NitroxVector3 leashPosition) | ||
{ | ||
ReverseDirection = reverseDirection; | ||
GrazingEndTime = grazingEndTime; | ||
LeashPosition = leashPosition; | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return $"[{nameof(SeaTreaderMetadata)} ReverseDirection: {ReverseDirection}, GrazingEndTime: {GrazingEndTime}, LeashPosition: {LeashPosition}]"; | ||
} | ||
} |
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,15 @@ | ||
using System; | ||
using NitroxModel.DataStructures; | ||
|
||
namespace NitroxModel.Packets; | ||
|
||
[Serializable] | ||
public class CreaturePoopPerformed : Packet | ||
{ | ||
public NitroxId CreatureId { get; } | ||
|
||
public CreaturePoopPerformed(NitroxId creatureId) | ||
{ | ||
CreatureId = creatureId; | ||
} | ||
} |
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,15 @@ | ||
using System; | ||
using NitroxModel.DataStructures; | ||
|
||
namespace NitroxModel.Packets; | ||
|
||
[Serializable] | ||
public class SeaTreaderChunkPickedUp : Packet | ||
{ | ||
public NitroxId ChunkId { get; } | ||
|
||
public SeaTreaderChunkPickedUp(NitroxId chunkId) | ||
{ | ||
ChunkId = chunkId; | ||
} | ||
} |
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,22 @@ | ||
using System; | ||
using NitroxModel.DataStructures; | ||
using NitroxModel.DataStructures.Unity; | ||
|
||
namespace NitroxModel.Packets; | ||
|
||
[Serializable] | ||
public class SeaTreaderSpawnedChunk : Packet | ||
{ | ||
public NitroxId CreatureId { get; } | ||
public NitroxId ChunkId { get; } | ||
public NitroxVector3 Position { get; } | ||
public NitroxQuaternion Rotation { get; } | ||
|
||
public SeaTreaderSpawnedChunk(NitroxId creatureId, NitroxId chunkId, NitroxVector3 position, NitroxQuaternion rotation) | ||
{ | ||
CreatureId = creatureId; | ||
ChunkId = chunkId; | ||
Position = position; | ||
Rotation = rotation; | ||
} | ||
} |
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.