diff --git a/RavenM/IngameNetManager.cs b/RavenM/IngameNetManager.cs index 0478390..cd94513 100644 --- a/RavenM/IngameNetManager.cs +++ b/RavenM/IngameNetManager.cs @@ -12,6 +12,7 @@ using UnityEngine; using Ravenfield.SpecOps; using RavenM.Commands; +using Ravenfield.Mods.Data; namespace RavenM { @@ -532,6 +533,8 @@ public class AudioContainer public KeyCode PlaceMarkerKeybind = KeyCode.BackQuote; + public List MapWeapons = new List(); + private void Awake() { instance = this; @@ -821,6 +824,7 @@ public void ResetState() OwnedProjectiles.Clear(); ClientProjectiles.Clear(); ClientDestructibles.Clear(); + MapWeapons.Clear(); ClientCanSpawnBot = false; diff --git a/RavenM/LobbySystem.cs b/RavenM/LobbySystem.cs index 8bbe9fd..f6758c0 100644 --- a/RavenM/LobbySystem.cs +++ b/RavenM/LobbySystem.cs @@ -11,6 +11,7 @@ using Ravenfield.Mutator.Configuration; using SimpleJSON; using System.Globalization; +using Ravenfield.Trigger; namespace RavenM { @@ -169,6 +170,19 @@ static void Prefix() Plugin.logger.LogInfo($"Registered new destructible root with name: {root.name} and id: {id}"); } + + IngameNetManager.instance.MapWeapons.Clear(); + foreach (var triggerEquipWeapon in Resources.FindObjectsOfTypeAll()) + { + if (triggerEquipWeapon.weaponType == TriggerEquipWeapon.WeaponType.FromWeaponEntry + && triggerEquipWeapon.weaponEntry != null + && !WeaponManager.instance.allWeapons.Contains(triggerEquipWeapon.weaponEntry)) + { + var entry = triggerEquipWeapon.weaponEntry; + Plugin.logger.LogInfo($"Detected map weapon with name: {entry.name}, and from map: {map.metaData.displayName}."); + IngameNetManager.instance.MapWeapons.Add(entry); + } + } } static void Postfix() diff --git a/RavenM/NetActorController.cs b/RavenM/NetActorController.cs index 1ec7866..ba3126a 100644 --- a/RavenM/NetActorController.cs +++ b/RavenM/NetActorController.cs @@ -223,6 +223,10 @@ public static WeaponManager.WeaponEntry GetWeaponEntryByHash(int hash) foreach (var entry in WeaponManager.instance.allWeapons) if (entry.name.GetHashCode() == hash) return entry; + + foreach (var entry in IngameNetManager.instance.MapWeapons) + if (entry.name.GetHashCode() == hash) + return entry; return null; }