File tree Expand file tree Collapse file tree
Communication/Packets/Processors
NitroxPatcher/Patches/Dynamic Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ public override void Process(PlayerStats playerStats)
1818 {
1919 if ( playerManager . TryFind ( playerStats . PlayerId , out RemotePlayer remotePlayer ) )
2020 {
21- RemotePlayerVitals vitals = remotePlayer . vitals ;
21+ RemotePlayerVitals vitals = remotePlayer . Vitals ;
2222 vitals . SetOxygen ( playerStats . Oxygen , playerStats . MaxOxygen ) ;
2323 vitals . SetHealth ( playerStats . Health ) ;
2424 vitals . SetFood ( playerStats . Food ) ;
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ public class RemotePlayer : INitroxPlayer
4040 public AnimationController AnimationController { get ; private set ; }
4141 public ItemsContainer Inventory { get ; private set ; }
4242 public Transform ItemAttachPoint { get ; private set ; }
43- public RemotePlayerVitals vitals { get ; private set ; }
43+ public RemotePlayerVitals Vitals { get ; private set ; }
4444
4545 public ushort PlayerId => PlayerContext . PlayerId ;
4646 public string PlayerName => PlayerContext . PlayerName ;
@@ -104,7 +104,7 @@ public void InitializeGameObject(GameObject playerBody)
104104 SetupPlayerSounds ( ) ;
105105 SetupMixins ( ) ;
106106
107- vitals = playerVitalsManager . CreateOrFindForPlayer ( this ) ;
107+ Vitals = playerVitalsManager . CreateOrFindForPlayer ( this ) ;
108108 RefreshVitalsVisibility ( ) ;
109109
110110 PlayerDisconnectEvent . AddHandler ( Body , _ =>
@@ -549,10 +549,10 @@ public void SetGameMode(NitroxGameMode gameMode)
549549
550550 private void RefreshVitalsVisibility ( )
551551 {
552- if ( vitals )
552+ if ( Vitals )
553553 {
554554 bool visible = PlayerContext . GameMode != NitroxGameMode . CREATIVE ;
555- vitals . SetStatsVisible ( visible ) ;
555+ Vitals . SetStatsVisible ( visible ) ;
556556 }
557557 }
558558
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ namespace NitroxPatcher.Patches.Dynamic;
1414/// </summary>
1515public sealed partial class MeleeAttack_CanDealDamageTo_Patch : NitroxPatch , IDynamicPatch
1616{
17- private static readonly MethodInfo TARGET_METHOD = Reflect . Method ( ( MeleeAttack t ) => t . CanDealDamageTo ( default ) ) ;
17+ internal static readonly MethodInfo TARGET_METHOD = Reflect . Method ( ( MeleeAttack t ) => t . CanDealDamageTo ( default ) ) ;
1818
1919 /*
2020 * REPLACE:
Original file line number Diff line number Diff line change 1+ using System . Collections . Generic ;
2+ using System . Reflection ;
3+ using System . Reflection . Emit ;
4+ using HarmonyLib ;
5+ using NitroxClient . GameLogic ;
6+ using NitroxClient . MonoBehaviours . Cyclops ;
7+ using NitroxModel . DataStructures ;
8+ using NitroxModel . Helper ;
9+ using UnityEngine ;
10+
11+ namespace NitroxPatcher . Patches . Dynamic ;
12+
13+
14+ /// <summary>
15+ /// Prevents non simulating players from running locally <see cref="MeleeAttack.OnTouch(Collider)"/>.
16+ ///
17+ /// Adds RemotePlayer support for the simulating player
18+ /// </summary>
19+ public sealed partial class MeleeAttack_OnTouch_Patch : NitroxPatch , IDynamicPatch
20+ {
21+ internal static readonly MethodInfo TARGET_METHOD = Reflect . Method ( ( MeleeAttack t ) => t . OnTouch ( default ) ) ;
22+
23+ public static bool Prefix ( MeleeAttack __instance )
24+ {
25+ if ( ! __instance . TryGetNitroxId ( out NitroxId creatureId ) ||
26+ Resolve < SimulationOwnership > ( ) . HasAnyLockType ( creatureId ) )
27+ {
28+ return true ;
29+ }
30+
31+ return false ;
32+ }
33+
34+ // TODO: Add transpiler to add support for held item eat from remote players, we might need to add an equivalent of Inventory.GetHeldItem()
35+ // For the MeleeAttack part , it'll natively work since RemotePlayer should have a LiveMixin
36+ }
You can’t perform that action at this time.
0 commit comments