using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using ComputerysModdingUtilities;
using FishNet;
using FishNet.Connection;
using FishNet.Managing;
using FishNet.Managing.Object;
using FishNet.Managing.Server;
using FishNet.Object;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MyceliumNetworking;
using Steamworks;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: StraftatMod(false)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Koki")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+582afc8342c0fb050c5cf732728e8c0cd4041d44")]
[assembly: AssemblyProduct("KokiWeapons")]
[assembly: AssemblyTitle("KokiWeapons")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
[HarmonyPatch(typeof(Settings))]
public class SpawnWeaponOnTaunt
{
public static List<GameObject> weapons = new List<GameObject>();
[HarmonyPatch("IncreaseTauntsAmount")]
public static void Prefix(Settings __instance)
{
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
string text = "";
if (Input.GetKeyDown((KeyCode)49))
{
text = "RC Car";
}
else if (Input.GetKeyDown((KeyCode)50))
{
text = "Repulsion Grenade";
}
else if (Input.GetKeyDown((KeyCode)51))
{
text = "HandGrenade";
}
else if (Input.GetKeyDown((KeyCode)52))
{
text = "Teleport Mine";
}
else if (Input.GetKeyDown((KeyCode)53))
{
text = "APMine";
}
else if (Input.GetKeyDown((KeyCode)54))
{
text = "Gun";
}
if (!(text == "") && InstanceFinder.IsServer)
{
FirstPersonController[] array = Object.FindObjectsOfType<FirstPersonController>();
foreach (FirstPersonController val in array)
{
Vector3 val2 = val.playerCameraHolder.transform.position + ((Vector3)(ref val.dirForward)).normalized;
val2.y -= 0.5f;
GameObject val3 = Object.Instantiate<GameObject>(SpawnerManager.NameToWeaponDict[text], val2, Quaternion.identity);
val3.GetComponent<ItemBehaviour>().DispenserDrop(Vector3.zero);
val3.GetComponent<Rigidbody>().isKinematic = true;
((NetworkBehaviour)val).ServerManager.Spawn(val3, (NetworkConnection)null);
weapons.Add(val3);
}
}
}
}
[HarmonyPatch(typeof(WeaponHandSpawner), "RpcLogic___SpawnObject_2587446063")]
public static class CreatePlaceItemEvent
{
public class PlaceItemEventArgs : EventArgs
{
public WeaponHandSpawner spawner;
public GameObject spawnedObj;
public bool runOriginalCode = false;
}
public static event EventHandler<PlaceItemEventArgs> PlaceItemEvent;
public static bool TriggerPlaceItemEvent(WeaponHandSpawner __instance, GameObject obj)
{
PlaceItemEventArgs placeItemEventArgs = new PlaceItemEventArgs
{
spawner = __instance,
spawnedObj = obj
};
CreatePlaceItemEvent.PlaceItemEvent(null, placeItemEventArgs);
return placeItemEventArgs.runOriginalCode;
}
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Expected O, but got Unknown
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Expected O, but got Unknown
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Expected O, but got Unknown
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Expected O, but got Unknown
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Expected O, but got Unknown
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Expected O, but got Unknown
MethodInfo methodInfo = AccessTools.Method(typeof(ServerManager), "Spawn", new Type[2]
{
typeof(GameObject),
typeof(NetworkConnection)
}, (Type[])null);
MethodInfo methodInfo2 = AccessTools.Method(typeof(CreatePlaceItemEvent), "TriggerPlaceItemEvent", (Type[])null, (Type[])null);
Label label = default(Label);
return new CodeMatcher(instructions, generator).End().MatchBack(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Ret, (object)null, (string)null)
}).CreateLabel(ref label)
.MatchBack(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Callvirt, (object)methodInfo, (string)null)
})
.Advance(1)
.Insert((CodeInstruction[])(object)new CodeInstruction[4]
{
new CodeInstruction(OpCodes.Ldarg_0, (object)null),
new CodeInstruction(OpCodes.Ldloc_0, (object)null),
new CodeInstruction(OpCodes.Call, (object)methodInfo2),
new CodeInstruction(OpCodes.Brfalse, (object)label)
})
.InstructionEnumeration();
}
}
[HarmonyPatch(typeof(Resources), "LoadAll", new Type[]
{
typeof(string),
typeof(Type)
})]
public static class InsertWeaponsIntoResources
{
public static void Postfix(string path, ref Object[] __result)
{
if (!(path != "RandomWeapons"))
{
List<Object> list = new List<Object>(__result);
list.AddRange((IEnumerable<Object>)KokiWeaponsPlugin.CustomWeapons);
__result = list.ToArray();
}
}
}
[HarmonyPatch(typeof(SpawnerManager), "PopulateAllWeapons")]
public static class PostWeaponRegistration
{
internal static AssetBundle SharedAssets;
public static void Postfix()
{
if (!KokiWeaponsPlugin.RegisteredWeapons)
{
KokiWeaponsPlugin.RegisteredWeapons = true;
LoadDecals();
RegisterFishnet.Postfix();
}
}
public static void LoadDecals()
{
PhysicsGrenade component = SpawnerManager.NameToWeaponDict["HandGrenade"].GetComponent<PhysicsGrenade>();
GameObject[] array = SharedAssets.LoadAllAssets<GameObject>();
foreach (GameObject val in array)
{
if (((Object)val).name.EndsWith("Decal"))
{
if (((Object)val).name == "explosionDecal")
{
Object.Instantiate<GameObject>(component.explosionDecal).transform.SetParent(val.transform);
}
else if (((Object)val).name == "bloodDecal")
{
Object.Instantiate<GameObject>(component.bloodSplatter).transform.SetParent(val.transform);
}
}
}
}
}
[HarmonyPatch(typeof(NetworkManager), "Start")]
public static class RegisterFishnet
{
public static void Postfix()
{
if (!KokiWeaponsPlugin.RegisteredWeapons)
{
return;
}
PrefabObjects spawnablePrefabs = InstanceFinder.NetworkManager.SpawnablePrefabs;
NetworkObject val = default(NetworkObject);
foreach (GameObject networkObject in KokiWeaponsPlugin.NetworkObjects)
{
if (Object.op_Implicit((Object)(object)networkObject))
{
networkObject.TryGetComponent<NetworkObject>(ref val);
spawnablePrefabs.AddObject(val, false);
}
}
spawnablePrefabs.InitializePrefabRange(0);
}
public static void DeregisterFishnet()
{
HashSet<NetworkObject> hashSet = new HashSet<NetworkObject>();
foreach (GameObject networkObject in KokiWeaponsPlugin.NetworkObjects)
{
hashSet.Add(networkObject.GetComponent<NetworkObject>());
}
NetworkManager networkManager = InstanceFinder.NetworkManager;
PrefabObjects spawnablePrefabs = networkManager.SpawnablePrefabs;
int objectCount = spawnablePrefabs.GetObjectCount();
List<NetworkObject> list = new List<NetworkObject>();
for (int i = 0; i < objectCount; i++)
{
NetworkObject @object = spawnablePrefabs.GetObject(true, i);
if ((Object)(object)@object != (Object)null && !hashSet.Contains(@object))
{
list.Add(@object);
}
}
spawnablePrefabs.Clear();
spawnablePrefabs.AddObjects(list, false);
spawnablePrefabs.InitializePrefabRange(0);
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.koki.kokiweapons", "Koki Weapons", "2.1.1")]
internal class KokiWeaponsPlugin : BaseUnityPlugin
{
internal static KokiWeaponsPlugin Instance;
private static Harmony Harmony;
private static readonly string[] BundleNames = new string[4] { "kokiweapons_shared", "tptrap", "repulsiongrenade", "rccar" };
internal static List<GameObject> CustomWeapons = new List<GameObject>();
internal static List<GameObject> NetworkObjects = new List<GameObject>();
internal static bool RegisteredWeapons = false;
internal static bool KWDebug = false;
private void Awake()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
Instance = this;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Harmony = new Harmony("com.koki.kokiweapons");
Harmony.PatchAll();
foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles())
{
if (BundleNames.Contains(((Object)allLoadedAssetBundle).name))
{
allLoadedAssetBundle.Unload(true);
}
}
LoadBundles();
((Component)this).gameObject.AddComponent<TPTrapNetworking>();
UpdateTrapLinkOnPlace.Init();
}
private void OnDestroy()
{
Harmony.UnpatchSelf();
foreach (GameObject weapon in SpawnWeaponOnTaunt.weapons)
{
if (Object.op_Implicit((Object)(object)weapon))
{
InstanceFinder.ServerManager.Despawn(weapon, (DespawnType?)null);
}
}
((Component)this).gameObject.GetComponent<TPTrapNetworking>().Deregister();
if (RegisteredWeapons)
{
Array.Resize(ref SpawnerManager.AllWeapons, SpawnerManager.AllWeapons.Length - CustomWeapons.Count);
RegisterFishnet.DeregisterFishnet();
}
}
private void LoadBundles()
{
string text = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
if (Utility.IsNullOrWhiteSpace(text))
{
KWDebug = true;
Debug.LogError((object)"DEBUG MODE ACTIVE");
text = Path.Combine(Paths.PluginPath, "DEVELOPMENT-BUILD-Koki Weapons");
}
else
{
Harmony.Unpatch((MethodBase)typeof(Settings).GetMethod("IncreaseTauntsAmount"), (HarmonyPatchType)1, "com.koki.kokiweapons");
}
AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(text, "kokiweapons_shared"));
Material[] array = val.LoadAllAssets<Material>();
foreach (Material val2 in array)
{
val2.shader = Shader.Find(((Object)val2.shader).name);
}
PostWeaponRegistration.SharedAssets = val;
string[] files = Directory.GetFiles(text);
foreach (string path in files)
{
string fileName = Path.GetFileName(path);
if (!BundleNames.Contains(fileName) || fileName == "kokiweapons_shared")
{
continue;
}
AssetBundle val3 = AssetBundle.LoadFromFile(Path.Combine(text, fileName));
GameObject[] array2 = val3.LoadAllAssets<GameObject>();
foreach (GameObject val4 in array2)
{
if (Object.op_Implicit((Object)(object)val4.GetComponent<ItemBehaviour>()))
{
CustomWeapons.Add(val4);
}
if (Object.op_Implicit((Object)(object)val4.GetComponent<NetworkObject>()))
{
NetworkObjects.Add(val4);
}
}
}
if (!KWDebug || !Object.op_Implicit((Object)(object)InstanceFinder.NetworkManager))
{
return;
}
SpawnerManager.AllWeapons = null;
SpawnerManager.PopulateAllWeapons();
Type[] array3 = Array.Empty<Type>();
Dictionary<string, Type> dictionary = array3.Zip(array3.Select((Type type) => type.Name), (Type k, string v) => new { k, v }).ToDictionary(x => x.v, x => x.k);
foreach (GameObject networkObject in NetworkObjects)
{
Component[] components = networkObject.GetComponents<Component>();
foreach (Component val5 in components)
{
if (dictionary.ContainsKey(((object)val5).GetType().Name))
{
Component destination = networkObject.AddComponent(dictionary[((object)val5).GetType().Name]);
CopyComponentData(val5, destination);
Object.Destroy((Object)(object)val5);
}
}
}
}
private static void CopyComponentData(Component source, Component destination)
{
try
{
string text = JsonUtility.ToJson((object)source);
JsonUtility.FromJsonOverwrite(text, (object)destination);
}
catch (Exception ex)
{
Debug.LogWarning((object)("[HotReload] Failed to copy data via JsonUtility: " + ex.Message));
}
}
}
public class KBGrenade : PhysicsGrenade
{
internal static ConfigEntry<int> grenadeDamage = ((BaseUnityPlugin)KokiWeaponsPlugin.Instance).Config.Bind<int>("KB Grenade", "Damage", 0, new ConfigDescription("How much damage the KB Grenade should deal on impact, range from 0-100.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
private bool _spin = true;
internal void KBExplosion(Vector3 position)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
((Component)this).transform.position = position;
if (base.isOwner)
{
Collider[] array = Physics.OverlapSphere(position, base.explosionRadius, LayerMask.op_Implicit(base.bodyLayer));
Rigidbody rb = null;
CollectionExtensions.DoIf<Collider>((IEnumerable<Collider>)array, (Func<Collider, bool>)((Collider c) => Object.op_Implicit((Object)(object)c) && ((Component)c).gameObject.TryGetComponent<Rigidbody>(ref rb)), (Action<Collider>)delegate(Collider item)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
Vector3 val3 = ((Component)item).transform.position - ((Component)this).transform.position;
val3.y = 0f;
((Vector3)(ref val3)).Normalize();
val3 *= 10f;
val3.y = 2f;
Transform transform2 = ((Component)item).transform;
transform2.position += new Vector3(0f, 2.5f, 0f);
rb.AddForce(val3, (ForceMode)1);
});
CollectionExtensions.Do<PlayerHealth>(array.Select((Collider c) => ((Component)c).GetComponentInParent<PlayerHealth>()).Distinct(), (Action<PlayerHealth>)delegate(PlayerHealth ph)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)ph) && !ph.sync___get_value_isKilled())
{
Vector3 val2 = ((Component)ph.controller).transform.position - ((Component)this).transform.position;
if (val2.y < 0f)
{
val2.y = 0f;
}
((Vector3)(ref val2)).Normalize();
if (ph.controller.isGrounded)
{
Transform transform = ((Component)ph.controller).transform;
transform.position += new Vector3(0f, 2.5f, 0f);
}
ph.controller.CustomAddForce(val2, 120f);
if (grenadeDamage.Value > 0)
{
ph.RemoveHealth((float)(grenadeDamage.Value / 25));
}
}
});
}
Object.Destroy((Object)(object)((Component)this).gameObject, 3f);
((Behaviour)this).enabled = false;
((Component)base.graph).gameObject.SetActive(false);
if (!base.fragGrenade)
{
GameObject val = Object.Instantiate<GameObject>(base.explosionVfx, ((Component)this).transform.position, Quaternion.identity);
if ((Object)(object)val.transform.Find("ball") != (Object)null)
{
val.transform.Find("ball").localScale = base.vfxScale;
}
}
Object.Instantiate<GameObject>(base.explosionDecal, ((Component)this).transform.position, Quaternion.identity);
base.audio.Play();
}
internal void Spin()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
base.graph.Rotate(base.rotateAxis * base.rotateSpeed * Time.deltaTime);
}
}
[HarmonyPatch(typeof(PhysicsGrenade))]
internal class KBGrenadeOverrides
{
[HarmonyPatch("RpcLogic___HandleExplosion_4276783012")]
[HarmonyPrefix]
private static bool RedirectHandleExplosion(PhysicsGrenade __instance, Vector3 position)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (__instance is KBGrenade kBGrenade)
{
kBGrenade.KBExplosion(position);
return false;
}
return true;
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void StartSpin(PhysicsGrenade __instance)
{
if (__instance is KBGrenade kBGrenade)
{
kBGrenade.Spin();
}
}
}
public class TPLink : MonoBehaviour
{
[NonSerialized]
public int otherTrapNob = -1;
}
public class TPTrap : MonoBehaviour
{
[NonSerialized]
public Transform owner;
private GameObject _otherTrap;
private bool _detonated = false;
public GameObject explosionVfx;
public AudioClip explosionAudio;
private void Awake()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
PauseManager.OnBeforeSpawn += new BeforeSpawnAction(Despawn);
Animation component = ((Component)((Component)this).transform.Find("TeleTrapPhysMesh").Find("trap_010")).GetComponent<Animation>();
component["tpmineSphere"].layer = 0;
component.Play("tpmineSphere");
component["tpmineTorus"].layer = 1;
component.Play("tpmineTorus");
}
public void Prime(GameObject other)
{
_otherTrap = other;
((Component)((Component)this).transform.Find("radius")).gameObject.SetActive(true);
}
private void OnTriggerStay(Collider col)
{
if (!Object.op_Implicit((Object)(object)_otherTrap) || _detonated || !((Component)col).CompareTag("Player") || !InstanceFinder.IsServer)
{
return;
}
_detonated = true;
GameObject[] players = GetPlayers();
TPTrap tPTrap = default(TPTrap);
_otherTrap.TryGetComponent<TPTrap>(ref tPTrap);
if (!tPTrap._detonated)
{
tPTrap._detonated = true;
GameObject[] players2 = tPTrap.GetPlayers();
IEnumerable<CSteamID> enumerable = from player in players
where TeleportIfHost(player, _otherTrap.transform.position)
select player into go
select GOToCSteamID(go);
IEnumerable<CSteamID> enumerable2 = from player in players2
where TeleportIfHost(player, ((Component)this).transform.position)
select player into go
select GOToCSteamID(go);
CollectionExtensions.Do<CSteamID>(enumerable, (Action<CSteamID>)delegate(CSteamID ID)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
TPTrapNetworking.TargetedRPC(ID, "TPPlayer", new object[1] { _otherTrap.transform.position });
});
CollectionExtensions.Do<CSteamID>(enumerable2, (Action<CSteamID>)delegate(CSteamID ID)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
TPTrapNetworking.TargetedRPC(ID, "TPPlayer", new object[1] { ((Component)this).transform.position });
});
int objectId = ((Component)this).gameObject.GetComponent<NetworkObject>().ObjectId;
int objectId2 = _otherTrap.GetComponent<NetworkObject>().ObjectId;
TPTrapNetworking.RPC("DestroyTrapPair", new object[2] { objectId, objectId2 });
}
else
{
Debug.LogError((object)"UHHHHHHHHHHHHHHHH OH");
}
}
private CSteamID GOToCSteamID(GameObject go)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
return (CSteamID)ulong.Parse(go.GetComponent<NetworkObject>().Owner.GetAddress());
}
private bool TeleportIfHost(GameObject potentialHost, Vector3 pos)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
CSteamID val = GOToCSteamID(potentialHost);
if (val == SteamUser.GetSteamID())
{
potentialHost.GetComponent<PlayerHealth>().sync___set_value_killer(owner, true);
potentialHost.GetComponent<FirstPersonController>().Teleport(pos, 0f, false, (Transform)null, 0f, 0f, true);
return false;
}
return true;
}
private GameObject[] GetPlayers()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(3.2f, 1.631936f, 3.2f);
int num = 67584;
Collider[] source = Physics.OverlapBox(((Component)this).transform.position, val, Quaternion.identity, num);
return (from col in source
select ((Component)((Component)col).transform.root).gameObject into go
where go.CompareTag("Player")
select go).Distinct().ToArray();
}
public void Explode()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)_otherTrap))
{
((Component)_otherTrap.transform.Find("radius")).gameObject.SetActive(false);
}
Object.Destroy((Object)(object)((Component)this).gameObject);
Object.Instantiate<GameObject>(explosionVfx, ((Component)this).transform.position, Quaternion.identity);
SoundManager.Instance.PlaySound(explosionAudio);
}
private void Despawn()
{
if (InstanceFinder.IsServer && Object.op_Implicit((Object)(object)this) && Object.op_Implicit((Object)(object)((Component)this).gameObject))
{
InstanceFinder.ServerManager.Despawn(((Component)this).gameObject, (DespawnType?)null);
}
}
}
public class TPTrapNetworking : MonoBehaviour
{
private static readonly uint ID = 932828u;
public void Start()
{
MyceliumNetwork.RegisterNetworkObject((object)this, ID, 0);
}
public void Deregister()
{
MyceliumNetwork.DeregisterNetworkObject((object)this, ID, 0);
}
public static void RPC(string methodname, object[] parameters)
{
MyceliumNetwork.RPC(ID, methodname, (ReliableType)1, parameters);
}
public static void TargetedRPC(CSteamID steamID, string methodname, object[] parameters)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
MyceliumNetwork.RPCTarget(ID, methodname, steamID, (ReliableType)1, parameters);
}
[CustomRPC]
public void LinkMines(int nobID1, int nobID2)
{
NetworkObject value3;
NetworkObject value4;
if (!InstanceFinder.IsServer && ((ManagedObjects)InstanceFinder.ClientManager.Objects).Spawned.TryGetValue(nobID1, out var value) && ((ManagedObjects)InstanceFinder.ClientManager.Objects).Spawned.TryGetValue(nobID2, out var value2))
{
GameObject gameObject = ((Component)value).gameObject;
GameObject gameObject2 = ((Component)value2).gameObject;
gameObject.GetComponent<TPTrap>().Prime(gameObject2);
gameObject2.GetComponent<TPTrap>().Prime(gameObject);
}
else if (((ManagedObjects)InstanceFinder.ServerManager.Objects).Spawned.TryGetValue(nobID1, out value3) && ((ManagedObjects)InstanceFinder.ServerManager.Objects).Spawned.TryGetValue(nobID2, out value4))
{
GameObject gameObject3 = ((Component)value3).gameObject;
GameObject gameObject4 = ((Component)value4).gameObject;
gameObject3.GetComponent<TPTrap>().Prime(gameObject4);
gameObject4.GetComponent<TPTrap>().Prime(gameObject3);
}
}
[CustomRPC]
public void DestroyTrapPair(int nobID1, int nobID2)
{
NetworkObject value;
NetworkObject value2;
if (!InstanceFinder.IsServer)
{
((ManagedObjects)InstanceFinder.ClientManager.Objects).Spawned.TryGetValue(nobID1, out value);
((ManagedObjects)InstanceFinder.ClientManager.Objects).Spawned.TryGetValue(nobID2, out value2);
}
else
{
((ManagedObjects)InstanceFinder.ServerManager.Objects).Spawned.TryGetValue(nobID1, out value);
((ManagedObjects)InstanceFinder.ServerManager.Objects).Spawned.TryGetValue(nobID2, out value2);
}
if (Object.op_Implicit((Object)(object)value))
{
((Component)value).gameObject.GetComponent<TPTrap>().Explode();
}
if (Object.op_Implicit((Object)(object)value2))
{
((Component)value2).gameObject.GetComponent<TPTrap>().Explode();
}
}
[CustomRPC]
public void TPPlayer(Vector3 position)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
FirstPersonController.instance.Teleport(position, 0f, false, (Transform)null, 0f, 0f, true);
}
}
public static class UpdateTrapLinkOnPlace
{
public static void Init()
{
CreatePlaceItemEvent.PlaceItemEvent += UpdateTrapLink;
}
public static void UpdateTrapLink(object sender, CreatePlaceItemEvent.PlaceItemEventArgs eventArgs)
{
WeaponHandSpawner spawner = eventArgs.spawner;
GameObject spawnedObj = eventArgs.spawnedObj;
spawnedObj.GetComponent<TPTrap>().owner = ((Component)spawner).transform.root;
TPLink tPLink = default(TPLink);
if (!((Component)spawner).gameObject.TryGetComponent<TPLink>(ref tPLink))
{
Debug.LogError((object)"no trap lnk :(");
eventArgs.runOriginalCode = true;
return;
}
if (tPLink.otherTrapNob == -1)
{
tPLink.otherTrapNob = spawnedObj.GetComponent<NetworkObject>().ObjectId;
return;
}
int objectId = spawnedObj.GetComponent<NetworkObject>().ObjectId;
int otherTrapNob = tPLink.otherTrapNob;
TPTrapNetworking.RPC("LinkMines", new object[2] { objectId, otherTrapNob });
}
}
[HarmonyPatch(typeof(Weapon), "TriggerEnvironment")]
public static class ExplodeTPTrapOnHit
{
public static void Prefix(GameObject obj)
{
GameObject gameObject = ((Component)obj.transform.root).gameObject;
if (Object.op_Implicit((Object)(object)gameObject.GetComponent<TPTrap>()))
{
TPTrapNetworking.RPC("DestroyTrapPair", new object[2]
{
gameObject.GetComponent<NetworkObject>().ObjectId,
-1
});
}
}
}
namespace KokiWeapons
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.koki.kokiweapons";
public const string PLUGIN_NAME = "Koki Weapons";
public const string PLUGIN_VERSION = "2.1.1";
}
}