using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using EnhancedEnterprises.NetcodePatcher;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using MoreUpgrades.Networking;
using MoreUpgrades.Utils;
using TerminalApi;
using TerminalApi.Classes;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EnhancedEnterprises")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds Upgrades to be bought via the Terminal")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+788ba98ccb45eb88f8890088edb2d4f0ea7a352a")]
[assembly: AssemblyProduct("EnhancedEnterprises")]
[assembly: AssemblyTitle("EnhancedEnterprises")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
}
}
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;
}
}
}
namespace MoreUpgrades
{
[HarmonyPatch(typeof(PlayerControllerB))]
internal class PlayerControllerBPatch
{
private static UpgradeManager upgradeManager;
public static RaycastHit hit;
private static int firstEmptyItemSlot;
[HarmonyPatch("BeginGrabObject")]
[HarmonyPrefix]
private static void BeginGrabObjectPrePatch(PlayerControllerB __instance, ref int ___interactableObjectsMask)
{
//IL_000e: 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_0028: Unknown result type (might be due to invalid IL or missing references)
Ray val = default(Ray);
((Ray)(ref val))..ctor(((Component)__instance.gameplayCamera).transform.position, ((Component)__instance.gameplayCamera).transform.forward);
Physics.Raycast(val, ref hit, __instance.grabDistance, ___interactableObjectsMask);
}
[HarmonyPatch("BeginGrabObject")]
[HarmonyPostfix]
private static void BeginGrabObjectPostPatch(PlayerControllerB __instance, ref GrabbableObject ___currentlyGrabbingObject, ref int ___interactableObjectsMask)
{
if (!((Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController))
{
if ((Object)(object)upgradeManager == (Object)null)
{
upgradeManager = GameObject.Find("MoreUpgrades.Upgrademanager").GetComponent<UpgradeManager>();
}
if (!((Object)(object)___currentlyGrabbingObject == (Object)null) && ((Component)((RaycastHit)(ref hit)).collider).gameObject.layer != 8 && ((Component)((RaycastHit)(ref hit)).collider).gameObject.tag == "PhysicsProp" && ___currentlyGrabbingObject.grabbable && firstEmptyItemSlot != -1)
{
float num = Mathf.Clamp(___currentlyGrabbingObject.itemProperties.weight - 1f, 0f, 10f) * ((float)upgradeManager.postman.Upgradelevel / 10f);
float num2 = Mathf.Clamp(___currentlyGrabbingObject.itemProperties.weight - 1f, 0f, 10f);
upgradeManager.postman.UpdateWeightOffset(___currentlyGrabbingObject.itemProperties.weight, reduce: false);
upgradeManager.postman.ReduceWeight(___currentlyGrabbingObject.itemProperties.weight);
}
}
}
[HarmonyPatch("SetObjectAsNoLongerHeld")]
[HarmonyPostfix]
private static void SetObjectAsNoLongerHeldPatch(PlayerControllerB __instance)
{
if (!((Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController))
{
GrabbableObject currentlyHeldObjectServer = __instance.currentlyHeldObjectServer;
float num = Mathf.Clamp(currentlyHeldObjectServer.itemProperties.weight - 1f, 0f, 10f) * ((float)upgradeManager.postman.Upgradelevel / 10f);
float num2 = Mathf.Clamp(currentlyHeldObjectServer.itemProperties.weight - 1f, 0f, 10f);
upgradeManager.postman.UpdateWeightOffset(currentlyHeldObjectServer.itemProperties.weight, reduce: true);
upgradeManager.postman.AddWeigth(currentlyHeldObjectServer.itemProperties.weight);
}
}
[HarmonyPatch("FirstEmptyItemSlot")]
[HarmonyPostfix]
private static void FirstEmptyItemSlotPatch(ref int __result)
{
firstEmptyItemSlot = __result;
}
}
[BepInPlugin("EnhancedEnterprises", "EnhancedEnterprises", "1.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
private AssetBundle Assets;
private List<Item> shopItems = new List<Item>();
private Logger logger = new Logger("Plugin");
private void Awake()
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
LoadModAssets();
if ((Object)(object)Assets == (Object)null)
{
logger.LogError("Failed to load custom assets. Skipping plugin...");
return;
}
NetcodePatcher();
Harmony val = new Harmony("EnhancedEnterprises");
val.PatchAll();
logger.LogInfo("Plugin EnhancedEnterprises is loaded!");
}
private void LoadModAssets()
{
try
{
logger.LogInfo("Loading Mod Assets...");
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if (File.Exists(Path.Combine(directoryName, "modassets")))
{
Assets = NetworkAssets.LoadAsset();
}
}
catch (Exception ex)
{
logger.LogError("Error in Mod Asset loading: " + ex.Message);
}
}
private void LoadShopItems()
{
logger.LogInfo("Loading Shop Items...");
Item item = Assets.LoadAsset<Item>("assets/items/energydrink/energydrink.asset");
shopItems.Add(item);
}
private void RegisterItemsToShop()
{
logger.LogInfo("Registering Items to Shop...");
foreach (Item shopItem in shopItems)
{
if ((Object)(object)shopItem == (Object)null)
{
logger.LogInfo("item is null");
}
Items.RegisterShopItem(shopItem, shopItem.creditsWorth);
logger.LogInfo($"Loaded item: {((Object)shopItem).name} worth: {shopItem.creditsWorth}!");
}
}
private static void NetcodePatcher()
{
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
Type[] array = types;
foreach (Type type in array)
{
MethodInfo[] methods = type.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);
}
}
}
}
}
[HarmonyPatch(typeof(RoundManager))]
internal class RoundManagerPatch
{
private static UpgradeManager upgradeManager;
[HarmonyPatch("SpawnScrapInLevel")]
[HarmonyPrefix]
private static void SpawnScrapInLevelPatch(RoundManager __instance)
{
if ((Object)(object)upgradeManager == (Object)null)
{
upgradeManager = GameObject.Find("MoreUpgrades.Upgrademanager").GetComponent<UpgradeManager>();
}
__instance.scrapValueMultiplier = upgradeManager.scrapPurifier.UpdateValue();
__instance.scrapAmountMultiplier = upgradeManager.scrapMagnet.UpdateValue();
}
[HarmonyPatch("DespawnPropsAtEndOfRound")]
[HarmonyPostfix]
private static void DespawnPropsAtEndOfRoundPatch(RoundManager __instance)
{
if (GameNetworkManager.Instance.isHostingGame)
{
new SaveController().SaveToFile();
}
}
}
public class SaveController
{
private Logger logger = new Logger("SaveController");
private UpgradeManager upgradeManager;
private SaveFile saveFile;
private string GetSaveFile()
{
string currentSaveFileName = GameNetworkManager.Instance.currentSaveFileName;
return Path.Combine(GetSaveDir(), currentSaveFileName + ".json");
}
private string GetSaveDir()
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
return Path.Combine(directoryName, "Saves");
}
private void CreateSaveFile()
{
if (!Directory.Exists(GetSaveDir()))
{
Directory.CreateDirectory(GetSaveDir());
}
if (!File.Exists(GetSaveFile()))
{
File.Create(GetSaveFile()).Dispose();
}
}
public void SaveToFile()
{
if ((Object)(object)upgradeManager == (Object)null)
{
upgradeManager = GameObject.Find("MoreUpgrades.Upgrademanager").GetComponent<UpgradeManager>();
}
logger.LogInfo("Saving to file: " + GetSaveFile());
CreateSaveFile();
PrepareSaveFile();
StreamWriter streamWriter = new StreamWriter(GetSaveFile());
streamWriter.Write(saveFile.ToJson());
streamWriter.Close();
}
private void PrepareSaveFile()
{
saveFile = new SaveFile(upgradeManager.postman.Upgradelevel, upgradeManager.biggerPockets.Upgradelevel, upgradeManager.scrapPurifier.Upgradelevel, upgradeManager.scrapMagnet.Upgradelevel, upgradeManager.weatherCleaner.Upgradelevel);
}
public void LoadFromSave()
{
if ((Object)(object)upgradeManager == (Object)null)
{
upgradeManager = GameObject.Find("MoreUpgrades.Upgrademanager").GetComponent<UpgradeManager>();
}
logger.LogInfo("Loading Save from file");
if (!File.Exists(GetSaveFile()))
{
logger.LogWarning("No save file found. Setting Upgrade Levels to 0...");
upgradeManager.postman.ResetValues();
upgradeManager.biggerPockets.ResetValues();
upgradeManager.scrapPurifier.ResetValues();
upgradeManager.scrapMagnet.ResetValues();
upgradeManager.weatherCleaner.ResetValues();
}
else
{
StreamReader streamReader = new StreamReader(GetSaveFile());
string text = streamReader.ReadLine();
streamReader.Close();
saveFile = new SaveFile();
JsonUtility.FromJsonOverwrite(text, (object)saveFile);
upgradeManager.postman.LevelUpTo(saveFile.postmanLevel);
upgradeManager.biggerPockets.LevelUpTo(saveFile.biggerPocketsLevel);
upgradeManager.scrapPurifier.LevelUpTo(saveFile.scrapPurifierLevel);
upgradeManager.scrapMagnet.LevelUpTo(saveFile.scrapMagnetLevel);
upgradeManager.weatherCleaner.LevelUpTo(saveFile.weatherCleanerLevel);
logger.LogInfo("Loading Save ile Complete!");
}
}
}
public class SaveFile : MonoBehaviour
{
public int postmanLevel;
public int biggerPocketsLevel;
public int scrapPurifierLevel;
public int scrapMagnetLevel;
public int weatherCleanerLevel;
public SaveFile()
{
}
public SaveFile(int postmanLevel, int biggerPocketsLevel, int scrapPurifierLevel, int scrapMagnetLevel, int weatherCleanerLevel)
{
this.postmanLevel = postmanLevel;
this.biggerPocketsLevel = biggerPocketsLevel;
this.scrapPurifierLevel = scrapPurifierLevel;
this.scrapMagnetLevel = scrapMagnetLevel;
this.weatherCleanerLevel = weatherCleanerLevel;
}
public string ToJson()
{
return JsonUtility.ToJson((object)this);
}
}
[HarmonyPatch(typeof(DeleteFileButton))]
internal class DeleteFileButtonPatch
{
private static Logger logger = new Logger("DeleteFileButtonPatch");
[HarmonyPatch("DeleteFile")]
[HarmonyPostfix]
private static void DeleteFilePatch(DeleteFileButton __instance)
{
if (__instance.fileToDelete >= 0 && __instance.fileToDelete <= 2)
{
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Saves", $"LCSaveFile{__instance.fileToDelete + 1}.json");
logger.LogInfo($"Deleting savefile: {__instance.fileToDelete + 1}");
if (File.Exists(path))
{
File.Delete(path);
}
}
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRoundPatch
{
private static UpgradeManager upgradeManager;
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch(StartOfRound __instance)
{
CreateUpgrademanager();
if ((Object)(object)upgradeManager == (Object)null)
{
upgradeManager = GameObject.Find("MoreUpgrades.Upgrademanager").GetComponent<UpgradeManager>();
}
upgradeManager.weatherCleaner.StartOfRound = __instance;
}
private static void CreateUpgrademanager()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
GameObject val = Object.Instantiate<GameObject>(new GameObject());
val.AddComponent<UpgradeManager>();
((Object)val).name = "MoreUpgrades.Upgrademanager";
}
}
[HarmonyPatch(typeof(Terminal))]
internal class TerminalPatch
{
private static readonly Logger logger = new Logger("TerminalPatch");
[SerializeField]
public static UpgradeManager upgradeManager;
private static Terminal terminal;
private static bool firstBoot = true;
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPatch(Terminal __instance)
{
terminal = __instance;
upgradeManager = GameObject.Find("MoreUpgrades.Upgrademanager").GetComponent<UpgradeManager>();
if (firstBoot)
{
upgradeManager.CreateUpgrades();
AddShopCommand();
AddUpgradeCommands();
AddInfoCommands();
}
}
private static void AddShopCommand()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: 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_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
TerminalApi.AddCommand("Enhanced", new CommandInfo
{
Category = "other",
Description = "Displays upgrades from the Enhanced Enterprises Inc. Company Shop.",
DisplayTextSupplier = delegate
{
upgradeManager = GameObject.Find("MoreUpgrades.Upgrademanager").GetComponent<UpgradeManager>();
return MoreUpgradesStore(upgradeManager.upgrades);
}
}, (string)null, true);
}
private static void AddUpgradeCommands()
{
//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_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
foreach (Upgrade upgrade2 in upgradeManager.upgrades)
{
TerminalApi.AddCommand(upgrade2.Name, new CommandInfo
{
Category = "hidden",
DisplayTextSupplier = delegate
{
upgradeManager = GameObject.Find("MoreUpgrades.Upgrademanager").GetComponent<UpgradeManager>();
Upgrade upgrade = null;
foreach (Upgrade upgrade3 in upgradeManager.upgrades)
{
if (upgrade3.Name.ToLower().IndexOf(TerminalApi.GetTerminalInput().ToLower()) == 0)
{
upgrade = upgrade3;
}
}
if (upgrade == null)
{
return "Failed to level up '" + TerminalApi.GetTerminalInput() + "'.\nTry to input the full upgrade name.\n\n";
}
if (upgrade.Upgradelevel < upgrade.UpgradelevelCap)
{
if (!CheckForEnoughCredits(upgrade.Price))
{
return "You don't have enought credits to buy this upgrade\n\n";
}
string text = "";
text = ((!upgrade.OnetimeUse) ? $"{upgrade.Name} has been upgraded to LVL {upgrade.Upgradelevel + 1}\n\n" : (upgrade.Name + " has been purchased successfully\n\n"));
upgrade.ClientLevelUp(((NetworkBehaviour)terminal).IsHost);
return text;
}
return upgrade.OnetimeUse ? (upgrade.Name + " has already been purchased\n\n") : $"{upgrade.Name} is already at max LVL {upgrade.UpgradelevelCap}\n\n";
}
}, "buy", true);
}
}
private static void AddInfoCommands()
{
//IL_002d: 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)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Expected O, but got Unknown
foreach (Upgrade upgrade2 in upgradeManager.upgrades)
{
TerminalApi.AddCommand("info " + upgrade2.Name, new CommandInfo
{
Category = "hidden",
DisplayTextSupplier = delegate
{
upgradeManager = GameObject.Find("MoreUpgrades.Upgrademanager").GetComponent<UpgradeManager>();
Upgrade upgrade = null;
foreach (Upgrade upgrade3 in upgradeManager.upgrades)
{
if (upgrade3.Name.ToLower() == TerminalApi.GetTerminalInput().ToLower())
{
upgrade = upgrade3;
}
}
return (upgrade == null) ? ("Failed to find info about '" + TerminalApi.GetTerminalInput() + "'.\nTry to input the full upgrade name.\n\n") : ("\nINFO: " + upgrade.Name + "\n----------------------------\n" + upgrade.Description + "\n\n");
}
}, (string)null, true);
}
}
private static bool CheckForEnoughCredits(int price)
{
if (terminal.groupCredits >= price)
{
Terminal obj = terminal;
SetGroupCredits(obj.groupCredits -= price);
return true;
}
return false;
}
private static void SetGroupCredits(int newAmount)
{
terminal.groupCredits = newAmount;
if (((NetworkBehaviour)terminal).IsClient)
{
terminal.BuyItemsServerRpc(new int[0], newAmount, terminal.numberOfItemsInDropship);
}
else
{
terminal.SyncGroupCreditsServerRpc(newAmount, terminal.numberOfItemsInDropship);
}
}
private static string MoreUpgradesStore(List<Upgrade> upgrades)
{
string text = "Welcome to the Enhanced Enterprises Inc. Store!\nBuy an upgrade or find out more about it using INFO.\n----------------------------\n";
foreach (Upgrade upgrade in upgrades)
{
text = text + "\n* " + upgrade.Name;
if (upgrade.Upgradelevel < upgrade.UpgradelevelCap)
{
text += $" // Price: ${upgrade.Price}";
}
if (upgrade.Upgradelevel > 0 && upgrade.Upgradelevel < upgrade.UpgradelevelCap)
{
text += $" // LVL {upgrade.Upgradelevel}";
}
else if (upgrade.Upgradelevel >= upgrade.UpgradelevelCap)
{
text += $" // Max LVL {upgrade.Upgradelevel}";
}
}
return text + "\n\n";
}
}
internal class UpgradeManager : MonoBehaviour
{
private Logger logger = new Logger("UpgradeManager");
private PlayerControllerB player;
private bool playerWasInsideFactory = false;
public Postman postman = new Postman();
public BiggerPockets biggerPockets = new BiggerPockets();
public ScrapPurifier scrapPurifier = new ScrapPurifier();
public ScrapMagnet scrapMagnet = new ScrapMagnet();
public WeatherCleaner weatherCleaner = new WeatherCleaner();
public List<Upgrade> upgrades = new List<Upgrade>();
private bool syncLevelsDone = false;
private void Start()
{
if ((Object)(object)player == (Object)null)
{
player = GameNetworkManager.Instance.localPlayerController;
}
}
public void CreateUpgrades()
{
upgrades.Add(postman);
upgrades.Add(scrapPurifier);
upgrades.Add(scrapMagnet);
upgrades.Add(weatherCleaner);
}
public void SetupUpgrades()
{
if (GameNetworkManager.Instance.isHostingGame)
{
new SaveController().LoadFromSave();
}
foreach (Upgrade upgrade in upgrades)
{
upgrade.Setup();
}
}
public void SyncUpgradeLevelsWithHost(int[] level)
{
if (!syncLevelsDone)
{
logger.LogInfo("Trying to sync upgrade Leves with Host...");
for (int i = 0; i < upgrades.Count; i++)
{
upgrades[i].ResetValues();
upgrades[i].LevelUpTo(level[i]);
}
syncLevelsDone = true;
}
}
private void Update()
{
if ((Object)(object)player == (Object)null)
{
if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
{
player = GameNetworkManager.Instance?.localPlayerController;
}
if (!((Object)(object)player != (Object)null))
{
return;
}
logger.LogInfo("Setting up upgrades...");
SetupUpgrades();
GameObject val = GameObject.Find("MoreUpgrades.NetworkHandler");
if ((Object)(object)val == (Object)null)
{
val = GameObject.Find("MoreUpgrades.NetworkHandler(Clone)");
if ((Object)(object)val == (Object)null)
{
logger.LogInfo("No NetworkHandler found");
return;
}
}
MoreUpgradesNetworkHandler component = val.GetComponent<MoreUpgradesNetworkHandler>();
component.SyncUpgradesServerRpc();
}
else if (player.isInsideFactory != playerWasInsideFactory)
{
playerWasInsideFactory = player.isInsideFactory;
postman.UpdateSpeed();
postman.ToggleWeight(player.isInsideFactory);
}
}
}
internal abstract class Upgrade
{
private int price = 0;
private string name = "UpgradeName";
private string description = "UpgradeDescription";
private int upgradelevel = 0;
private int upgradelevelCap = 10;
private bool onetimeUse = false;
private bool debug = true;
private readonly Logger logger = new Logger("Upgrade");
private MoreUpgradesNetworkHandler networkHandler;
public int Price
{
get
{
return price;
}
set
{
price = value;
}
}
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
public string Description
{
get
{
return description;
}
set
{
description = value;
}
}
public int Upgradelevel
{
get
{
return upgradelevel;
}
set
{
upgradelevel = value;
}
}
public int UpgradelevelCap
{
get
{
return upgradelevelCap;
}
set
{
upgradelevelCap = value;
}
}
public bool OnetimeUse
{
get
{
return onetimeUse;
}
set
{
onetimeUse = value;
}
}
public bool Debug => debug;
public Logger Logger => logger;
public MoreUpgradesNetworkHandler NetworkHandler
{
get
{
return networkHandler;
}
set
{
networkHandler = value;
}
}
public virtual void Setup()
{
MoreUpgradesNetworkHandler.UpgradeEvent += RpcLevelUp;
}
public void CheckForNetworkHandler()
{
if (!((Object)(object)networkHandler != (Object)null))
{
GameObject val = GameObject.Find("MoreUpgrades.NetworkHandler");
if ((Object)(object)val == (Object)null)
{
val = GameObject.Find("MoreUpgrades.NetworkHandler(Clone)");
}
networkHandler = val.GetComponent<MoreUpgradesNetworkHandler>();
}
}
public void RpcLevelUp(string eventName)
{
if (!(eventName != GetUpgradeName()))
{
Logger.LogInfo("RpcLevelUp: " + GetUpgradeName());
LevelUp();
}
}
public void ClientLevelUp(bool isHost)
{
CheckForNetworkHandler();
Logger.LogInfo($"ClientLevelUp: {GetUpgradeName()}, Level: {Upgradelevel + 1}");
if (!isHost)
{
NetworkHandler.UpgradeLevelUpServerRpc(GetUpgradeName());
}
else
{
NetworkHandler.UpgradeLevelUpClientRpc(GetUpgradeName());
}
}
public virtual string GetUpgradeName()
{
return GetType().Name.ToString();
}
public abstract void LevelUp();
public void LevelUpTo(int level)
{
for (int i = Upgradelevel; i < level; i++)
{
LevelUp();
}
}
public virtual void ResetValues()
{
upgradelevel = 0;
networkHandler = null;
}
}
internal class Postman : Upgrade
{
private bool speedUpgradeApplyed = false;
private PlayerControllerB player;
private float speedOffset = 0f;
private float speedOffsetTotal = 0f;
private float weightOffset = 0f;
private float vanillaWeight = 0f;
public Postman()
{
base.Price = 500;
base.Name = "Postman";
base.Description = "This is a suit attachment created by The Company to allow you to move more quickly and carry more weight. For some currently unknown reason, this device is deactivated while inside of a building. The Company promised to repair it, once you finished work.";
base.UpgradelevelCap = 5;
}
public override void Setup()
{
CheckForPlayer();
CheckForNetworkHandler();
base.Setup();
}
public override void ResetValues()
{
base.ResetValues();
speedUpgradeApplyed = false;
player = null;
speedOffset = 0f;
speedOffsetTotal = 0f;
weightOffset = 0f;
vanillaWeight = 0f;
}
public override string GetUpgradeName()
{
return GetType().Name.ToString();
}
private void CheckForPlayer()
{
if (!((Object)(object)player != (Object)null))
{
player = GameNetworkManager.Instance.localPlayerController;
}
}
public void UpdateSpeed(bool updateTotal = true)
{
if (base.Upgradelevel > 0)
{
CheckForPlayer();
float num = ((!updateTotal) ? speedOffset : speedOffsetTotal);
if (player.isInsideFactory && speedUpgradeApplyed)
{
PlayerControllerB obj = player;
obj.movementSpeed -= num;
speedUpgradeApplyed = false;
}
if (!player.isInsideFactory && !speedUpgradeApplyed)
{
PlayerControllerB obj2 = player;
obj2.movementSpeed += num;
speedUpgradeApplyed = true;
}
if (base.Debug)
{
base.Logger.LogDebug("----UpdateSpeed() called----");
base.Logger.LogDebug($"player found?: {(Object)(object)player != (Object)null}");
base.Logger.LogDebug($"player.isInsideFactory: {player.isInsideFactory}");
base.Logger.LogDebug($"player.movementSpeed: {player.movementSpeed}");
base.Logger.LogDebug($"currentSpeedOffset: {num}");
base.Logger.LogDebug("----UpdateSpeed() called----");
}
}
}
public void ReduceWeight(float objectWeight)
{
if (base.Upgradelevel > 0)
{
CheckForPlayer();
vanillaWeight += objectWeight;
objectWeight = Mathf.Round(objectWeight * 100f) / 100f;
float num = 0f;
if (!player.isInsideFactory)
{
num = (float)base.Upgradelevel / 10f;
}
float num2 = Mathf.Clamp(objectWeight - 1f, 0f, 10f) * num;
PlayerControllerB obj = player;
obj.carryWeight -= num2;
if (base.Debug)
{
base.Logger.LogDebug("----ReduceWeight() called----");
base.Logger.LogDebug($"objectWeight: {objectWeight}");
base.Logger.LogDebug($"Upgradelevel: {base.Upgradelevel}");
base.Logger.LogDebug($"player found?: {(Object)(object)player != (Object)null}");
base.Logger.LogDebug($"player.isInsideFactory: {player.isInsideFactory}");
base.Logger.LogDebug($"player.carryWeight: {player.carryWeight}");
base.Logger.LogDebug("----ReduceWeight() called----");
}
}
}
public void AddWeigth(float objectWeight)
{
if (base.Upgradelevel > 0)
{
CheckForPlayer();
vanillaWeight -= objectWeight;
objectWeight = Mathf.Round(objectWeight * 100f) / 100f;
float num = 0f;
if (!player.isInsideFactory)
{
num = (float)base.Upgradelevel / 10f;
}
float num2 = Mathf.Clamp(objectWeight - 1f, 0f, 10f) * num;
PlayerControllerB obj = player;
obj.carryWeight += num2;
if (base.Debug)
{
base.Logger.LogDebug("----AddWeigth() called----");
base.Logger.LogDebug($"objectWeight: {objectWeight}");
base.Logger.LogDebug($"Upgradelevel: {base.Upgradelevel}");
base.Logger.LogDebug($"player found?: {(Object)(object)player != (Object)null}");
base.Logger.LogDebug($"player.isInsideFactory: {player.isInsideFactory}");
base.Logger.LogDebug($"player.carryWeight: {player.carryWeight}");
base.Logger.LogDebug("----AddWeigth() called----");
}
}
}
public void ToggleWeight(bool isInsideFactory)
{
if (base.Upgradelevel > 0)
{
CheckForPlayer();
if (isInsideFactory)
{
PlayerControllerB obj = player;
obj.carryWeight += weightOffset;
}
else
{
PlayerControllerB obj2 = player;
obj2.carryWeight -= weightOffset;
}
if (base.Debug)
{
base.Logger.LogDebug("----ToggleWeight() called----");
base.Logger.LogDebug($"new player.carryWeight: {player.carryWeight}");
base.Logger.LogDebug($"weightOffset: {weightOffset}");
base.Logger.LogDebug("----ToggleWeight() called----");
}
}
}
public void UpdateWeightOffset(float vanillaWeightChange, bool reduce)
{
vanillaWeightChange -= 1f;
float num = Mathf.Clamp(vanillaWeightChange, 0f, 10f) * ((float)(10 - base.Upgradelevel) / 10f);
if (reduce)
{
weightOffset -= vanillaWeightChange - num;
}
else
{
weightOffset += vanillaWeightChange - num;
}
if (base.Debug)
{
base.Logger.LogDebug("----UpdateWeightOffset() called----");
base.Logger.LogDebug($"upgradeWeightChange: {num}");
base.Logger.LogDebug($"weightOffset: {weightOffset}");
base.Logger.LogDebug("----UpdateWeightOffset() called----");
}
}
private void SetWeightOffset(float totalWeight)
{
totalWeight = Mathf.Round(totalWeight * 100f) / 100f - 1f;
totalWeight = Mathf.Clamp(totalWeight, 0f, 10f);
float num = (float)base.Upgradelevel / 10f;
weightOffset = totalWeight * num;
if (base.Debug)
{
base.Logger.LogDebug("----SetWeightOffset() called----");
base.Logger.LogDebug($"totalWeight: {totalWeight}");
base.Logger.LogDebug($"weightOffset: {weightOffset}");
base.Logger.LogDebug("----SetWeightOffset() called----");
}
}
private void SetPlayerWeight(float weight)
{
player.carryWeight = weight;
if (base.Debug)
{
base.Logger.LogDebug("----SetPlayerWeight() called----");
base.Logger.LogDebug($"weight: {weight}");
base.Logger.LogDebug($"player.carryWeight: {player.carryWeight}");
base.Logger.LogDebug("----SetPlayerWeight() called----");
}
}
public override void LevelUp()
{
if (base.Debug)
{
base.Logger.LogDebug("----LevelUp() called----");
base.Logger.LogDebug($"Upgradelevel: {base.Upgradelevel}");
base.Logger.LogDebug("----LevelUp() called----");
}
base.Upgradelevel++;
speedOffset = (float)base.Upgradelevel * 0.35f;
speedOffsetTotal += speedOffset;
speedUpgradeApplyed = false;
base.Price += (int)MathF.Round((float)base.Price * 0.15f);
base.Price -= base.Price % 5;
UpdateSpeed(updateTotal: false);
SetPlayerWeight(vanillaWeight);
SetWeightOffset(vanillaWeight);
if (player.isInsideFactory)
{
SetPlayerWeight((vanillaWeight >= 1f) ? vanillaWeight : 1f);
}
else
{
SetPlayerWeight(((vanillaWeight >= 1f) ? vanillaWeight : 1f) - weightOffset);
}
}
}
internal class BiggerPockets : Upgrade
{
public BiggerPockets()
{
base.Price = 750;
base.Name = "Bigger Pockets";
base.Description = "A type of suit that was created long ago to carry around more items. It's a little dusty, but it could come in handy when roaming around the moons collecting scrap.";
base.UpgradelevelCap = 2;
}
public override void Setup()
{
base.Setup();
}
public override string GetUpgradeName()
{
return GetType().Name.ToString();
}
public override void LevelUp()
{
base.Upgradelevel++;
base.Price += (int)MathF.Round((float)base.Price * 0.25f);
base.Price -= base.Price % 5;
}
}
internal class ScrapPurifier : Upgrade
{
public ScrapPurifier()
{
base.Price = 900;
base.Name = "Glove of Midas";
base.Description = "A misterious glove from an distant moon that makes scrap more valueable.";
base.UpgradelevelCap = 2;
}
public override void Setup()
{
base.Setup();
}
public override string GetUpgradeName()
{
return GetType().Name.ToString();
}
public float UpdateValue()
{
return 1f + (float)base.Upgradelevel * 0.5f;
}
public override void LevelUp()
{
base.Upgradelevel++;
base.Price += (int)MathF.Round((float)base.Price * 0.25f);
base.Price -= base.Price % 5;
}
}
internal class ScrapMagnet : Upgrade
{
public ScrapMagnet()
{
base.Price = 1200;
base.Name = "Flux Radar";
base.Description = "A improved radar which is able to detect more scrap inside the building.";
base.UpgradelevelCap = 2;
}
public override void Setup()
{
base.Setup();
}
public override string GetUpgradeName()
{
return GetType().Name.ToString();
}
public float UpdateValue()
{
return 1f + (float)base.Upgradelevel * 0.3f;
}
public override void LevelUp()
{
base.Upgradelevel++;
base.Price += (int)MathF.Round((float)base.Price * 0.25f);
base.Price -= base.Price % 5;
}
}
internal class WeatherCleaner : Upgrade
{
private StartOfRound startOfRound;
public StartOfRound StartOfRound
{
get
{
return startOfRound;
}
set
{
startOfRound = value;
}
}
public WeatherCleaner()
{
base.Price = 400;
base.Name = "Weather Cleaner";
base.Description = "There is some sort of device installed on this ship that can alter the weather on moons across the galaxy, but of course it requires a premium subscription to work.\nBeware, it was reported to malfunction on rare occasions, changing the weather to something worse than it was before before.";
base.UpgradelevelCap = 1;
base.OnetimeUse = true;
}
public override void Setup()
{
base.Setup();
}
public override string GetUpgradeName()
{
return GetType().Name.ToString();
}
public void ClearWeather()
{
//IL_0071: 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)
if (base.Debug)
{
base.Logger.LogDebug($"startOfRound there yet?: {(Object)(object)startOfRound != (Object)null}");
}
base.Logger.LogInfo("Clearing weather...");
if (Random.Range(0f, 1f) > 0.02f)
{
for (int i = 0; i < startOfRound.levels.Length; i++)
{
startOfRound.levels[i].currentWeather = (LevelWeatherType)(-1);
}
base.Logger.LogInfo("Cleared weather!");
return;
}
base.Logger.LogInfo("Failed to clear weather, rerolling...");
List<int> list = new List<int> { 0, 6, 11, 21, 46, 56, 71 };
for (int j = 0; j < startOfRound.levels.Length; j++)
{
int num = Random.Range(0, 100);
for (int k = 0; k < list.Count; k++)
{
if (num <= list[k])
{
startOfRound.levels[j].currentWeather = (LevelWeatherType)(k - 1);
break;
}
}
}
base.Logger.LogInfo("Done rerolling weather!");
}
public override void LevelUp()
{
base.Upgradelevel++;
ClearWeather();
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "EnhancedEnterprises";
public const string PLUGIN_NAME = "EnhancedEnterprises";
public const string PLUGIN_VERSION = "1.0.1";
}
}
namespace MoreUpgrades.Networking
{
public class NetworkAssets
{
private static AssetBundle assets;
public static AssetBundle LoadAsset()
{
if ((Object)(object)assets != (Object)null)
{
return assets;
}
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
assets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "modassets"));
return assets;
}
}
public class MoreUpgradesNetworkHandler : NetworkBehaviour
{
private static readonly Logger logger = new Logger("NetworkHandler");
public static MoreUpgradesNetworkHandler Instance { get; private set; }
public static event Action<string> UpgradeEvent;
public override void OnNetworkSpawn()
{
MoreUpgradesNetworkHandler.UpgradeEvent = null;
try
{
if ((NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) && (Object)(object)Instance != (Object)null)
{
MoreUpgradesNetworkHandler instance = Instance;
if (instance != null)
{
((Component)instance).gameObject.GetComponent<NetworkObject>().Despawn(true);
}
}
Instance = this;
}
catch (Exception ex)
{
logger.LogError("Error in OnNetworkSpawn:\n" + ex.Message);
}
((NetworkBehaviour)this).OnNetworkSpawn();
}
[ClientRpc]
public void UpgradeLevelUpClientRpc(string eventName)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: 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_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: 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(905127050u, val, (RpcDelivery)0);
bool flag = eventName != null;
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
if (flag)
{
((FastBufferWriter)(ref val2)).WriteValueSafe(eventName, false);
}
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 905127050u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
logger.LogInfo("Client Netowrk event called: " + eventName);
MoreUpgradesNetworkHandler.UpgradeEvent?.Invoke(eventName);
}
}
[ServerRpc(RequireOwnership = false)]
public void UpgradeLevelUpServerRpc(string eventName)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: 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_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: 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 != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1395280519u, val, (RpcDelivery)0);
bool flag = eventName != null;
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
if (flag)
{
((FastBufferWriter)(ref val2)).WriteValueSafe(eventName, false);
}
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1395280519u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
{
logger.LogInfo("Server Netowrk event called: " + eventName);
UpgradeLevelUpClientRpc(eventName);
}
}
[ClientRpc]
public void GetUpgradeLevelsClientRpc(int[] level)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: 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_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: 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)
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(6451751u, val, (RpcDelivery)0);
bool flag = level != null;
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
if (flag)
{
((FastBufferWriter)(ref val2)).WriteValueSafe<int>(level, default(ForPrimitives));
}
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 6451751u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
{
return;
}
logger.LogInfo("Getting Upgrade Levels...");
if (!((NetworkBehaviour)this).IsHost)
{
logger.LogInfo("Isn't host");
GameObject val3 = GameObject.Find("MoreUpgrades.Upgrademanager");
if (!((Object)(object)val3 == (Object)null))
{
UpgradeManager component = val3.GetComponent<UpgradeManager>();
logger.LogInfo("Syncing upgrade Levels...");
component.SyncUpgradeLevelsWithHost(level);
}
}
}
[ServerRpc(RequireOwnership = false)]
public void SyncUpgradesServerRpc()
{
//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)
{
return;
}
if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2147696769u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2147696769u, val, (RpcDelivery)0);
}
if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
{
return;
}
logger.LogInfo("Syncing Upgrades...");
if (!((NetworkBehaviour)this).IsHost)
{
return;
}
logger.LogInfo("Is host");
GameObject val3 = GameObject.Find("MoreUpgrades.Upgrademanager");
if ((Object)(object)val3 == (Object)null)
{
return;
}
UpgradeManager component = val3.GetComponent<UpgradeManager>();
List<int> list = new List<int>();
foreach (Upgrade upgrade in component.upgrades)
{
list.Add(upgrade.Upgradelevel);
}
GetUpgradeLevelsClientRpc(list.ToArray());
}
protected override void __initializeVariables()
{
((NetworkBehaviour)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_MoreUpgradesNetworkHandler()
{
//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
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(905127050u, new RpcReceiveHandler(__rpc_handler_905127050));
NetworkManager.__rpc_func_table.Add(1395280519u, new RpcReceiveHandler(__rpc_handler_1395280519));
NetworkManager.__rpc_func_table.Add(6451751u, new RpcReceiveHandler(__rpc_handler_6451751));
NetworkManager.__rpc_func_table.Add(2147696769u, new RpcReceiveHandler(__rpc_handler_2147696769));
}
private static void __rpc_handler_905127050(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool flag = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
string eventName = null;
if (flag)
{
((FastBufferReader)(ref reader)).ReadValueSafe(ref eventName, false);
}
target.__rpc_exec_stage = (__RpcExecStage)2;
((MoreUpgradesNetworkHandler)(object)target).UpgradeLevelUpClientRpc(eventName);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_1395280519(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool flag = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
string eventName = null;
if (flag)
{
((FastBufferReader)(ref reader)).ReadValueSafe(ref eventName, false);
}
target.__rpc_exec_stage = (__RpcExecStage)1;
((MoreUpgradesNetworkHandler)(object)target).UpgradeLevelUpServerRpc(eventName);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_6451751(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: 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_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: 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)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool flag = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
int[] level = null;
if (flag)
{
((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref level, default(ForPrimitives));
}
target.__rpc_exec_stage = (__RpcExecStage)2;
((MoreUpgradesNetworkHandler)(object)target).GetUpgradeLevelsClientRpc(level);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2147696769(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)1;
((MoreUpgradesNetworkHandler)(object)target).SyncUpgradesServerRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "MoreUpgradesNetworkHandler";
}
}
[HarmonyPatch]
public class NetworkObjectManager
{
private static AssetBundle Assets;
private static GameObject networkPrefab;
[HarmonyPostfix]
[HarmonyPatch(typeof(GameNetworkManager))]
[HarmonyPatch("Start")]
public static void StartPatch()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
Assets = NetworkAssets.LoadAsset();
if (!((Object)(object)networkPrefab != (Object)null))
{
networkPrefab = (GameObject)Assets.LoadAsset("NetworkHandler");
networkPrefab.AddComponent<MoreUpgradesNetworkHandler>();
((Object)networkPrefab).name = "MoreUpgrades.NetworkHandler";
NetworkManager.Singleton.AddNetworkPrefab(networkPrefab);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(StartOfRound))]
[HarmonyPatch("Awake")]
private static void AwakePatch()
{
//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)
if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
{
GameObject val = Object.Instantiate<GameObject>(networkPrefab, Vector3.zero, Quaternion.identity);
val.GetComponent<NetworkObject>().Spawn(false);
((Object)val).name = "MoreUpgrades.NetworkHandler";
}
}
}
}
namespace MoreUpgrades.Utils
{
public class Logger
{
private readonly ManualLogSource logSource;
private string moduleName;
public Logger(string moduleName)
{
logSource = Logger.CreateLogSource("EnhancedEnterprises");
this.moduleName = moduleName;
}
public void LogDebug(string message)
{
logSource.LogDebug((object)("[" + moduleName + "]: " + message));
}
public void LogInfo(string message)
{
logSource.LogInfo((object)("[" + moduleName + "]: " + message));
}
public void LogWarning(string message)
{
logSource.LogWarning((object)("[" + moduleName + "]: " + message));
}
public void LogError(string message)
{
logSource.LogError((object)("[" + moduleName + "]: " + message));
}
}
}
namespace EnhancedEnterprises.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}