using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dissonance.Config;
using GameNetcodeStuff;
using LethalLib.Extras;
using LethalLib.Modules;
using MonoMod.RuntimeDetour;
using MyCustomContent;
using MyCustomContent.Extensions;
using MyCustomContent.MonoBehaviours;
using MyCustomContent.Patches;
using MyCustomMod.NetcodePatcher;
using On;
using Unity.Netcode;
using Unity.Netcode.Components;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MyCustomMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MyCustomMod")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b061c52b-7af8-4e27-8d9b-ff26300ec612")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
}
}
namespace LethalLib.Modules
{
public class SaveData
{
public static List<string> saveKeys = new List<string>();
public static void Init()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
GameNetworkManager.ResetSavedGameValues += new hook_ResetSavedGameValues(GameNetworkManager_ResetSavedGameValues);
GameNetworkManager.SaveItemsInShip += new hook_SaveItemsInShip(GameNetworkManager_SaveItemsInShip);
StartOfRound.LoadShipGrabbableItems += new hook_LoadShipGrabbableItems(StartOfRound_LoadShipGrabbableItems);
}
private static void StartOfRound_LoadShipGrabbableItems(orig_LoadShipGrabbableItems orig, StartOfRound self)
{
orig.Invoke(self);
SaveableObject[] array = Object.FindObjectsOfType<SaveableObject>();
SaveableNetworkBehaviour[] array2 = Object.FindObjectsOfType<SaveableNetworkBehaviour>();
SaveableObject[] array3 = array;
foreach (SaveableObject saveableObject in array3)
{
saveableObject.LoadObjectData();
}
SaveableNetworkBehaviour[] array4 = array2;
foreach (SaveableNetworkBehaviour saveableNetworkBehaviour in array4)
{
saveableNetworkBehaviour.LoadObjectData();
}
if (ES3.KeyExists("LethalLibItemSaveKeys", GameNetworkManager.Instance.currentSaveFileName))
{
saveKeys = ES3.Load<List<string>>("LethalLibItemSaveKeys", GameNetworkManager.Instance.currentSaveFileName);
}
}
private static void GameNetworkManager_SaveItemsInShip(orig_SaveItemsInShip orig, GameNetworkManager self)
{
orig.Invoke(self);
SaveableObject[] array = Object.FindObjectsOfType<SaveableObject>();
SaveableNetworkBehaviour[] array2 = Object.FindObjectsOfType<SaveableNetworkBehaviour>();
SaveableObject[] array3 = array;
foreach (SaveableObject saveableObject in array3)
{
saveableObject.SaveObjectData();
}
SaveableNetworkBehaviour[] array4 = array2;
foreach (SaveableNetworkBehaviour saveableNetworkBehaviour in array4)
{
saveableNetworkBehaviour.SaveObjectData();
}
ES3.Save<List<string>>("LethalLibItemSaveKeys", saveKeys, GameNetworkManager.Instance.currentSaveFileName);
}
private static void GameNetworkManager_ResetSavedGameValues(orig_ResetSavedGameValues orig, GameNetworkManager self)
{
orig.Invoke(self);
foreach (string saveKey in saveKeys)
{
ES3.DeleteKey(saveKey, GameNetworkManager.Instance.currentSaveFileName);
}
saveKeys.Clear();
}
public static void SaveObjectData<T>(string key, T data, int objectId)
{
List<T> list = new List<T>();
if (ES3.KeyExists("LethalThingsSave_" + key, GameNetworkManager.Instance.currentSaveFileName))
{
list = ES3.Load<List<T>>("LethalThingsSave_" + key, GameNetworkManager.Instance.currentSaveFileName);
}
List<int> list2 = new List<int>();
if (ES3.KeyExists("LethalThingsSave_objectIds_" + key, GameNetworkManager.Instance.currentSaveFileName))
{
list2 = ES3.Load<List<int>>("LethalThingsSave_objectIds_" + key, GameNetworkManager.Instance.currentSaveFileName);
}
list.Add(data);
list2.Add(objectId);
if (!saveKeys.Contains("LethalThingsSave_" + key))
{
saveKeys.Add("LethalThingsSave_" + key);
}
if (!saveKeys.Contains("LethalThingsSave_objectIds_" + key))
{
saveKeys.Add("LethalThingsSave_objectIds_" + key);
}
ES3.Save<List<T>>("LethalThingsSave_" + key, list, GameNetworkManager.Instance.currentSaveFileName);
ES3.Save<List<int>>("LethalThingsSave_objectIds_" + key, list2, GameNetworkManager.Instance.currentSaveFileName);
}
public static T LoadObjectData<T>(string key, int objectId)
{
List<T> list = new List<T>();
if (ES3.KeyExists("LethalThingsSave_" + key, GameNetworkManager.Instance.currentSaveFileName))
{
list = ES3.Load<List<T>>("LethalThingsSave_" + key, GameNetworkManager.Instance.currentSaveFileName);
}
List<int> list2 = new List<int>();
if (ES3.KeyExists("LethalThingsSave_objectIds_" + key, GameNetworkManager.Instance.currentSaveFileName))
{
list2 = ES3.Load<List<int>>("LethalThingsSave_objectIds_" + key, GameNetworkManager.Instance.currentSaveFileName);
}
if (!saveKeys.Contains("LethalThingsSave_" + key))
{
saveKeys.Add("LethalThingsSave_" + key);
}
if (!saveKeys.Contains("LethalThingsSave_objectIds_" + key))
{
saveKeys.Add("LethalThingsSave_objectIds_" + key);
}
if (list2.Contains(objectId))
{
int index = list2.IndexOf(objectId);
return list[index];
}
return default(T);
}
}
}
namespace MyCustomMod
{
public class HalfFull : SaveableObject
{
public Transform spawnPoint;
private RaycastHit[] objectsHitByBullet = (RaycastHit[])(object)new RaycastHit[20];
public int maxAmmo = 6;
public int startingAmmo = 3;
public LayerMask hitMask;
private PlayerControllerB previousPlayerHeldBy;
private NetworkVariable<int> currentAmmo = new NetworkVariable<int>(3, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);
private NetworkVariable<bool> isLoaded = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)1);
private bool localIsLoaded = false;
private Ray ray;
public AudioSource audioSrc;
public AudioClip fireClip;
public AudioClip emptyClip;
public AudioClip spinClip;
public Animator anim;
public ParticleSystem fireParticals;
private float spinCooldown = 0.7f;
private float spinCooldownAtTime = 0f;
private float fireCooldown = 0.6f;
private float fireCooldownAtTime = 0f;
public override void SaveObjectData()
{
SaveData.SaveObjectData("halfFullAmmoData", currentAmmo.Value, uniqueId);
SaveData.SaveObjectData("halfFullLoadedData", isLoaded.Value, uniqueId);
}
public override void LoadObjectData()
{
if (((NetworkBehaviour)this).IsHost)
{
currentAmmo.Value = SaveData.LoadObjectData<int>("halfFullAmmoData", uniqueId);
isLoaded.Value = SaveData.LoadObjectData<bool>("halfFullLoadedData", uniqueId);
}
}
public override void OnNetworkSpawn()
{
((NetworkBehaviour)this).OnNetworkSpawn();
Plugin.logger.LogInfo((object)("Current Ammo: " + currentAmmo.Value + ", Is Loaded: " + isLoaded.Value));
if (((NetworkBehaviour)this).IsServer)
{
currentAmmo.Value = Config.revolverShots.Value;
isLoaded.Value = localIsLoaded;
}
}
public override void ItemActivate(bool used, bool buttonDown = true)
{
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
((GrabbableObject)this).ItemActivate(used, buttonDown);
if (currentAmmo.Value > 0 && isLoaded.Value && fireCooldownAtTime + fireCooldown < Time.time)
{
if (((NetworkBehaviour)this).IsHost)
{
NetworkVariable<int> obj = currentAmmo;
int value = obj.Value;
obj.Value = value - 1;
}
anim.Play("fire");
audioSrc.PlayOneShot(fireClip);
fireParticals.Play();
if (((NetworkBehaviour)this).IsOwner)
{
isLoaded.Value = false;
if (((NetworkBehaviour)this).IsHost)
{
Fire(spawnPoint.position, spawnPoint.forward);
}
else
{
Plugin.logger.LogInfo((object)"Sending fire server rpc");
FireServerRpc(spawnPoint.position, spawnPoint.forward);
}
}
fireCooldownAtTime = Time.time;
}
else if (fireCooldownAtTime + fireCooldown < Time.time)
{
Plugin.logger.LogInfo((object)"Bullet not loaded");
audioSrc.PlayOneShot(emptyClip);
fireCooldownAtTime = Time.time;
}
}
public void Fire(Vector3 pos, Vector3 dir)
{
//IL_0012: 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_0014: 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)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
Plugin.logger.LogInfo((object)"Revolver fired");
ray = new Ray(pos, dir);
int num = Physics.RaycastNonAlloc(ray, objectsHitByBullet, 100f, LayerMask.op_Implicit(hitMask), (QueryTriggerInteraction)2);
Plugin.logger.LogInfo((object)("Number of hits: " + num));
IHittable val = default(IHittable);
for (int i = 0; i < num; i++)
{
if (((Component)((RaycastHit)(ref objectsHitByBullet[i])).transform).TryGetComponent<IHittable>(ref val))
{
val.Hit(85, spawnPoint.forward, previousPlayerHeldBy, false);
continue;
}
Plugin.logger.LogInfo((object)("Could not get hittable script from collider, transform: " + ((Object)((RaycastHit)(ref objectsHitByBullet[i])).transform).name));
Plugin.logger.LogInfo((object)("collider: " + ((Object)((RaycastHit)(ref objectsHitByBullet[i])).collider).name));
}
}
[ServerRpc]
public void FireServerRpc(Vector3 pos, Vector3 dir)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Invalid comparison between Unknown and I4
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Invalid comparison between Unknown and I4
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
{
if ((int)networkManager.LogLevel <= 1)
{
Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
}
return;
}
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1246519813u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe(ref pos);
((FastBufferWriter)(ref val2)).WriteValueSafe(ref dir);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1246519813u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
Plugin.logger.LogInfo((object)"Running Server rpc");
Fire(pos, dir);
}
}
public override void ItemInteractLeftRight(bool right)
{
((GrabbableObject)this).ItemInteractLeftRight(right);
Plugin.logger.LogInfo((object)"Spinning barrel");
if (!right && spinCooldownAtTime + spinCooldown < Time.time)
{
anim.Play("spin");
audioSrc.PlayOneShot(spinClip);
Plugin.logger.LogInfo((object)("Current ammo: " + currentAmmo.Value));
if (((NetworkBehaviour)this).IsOwner && currentAmmo.Value <= 0)
{
isLoaded.Value = false;
Plugin.logger.LogInfo((object)"Chamber empty");
}
else if (((NetworkBehaviour)this).IsOwner)
{
Random random = new Random();
double num = random.NextDouble() * (double)maxAmmo;
bool value = ((!(num > (double)currentAmmo.Value)) ? true : false);
isLoaded.Value = value;
Plugin.logger.LogInfo((object)("Spun the chamber. Loaded bullet: " + value));
}
spinCooldownAtTime = Time.time;
}
}
public override void PocketItem()
{
((GrabbableObject)this).PocketItem();
if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
{
((GrabbableObject)this).playerHeldBy.equippedUsableItemQE = false;
}
}
public override void DiscardItem()
{
((GrabbableObject)this).DiscardItem();
if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
{
((GrabbableObject)this).playerHeldBy.equippedUsableItemQE = false;
}
}
public override void EquipItem()
{
((GrabbableObject)this).EquipItem();
if ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null)
{
previousPlayerHeldBy = ((GrabbableObject)this).playerHeldBy;
((GrabbableObject)this).playerHeldBy.equippedUsableItemQE = true;
}
}
protected override void __initializeVariables()
{
if (currentAmmo == null)
{
throw new Exception("HalfFull.currentAmmo cannot be null. All NetworkVariableBase instances must be initialized.");
}
((NetworkVariableBase)currentAmmo).Initialize((NetworkBehaviour)(object)this);
((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)currentAmmo, "currentAmmo");
((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)currentAmmo);
if (isLoaded == null)
{
throw new Exception("HalfFull.isLoaded cannot be null. All NetworkVariableBase instances must be initialized.");
}
((NetworkVariableBase)isLoaded).Initialize((NetworkBehaviour)(object)this);
((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)isLoaded, "isLoaded");
((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)isLoaded);
base.__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_HalfFull()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(1246519813u, new RpcReceiveHandler(__rpc_handler_1246519813));
}
private static void __rpc_handler_1246519813(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: 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_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Invalid comparison between Unknown and I4
NetworkManager networkManager = target.NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
{
if ((int)networkManager.LogLevel <= 1)
{
Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
}
}
else
{
Vector3 pos = default(Vector3);
((FastBufferReader)(ref reader)).ReadValueSafe(ref pos);
Vector3 dir = default(Vector3);
((FastBufferReader)(ref reader)).ReadValueSafe(ref dir);
target.__rpc_exec_stage = (__RpcExecStage)1;
((HalfFull)(object)target).FireServerRpc(pos, dir);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "HalfFull";
}
}
}
namespace MyCustomContent
{
public class Config
{
public static ConfigEntry<int> davidSpawnWeight;
public static ConfigEntry<int> amogusSpawnWeight;
public static ConfigEntry<int> happyMealSpawnWeight;
public static ConfigEntry<int> flamingoSpawnWeight;
public static ConfigEntry<int> specterSpawnWeight;
public static ConfigEntry<int> imposterSpawnWeight;
public static ConfigEntry<int> imposterVoiceInterval;
public static ConfigEntry<int> imposterFleeMeter;
public static ConfigEntry<int> revolverPrice;
public static ConfigEntry<int> revolverShots;
public static ConfigEntry<int> shrineCost;
public static ConfigFile VolumeConfig;
public static ConfigEntry<string> version;
public static void Load()
{
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Expected O, but got Unknown
davidSpawnWeight = Plugin.config.Bind<int>("Scrap", "David", 20, "How much David spawns (higher = more common)");
amogusSpawnWeight = Plugin.config.Bind<int>("Scrap", "Amogus", 20, "How much Amogus spawns (higher = more common)");
happyMealSpawnWeight = Plugin.config.Bind<int>("Scrap", "Happy Meal", 20, "How much Happy Meal spawns (higher = more common)");
flamingoSpawnWeight = Plugin.config.Bind<int>("Scrap", "Flamingo", 10, "How much flamingo spawns (higher = more common)");
specterSpawnWeight = Plugin.config.Bind<int>("Enemy", "Specter Chance", 40, "How often specters spawn (higher = more common)");
imposterSpawnWeight = Plugin.config.Bind<int>("Enemy", "Imposter Chance", 40, "How often imposters spawn (higher = more common)");
imposterVoiceInterval = Plugin.config.Bind<int>("Enemy", "Imposter voice cooldown", 8, "Time between imposter voicelines");
imposterFleeMeter = Plugin.config.Bind<int>("Enemy", "Imposter flee meter", 20, "Increase/decrease the amount of time needed staring at the imposter for it to flee");
revolverPrice = Plugin.config.Bind<int>("Item", "Revolver Price", 130, "Change price of the half full revolver");
revolverShots = Plugin.config.Bind<int>("Item", "Starting Revolver Rounds", 3, "Changes how many rounds the revolver starts with");
shrineCost = Plugin.config.Bind<int>("Item", "Shrine Cost", 220, "How much the shrine costs");
version = Plugin.config.Bind<string>("Misc", "Version", "1.0.0", "Version of the mod config.");
VolumeConfig = new ConfigFile(Paths.ConfigPath + "\\MyCustomStuff.AudioVolume.cfg", true);
}
}
public class Content
{
public class CustomItem
{
public string name = "";
public string itemPath = "";
public string infoPath = "";
public Action<Item> itemAction = delegate
{
};
public bool enabled = true;
public CustomItem(string name, string itemPath, string infoPath, Action<Item> action = null)
{
this.name = name;
this.itemPath = itemPath;
this.infoPath = infoPath;
if (action != null)
{
itemAction = action;
}
}
public static CustomItem Add(string name, string itemPath, string infoPath = null, Action<Item> action = null)
{
return new CustomItem(name, itemPath, infoPath, action);
}
}
public class CustomUnlockable
{
public string name = "";
public string unlockablePath = "";
public string infoPath = "";
public Action<UnlockableItem> unlockableAction = delegate
{
};
public bool enabled = true;
public int unlockCost = -1;
public CustomUnlockable(string name, string unlockablePath, string infoPath, Action<UnlockableItem> action = null, int unlockCost = -1)
{
this.name = name;
this.unlockablePath = unlockablePath;
this.infoPath = infoPath;
if (action != null)
{
unlockableAction = action;
}
this.unlockCost = unlockCost;
}
public static CustomUnlockable Add(string name, string unlockablePath, string infoPath = null, Action<UnlockableItem> action = null, int unlockCost = -1, bool enabled = true)
{
CustomUnlockable customUnlockable = new CustomUnlockable(name, unlockablePath, infoPath, action, unlockCost);
customUnlockable.enabled = enabled;
return customUnlockable;
}
}
public class CustomShopItem : CustomItem
{
public int itemPrice = 0;
public CustomShopItem(string name, string itemPath, string infoPath = null, int itemPrice = 0, Action<Item> action = null)
: base(name, itemPath, infoPath, action)
{
this.itemPrice = itemPrice;
}
public static CustomShopItem Add(string name, string itemPath, string infoPath = null, int itemPrice = 0, Action<Item> action = null, bool enabled = true)
{
CustomShopItem customShopItem = new CustomShopItem(name, itemPath, infoPath, itemPrice, action);
customShopItem.enabled = enabled;
return customShopItem;
}
}
public class CustomScrap : CustomItem
{
public LevelTypes levelType = (LevelTypes)(-1);
public int rarity = 0;
public CustomScrap(string name, string itemPath, LevelTypes levelType, int rarity, Action<Item> action = null)
: base(name, itemPath, null, action)
{
//IL_0002: 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_001d: Unknown result type (might be due to invalid IL or missing references)
this.levelType = levelType;
this.rarity = rarity;
}
public static CustomScrap Add(string name, string itemPath, LevelTypes levelType, int rarity, Action<Item> action = null)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
return new CustomScrap(name, itemPath, levelType, rarity, action);
}
}
public class CustomPlainItem : CustomItem
{
public CustomPlainItem(string name, string itemPath, Action<Item> action = null)
: base(name, itemPath, null, action)
{
}
public static CustomPlainItem Add(string name, string itemPath, Action<Item> action = null)
{
return new CustomPlainItem(name, itemPath, action);
}
}
public class CustomEnemy
{
public string name;
public string enemyPath;
public int rarity;
public LevelTypes levelFlags;
public SpawnType spawnType;
public string infoKeyword;
public string infoNode;
public bool enabled = true;
public CustomEnemy(string name, string enemyPath, int rarity, LevelTypes levelFlags, SpawnType spawnType, string infoKeyword, string infoNode)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
this.name = name;
this.enemyPath = enemyPath;
this.rarity = rarity;
this.levelFlags = levelFlags;
this.spawnType = spawnType;
this.infoKeyword = infoKeyword;
this.infoNode = infoNode;
}
public static CustomEnemy Add(string name, string enemyPath, int rarity, LevelTypes levelFlags, SpawnType spawnType, string infoKeyword, string infoNode, bool enabled = true)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
CustomEnemy customEnemy = new CustomEnemy(name, enemyPath, rarity, levelFlags, spawnType, infoKeyword, infoNode);
customEnemy.enabled = enabled;
return customEnemy;
}
}
public class CustomMapObject
{
public string name;
public string objectPath;
public LevelTypes levelFlags;
public Func<SelectableLevel, AnimationCurve> spawnRateFunction;
public bool enabled = true;
public CustomMapObject(string name, string objectPath, LevelTypes levelFlags, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null, bool enabled = false)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
this.name = name;
this.objectPath = objectPath;
this.levelFlags = levelFlags;
this.spawnRateFunction = spawnRateFunction;
this.enabled = enabled;
}
public static CustomMapObject Add(string name, string objectPath, LevelTypes levelFlags, Func<SelectableLevel, AnimationCurve> spawnRateFunction = null, bool enabled = false)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
return new CustomMapObject(name, objectPath, levelFlags, spawnRateFunction, enabled);
}
}
public static AssetBundle MainAssets;
public static Dictionary<string, GameObject> Prefabs = new Dictionary<string, GameObject>();
public static GameObject devMenuPrefab;
public static List<CustomUnlockable> customUnlockables;
public static List<CustomItem> customItems;
public static List<CustomEnemy> customEnemies;
public static List<CustomMapObject> customMapObjects;
public static GameObject ConfigManagerPrefab;
public static void TryLoadAssets()
{
if ((Object)(object)MainAssets == (Object)null)
{
MainAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "mybundle"));
Plugin.logger.LogInfo((object)"Loaded asset bundle");
}
}
public static void Load()
{
//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
//IL_04fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0502: Unknown result type (might be due to invalid IL or missing references)
//IL_05d3: Unknown result type (might be due to invalid IL or missing references)
TryLoadAssets();
customItems = new List<CustomItem>
{
CustomScrap.Add("David", "Assets/Custom/Scrap/David/David.asset", (LevelTypes)(-1), Config.davidSpawnWeight.Value),
CustomScrap.Add("Amogus", "Assets/Custom/Scrap/Amogus/purple.asset", (LevelTypes)(-1), Config.amogusSpawnWeight.Value),
CustomScrap.Add("Happy Meal", "Assets/Custom/Scrap/HappyMeal/HappyMeal.asset", (LevelTypes)(-1), Config.happyMealSpawnWeight.Value),
CustomScrap.Add("Flamingo", "Assets/Custom/Scrap/Flamingo/flamingo.asset", (LevelTypes)(-1), Config.flamingoSpawnWeight.Value),
CustomShopItem.Add("Half Full Revolver", "Assets/Custom/ShopItems/HalfFull/HalfFull.asset", "Assets/Custom/ShopItems/HalfFull/HalfFullNode.asset", Config.revolverPrice.Value)
};
customEnemies = new List<CustomEnemy>
{
CustomEnemy.Add("Specter", "Assets/Custom/Enemies/Specter/Specter.asset", Config.specterSpawnWeight.Value, (LevelTypes)(-1), (SpawnType)0, "Assets/Custom/Enemies/custom-keyword.asset", "Assets/Custom/Enemies/Specter/custom-node.asset"),
CustomEnemy.Add("Imposter", "Assets/Custom/Enemies/Imposter/Imposter.asset", Config.imposterSpawnWeight.Value, (LevelTypes)(-1), (SpawnType)0, "Assets/Custom/Enemies/Imposter/Imposter_keyword.asset", "Assets/Custom/Enemies/Imposter/Imposter_node.asset")
};
customUnlockables = new List<CustomUnlockable> { CustomUnlockable.Add("Shrine", "Assets/Custom/ShopItems/Shrine/Shrine.asset", "Assets/Custom/ShopItems/Shrine/ShrineNode.asset", null, Config.shrineCost.Value) };
customMapObjects = new List<CustomMapObject>();
foreach (CustomItem customItem in customItems)
{
if (customItem.enabled)
{
Item val = MainAssets.LoadAsset<Item>(customItem.itemPath);
if ((Object)(object)val.spawnPrefab.GetComponent<NetworkTransform>() == (Object)null && (Object)(object)val.spawnPrefab.GetComponent<CustomNetworkTransform>() == (Object)null)
{
NetworkTransform val2 = val.spawnPrefab.AddComponent<NetworkTransform>();
val2.SlerpPosition = false;
val2.Interpolate = false;
val2.SyncPositionX = false;
val2.SyncPositionY = false;
val2.SyncPositionZ = false;
val2.SyncScaleX = false;
val2.SyncScaleY = false;
val2.SyncScaleZ = false;
val2.UseHalfFloatPrecision = true;
}
Prefabs.Add(customItem.name, val.spawnPrefab);
Utilities.FixMixerGroups(val.spawnPrefab);
NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
customItem.itemAction(val);
if (customItem is CustomShopItem)
{
TerminalNode val3 = MainAssets.LoadAsset<TerminalNode>(customItem.infoPath);
Plugin.logger.LogInfo((object)$"Registering shop item {customItem.name} with price {((CustomShopItem)customItem).itemPrice}");
Items.RegisterShopItem(val, (TerminalNode)null, (TerminalNode)null, val3, ((CustomShopItem)customItem).itemPrice);
}
else if (customItem is CustomScrap)
{
Items.RegisterScrap(val, ((CustomScrap)customItem).rarity, ((CustomScrap)customItem).levelType);
}
else if (customItem is CustomPlainItem)
{
Items.RegisterItem(val);
}
}
}
foreach (CustomUnlockable customUnlockable in customUnlockables)
{
if (customUnlockable.enabled)
{
UnlockableItem unlockable = MainAssets.LoadAsset<UnlockableItemDef>(customUnlockable.unlockablePath).unlockable;
if ((Object)(object)unlockable.prefabObject != (Object)null)
{
NetworkPrefabs.RegisterNetworkPrefab(unlockable.prefabObject);
}
Prefabs.Add(customUnlockable.name, unlockable.prefabObject);
Utilities.FixMixerGroups(unlockable.prefabObject);
TerminalNode val4 = null;
if (customUnlockable.infoPath != null)
{
val4 = MainAssets.LoadAsset<TerminalNode>(customUnlockable.infoPath);
}
Unlockables.RegisterUnlockable(unlockable, (StoreType)2, (TerminalNode)null, (TerminalNode)null, val4, customUnlockable.unlockCost);
Plugin.logger.LogInfo((object)$"Registered '{unlockable.unlockableName}' for price: {customUnlockable.unlockCost}");
}
}
foreach (CustomEnemy customEnemy in customEnemies)
{
if (customEnemy.enabled)
{
EnemyType val5 = MainAssets.LoadAsset<EnemyType>(customEnemy.enemyPath);
TerminalNode val6 = MainAssets.LoadAsset<TerminalNode>(customEnemy.infoNode);
TerminalKeyword val7 = null;
if (customEnemy.infoKeyword != null)
{
val7 = MainAssets.LoadAsset<TerminalKeyword>(customEnemy.infoKeyword);
}
NetworkPrefabs.RegisterNetworkPrefab(val5.enemyPrefab);
Prefabs.Add(customEnemy.name, val5.enemyPrefab);
Utilities.FixMixerGroups(val5.enemyPrefab);
Enemies.RegisterEnemy(val5, customEnemy.rarity, customEnemy.levelFlags, customEnemy.spawnType, val6, val7);
Plugin.logger.LogInfo((object)("Registered enemy: " + customEnemy.name));
}
}
foreach (CustomMapObject customMapObject in customMapObjects)
{
if (customMapObject.enabled)
{
SpawnableMapObjectDef val8 = MainAssets.LoadAsset<SpawnableMapObjectDef>(customMapObject.objectPath);
NetworkPrefabs.RegisterNetworkPrefab(val8.spawnableMapObject.prefabToSpawn);
Prefabs.Add(customMapObject.name, val8.spawnableMapObject.prefabToSpawn);
Utilities.FixMixerGroups(val8.spawnableMapObject.prefabToSpawn);
MapObjects.RegisterMapObject(val8, customMapObject.levelFlags, customMapObject.spawnRateFunction);
}
}
foreach (KeyValuePair<string, GameObject> prefab in Prefabs)
{
GameObject value = prefab.Value;
string key = prefab.Key;
AudioSource[] componentsInChildren = value.GetComponentsInChildren<AudioSource>();
if (componentsInChildren.Length != 0)
{
ConfigEntry<float> val9 = Config.VolumeConfig.Bind<float>("Volume", key ?? "", 100f, "Audio volume for " + key + " (0 - 100)");
AudioSource[] array = componentsInChildren;
foreach (AudioSource val10 in array)
{
val10.volume *= val9.Value / 100f;
}
}
}
try
{
IEnumerable<Type> loadableTypes = Assembly.GetExecutingAssembly().GetLoadableTypes();
foreach (Type item in loadableTypes)
{
MethodInfo[] methods = item.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
MethodInfo[] array2 = methods;
foreach (MethodInfo methodInfo in array2)
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
if (customAttributes.Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
}
catch (Exception)
{
}
Plugin.logger.LogInfo((object)"Custom content loaded!");
}
}
public class CustomAI : EnemyAI
{
public AISearchRoutine searchForPlayers;
public bool investigating = false;
public bool hasBegunInvestigating = false;
public Vector3 investigatePosition;
private ManualLogSource myLogSource;
public override void Start()
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
((EnemyAI)this).Start();
Transform val = ((Component)this).transform.Find("Model");
myLogSource = Plugin.logger;
myLogSource.LogInfo((object)"Custom Enemy Spawned");
searchForPlayers = new AISearchRoutine();
((Component)base.creatureVoice).gameObject.AddComponent<OccludeAudio>();
}
public override void DoAIInterval()
{
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).DoAIInterval();
if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
{
return;
}
base.targetPlayer = ((EnemyAI)this).CheckLineOfSightForClosestPlayer(80f, 60, 1, 1.5f);
if ((Object)(object)base.targetPlayer != (Object)null)
{
myLogSource.LogInfo((object)"Found player");
((EnemyAI)this).StopSearch(searchForPlayers, true);
if (!base.movingTowardsTargetPlayer)
{
((EnemyAI)this).SwitchToBehaviourState(1);
}
base.movingTowardsTargetPlayer = true;
hasBegunInvestigating = false;
investigating = false;
if ((Object)(object)base.targetPlayer != (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
((EnemyAI)this).ChangeOwnershipOfEnemy(base.targetPlayer.actualClientId);
}
}
else if (investigating)
{
myLogSource.LogInfo((object)"Investigating");
if (!hasBegunInvestigating)
{
hasBegunInvestigating = true;
((EnemyAI)this).StopSearch(base.currentSearch, false);
((EnemyAI)this).SetDestinationToPosition(investigatePosition, false);
((EnemyAI)this).SwitchToBehaviourState(0);
}
if (Vector3.Distance(((Component)this).transform.position, investigatePosition) < 5f)
{
investigating = false;
hasBegunInvestigating = false;
}
}
else if (!searchForPlayers.inProgress)
{
myLogSource.LogInfo((object)"Searching");
base.movingTowardsTargetPlayer = false;
((EnemyAI)this).StartSearch(((Component)this).transform.position, searchForPlayers);
((EnemyAI)this).SwitchToBehaviourState(0);
}
}
public override void Update()
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).Update();
if (base.ventAnimationFinished && (Object)(object)base.creatureAnimator != (Object)null && !base.isEnemyDead && !StartOfRound.Instance.allPlayersDead)
{
Vector3 serverPosition = base.serverPosition;
if (base.stunNormalizedTimer > 0f)
{
base.agent.speed = 0f;
}
else if (((NetworkBehaviour)this).IsOwner)
{
base.agent.speed = 1.5f;
}
}
}
public override void OnCollideWithPlayer(Collider other)
{
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).OnCollideWithPlayer(other);
myLogSource.LogInfo((object)("Collider tag: " + ((Object)other).name + "Collider name: " + ((Object)other).name));
if (((Component)other).CompareTag("Player") || ((Component)((Component)other).transform.parent).CompareTag("Player"))
{
myLogSource.LogInfo((object)("Hitting player " + ((Object)((Component)other).gameObject).name));
PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
if ((Object)(object)val != (Object)null)
{
myLogSource.LogInfo((object)"Player is collidable");
val.DamagePlayer(150, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
}
else
{
myLogSource.LogInfo((object)"Player collider on parent?");
val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(((Component)((Component)other).transform.parent).GetComponent<Collider>(), false, false);
val.DamagePlayer(150, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
}
}
}
public override void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot = 0, int noiseID = 0)
{
//IL_0013: 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)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
myLogSource.LogInfo((object)"Custom Enemy Heard Noise");
((EnemyAI)this).DetectNoise(noisePosition, noiseLoudness, timesPlayedInOneSpot, noiseID);
float num = Vector3.Distance(noisePosition, ((Component)this).transform.position);
if (!(num > 15f) && !base.movingTowardsTargetPlayer)
{
investigatePosition = noisePosition;
}
}
public void InvestigatePosition(Vector3 position)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
myLogSource.LogInfo((object)"Investigating Position");
if (!hasBegunInvestigating)
{
investigatePosition = position;
investigating = true;
}
}
protected override void __initializeVariables()
{
((EnemyAI)this).__initializeVariables();
}
protected internal override string __getTypeName()
{
return "CustomAI";
}
}
public class ImposterAI : EnemyAI
{
public AISearchRoutine searchForPlayers;
public bool investigating = false;
public bool hasBegunInvestigating = false;
public bool fleeing = false;
public Vector3 investigatePosition;
public SkinnedMeshRenderer rendererLOD0;
public SkinnedMeshRenderer rendererLOD1;
public SkinnedMeshRenderer rendererLOD2;
private float voiceCD = 8f;
private float lastSpoke = 0f;
private bool startingToFlee = false;
private float timeToStartFlee = 0f;
private float waitToStartFlee = 0.6f;
private int fleeMeter = 0;
private int fleeMeterThreshold = 25;
private float lastInSightCheck = 0f;
private float inFleeTimer = 20f;
private float timeWhenFled = 0f;
private float targetDist = 999f;
private List<Transform> ignoredNodes = new List<Transform>();
private Transform fleeNode;
private Ray enemyRay;
private RaycastHit enemyRayHit;
private int currentFootstepSurfaceIndex;
private int previousFootstepClip;
private float footsetpInterval = 0.8f;
private float lastFootstepTime = 0f;
public AudioSource movementAudio;
private float attackCooldownInterval = 3f;
private float lastTimeAttacked = 0f;
public override void Start()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
((EnemyAI)this).Start();
Transform val = ((Component)this).transform.Find("Model");
searchForPlayers = new AISearchRoutine();
((EnemyAI)this).SwitchToBehaviourState(0);
base.agent.stoppingDistance = 0f;
base.debugEnemyAI = false;
voiceCD = Config.imposterVoiceInterval.Value;
fleeMeterThreshold = Config.imposterFleeMeter.Value;
PlayerControllerB val2 = StartOfRound.Instance.allPlayerScripts[Random.Range(0, StartOfRound.Instance.allPlayerScripts.Length)];
if (!val2.isPlayerControlled && StartOfRound.Instance.livingPlayers > 0)
{
while (!val2.isPlayerControlled)
{
val2 = StartOfRound.Instance.allPlayerScripts[Random.Range(0, StartOfRound.Instance.allPlayerScripts.Length)];
}
}
int currentSuitID = val2.currentSuitID;
SetSuit(currentSuitID);
SetSuitClientRpc(currentSuitID);
}
public override void DoAIInterval()
{
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
//IL_0466: Unknown result type (might be due to invalid IL or missing references)
//IL_046c: Unknown result type (might be due to invalid IL or missing references)
//IL_0453: Unknown result type (might be due to invalid IL or missing references)
//IL_0339: Unknown result type (might be due to invalid IL or missing references)
//IL_035e: Unknown result type (might be due to invalid IL or missing references)
//IL_038c: Unknown result type (might be due to invalid IL or missing references)
//IL_0391: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).DoAIInterval();
if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
{
return;
}
if (lastFootstepTime + footsetpInterval < Time.time)
{
PlayFootstepSound();
lastFootstepTime = Time.time;
}
Vector3 val;
if (((EnemyAI)this).TargetClosestPlayer(1.5f, false, 360f) && !fleeing)
{
if ((Object)(object)base.targetPlayer != (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
Plugin.logger.LogInfo((object)"player ownership changed");
((EnemyAI)this).ChangeOwnershipOfEnemy(base.targetPlayer.actualClientId);
}
((EnemyAI)this).StopSearch(base.currentSearch, true);
ChooseClosestNodeToPlayer();
hasBegunInvestigating = false;
investigating = false;
targetDist = Vector3.Distance(((Component)base.targetPlayer).transform.position, ((Component)this).transform.position);
if (targetDist <= 18f && lastSpoke + voiceCD < Time.time)
{
Plugin.logger.LogInfo((object)"Target in range, playing audio clip");
if (((NetworkBehaviour)this).IsHost)
{
PlaySample();
PlaySampleClientRpc();
}
else
{
PlaySampleServerRpc();
}
}
if ((Object)(object)((EnemyAI)this).CheckLineOfSightForPlayer(90f, 15, -1) != (Object)null)
{
Plugin.logger.LogInfo((object)"Player is in sight and in range");
if (lastInSightCheck + 0.4f < Time.time)
{
Plugin.logger.LogInfo((object)"Imposter has been seen");
lastInSightCheck = Time.time;
}
base.movingTowardsTargetPlayer = true;
fleeMeter++;
}
else
{
base.movingTowardsTargetPlayer = false;
}
if (fleeMeter >= fleeMeterThreshold)
{
Plugin.logger.LogInfo((object)"Imposter is now fleeing");
fleeing = true;
timeToStartFlee = Time.time;
startingToFlee = true;
fleeMeter = 0;
}
else if (targetDist <= 4f && Object.op_Implicit((Object)(object)((EnemyAI)this).CheckLineOfSightForPlayer(90f, 60, -1)))
{
Plugin.logger.LogInfo((object)"kill player");
((EnemyAI)this).SwitchToBehaviourState(2);
PlayerControllerB targetPlayer = base.targetPlayer;
val = default(Vector3);
targetPlayer.DamagePlayer(50, true, true, (CauseOfDeath)0, 0, false, val);
fleeing = true;
timeToStartFlee = Time.time;
fleeMeter = 0;
startingToFlee = true;
}
return;
}
targetDist = 999f;
if (fleeing)
{
if (timeToStartFlee + waitToStartFlee > Time.time)
{
Plugin.logger.LogInfo((object)"waiting for anim to flee");
}
else if (startingToFlee)
{
((EnemyAI)this).StopSearch(base.currentSearch, true);
startingToFlee = false;
fleeNode = ((EnemyAI)this).ChooseFarthestNodeFromPosition(((Component)this).transform.position, true, 0, false);
base.targetNode = fleeNode;
((EnemyAI)this).SetDestinationToPosition(fleeNode.position, true);
timeWhenFled = Time.time;
ignoredNodes.Clear();
ManualLogSource logger = Plugin.logger;
val = base.destination;
logger.LogInfo((object)("Fleeing to: " + ((object)(Vector3)(ref val)).ToString()));
if (base.currentBehaviourStateIndex != 0)
{
((EnemyAI)this).SwitchToBehaviourState(0);
}
}
else if (inFleeTimer + timeWhenFled < Time.time)
{
Plugin.logger.LogInfo((object)"stopped fleeing");
investigating = true;
hasBegunInvestigating = false;
fleeing = false;
}
}
else if (investigating)
{
Plugin.logger.LogInfo((object)"Investigating");
if (!hasBegunInvestigating)
{
hasBegunInvestigating = true;
((EnemyAI)this).StopSearch(base.currentSearch, false);
((EnemyAI)this).SetDestinationToPosition(investigatePosition, false);
}
if (Vector3.Distance(((Component)this).transform.position, investigatePosition) < 5f)
{
investigating = false;
hasBegunInvestigating = false;
}
}
else if (!searchForPlayers.inProgress)
{
Plugin.logger.LogInfo((object)"Starting investigation");
((EnemyAI)this).StartSearch(((Component)this).transform.position, searchForPlayers);
base.movingTowardsTargetPlayer = false;
}
}
public override void Update()
{
((EnemyAI)this).Update();
if (!base.ventAnimationFinished || !((Object)(object)base.creatureAnimator != (Object)null) || base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
{
return;
}
if (base.stunNormalizedTimer > 0f)
{
base.agent.speed = 0f;
footsetpInterval = 999f;
}
else
{
if (!((NetworkBehaviour)this).IsOwner)
{
return;
}
if ((targetDist <= 10f && !fleeing) || (targetDist <= 10f && startingToFlee))
{
base.agent.speed = 3f;
footsetpInterval = 0.4f;
if (Object.op_Implicit((Object)(object)((EnemyAI)this).CheckLineOfSightForPlayer(90f, 40, -1)) || targetDist <= 6f)
{
base.agent.speed = 0f;
footsetpInterval = 999f;
if (base.currentBehaviourStateIndex != 1 && base.currentBehaviourStateIndex != 2)
{
((EnemyAI)this).SwitchToBehaviourState(1);
}
}
}
else
{
base.agent.speed = 8f;
footsetpInterval = 0.2f;
if (base.currentBehaviourStateIndex != 0 && base.currentBehaviourStateIndex != 2)
{
((EnemyAI)this).SwitchToBehaviourState(0);
}
}
}
}
public override void OnCollideWithPlayer(Collider other)
{
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).OnCollideWithPlayer(other);
if (((Component)other).CompareTag("Player") || (((Component)((Component)other).transform.parent).CompareTag("Player") && attackCooldownInterval + lastTimeAttacked < Time.time))
{
Plugin.logger.LogInfo((object)("Hitting player " + ((Object)((Component)other).gameObject).name));
PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
if ((Object)(object)val != (Object)null)
{
Plugin.logger.LogInfo((object)"Player is collidable");
((EnemyAI)this).SwitchToBehaviourState(2);
val.DamagePlayer(50, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
fleeing = true;
timeToStartFlee = Time.time;
startingToFlee = true;
}
else
{
Plugin.logger.LogInfo((object)"Player collider on parent?");
val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(((Component)((Component)other).transform.parent).GetComponent<Collider>(), false, false);
((EnemyAI)this).SwitchToBehaviourState(2);
val.DamagePlayer(50, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
fleeing = true;
timeToStartFlee = Time.time;
startingToFlee = true;
}
lastTimeAttacked = Time.time;
}
}
[ClientRpc]
public void PlaySampleClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: 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)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2658930220u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2658930220u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
PlaySample();
}
}
}
[ServerRpc]
public void PlaySampleServerRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Invalid comparison between Unknown and I4
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Invalid comparison between Unknown and I4
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
{
if ((int)networkManager.LogLevel <= 1)
{
Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
}
return;
}
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1219689617u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1219689617u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
PlaySampleClientRpc();
}
}
public void PlaySample()
{
AudioClip sample = SkinwalkerPersistent.Instance.GetSample();
base.creatureVoice.PlayOneShot(sample);
lastSpoke = Time.time;
}
public void ChooseClosestNodeToPlayer()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: 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_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)base.targetNode == (Object)null)
{
base.targetNode = base.allAINodes[0].transform;
}
Transform val = ((EnemyAI)this).ChooseClosestNodeToPosition(((Component)base.targetPlayer).transform.position, true, 0);
if ((Object)(object)val != (Object)null)
{
base.targetNode = val;
}
float num = Vector3.Distance(((Component)base.targetPlayer).transform.position, ((Component)this).transform.position);
if (num - base.mostOptimalDistance < 0.1f && (!((EnemyAI)this).PathIsIntersectedByLineOfSight(((Component)base.targetPlayer).transform.position, true, true) || num < 3f))
{
if (base.pathDistance > 10f && !ignoredNodes.Contains(base.targetNode) && ignoredNodes.Count < 4)
{
ignoredNodes.Add(base.targetNode);
}
base.movingTowardsTargetPlayer = true;
}
else
{
((EnemyAI)this).SetDestinationToPosition(base.targetNode.position, false);
}
}
[ClientRpc]
public void SetSuitClientRpc(int suitId)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1123682967u, val, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val2, suitId);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1123682967u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
SetSuit(suitId);
}
}
}
public void SetSuit(int suitId)
{
Material suitMaterial = StartOfRound.Instance.unlockablesList.unlockables[suitId].suitMaterial;
((Renderer)rendererLOD0).material = suitMaterial;
((Renderer)rendererLOD1).material = suitMaterial;
((Renderer)rendererLOD2).material = suitMaterial;
}
public void GetMaterialStandingOn()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: 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_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
enemyRay = new Ray(((Component)this).transform.position + Vector3.up, -Vector3.up);
if (!Physics.Raycast(enemyRay, ref enemyRayHit, 6f, StartOfRound.Instance.walkableSurfacesMask, (QueryTriggerInteraction)1) || ((Component)((RaycastHit)(ref enemyRayHit)).collider).CompareTag(StartOfRound.Instance.footstepSurfaces[currentFootstepSurfaceIndex].surfaceTag))
{
return;
}
for (int i = 0; i < StartOfRound.Instance.footstepSurfaces.Length; i++)
{
if (((Component)((RaycastHit)(ref enemyRayHit)).collider).CompareTag(StartOfRound.Instance.footstepSurfaces[i].surfaceTag))
{
currentFootstepSurfaceIndex = i;
break;
}
}
}
public void PlayFootstepSound()
{
GetMaterialStandingOn();
int num = Random.Range(0, StartOfRound.Instance.footstepSurfaces[currentFootstepSurfaceIndex].clips.Length);
if (num == previousFootstepClip)
{
num = (num + 1) % StartOfRound.Instance.footstepSurfaces[currentFootstepSurfaceIndex].clips.Length;
}
movementAudio.pitch = Random.Range(0.93f, 1.07f);
float num2 = 0.95f;
if (!fleeing)
{
num2 = 0.75f;
}
movementAudio.PlayOneShot(StartOfRound.Instance.footstepSurfaces[currentFootstepSurfaceIndex].clips[num], num2);
previousFootstepClip = num;
WalkieTalkie.TransmitOneShotAudio(movementAudio, StartOfRound.Instance.footstepSurfaces[currentFootstepSurfaceIndex].clips[num], num2);
}
protected override void __initializeVariables()
{
((EnemyAI)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_ImposterAI()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(2658930220u, new RpcReceiveHandler(__rpc_handler_2658930220));
NetworkManager.__rpc_func_table.Add(1219689617u, new RpcReceiveHandler(__rpc_handler_1219689617));
NetworkManager.__rpc_func_table.Add(1123682967u, new RpcReceiveHandler(__rpc_handler_1123682967));
}
private static void __rpc_handler_2658930220(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((ImposterAI)(object)target).PlaySampleClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1219689617(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: 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_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Invalid comparison between Unknown and I4
NetworkManager networkManager = target.NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
{
if ((int)networkManager.LogLevel <= 1)
{
Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
}
}
else
{
target.__rpc_exec_stage = (__RpcExecStage)1;
((ImposterAI)(object)target).PlaySampleServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1123682967(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0023: 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_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
int suitClientRpc = default(int);
ByteUnpacker.ReadValueBitPacked(reader, ref suitClientRpc);
target.__rpc_exec_stage = (__RpcExecStage)2;
((ImposterAI)(object)target).SetSuitClientRpc(suitClientRpc);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "ImposterAI";
}
}
public class SkinwalkerPersistent : MonoBehaviour
{
private string audioFolder;
private List<AudioClip> cachedAudio = new List<AudioClip>();
private float nextTimeToCheckFolder = 30f;
private float nextTimeToCheckEnemies = 30f;
private const float folderScanInterval = 8f;
private const float enemyScanInterval = 5f;
public static SkinwalkerPersistent Instance { get; private set; }
private void Awake()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
((Component)this).transform.position = Vector3.zero;
Plugin.logger.LogInfo((object)"skinwalker persistent initialized");
audioFolder = Path.Combine(Application.dataPath, "..", "Dissonance_Diagnostics");
EnableRecording();
Plugin.logger.LogInfo((object)audioFolder);
if (!Directory.Exists(audioFolder))
{
Directory.CreateDirectory(audioFolder);
}
}
private void Update()
{
if (!(Time.realtimeSinceStartup > nextTimeToCheckFolder))
{
return;
}
nextTimeToCheckFolder = Time.realtimeSinceStartup + 8f;
if (!Directory.Exists(audioFolder))
{
Plugin.logger.LogInfo((object)("Audio folder not present. Don't worry about it, it will be created automatically when you play with friends. (" + audioFolder + ")"));
Directory.CreateDirectory(audioFolder);
}
string[] files = Directory.GetFiles(audioFolder);
Plugin.logger.LogInfo((object)$"Got audio file paths ({files.Length})");
string[] array = files;
string[] array2 = array;
foreach (string path in array2)
{
((MonoBehaviour)this).StartCoroutine(LoadWavFile(path, delegate(AudioClip audioClip)
{
cachedAudio.Add(audioClip);
}));
}
}
private void Start()
{
try
{
if (Directory.Exists(audioFolder))
{
Directory.Delete(audioFolder, recursive: true);
}
}
catch (Exception ex)
{
Plugin.logger.LogInfo((object)ex);
}
}
private void OnApplicationQuit()
{
DisableRecording();
}
private void EnableRecording()
{
DebugSettings.Instance.EnablePlaybackDiagnostics = true;
DebugSettings.Instance.RecordFinalAudio = true;
}
internal IEnumerator LoadWavFile(string path, Action<AudioClip> callback)
{
UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(path, (AudioType)20);
try
{
yield return www.SendWebRequest();
if ((int)www.result == 1)
{
AudioClip audioClip = DownloadHandlerAudioClip.GetContent(www);
if (audioClip.length > 0.9f)
{
callback(audioClip);
}
try
{
File.Delete(path);
}
catch (Exception)
{
}
}
}
finally
{
((IDisposable)www)?.Dispose();
}
}
private void DisableRecording()
{
DebugSettings.Instance.EnablePlaybackDiagnostics = false;
DebugSettings.Instance.RecordFinalAudio = false;
if (Directory.Exists(audioFolder))
{
Directory.Delete(audioFolder, recursive: true);
}
}
public AudioClip GetSample()
{
while (cachedAudio.Count > 200)
{
cachedAudio.RemoveAt(Random.Range(0, cachedAudio.Count));
}
if (cachedAudio.Count > 0)
{
int index = Random.Range(0, cachedAudio.Count - 1);
AudioClip result = cachedAudio[index];
cachedAudio.RemoveAt(index);
return result;
}
return null;
}
public void ClearCache()
{
cachedAudio.Clear();
}
}
[BepInPlugin("camtas.myCustomContent", "My Custom Content", "0.5.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public const string ModGUID = "camtas.myCustomContent";
public const string ModName = "My Custom Content";
public const string ModVersion = "0.5.0";
public static ManualLogSource logger;
public static ConfigFile config;
public static bool devMode;
private void Awake()
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
logger = Logger.CreateLogSource("My Custom Log Source");
config = ((BaseUnityPlugin)this).Config;
Utilities.Init();
Config.Load();
Content.Load();
MyCustomContent.Patches.Patches.Load();
GameObject val = new GameObject("MCC Mod Manager");
val.AddComponent<SkinwalkerPersistent>();
((Object)val).hideFlags = (HideFlags)61;
Object.DontDestroyOnLoad((Object)(object)val);
}
}
public class Utilities
{
private static Dictionary<int, int> _masksByLayer;
public static void Init()
{
GenerateLayerMap();
}
public static void GenerateLayerMap()
{
_masksByLayer = new Dictionary<int, int>();
for (int i = 0; i < 32; i++)
{
int num = 0;
for (int j = 0; j < 32; j++)
{
if (!Physics.GetIgnoreLayerCollision(i, j))
{
num |= 1 << j;
}
}
_masksByLayer.Add(i, num);
}
}
public static int MaskForLayer(int layer)
{
return _masksByLayer[layer];
}
public static void LoadPrefab(string name, Vector3 position)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
if (Content.Prefabs.ContainsKey(name))
{
Plugin.logger.LogInfo((object)("Loading prefab " + name));
GameObject val = Object.Instantiate<GameObject>(Content.Prefabs[name], position, Quaternion.identity);
val.GetComponent<NetworkObject>().Spawn(false);
}
else
{
Plugin.logger.LogWarning((object)("Prefab " + name + " not found!"));
}
}
public static void TeleportPlayer(int playerObj, Vector3 teleportPos)
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[playerObj];
if (Object.op_Implicit((Object)(object)Object.FindObjectOfType<AudioReverbPresets>()))
{
Object.FindObjectOfType<AudioReverbPresets>().audioPresets[2].ChangeAudioReverbForPlayer(val);
}
val.isInElevator = false;
val.isInHangarShipRoom = false;
val.isInsideFactory = true;
val.averageVelocity = 0f;
val.velocityLastFrame = Vector3.zero;
StartOfRound.Instance.allPlayerScripts[playerObj].TeleportPlayer(teleportPos, false, 0f, false, true);
StartOfRound.Instance.allPlayerScripts[playerObj].beamOutParticle.Play();
if ((Object)(object)val == (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
}
}
public static IEnumerator TeleportPlayerBody(int playerObj, Vector3 teleportPosition)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
float startTime = Time.realtimeSinceStartup;
yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)StartOfRound.Instance.allPlayerScripts[playerObj].deadBody != (Object)null || Time.realtimeSinceStartup - startTime > 2f));
if (StartOfRound.Instance.inShipPhase || SceneManager.sceneCount <= 1)
{
yield break;
}
DeadBodyInfo deadBody = StartOfRound.Instance.allPlayerScripts[playerObj].deadBody;
if ((Object)(object)deadBody != (Object)null)
{
deadBody.attachedTo = null;
deadBody.attachedLimb = null;
deadBody.secondaryAttachedLimb = null;
deadBody.secondaryAttachedTo = null;
if ((Object)(object)deadBody.grabBodyObject != (Object)null && deadBody.grabBodyObject.isHeld && (Object)(object)deadBody.grabBodyObject.playerHeldBy != (Object)null)
{
deadBody.grabBodyObject.playerHeldBy.DropAllHeldItems(true, false);
}
deadBody.isInShip = false;
deadBody.parentedToShip = false;
((Component)deadBody).transform.SetParent((Transform)null, true);
deadBody.SetRagdollPositionSafely(teleportPosition, true);
}
}
public static void TeleportEnemy(EnemyAI enemy, Vector3 teleportPos)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: 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)
enemy.serverPosition = teleportPos;
((Component)enemy).transform.position = teleportPos;
enemy.agent.Warp(teleportPos);
enemy.SyncPositionToClients();
}
public static void CreateExplosion(Vector3 explosionPosition, bool spawnExplosionEffect = false, int damage = 20, float minDamageRange = 0f, float maxDamageRange = 1f, int enemyHitForce = 6, CauseOfDeath causeOfDeath = 3, PlayerControllerB attacker = null)
{
//IL_00a1: 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_006f: 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)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: 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)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0323: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Unknown result type (might be due to invalid IL or missing references)
//IL_029e: Unknown result type (might be due to invalid IL or missing references)
Debug.Log((object)"Spawning explosion at pos: {explosionPosition}");
Transform val = null;
if ((Object)(object)RoundManager.Instance != (Object)null && (Object)(object)RoundManager.Instance.mapPropsContainer != (Object)null && (Object)(object)RoundManager.Instance.mapPropsContainer.transform != (Object)null)
{
val = RoundManager.Instance.mapPropsContainer.transform;
}
if (spawnExplosionEffect)
{
Object.Instantiate<GameObject>(StartOfRound.Instance.explosionPrefab, explosionPosition, Quaternion.Euler(-90f, 0f, 0f), val).SetActive(true);
}
float num = Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, explosionPosition);
if (num < 14f)
{
HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
}
else if (num < 25f)
{
HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
}
Collider[] array = Physics.OverlapSphere(explosionPosition, maxDamageRange, 2621448, (QueryTriggerInteraction)2);
PlayerControllerB val2 = null;
for (int i = 0; i < array.Length; i++)
{
float num2 = Vector3.Distance(explosionPosition, ((Component)array[i]).transform.position);
if (num2 > 4f && Physics.Linecast(explosionPosition, ((Component)array[i]).transform.position + Vector3.up * 0.3f, 256, (QueryTriggerInteraction)1))
{
continue;
}
if (((Component)array[i]).gameObject.layer == 3)
{
val2 = ((Component)array[i]).gameObject.GetComponent<PlayerControllerB>();
if ((Object)(object)val2 != (Object)null && ((NetworkBehaviour)val2).IsOwner)
{
float num3 = 1f - Mathf.Clamp01((num2 - minDamageRange) / (maxDamageRange - minDamageRange));
val2.DamagePlayer((int)((float)damage * num3), true, true, causeOfDeath, 0, false, default(Vector3));
}
}
else if (((Component)array[i]).gameObject.layer == 21)
{
Landmine componentInChildren = ((Component)array[i]).gameObject.GetComponentInChildren<Landmine>();
if ((Object)(object)componentInChildren != (Object)null && !componentInChildren.hasExploded && num2 < 6f)
{
Debug.Log((object)"Setting off other mine");
}
}
else if (((Component)array[i]).gameObject.layer == 19)
{
EnemyAICollisionDetect componentInChildren2 = ((Component)array[i]).gameObject.GetComponentInChildren<EnemyAICollisionDetect>();
if ((Object)(object)componentInChildren2 != (Object)null && ((NetworkBehaviour)componentInChildren2.mainScript).IsOwner && num2 < 4.5f)
{
componentInChildren2.mainScript.HitEnemyOnLocalClient(enemyHitForce, default(Vector3), attacker, false);
}
}
}
int num4 = ~LayerMask.GetMask(new string[1] { "Room" });
num4 = ~LayerMask.GetMask(new string[1] { "Colliders" });
array = Physics.OverlapSphere(explosionPosition, 10f, num4);
for (int j = 0; j < array.Length; j++)
{
Rigidbody component = ((Component)array[j]).GetComponent<Rigidbody>();
if ((Object)(object)component != (Object)null)
{
component.AddExplosionForce(70f, explosionPosition, 10f);
}
}
}
}
}
namespace MyCustomContent.Patches
{
public class Miscellaneous
{
public static void Load()
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Expected O, but got Unknown
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Expected O, but got Unknown
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Expected O, but got Unknown
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Expected O, but got Unknown
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Expected O, but got Unknown
Hook val = new Hook((MethodBase)typeof(Object).GetMethod("Instantiate", new Type[3]
{
typeof(Object),
typeof(Transform),
typeof(bool)
}), typeof(Miscellaneous).GetMethod("InstantiateOPI"));
Hook val2 = new Hook((MethodBase)typeof(Object).GetMethod("Instantiate", new Type[2]
{
typeof(Object),
typeof(Transform)
}), typeof(Miscellaneous).GetMethod("InstantiateOP"));
Hook val3 = new Hook((MethodBase)typeof(Object).GetMethod("Instantiate", new Type[1] { typeof(Object) }), typeof(Miscellaneous).GetMethod("InstantiateO"));
Hook val4 = new Hook((MethodBase)typeof(Object).GetMethod("Instantiate", new Type[3]
{
typeof(Object),
typeof(Vector3),
typeof(Quaternion)
}), typeof(Miscellaneous).GetMethod("InstantiateOPR"));
Hook val5 = new Hook((MethodBase)typeof(Object).GetMethod("Instantiate", new Type[4]
{
typeof(Object),
typeof(Vector3),
typeof(Quaternion),
typeof(Transform)
}), typeof(Miscellaneous).GetMethod("InstantiateOPRP"));
}
public static Object InstantiateOPI(Func<Object, Transform, bool, Object> orig, Object original, Transform parent, bool instantiateInWorldSpace)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
Object val = orig(original, parent, instantiateInWorldSpace);
if (val != (Object)null && val is GameObject)
{
GameObject val2 = (GameObject)val;
Collider[] componentsInChildren = val2.GetComponentsInChildren<Collider>();
foreach (Collider val3 in componentsInChildren)
{
if (!((Object)(object)((Component)val3).gameObject.GetComponent<RootMarker>() != (Object)null))
{
RootMarker rootMarker = ((Component)val3).gameObject.AddComponent<RootMarker>();
rootMarker.root = val2.transform;
}
}
}
return val;
}
public static Object InstantiateOP(Func<Object, Transform, Object> orig, Object original, Transform parent)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
Object val = orig(original, parent);
if (val != (Object)null && val is GameObject)
{
GameObject val2 = (GameObject)val;
Collider[] componentsInChildren = val2.GetComponentsInChildren<Collider>();
foreach (Collider val3 in componentsInChildren)
{
if (!((Object)(object)((Component)val3).gameObject.GetComponent<RootMarker>() != (Object)null))
{
RootMarker rootMarker = ((Component)val3).gameObject.AddComponent<RootMarker>();
rootMarker.root = val2.transform;
}
}
}
return val;
}
public static Object InstantiateO(Func<Object, Object> orig, Object original)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
Object val = orig(original);
if (val != (Object)null && val is GameObject)
{
GameObject val2 = (GameObject)val;
Collider[] componentsInChildren = val2.GetComponentsInChildren<Collider>();
foreach (Collider val3 in componentsInChildren)
{
if (!((Object)(object)((Component)val3).gameObject.GetComponent<RootMarker>() != (Object)null))
{
RootMarker rootMarker = ((Component)val3).gameObject.AddComponent<RootMarker>();
rootMarker.root = val2.transform;
}
}
}
return val;
}
public static Object InstantiateOPR(Func<Object, Vector3, Quaternion, Object> orig, Object original, Vector3 position, Quaternion rotation)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
Object val = orig(original, position, rotation);
if (val != (Object)null && val is GameObject)
{
GameObject val2 = (GameObject)val;
Collider[] componentsInChildren = val2.GetComponentsInChildren<Collider>();
foreach (Collider val3 in componentsInChildren)
{
if (!((Object)(object)((Component)val3).gameObject.GetComponent<RootMarker>() != (Object)null))
{
RootMarker rootMarker = ((Component)val3).gameObject.AddComponent<RootMarker>();
rootMarker.root = val2.transform;
}
}
}
return val;
}
public static Object InstantiateOPRP(Func<Object, Vector3, Quaternion, Transform, Object> orig, Object original, Vector3 position, Quaternion rotation, Transform parent)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: 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_002e: Expected O, but got Unknown
Object val = orig(original, position, rotation, parent);
if (val != (Object)null && val is GameObject)
{
GameObject val2 = (GameObject)val;
Collider[] componentsInChildren = val2.GetComponentsInChildren<Collider>();
foreach (Collider val3 in componentsInChildren)
{
if (!((Object)(object)((Component)val3).gameObject.GetComponent<RootMarker>() != (Object)null))
{
RootMarker rootMarker = ((Component)val3).gameObject.AddComponent<RootMarker>();
rootMarker.root = val2.transform;
}
}
}
return val;
}
private static void StartOfRound_Start(orig_Start orig, StartOfRound self)
{
orig.Invoke(self);
SelectableLevel[] levels = self.levels;
foreach (SelectableLevel val in levels)
{
val.spawnableScrap.RemoveAll((SpawnableItemWithRarity scrap) => ((Object)scrap.spawnableItem).name == "dingus");
}
self.allItemsList.itemsList.RemoveAll((Item item) => ((Object)item).name == "dingus");
}
}
public class Patches
{
public static void Load()
{
SaveData.Init();
}
}
}
namespace MyCustomContent.MonoBehaviours
{
public class CustomNetworkTransform : NetworkBehaviour
{
public bool syncPosition = true;
public bool syncRotation = true;
public bool syncScale = true;
public float positionDiffLimit = 0.1f;
public float rotationDiffLimit = 0.1f;
public float scaleDiffLimit = 0.1f;
public bool lerpPosition = true;
public bool lerpRotation = true;
public bool lerpScale = true;
public float positionLerpSpeed = 10f;
public float rotationLerpSpeed = 10f;
public float scaleLerpSpeed = 10f;
private Vector3 _lastPosition;
private Vector3 _lastRotation;
private Vector3 _lastScale;
private Vector3 _targetPosition;
private Quaternion _targetRotation;
private Vector3 _targetScale;
public void FixedUpdate()
{
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: 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_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
if (((NetworkBehaviour)this).IsServer)
{
if (syncPosition && Vector3.Distance(((Component)this).transform.position, _lastPosition) > positionDiffLimit)
{
_lastPosition = ((Component)this).transform.position;
UpdatePositionClientRpc(((Component)this).transform.position);
}
if (syncRotation && Quaternion.Angle(Quaternion.Euler(((Component)this).transform.eulerAngles), Quaternion.Euler(_lastRotation)) > rotationDiffLimit)
{
_lastRotation = ((Component)this).transform.eulerAngles;
UpdateRotationClientRpc(((Component)this).transform.eulerAngles);
}
if (syncScale && Vector3.Distance(((Component)this).transform.localScale, _lastScale) > scaleDiffLimit)
{
_lastScale = ((Component)this).transform.localScale;
UpdateScaleClientRpc(((Component)this).transform.localScale);
}
}
else
{
if (lerpPosition)
{
((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, _targetPosition, Time.fixedDeltaTime * positionLerpSpeed);
}
if (lerpRotation)
{
((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, _targetRotation, Time.fixedDeltaTime * rotationLerpSpeed);
}
if (lerpScale)
{
((Component)this).transform.localScale = Vector3.Lerp(((Component)this).transform.localScale, _targetScale, Time.fixedDeltaTime * scaleLerpSpeed);
}
}
}
[ClientRpc]
public void UpdatePositionClientRpc(Vector3 position)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3523576079u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe(ref position);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3523576079u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsServer && syncPosition)
{
if (lerpPosition)
{
_targetPosition = position;
}
else
{
((Component)this).transform.position = position;
}
}
}
[ClientRpc]
public void UpdateRotationClientRpc(Vector3 rotation)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1681321577u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe(ref rotation);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1681321577u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsServer && syncRotation)
{
if (lerpRotation)
{
_targetRotation = Quaternion.Euler(rotation);
}
else
{
((Component)this).transform.rotation = Quaternion.Euler(rotation);
}
}
}
[ClientRpc]
public void UpdateScaleClientRpc(Vector3 scale)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1994939058u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe(ref scale);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1994939058u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsServer && syncScale)
{
if (lerpScale)
{
_targetScale = scale;
}
else
{
((Component)this).transform.localScale = scale;
}
}
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_CustomNetworkTransform()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(3523576079u, new RpcReceiveHandler(__rpc_handler_3523576079));
NetworkManager.__rpc_func_table.Add(1681321577u, new RpcReceiveHandler(__rpc_handler_1681321577));
NetworkManager.__rpc_func_table.Add(1994939058u, new RpcReceiveHandler(__rpc_handler_1994939058));
}
private static void __rpc_handler_3523576079(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0036: 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_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
Vector3 position = default(Vector3);
((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
target.__rpc_exec_stage = (__RpcExecStage)2;
((CustomNetworkTransform)(object)target).UpdatePositionClientRpc(position);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1681321577(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0036: 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_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
Vector3 rotation = default(Vector3);
((FastBufferReader)(ref reader)).ReadValueSafe(ref rotation);
target.__rpc_exec_stage = (__RpcExecStage)2;
((CustomNetworkTransform)(object)target).UpdateRotationClientRpc(rotation);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1994939058(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0036: 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_0050: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
Vector3 scale = default(Vector3);
((FastBufferReader)(ref reader)).ReadValueSafe(ref scale);
target.__rpc_exec_stage = (__RpcExecStage)2;
((CustomNetworkTransform)(object)target).UpdateScaleClientRpc(scale);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "CustomNetworkTransform";
}
}
public class RootMarker : MonoBehaviour
{
public Transform root;
}
public abstract class SaveableNetworkBehaviour : NetworkBehaviour
{
public int uniqueId = 0;
public abstract void SaveObjectData();
public abstract void LoadObjectData();
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
protected internal override string __getTypeName()
{
return "SaveableNetworkBehaviour";
}
}
public abstract class SaveableObject : GrabbableObject
{
public int uniqueId = 0;
public override void LoadItemSaveData(int saveData)
{
((GrabbableObject)this).LoadItemSaveData(saveData);
uniqueId = saveData;
}
public override int GetItemDataToSave()
{
return uniqueId;
}
public virtual void Awake()
{
if (((NetworkBehaviour)this).IsHost)
{
uniqueId = Random.Range(0, 1000000);
Plugin.logger.LogInfo((object)"This is where it screws up");
SaveableNetworkBehaviour[] componentsInChildren = ((Component)((Component)this).transform).GetComponentsInChildren<SaveableNetworkBehaviour>();
SaveableNetworkBehaviour[] array = componentsInChildren;
foreach (SaveableNetworkBehaviour saveableNetworkBehaviour in array)
{
saveableNetworkBehaviour.uniqueId = uniqueId;
}
}
}
public abstract void SaveObjectData();
public abstract void LoadObjectData();
protected override void __initializeVariables()
{
((GrabbableObject)this).__initializeVariables();
}
protected internal override string __getTypeName()
{
return "SaveableObject";
}
}
}
namespace MyCustomContent.Extensions
{
public static class AssemblyExtensions
{
public static IEnumerable<Type> GetLoadableTypes(this Assembly assembly)
{
try
{
return assembly.GetTypes();
}
catch (ReflectionTypeLoadException ex)
{
return ex.Types.Where((Type t) => t != null);
}
}
}
}
namespace MyCustomMod.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}