Skip to content

Commit 450c2b0

Browse files
authored
Fix tool inspect animation replaying on login (SubnauticaNitrox#2634)
1 parent c47fc40 commit 450c2b0

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

NitroxClient/Communication/Packets/Processors/PlayerHeldItemChangedProcessor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using Nitrox.Model.Core;
33
using Nitrox.Model.DataStructures;
44
using Nitrox.Model.Helper;
@@ -73,7 +73,7 @@ public override void Process(PlayerHeldItemChanged packet)
7373
item.SetActive(true);
7474
tool.SetHandIKTargetsEnabled(true);
7575
SafeAnimator.SetBool(opPlayer.Value.ArmsController.GetComponent<Animator>(), $"holding_{tool.animToolName}", true);
76-
opPlayer.Value.AnimationController["using_tool_first"] = packet.IsFirstTime == null;
76+
opPlayer.Value.AnimationController["using_tool_first"] = packet.IsFirstTime != null;
7777

7878
if (item.TryGetComponent(out FPModel fpModelDraw)) //FPModel needs to be updated
7979
{

NitroxClient/GameLogic/InitialSync/PlayerInitialSyncProcessor.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
using System.Collections;
2+
using System.Collections.Generic;
23
using System.Text;
34
using NitroxClient.GameLogic.InitialSync.Abstract;
45
using NitroxClient.MonoBehaviours;
56
using Nitrox.Model.DataStructures;
67
using Nitrox.Model.DataStructures.GameLogic;
78
using Nitrox.Model.Server;
9+
using Nitrox.Model.Subnautica.DataStructures;
810
using Nitrox.Model.Subnautica.DataStructures.GameLogic;
911
using UnityEngine;
1012

@@ -35,6 +37,7 @@ public PlayerInitialSyncProcessor(Items item, ItemContainers itemContainers, Loc
3537
AddStep(sync => SetPlayerGameObjectId(sync.PlayerGameObjectId));
3638
AddStep(sync => AddStartingItemsToPlayer(sync.FirstTimeConnecting));
3739
AddStep(sync => SetPlayerStats(sync.PlayerStatsData));
40+
AddStep(sync => SetUsedItems(sync.UsedItems));
3841
AddStep(sync => SetPlayerGameMode(sync.GameMode));
3942
AddStep(sync => ApplySettings(sync.KeepInventoryOnDeath, sync.SessionSettings.FastHatch, sync.SessionSettings.FastGrow));
4043
}
@@ -133,6 +136,20 @@ private static void SetPlayerStats(PlayerStatsData statsData)
133136
Player.main.GetPDA().Close();
134137
}
135138

139+
private static void SetUsedItems(List<NitroxTechType> usedItems)
140+
{
141+
if (usedItems == null)
142+
{
143+
return;
144+
}
145+
146+
foreach (NitroxTechType usedItem in usedItems)
147+
{
148+
Player.main.usedTools.Add(usedItem.ToUnity());
149+
}
150+
Log.Info($"Received initial sync packet with {usedItems.Count} used items");
151+
}
152+
136153
private static void SetPlayerGameMode(NitroxGameMode gameMode)
137154
{
138155
Log.Info($"Received initial sync packet with gamemode {gameMode}");

NitroxPatcher/Patches/Dynamic/QuickSlots_SelectInternal_Patch.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ public static void Prefix(QuickSlots __instance, int slotID, ref NitroxTechType
1919
{
2020
return;
2121
}
22-
__state = Player.main.IsToolUsed(item.item.GetTechType()) ? item.item.GetTechType().ToDto() : null;
22+
// Send the TechType if this is the first time using the tool (not yet in usedTools)
23+
__state = Player.main.IsToolUsed(item.item.GetTechType()) ? null : item.item.GetTechType().ToDto();
2324
}
2425

2526
public static void Postfix(InventoryItem ____heldItem, NitroxTechType __state)

0 commit comments

Comments
 (0)