From 2bb8baa23c3651118d4a2a646bb39aa104227d52 Mon Sep 17 00:00:00 2001 From: sebastianhampel1 Date: Thu, 15 Jun 2023 13:03:27 -0400 Subject: [PATCH] Network fixes 2 --- Assets/Scripts/Item/InteractableItem.cs | 3 +++ Assets/Scripts/Item/Pistol/PistolComponent.cs | 2 +- .../Player/NoiseVisibilitySettingsManager.cs | 3 ++- .../Player/PlayerInteractionHandler.cs | 19 +++++++++++-------- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Assets/Scripts/Item/InteractableItem.cs b/Assets/Scripts/Item/InteractableItem.cs index b6cda6b..5402795 100644 --- a/Assets/Scripts/Item/InteractableItem.cs +++ b/Assets/Scripts/Item/InteractableItem.cs @@ -1,3 +1,4 @@ +using FishNet.Object; using TMPro; using UnityEngine; using UnityEngine.UI; @@ -46,7 +47,9 @@ namespace Item isEnabled = true; } + public abstract bool Interact(); + [ServerRpc] public abstract bool Interact(ref Inventory inventory, ref HeavyInteractableItem heavyInvent); protected void BaseAwake() diff --git a/Assets/Scripts/Item/Pistol/PistolComponent.cs b/Assets/Scripts/Item/Pistol/PistolComponent.cs index af81a5f..f75fb55 100644 --- a/Assets/Scripts/Item/Pistol/PistolComponent.cs +++ b/Assets/Scripts/Item/Pistol/PistolComponent.cs @@ -138,7 +138,7 @@ namespace Item shootLight.gameObject.SetActive(true); // var projectile = Instantiate(projectilePrefab, bulletSpawnPoint); -var projectile = Instantiate(projectilePrefab, bulletSpawnPoint); + var projectile = Instantiate(projectilePrefab, bulletSpawnPoint); InstanceFinder.ServerManager.Spawn(projectile); //var projectile = Instantiate(projectilePrefab, bulletSpawnPoint); //InstanceFinder.ServerManager.Spawn(projectile); diff --git a/Assets/Scripts/Player/NoiseVisibilitySettingsManager.cs b/Assets/Scripts/Player/NoiseVisibilitySettingsManager.cs index c996f05..664c8e5 100644 --- a/Assets/Scripts/Player/NoiseVisibilitySettingsManager.cs +++ b/Assets/Scripts/Player/NoiseVisibilitySettingsManager.cs @@ -1,3 +1,4 @@ +using FishNet.Object; using UnityEngine; namespace Player @@ -46,7 +47,7 @@ namespace Player timeSinceLastShot -= Time.deltaTime; } - + [ServerRpc] public void ShotFired() { timeSinceLastShot = shootNoiseDuration; diff --git a/Assets/Scripts/Player/PlayerInteractionHandler.cs b/Assets/Scripts/Player/PlayerInteractionHandler.cs index 249d499..12563c8 100644 --- a/Assets/Scripts/Player/PlayerInteractionHandler.cs +++ b/Assets/Scripts/Player/PlayerInteractionHandler.cs @@ -198,14 +198,17 @@ public class PlayerInteractionHandler : NetworkBehaviour if (Input.GetButtonDown("Fire3")&&inputEnbaled) if (!IsCarrying) { - if(!IsServer) - SwitchWeaponMode(); - GunEnabled = !GunEnabled; - if (!GunEnabled) - pistol.Disable(); - pistol.gameObject.SetActive(GunEnabled); - if (GunEnabled) - pistol.Enable(); + + SwitchWeaponMode(); + if (!IsServer) { + GunEnabled = !GunEnabled; + if (!GunEnabled) + pistol.Disable(); + pistol.gameObject.SetActive(GunEnabled); + if (GunEnabled) + pistol.Enable(); + } + } if (GunEnabled)