-
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
1f7f9ec
commit c0598d1
Showing
36 changed files
with
903 additions
and
17 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
Nitrox.Test/Patcher/Patches/Dynamic/SeaDragonMeleeAttack_OnTouchFront_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 SeaDragonMeleeAttack_OnTouchFront_PatchTest | ||
{ | ||
[TestMethod] | ||
public void Sanity() | ||
{ | ||
IEnumerable<CodeInstruction> originalIl = PatchTestHelper.GetInstructionsFromMethod(SeaDragonMeleeAttack_OnTouchFront_Patch.TARGET_METHOD); | ||
IEnumerable<CodeInstruction> transformedIl = SeaDragonMeleeAttack_OnTouchFront_Patch.Transpiler(originalIl); | ||
transformedIl.Count().Should().Be(originalIl.Count() + 9); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
Nitrox.Test/Patcher/Patches/Dynamic/SeaDragonMeleeAttack_SwatAttack_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 SeaDragonMeleeAttack_SwatAttack_PatchTest | ||
{ | ||
[TestMethod] | ||
public void Sanity() | ||
{ | ||
IEnumerable<CodeInstruction> originalIl = PatchTestHelper.GetInstructionsFromMethod(SeaDragonMeleeAttack_SwatAttack_Patch.TARGET_METHOD); | ||
IEnumerable<CodeInstruction> transformedIl = SeaDragonMeleeAttack_SwatAttack_Patch.Transpiler(originalIl); | ||
transformedIl.Count().Should().Be(originalIl.Count() + 4); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
NitroxClient/Communication/Packets/Processors/RangedAttackLastTargetUpdateProcessor.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 RangedAttackLastTargetUpdateProcessor : ClientPacketProcessor<RangedAttackLastTargetUpdate> | ||
{ | ||
public override void Process(RangedAttackLastTargetUpdate packet) | ||
{ | ||
AI.RangedAttackLastTargetUpdate(packet.CreatureId, packet.TargetId, packet.AttackTypeIndex, packet.State); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
NitroxClient/Communication/Packets/Processors/SeaDragonAttackTargetProcessor.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,53 @@ | ||
using NitroxClient.Communication.Packets.Processors.Abstract; | ||
using NitroxClient.GameLogic.PlayerLogic; | ||
using NitroxClient.MonoBehaviours; | ||
using NitroxModel.Packets; | ||
using UnityEngine; | ||
|
||
namespace NitroxClient.Communication.Packets.Processors; | ||
|
||
public class SeaDragonAttackTargetProcessor : ClientPacketProcessor<SeaDragonAttackTarget> | ||
{ | ||
public override void Process(SeaDragonAttackTarget packet) | ||
{ | ||
if (!NitroxEntity.TryGetComponentFrom(packet.SeaDragonId, out SeaDragonMeleeAttack seaDragonMeleeAttack) || | ||
!NitroxEntity.TryGetObjectFrom(packet.TargetId, out GameObject target)) | ||
{ | ||
return; | ||
} | ||
|
||
seaDragonMeleeAttack.seaDragon.Aggression.Value = packet.Aggression; | ||
if (target.GetComponent<SubControl>()) | ||
{ | ||
// SeaDragonMeleeAttack.OnTouchFront's useful part about Cyclops attack | ||
seaDragonMeleeAttack.animator.SetTrigger("shove"); | ||
seaDragonMeleeAttack.SendMessage("OnMeleeAttack", target, SendMessageOptions.DontRequireReceiver); | ||
seaDragonMeleeAttack.timeLastBite = Time.time; | ||
return; | ||
} | ||
|
||
|
||
// SeaDragonMeleeAttack.OnTouchFront's useful part about local player attack | ||
Collider collider; | ||
if (target.TryGetComponent(out RemotePlayerIdentifier remotePlayerIdentifier)) | ||
{ | ||
collider = remotePlayerIdentifier.RemotePlayer.Collider; | ||
} | ||
else if (target.GetComponent<Player>()) | ||
{ | ||
collider = Player.mainCollider; | ||
} | ||
else | ||
{ | ||
return; | ||
} | ||
|
||
seaDragonMeleeAttack.timeLastBite = Time.time; | ||
if (seaDragonMeleeAttack.attackSound) | ||
{ | ||
// TODO: Adapt this code when #1780 is merged | ||
Utils.PlayEnvSound(seaDragonMeleeAttack.attackSound, collider.transform.position, 20f); | ||
} | ||
seaDragonMeleeAttack.OnTouch(collider); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
NitroxClient/Communication/Packets/Processors/SeaDragonGrabExosuitProcessor.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,23 @@ | ||
using NitroxClient.Communication.Packets.Processors.Abstract; | ||
using NitroxClient.MonoBehaviours; | ||
using NitroxModel.Packets; | ||
|
||
namespace NitroxClient.Communication.Packets.Processors; | ||
|
||
public class SeaDragonGrabExosuitProcessor : ClientPacketProcessor<SeaDragonGrabExosuit> | ||
{ | ||
public override void Process(SeaDragonGrabExosuit packet) | ||
{ | ||
if (!NitroxEntity.TryGetComponentFrom(packet.SeaDragonId, out SeaDragon seaDragon) || | ||
!NitroxEntity.TryGetComponentFrom(packet.TargetId, out Exosuit exosuit)) | ||
{ | ||
return; | ||
} | ||
|
||
using (PacketSuppressor<SeaDragonGrabExosuit>.Suppress()) | ||
{ | ||
seaDragon.GrabExosuit(exosuit); | ||
seaDragon.CancelInvoke(nameof(SeaDragon.DamageExosuit)); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
NitroxClient/Communication/Packets/Processors/SeaDragonSwatAttackProcessor.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,24 @@ | ||
using NitroxClient.Communication.Packets.Processors.Abstract; | ||
using NitroxClient.MonoBehaviours; | ||
using NitroxModel.Packets; | ||
using UnityEngine; | ||
|
||
namespace NitroxClient.Communication.Packets.Processors; | ||
|
||
public class SeaDragonSwatAttackProcessor : ClientPacketProcessor<SeaDragonSwatAttack> | ||
{ | ||
public override void Process(SeaDragonSwatAttack packet) | ||
{ | ||
if (!NitroxEntity.TryGetComponentFrom(packet.SeaDragonId, out SeaDragonMeleeAttack seaDragonMeleeAttack) || | ||
!NitroxEntity.TryGetObjectFrom(packet.TargetId, out GameObject targetObject)) | ||
{ | ||
return; | ||
} | ||
|
||
using (PacketSuppressor<SeaDragonSwatAttack>.Suppress()) | ||
{ | ||
seaDragonMeleeAttack.seaDragon.Aggression.Value = packet.Aggression; | ||
seaDragonMeleeAttack.SwatAttack(targetObject, packet.IsRightHand); | ||
} | ||
} | ||
} |
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
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,27 @@ | ||
using System; | ||
using NitroxModel.DataStructures; | ||
|
||
namespace NitroxModel.Packets; | ||
|
||
[Serializable] | ||
public class RangedAttackLastTargetUpdate : Packet | ||
{ | ||
public NitroxId CreatureId { get; } | ||
public NitroxId TargetId { get; } | ||
public int AttackTypeIndex { get; } | ||
public ActionState State { get; } | ||
|
||
public RangedAttackLastTargetUpdate(NitroxId creatureId, NitroxId targetId, int attackTypeIndex, ActionState state) | ||
{ | ||
CreatureId = creatureId; | ||
TargetId = targetId; | ||
AttackTypeIndex = attackTypeIndex; | ||
State = state; | ||
} | ||
|
||
public enum ActionState | ||
{ | ||
CHARGING, | ||
CASTING | ||
} | ||
} |
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,19 @@ | ||
using System; | ||
using NitroxModel.DataStructures; | ||
|
||
namespace NitroxModel.Packets; | ||
|
||
[Serializable] | ||
public class SeaDragonAttackTarget : Packet | ||
{ | ||
public NitroxId SeaDragonId { get; } | ||
public NitroxId TargetId { get; } | ||
public float Aggression { get; } | ||
|
||
public SeaDragonAttackTarget(NitroxId seaDragonId, NitroxId targetId, float aggression) | ||
{ | ||
SeaDragonId = seaDragonId; | ||
TargetId = targetId; | ||
Aggression = aggression; | ||
} | ||
} |
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 System; | ||
using NitroxModel.DataStructures; | ||
|
||
namespace NitroxModel.Packets; | ||
|
||
[Serializable] | ||
public class SeaDragonGrabExosuit : Packet | ||
{ | ||
public NitroxId SeaDragonId { get; } | ||
public NitroxId TargetId { get; } | ||
|
||
public SeaDragonGrabExosuit(NitroxId seaDragonId, NitroxId targetId) | ||
{ | ||
SeaDragonId = seaDragonId; | ||
TargetId = targetId; | ||
} | ||
} |
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,21 @@ | ||
using System; | ||
using NitroxModel.DataStructures; | ||
|
||
namespace NitroxModel.Packets; | ||
|
||
[Serializable] | ||
public class SeaDragonSwatAttack : Packet | ||
{ | ||
public NitroxId SeaDragonId { get; } | ||
public NitroxId TargetId { get; } | ||
public bool IsRightHand { get; } | ||
public float Aggression { get; } | ||
|
||
public SeaDragonSwatAttack(NitroxId seaDragonId, NitroxId targetId, bool isRightHand, float aggression) | ||
{ | ||
SeaDragonId = seaDragonId; | ||
TargetId = targetId; | ||
IsRightHand = isRightHand; | ||
Aggression = aggression; | ||
} | ||
} |
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.