Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Juices Mod v2.0.0
Shlygly.JuicesMod.dll
Decompiled 5 months agousing 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.Serialization.Formatters.Binary; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using JuicesMod.Behaviours; using JuicesMod.Enums; using JuicesMod.Patches; using JuicesMod.Properties; using LethalLib.Extras; using LethalLib.Modules; using Microsoft.CodeAnalysis; using Shlygly.JuicesMod.NetcodePatcher; using Unity.Collections; 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("Shlygly.JuicesMod")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("2.0.0.0")] [assembly: AssemblyInformationalVersion("2.0.0+b5188ce6dbedf281242ce1febfe8f45c831876fb")] [assembly: AssemblyProduct("JuicesMod")] [assembly: AssemblyTitle("Shlygly.JuicesMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 JuicesMod { internal class Config : SyncedInstance<Config> { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnRequestSync; public static HandleNamedMessageDelegate <1>__OnReceiveSync; } public readonly ConfigEntry<int> cartonsRarity; public readonly ConfigEntry<int> premiumsRarity; public readonly ConfigEntry<int> packRarity; public readonly ConfigEntry<int> canRarity; public readonly ConfigEntry<bool> vitaminDetectorEnabled; public Config(ConfigFile configFile) { InitInstance(this); configFile.SaveOnConfigSet = false; cartonsRarity = configFile.Bind<int>("Items.Rarity", "CartonsRarity", 60, "How likely cartons juices spawn (between 1 and 100)"); premiumsRarity = configFile.Bind<int>("Items.Rarity", "PremiumRarity", 40, "How likely premiums juices spawn (between 1 and 100)"); packRarity = configFile.Bind<int>("Items.Rarity", "PackRarity", 20, "How likely six pack juices spawn (between 1 and 100)"); canRarity = configFile.Bind<int>("Items.Rarity", "CanRarity", 50, "How likely cans juices spawn (between 1 and 100)"); vitaminDetectorEnabled = configFile.Bind<bool>("Items.Enabled", "VitaminDetectorEnabled", true, "Allow players to buy and use the VitaminDetector"); ClearOrphanedEntries(configFile); configFile.Save(); configFile.SaveOnConfigSet = true; } private static void ClearOrphanedEntries(ConfigFile configFile) { PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries"); Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(configFile); dictionary.Clear(); } public static void RequestSync() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (!SyncedInstance<Config>.IsClient) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(SyncedInstance<Config>.IntSize, (Allocator)2, -1); try { SyncedInstance<Config>.MessageManager.SendNamedMessage("ModName_OnRequestConfigSync", 0uL, val, (NetworkDelivery)3); } finally { ((IDisposable)(FastBufferWriter)(ref val)).Dispose(); } } public static void OnRequestSync(ulong clientId, FastBufferReader _) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) if (!SyncedInstance<Config>.IsHost) { return; } Plugin.Logger.LogInfo((object)$"Config sync request received from client: {clientId}"); byte[] array = SyncedInstance<Config>.SerializeToBytes(SyncedInstance<Config>.Instance); int num = array.Length; FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(num + SyncedInstance<Config>.IntSize, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0); SyncedInstance<Config>.MessageManager.SendNamedMessage("ModName_OnReceiveConfigSync", clientId, val, (NetworkDelivery)3); } catch (Exception arg) { Plugin.Logger.LogInfo((object)$"Error occurred syncing config with client: {clientId}\n{arg}"); } finally { ((IDisposable)(FastBufferWriter)(ref val)).Dispose(); } } public static void OnReceiveSync(ulong _, FastBufferReader reader) { //IL_002d: 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 (!((FastBufferReader)(ref reader)).TryBeginRead(SyncedInstance<Config>.IntSize)) { Plugin.Logger.LogError((object)"Config sync error: Could not begin reading buffer."); return; } int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives)); if (!((FastBufferReader)(ref reader)).TryBeginRead(num)) { Plugin.Logger.LogError((object)"Config sync error: Host could not sync."); return; } byte[] data = new byte[num]; ((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0); SyncedInstance<Config>.SyncInstance(data); Plugin.Logger.LogInfo((object)"Successfully synced config with host."); } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] public static void InitializeLocalPlayer() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown if (SyncedInstance<Config>.IsHost) { CustomMessagingManager messageManager = SyncedInstance<Config>.MessageManager; object obj = <>O.<0>__OnRequestSync; if (obj == null) { HandleNamedMessageDelegate val = OnRequestSync; <>O.<0>__OnRequestSync = val; obj = (object)val; } messageManager.RegisterNamedMessageHandler("JuicesMod_OnRequestConfigSync", (HandleNamedMessageDelegate)obj); SyncedInstance<Config>.Synced = true; return; } SyncedInstance<Config>.Synced = false; CustomMessagingManager messageManager2 = SyncedInstance<Config>.MessageManager; object obj2 = <>O.<1>__OnReceiveSync; if (obj2 == null) { HandleNamedMessageDelegate val2 = OnReceiveSync; <>O.<1>__OnReceiveSync = val2; obj2 = (object)val2; } messageManager2.RegisterNamedMessageHandler("JuicesMod_OnReceiveConfigSync", (HandleNamedMessageDelegate)obj2); RequestSync(); } [HarmonyPostfix] [HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")] public static void PlayerLeave() { SyncedInstance<Config>.RevertSync(); } } public class JuicesBuilder { private readonly AssetBundle bundle; private Dictionary<Item, Tuple<FruitProperty, JuiceTypeProperty>> juices = new Dictionary<Item, Tuple<FruitProperty, JuiceTypeProperty>>(); private Dictionary<JuiceTypeProperty, Item> multifruits = new Dictionary<JuiceTypeProperty, Item>(); public Item[] Juices { get { Dictionary<Item, Tuple<FruitProperty, JuiceTypeProperty>>.KeyCollection keys = juices.Keys; int num = 0; Item[] array = (Item[])(object)new Item[keys.Count]; foreach (Item item in keys) { array[num] = item; num++; } return array; } } public JuicesBuilder(AssetBundle bundle) { this.bundle = bundle; } public void registerJuice(FruitProperty fruit, JuiceTypeProperty type, LevelTypes levelType = -1) { //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Expected O, but got Unknown try { Item val = Object.Instantiate<Item>(bundle.LoadAsset<Item>("Assets/JuicesMod/Juices/" + type.Name + "JuiceItem.asset")); val.itemName = string.Format(type.Label, fruit.Name); val.minValue = type.MinValue; val.maxValue = type.MaxValue; val.spawnPrefab = NetworkPrefabs.CloneNetworkPrefab(bundle.LoadAsset<GameObject>("Assets/JuicesMod/Juices/" + type.Name + "Juice.prefab"), val.itemName); PhysicsProp component = val.spawnPrefab.GetComponent<PhysicsProp>(); ((GrabbableObject)component).itemProperties = val; Dictionary<string, Texture2D> dictionary = new Dictionary<string, Texture2D>(); if (type.Name == "Pack") { Texture2D value = bundle.LoadAsset<Texture2D>("Assets/JuicesMod/Sources/Textures/" + fruit.Name + "JuiceCarton.png"); dictionary.Add("Model/JuiceBox", value); dictionary.Add("Model/JuiceBox.001", value); dictionary.Add("Model/JuiceBox.002", value); dictionary.Add("Model/JuiceBox.003", value); dictionary.Add("Model/JuiceBox.004", value); dictionary.Add("Model/JuiceBox.005", value); } else { Texture2D value = bundle.LoadAsset<Texture2D>("Assets/JuicesMod/Sources/Textures/" + fruit.Name + "Juice" + type.Name + ".png"); dictionary.Add("Model", value); } foreach (KeyValuePair<string, Texture2D> item in dictionary) { MeshRenderer component2 = ((Component)val.spawnPrefab.transform.Find(item.Key)).GetComponent<MeshRenderer>(); Material[] materials = ((Renderer)component2).materials; for (int i = 0; i < materials.Length; i++) { Material val2 = new Material(materials[i]) { mainTexture = (Texture)(object)item.Value }; materials[i] = val2; } ((Renderer)component2).materials = materials; } ScanNodeProperties component3 = ((Component)val.spawnPrefab.transform.Find("ScanNode")).GetComponent<ScanNodeProperties>(); component3.headerText = val.itemName; NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab); Utilities.FixMixerGroups(val.spawnPrefab); Items.RegisterScrap(val, type.Rarity, levelType); juices.Add(val, new Tuple<FruitProperty, JuiceTypeProperty>(fruit, type)); Plugin.Logger.LogInfo((object)("Registered juice : " + fruit.Name + " juice in " + type.Name + " format")); } catch (Exception arg) { Plugin.Logger.LogError((object)$"Can't register {fruit.Name} juice in {type.Name} format !\n{arg}"); } } public void registerMultifruitJuice(JuiceTypeProperty type) { //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Expected O, but got Unknown try { Item val = Object.Instantiate<Item>(bundle.LoadAsset<Item>("Assets/JuicesMod/Juices/" + type.Name + "JuiceItem.asset")); val.itemName = string.Format(type.Label, "Multifruit"); val.spawnPrefab = NetworkPrefabs.CloneNetworkPrefab(bundle.LoadAsset<GameObject>("Assets/JuicesMod/Juices/" + type.Name + "Juice.prefab"), val.itemName); PhysicsProp component = val.spawnPrefab.GetComponent<PhysicsProp>(); ((GrabbableObject)component).itemProperties = val; Dictionary<string, Texture2D> dictionary = new Dictionary<string, Texture2D>(); if (type.Name == "Pack") { Texture2D value = bundle.LoadAsset<Texture2D>("Assets/JuicesMod/Sources/Textures/MultifruitJuiceCarton.png"); dictionary.Add("Model/JuiceBox", value); dictionary.Add("Model/JuiceBox.001", value); dictionary.Add("Model/JuiceBox.002", value); dictionary.Add("Model/JuiceBox.003", value); dictionary.Add("Model/JuiceBox.004", value); dictionary.Add("Model/JuiceBox.005", value); } else { Texture2D value = bundle.LoadAsset<Texture2D>("Assets/JuicesMod/Sources/Textures/MultifruitJuice" + type.Name + ".png"); dictionary.Add("Model", value); } foreach (KeyValuePair<string, Texture2D> item in dictionary) { MeshRenderer component2 = ((Component)val.spawnPrefab.transform.Find(item.Key)).GetComponent<MeshRenderer>(); Material[] materials = ((Renderer)component2).materials; for (int i = 0; i < materials.Length; i++) { Material val2 = new Material(materials[i]) { mainTexture = (Texture)(object)item.Value }; materials[i] = val2; } ((Renderer)component2).materials = materials; } ScanNodeProperties component3 = ((Component)val.spawnPrefab.transform.Find("ScanNode")).GetComponent<ScanNodeProperties>(); component3.headerText = val.itemName; NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab); Utilities.FixMixerGroups(val.spawnPrefab); Items.RegisterScrap(val, 0, (LevelTypes)1); multifruits.Add(type, val); Plugin.Logger.LogInfo((object)("Registered juice : Multifruit juice in " + type.Name + " format")); } catch (Exception) { Plugin.Logger.LogError((object)("Can't register Multifruit juice in " + type.Name + " format !")); } } public bool hasJuiceProperty(GrabbableObject item) { return juices.ContainsKey(item.itemProperties); } public JuiceProperty getJuiceProperty(GrabbableObject item) { if (hasJuiceProperty(item)) { Tuple<FruitProperty, JuiceTypeProperty> tuple = juices[item.itemProperties]; return new JuiceProperty(tuple.Item1, tuple.Item2, item.scrapValue); } throw new ArgumentException("Unable to find juice property for item \"" + ((Object)item).name + "\". Did you miss a check with \"hasJuiceProperty\" ?"); } public bool isMultifruit(GrabbableObject item) { return multifruits.ContainsValue(item.itemProperties); } public Item getMultifruit(JuiceTypeProperty type) { if (multifruits.ContainsKey(type)) { return multifruits[type]; } return multifruits.Values.FirstOrDefault(); } } [BepInPlugin("Shlygly.JuicesMod", "JuicesMod", "2.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public static Plugin instance; internal static ManualLogSource Logger; internal static Config BoundConfig { get; private set; } public JuicesBuilder JuicesBuilder { get; private set; } = null; public UnlockablesBuilder UnlockablesBuilder { get; private set; } = null; public Item VitaminDetector { get; private set; } = null; private void Awake() { instance = this; Logger = ((BaseUnityPlugin)this).Logger; BoundConfig = new Config(((BaseUnityPlugin)this).Config); string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "juicesmod"); AssetBundle val = AssetBundle.LoadFromFile(text); JuiceTypeProperty.Initialize(); JuicesBuilder = new JuicesBuilder(val); UnlockablesBuilder = new UnlockablesBuilder(val); foreach (JuiceTypeProperty value in JuiceTypeProperty.JUICE_TYPES.Values) { FruitProperty[] fRUITS = FruitProperty.FRUITS; foreach (FruitProperty fruit in fRUITS) { JuicesBuilder.registerJuice(fruit, value, (LevelTypes)(-1)); } JuicesBuilder.registerMultifruitJuice(value); } UnlockablesBuilder.register("JuiceBlender", 80, (StoreType)1); UnlockablesBuilder.register("Neons/Sapik", 24, (StoreType)1); UnlockablesBuilder.register("Neons/Cedhou", 24, (StoreType)1); UnlockablesBuilder.register("Neons/Saifrai", 24, (StoreType)1); try { if (SyncedInstance<Config>.Instance.vitaminDetectorEnabled.Value) { VitaminDetector = val.LoadAsset<Item>("Assets/JuicesMod/VitaminDetectorItem.asset"); NetworkPrefabs.RegisterNetworkPrefab(VitaminDetector.spawnPrefab); Utilities.FixMixerGroups(VitaminDetector.spawnPrefab); TerminalNode val2 = ScriptableObject.CreateInstance<TerminalNode>(); val2.clearPreviousText = true; val2.displayText = "A radar that detects nearby fruit juices.\n\n"; Items.RegisterShopItem(VitaminDetector, (TerminalNode)null, (TerminalNode)null, val2, 74); Logger.LogInfo((object)"Registered Vitamin Detector"); } else { Logger.LogInfo((object)"Vitamin Detector disabled"); } } catch (Exception) { Logger.LogError((object)"Can't register Vitamin Detector !"); } try { Harmony.CreateAndPatchAll(typeof(PlayerControllerBPatch), (string)null); } catch (Exception) { Logger.LogError((object)"Can't apply Harmony patches !"); } RegisterRPCs(); Logger.LogInfo((object)"Juices Mod Loaded"); } private void RegisterRPCs() { 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); } } } } } [Serializable] public class SyncedInstance<T> { [NonSerialized] protected static int IntSize = 4; internal static CustomMessagingManager MessageManager => NetworkManager.Singleton.CustomMessagingManager; internal static bool IsClient => NetworkManager.Singleton.IsClient; internal static bool IsHost => NetworkManager.Singleton.IsHost; public static T Default { get; private set; } public static T Instance { get; private set; } public static bool Synced { get; internal set; } protected void InitInstance(T instance) { Default = instance; Instance = instance; IntSize = 4; } internal static void SyncInstance(byte[] data) { Instance = DeserializeFromBytes(data); Synced = true; } internal static void RevertSync() { Instance = Default; Synced = false; } public static byte[] SerializeToBytes(T val) { BinaryFormatter binaryFormatter = new BinaryFormatter(); using MemoryStream memoryStream = new MemoryStream(); try { binaryFormatter.Serialize(memoryStream, val); return memoryStream.ToArray(); } catch (Exception arg) { Plugin.Logger.LogError((object)$"Error serializing instance: {arg}"); return null; } } public static T DeserializeFromBytes(byte[] data) { BinaryFormatter binaryFormatter = new BinaryFormatter(); using MemoryStream serializationStream = new MemoryStream(data); try { return (T)binaryFormatter.Deserialize(serializationStream); } catch (Exception arg) { Plugin.Logger.LogError((object)$"Error deserializing instance: {arg}"); return default(T); } } } public class UnlockablesBuilder { private readonly AssetBundle bundle; public UnlockablesBuilder(AssetBundle bundle) { this.bundle = bundle; } public void register(string assetName, int price, StoreType storeType) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) try { UnlockableItemDef val = bundle.LoadAsset<UnlockableItemDef>("Assets/JuicesMod/Unlockables/" + assetName + "/UnlockableItemDef.asset"); NetworkPrefabs.RegisterNetworkPrefab(val.unlockable.prefabObject); Utilities.FixMixerGroups(val.unlockable.prefabObject); Unlockables.RegisterUnlockable(val, price, storeType); Plugin.Logger.LogInfo((object)("Registered unlockable : " + assetName)); } catch (Exception) { Plugin.Logger.LogError((object)("Can't register " + assetName + " !")); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "Shlygly.JuicesMod"; public const string PLUGIN_NAME = "JuicesMod"; public const string PLUGIN_VERSION = "2.0.0"; } } namespace JuicesMod.Properties { public struct FruitProperty : INetworkSerializable { [ES3NonSerializable] public static FruitProperty[] FRUITS = new FruitProperty[7] { new FruitProperty("Orange", new Color(1f, 0.5882353f, 0f)), new FruitProperty("Apple", new Color(0.78039217f, 0.5568628f, 11f / 85f)), new FruitProperty("Pineapple", new Color(1f, 0.8784314f, 0.5137255f)), new FruitProperty("Tomato", new Color(47f / 51f, 0f, 0f)), new FruitProperty("Prune", new Color(0.44313726f, 0f, 29f / 51f)), new FruitProperty("Banana", new Color(0.9490196f, 76f / 85f, 0.6156863f)), new FruitProperty("Grape", new Color(0.4392157f, 0.18039216f, 18f / 85f)) }; public string Name; public Color Color; public FruitProperty(string name, Color color) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) Name = name; Color = color; } public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter { serializer.SerializeValue(ref Name, false); serializer.SerializeValue(ref Color); } } public struct JuiceProperty : INetworkSerializable { public FruitProperty Fruit; public JuiceTypeProperty Type; public int ScrapValue; public JuiceProperty(FruitProperty fruit, JuiceTypeProperty type, int scrapValue) { Fruit = fruit; Type = type; ScrapValue = scrapValue; } public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter { //IL_0007: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) Fruit.NetworkSerialize<T>(serializer); Type.NetworkSerialize<T>(serializer); ((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref ScrapValue, default(ForPrimitives)); } } public struct JuiceTypeProperty : INetworkSerializable { [ES3NonSerializable] public static Dictionary<string, JuiceTypeProperty> JUICE_TYPES = new Dictionary<string, JuiceTypeProperty>(); public string Name; public string Label; public float Multiplier; public int MinValue; public int MaxValue; public int Rarity; public static void Initialize() { JUICE_TYPES.Add("Carton", new JuiceTypeProperty("Carton", "{0} Juice", 1.2f, 20, 40, SyncedInstance<Config>.Instance.cartonsRarity.Value)); JUICE_TYPES.Add("Premium", new JuiceTypeProperty("Premium", "{0} Juice (Premium Quality)", 1.5f, 30, 60, SyncedInstance<Config>.Instance.premiumsRarity.Value)); JUICE_TYPES.Add("Pack", new JuiceTypeProperty("Pack", "{0} Juice (Six Pack)", 1.3f, 80, 140, SyncedInstance<Config>.Instance.packRarity.Value)); JUICE_TYPES.Add("Can", new JuiceTypeProperty("Can", "{0} Juice (Can)", 1.1f, 10, 30, SyncedInstance<Config>.Instance.canRarity.Value)); } public JuiceTypeProperty(string name, string label, float multiplier, int minValue, int maxValue, int rarity) { Name = name; Label = label; Multiplier = multiplier; MinValue = (int)Mathf.Ceil((float)minValue / 0.4f); MaxValue = (int)Mathf.Ceil((float)maxValue / 0.4f); Rarity = rarity; } public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter { //IL_0029: 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) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_005d: 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_0074: Unknown result type (might be due to invalid IL or missing references) serializer.SerializeValue(ref Name, false); serializer.SerializeValue(ref Label, false); ((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref Multiplier, default(ForPrimitives)); ((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref MinValue, default(ForPrimitives)); ((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref MaxValue, default(ForPrimitives)); ((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref Rarity, default(ForPrimitives)); } } } namespace JuicesMod.Patches { public class PlayerControllerBPatch { [HarmonyPatch(typeof(PlayerControllerB), "Start")] [HarmonyPostfix] private static void PlayerControllerB_Start(PlayerControllerB __instance) { if ((Object)(object)((Component)__instance).GetComponent<PlayerControllerBBehaviour>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<PlayerControllerBBehaviour>(); } } } } namespace JuicesMod.Enums { public enum JuiceEffect { None = 0, Healing = 1, Damages = 2, Marathoner = 4, Asmathic = 8, NightVision = 0x10, UpsideDown = 0x20, EMP = 0x40, SignalJamming = 0x80 } } namespace JuicesMod.Behaviours { public class CanJuiceBehaviour : PhysicsProp { private (MethodInfo, JuiceEffectInfo)[] juiceEffects = Array.Empty<(MethodInfo, JuiceEffectInfo)>(); public AudioSource ItemAudio; public AudioClip DrinkClip; private int DebugEffectIndex = 0; public override void Start() { juiceEffects = (from method in ((object)this).GetType().GetMethods() select (method, method.GetCustomAttribute<JuiceEffectInfo>()) into data where data.Item2 != null select data).ToArray(); ((GrabbableObject)this).Start(); } public override void ItemActivate(bool used, bool buttonDown = true) { PlayerControllerBBehaviour component = ((Component)((GrabbableObject)this).playerHeldBy).GetComponent<PlayerControllerBBehaviour>(); if ((Object)(object)component != (Object)null) { if (component.CurrentJuiceEffect == JuiceEffect.None) { ((MonoBehaviour)this).StartCoroutine(Drink(component, buttonDown)); } else if (((NetworkBehaviour)((GrabbableObject)this).playerHeldBy).IsOwner) { HUDManager.Instance.DisplayTip("Don't drink !", "Cumulating juice effects is dangerous...", false, false, "LC_Tip1"); } } } public IEnumerator Drink(PlayerControllerBBehaviour player, bool buttonDown = true) { ((GrabbableObject)this).playerHeldBy.activatingItem = buttonDown; ((GrabbableObject)this).playerHeldBy.playerBodyAnimator.SetBool("useTZPItem", buttonDown); ItemAudio.PlayOneShot(DrinkClip); yield return (object)new WaitForSeconds(2f); var (method, effectInfo) = juiceEffects[Random.RandomRangeInt(0, juiceEffects.Length)]; effectInfo.DisplayEffectTip(((GrabbableObject)this).playerHeldBy); method.Invoke(this, new object[1] { player }); ((GrabbableObject)this).playerHeldBy.activatingItem = false; ((GrabbableObject)this).playerHeldBy.playerBodyAnimator.SetBool("useTZPItem", false); ((GrabbableObject)this).playerHeldBy.DespawnHeldObject(); } public void DebugApplyEffect(PlayerControllerBBehaviour player) { var (methodInfo, juiceEffectInfo) = juiceEffects[DebugEffectIndex]; juiceEffectInfo.DisplayEffectTip(((GrabbableObject)this).playerHeldBy); methodInfo.Invoke(this, new object[1] { player }); } [JuiceEffectInfo("Healing", "Restoring full health", true)] public void HealingEffect(PlayerControllerBBehaviour player) { player.ApplyJuiceEffect(JuiceEffect.Healing, 1, Array.Empty<object>()); } [JuiceEffectInfo("Damages", "Loosing half health", false)] public void DamagesEffect(PlayerControllerBBehaviour player) { player.ApplyJuiceEffect(JuiceEffect.Damages, 1, new object[1] { ((GrabbableObject)this).playerHeldBy.health / 2 }); } [JuiceEffectInfo("Marathoner", "More stamina for 10 minutes", true)] public void MarathonerEffect(PlayerControllerBBehaviour player) { ((GrabbableObject)this).playerHeldBy.sprintMeter = 1f; player.ApplyJuiceEffect(JuiceEffect.Marathoner, 600, new object[1] { ((GrabbableObject)this).playerHeldBy.sprintTime }); } [JuiceEffectInfo("Asthmatic", "Less stamina for 10 minutes", false)] public void AsthmaticEffect(PlayerControllerBBehaviour player) { player.ApplyJuiceEffect(JuiceEffect.Asmathic, 600, new object[1] { ((GrabbableObject)this).playerHeldBy.sprintTime }); } [JuiceEffectInfo("Night vision", "Better vision inside factories for 5 minutes", true)] public void NightVisionEffect(PlayerControllerBBehaviour player) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) player.ApplyJuiceEffect(JuiceEffect.NightVision, 300, new object[6] { ((GrabbableObject)this).playerHeldBy.nightVision.color, ((GrabbableObject)this).playerHeldBy.nightVision.intensity, ((GrabbableObject)this).playerHeldBy.nightVision.range, ((GrabbableObject)this).playerHeldBy.nightVision.shadowStrength, ((GrabbableObject)this).playerHeldBy.nightVision.shadows, ((GrabbableObject)this).playerHeldBy.nightVision.shape }); } [JuiceEffectInfo("Upside down", "Reverse vision for 5 minutes", false)] public void UpsideDownEffect(PlayerControllerBBehaviour player) { player.ApplyJuiceEffect(JuiceEffect.UpsideDown, 300, Array.Empty<object>()); } [JuiceEffectInfo("Electromagnetic pulse", "Disable all turrets for 2 minutes", true)] public void EmpEffect(PlayerControllerBBehaviour player) { player.ApplyJuiceEffect(JuiceEffect.EMP, 120, Array.Empty<object>()); } [JuiceEffectInfo("Signal jamming", "All turrets go crazy for 2 minutes", false)] public void SignalJammingEffect(PlayerControllerBBehaviour player) { player.ApplyJuiceEffect(JuiceEffect.SignalJamming, 120, Array.Empty<object>()); } protected override void __initializeVariables() { ((PhysicsProp)this).__initializeVariables(); } protected override void __initializeRpcs() { ((PhysicsProp)this).__initializeRpcs(); } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "CanJuiceBehaviour"; } } [AttributeUsage(AttributeTargets.Method, Inherited = true)] public class JuiceEffectInfo : Attribute { [CompilerGenerated] [DebuggerBrowsable(DebuggerBrowsableState.Never)] private string <name>P; [CompilerGenerated] [DebuggerBrowsable(DebuggerBrowsableState.Never)] private string <description>P; [CompilerGenerated] [DebuggerBrowsable(DebuggerBrowsableState.Never)] private bool <isPositive>P; public string Name => <name>P; public string Description => <description>P; public bool IsPositive => <isPositive>P; public JuiceEffectInfo(string name, string description, bool isPositive) { <name>P = name; <description>P = description; <isPositive>P = isPositive; base..ctor(); } public void DisplayEffectTip(PlayerControllerB player) { if (((NetworkBehaviour)player).IsOwner) { HUDManager.Instance.DisplayTip(Name, Description, !<isPositive>P, false, "LC_Tip1"); } } } public class PlayerControllerBBehaviour : NetworkBehaviour { private const float TRANSITION_DURATION = 1f; private JuiceEffect currentJuiceEffect; private JuiceEffect lastJuiceEffect; private float transitionDelta; public JuiceEffect CurrentJuiceEffect { get { return currentJuiceEffect; } private set { lastJuiceEffect = currentJuiceEffect; currentJuiceEffect = value; transitionDelta = 1f; } } public object[] Parameters { get; set; } public PlayerControllerBBehaviour() { CurrentJuiceEffect = JuiceEffect.None; lastJuiceEffect = JuiceEffect.None; transitionDelta = 0f; Parameters = Array.Empty<object>(); } public void ApplyJuiceEffect(JuiceEffect effect, int duration, object[] parameters) { ((MonoBehaviour)this).StartCoroutine(applyJuiceEffectCoroutine(effect, duration, parameters)); } private IEnumerator applyJuiceEffectCoroutine(JuiceEffect effect, int duration, object[] parameters) { Parameters = parameters; CurrentJuiceEffect = effect; yield return (object)new WaitForSecondsRealtime((float)duration); CurrentJuiceEffect = JuiceEffect.None; } public void Update() { //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB component = ((Component)this).GetComponent<PlayerControllerB>(); if (currentJuiceEffect != lastJuiceEffect) { if (currentJuiceEffect == JuiceEffect.Healing) { component.health = Mathf.CeilToInt(Mathf.Lerp((float)component.health, 100f, 0.5f)); } if (currentJuiceEffect == JuiceEffect.Damages) { component.health = Mathf.FloorToInt(Mathf.Lerp((float)component.health, (float)(int)Parameters[0], 0.5f)); } if ((currentJuiceEffect | lastJuiceEffect).HasFlag(JuiceEffect.Marathoner)) { float num = (float)Parameters[0] * (float)((currentJuiceEffect != JuiceEffect.Marathoner) ? 1 : 10); component.sprintTime = Mathf.Lerp(component.sprintTime, num, 0.5f); } if ((currentJuiceEffect | lastJuiceEffect).HasFlag(JuiceEffect.Asmathic)) { float num2 = (float)Parameters[0] * ((currentJuiceEffect == JuiceEffect.Asmathic) ? 0.1f : 1f); component.sprintTime = Mathf.Lerp(component.sprintTime, num2, 0.5f); } if ((currentJuiceEffect | lastJuiceEffect).HasFlag(JuiceEffect.NightVision)) { bool flag = currentJuiceEffect == JuiceEffect.NightVision; Light nightVision = component.nightVision; nightVision.color = Color.Lerp(nightVision.color, flag ? new Color(0f, 1f, 0f, 1f) : ((Color)Parameters[0]), 0.5f); nightVision.intensity = Mathf.Lerp(nightVision.intensity, flag ? 10000f : ((float)Parameters[1]), 0.5f); nightVision.range = Mathf.Lerp(nightVision.range, flag ? 100000f : ((float)Parameters[2]), 0.5f); nightVision.shadowStrength = Mathf.Lerp(nightVision.shadowStrength, flag ? 0f : ((float)Parameters[3]), 0.5f); nightVision.shadows = (LightShadows)((!flag) ? ((int)(LightShadows)Parameters[4]) : 0); nightVision.shape = (LightShape)(flag ? 2 : ((int)(LightShape)Parameters[5])); component.nightVision = nightVision; } if ((currentJuiceEffect | lastJuiceEffect).HasFlag(JuiceEffect.UpsideDown)) { int num3 = ((currentJuiceEffect == JuiceEffect.UpsideDown) ? 180 : 0); Quaternion rotation = ((Component)component.gameplayCamera).transform.rotation; Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles; eulerAngles.z = Mathf.Lerp((eulerAngles.z + (float)(180 - num3)) % 360f - (float)(180 - num3), (float)num3, 0.5f); ((Component)component.gameplayCamera).transform.rotation = Quaternion.Euler(eulerAngles); } if ((currentJuiceEffect | lastJuiceEffect).HasFlag(JuiceEffect.EMP)) { Turret[] array = Object.FindObjectsByType<Turret>((FindObjectsSortMode)0); foreach (Turret val in array) { val.ToggleTurretEnabled(currentJuiceEffect != JuiceEffect.EMP); } } } else if (currentJuiceEffect == JuiceEffect.NightVision) { Light nightVision2 = component.nightVision; nightVision2.color = Color.Lerp(new Color(0f, 1f, 0.25f, 1f), new Color(0f, 1f, 0f, 1f), Mathf.Sin(MathF.PI * 2f * Time.time / 4f)); nightVision2.intensity = 10000f + Mathf.Sin(MathF.PI * 2f * Time.time / 2f) * 1000f; component.nightVision = nightVision2; } else if (currentJuiceEffect == JuiceEffect.SignalJamming) { Turret[] array2 = Object.FindObjectsByType<Turret>((FindObjectsSortMode)0); foreach (Turret val2 in array2) { if (!val2.enteringBerserkMode) { val2.EnterBerserkModeServerRpc(((Object)component).GetInstanceID()); } } } if (transitionDelta > 0f) { transitionDelta = Mathf.Max(0f, transitionDelta - Time.deltaTime); if (transitionDelta == 0f) { lastJuiceEffect = currentJuiceEffect; } } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { ((NetworkBehaviour)this).__initializeRpcs(); } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "PlayerControllerBBehaviour"; } } public class ShipJuiceBlenderBehaviour : NetworkBehaviour { public bool isPowered = false; public bool hasBeenMixed = false; private List<JuiceProperty> juiceContent = new List<JuiceProperty>(); private float _juiceLevel = 0f; public Animator bladeAnimator; public Animator speedSwitchAnimator; public List<Renderer> juiceRenderers = new List<Renderer>(); public InteractTrigger powerButtonTrigger; public InteractTrigger addJuiceTrigger; public GameObject juiceSpawnFX; public AudioSource blenderMixAudioSource; public AudioSource sfxAudioSource; public List<AudioClip> addJuiceSFX = new List<AudioClip>(); public AudioClip powerButtonSFX; public void Awake() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) if (ES3.KeyExists("JuicesMod_JuiceBlender_Content", GameNetworkManager.Instance.currentSaveFileName)) { juiceContent = ES3.Load<JuiceProperty[]>("JuicesMod_JuiceBlender_Content", GameNetworkManager.Instance.currentSaveFileName).ToList(); for (int i = 0; i < juiceContent.Count; i++) { juiceRenderers[i].material.color = juiceContent[i].Fruit.Color; } } if (!blenderMixAudioSource.isPlaying) { blenderMixAudioSource.Play(); } blenderMixAudioSource.pitch = 0f; } public void Update() { //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) addJuiceTrigger.disabledHoverTip = (isPowered ? "Can't add juice while blending" : "Blender is full"); addJuiceTrigger.interactable = !isPowered && juiceContent.Count < 4; powerButtonTrigger.interactable = juiceContent.Count > 0; if (isPowered) { AudioSource obj = blenderMixAudioSource; obj.pitch += (1f - blenderMixAudioSource.pitch) * 1f / 4f; } else { AudioSource obj2 = blenderMixAudioSource; obj2.pitch += (0.5f - blenderMixAudioSource.pitch) * 1f / 16f; } blenderMixAudioSource.volume = Mathf.Pow(2f * blenderMixAudioSource.pitch - 1f, 0.25f); _juiceLevel += ((float)juiceContent.Count - _juiceLevel) / 2f; Color val = default(Color); foreach (var item in juiceRenderers.Select((Renderer value, int index) => new { index, value })) { Color color; if ((isPowered || hasBeenMixed) && juiceContent.Count > 0) { ((Color)(ref val))..ctor(juiceRenderers.Take(juiceContent.Count).Average((Renderer r) => r.material.color.r), juiceRenderers.Take(juiceContent.Count).Average((Renderer r) => r.material.color.g), juiceRenderers.Take(juiceContent.Count).Average((Renderer r) => r.material.color.b)); color = Color.Lerp(item.value.material.color, val, 0.1f); } else { color = item.value.material.color; } color.a = Mathf.Clamp(_juiceLevel - (float)item.index, 0f, 1f); item.value.material.color = color; } } public void SaveState() { ES3.Save<JuiceProperty[]>("JuicesMod_JuiceBlender_Content", juiceContent.ToArray(), GameNetworkManager.Instance.currentSaveFileName); } public void DebugSpawnJuices() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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) HUDManager.Instance.DisplayTip("Spawning juices !", "16 random juices gonna be spawn !", false, false, "LC_Tip1"); for (int i = 0; i < 16; i++) { Item val = Plugin.instance.JuicesBuilder.Juices[Random.RandomRangeInt(0, Plugin.instance.JuicesBuilder.Juices.Length)]; GameObject val2 = Object.Instantiate<GameObject>(val.spawnPrefab, ((Component)this).gameObject.transform.position + Vector3.left * (float)i / 2f, Quaternion.identity, StartOfRound.Instance.propsContainer); ((GrabbableObject)val2.GetComponent<PhysicsProp>()).SetScrapValue((int)Random.Range((float)val.minValue * 0.4f, (float)val.maxValue * 0.4f)); val2.GetComponent<GrabbableObject>().fallTime = 0f; val2.GetComponent<NetworkObject>().Spawn(false); } } public void EarlyToggleSwitch() { if (!isPowered) { powerButtonTrigger.timeToHold = 3f; JuiceTypeProperty type = juiceContent.Find((JuiceProperty j) => j.Type.Multiplier == juiceContent.Min((JuiceProperty j2) => j2.Type.Multiplier)).Type; int num = juiceContent.Sum((JuiceProperty j) => j.ScrapValue); float num2 = Mathf.Lerp(1f, type.Multiplier, (float)(juiceContent.Count - 1) / 3f); HUDManager.Instance.DisplayTip(type.Name + " multifruit", $"Mixing these {juiceContent.Count} juices will produce a {type.Name.ToLower()} multifuit with a x{num2:0.##} bonus worth {(float)num * num2:0.00}.", false, false, "LC_Tip1"); } else { powerButtonTrigger.timeToHold = 0.5f; } } public void ToggleSwitch(PlayerControllerB player) { SetBlendingStateServerRpc(!isPowered); } [ServerRpc(RequireOwnership = false)] public void SetBlendingStateServerRpc(bool state) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_007d: 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_0097: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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) 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(2905137838u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref state, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2905137838u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost)) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; if (!state) { JuiceTypeProperty type = juiceContent.Find((JuiceProperty j) => j.Type.Multiplier == juiceContent.Min((JuiceProperty j2) => j2.Type.Multiplier)).Type; GameObject val3 = Object.Instantiate<GameObject>(Plugin.instance.JuicesBuilder.getMultifruit(type).spawnPrefab, ((Component)this).transform.position + Vector3.up + ((Component)this).transform.forward * 0.5f, ((Component)this).transform.rotation, RoundManager.Instance.spawnedScrapContainer); int scrapValue = (int)Mathf.Ceil((float)juiceContent.Sum((JuiceProperty j) => j.ScrapValue) * type.Multiplier); val3.GetComponent<GrabbableObject>().fallTime = 0f; val3.GetComponent<NetworkObject>().Spawn(false); StopBlendingClientRpc(NetworkObjectReference.op_Implicit(val3), scrapValue); } else { StartBlendingClientRpc(); } } [ClientRpc] public void StartBlendingClientRpc() { //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) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1829654523u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1829654523u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; ApplyBlendingState(state: true); } } } [ClientRpc] public void StopBlendingClientRpc(NetworkObjectReference multifruit, int scrapValue) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_007d: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3335357439u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkObjectReference>(ref multifruit, default(ForNetworkSerializable)); BytePacker.WriteValueBitPacked(val2, scrapValue); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3335357439u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; ((GrabbableObject)NetworkObjectReference.op_Implicit(multifruit).GetComponent<PhysicsProp>()).SetScrapValue(scrapValue); juiceContent.Clear(); GameObject val3 = Object.Instantiate<GameObject>(juiceSpawnFX, NetworkObjectReference.op_Implicit(multifruit).transform.position, Quaternion.identity, NetworkObjectReference.op_Implicit(multifruit).transform); AudioSource component = val3.GetComponent<AudioSource>(); if ((Object)(object)component != (Object)null && !component.isPlaying) { component.Play(); } ApplyBlendingState(state: false); SaveState(); } } private void ApplyBlendingState(bool state) { isPowered = state; hasBeenMixed = true; speedSwitchAnimator.SetBool("power", isPowered); bladeAnimator.SetBool("power", isPowered); sfxAudioSource.PlayOneShot(powerButtonSFX); } public void AddJuice(PlayerControllerB player) { if (juiceContent.Count < 4) { GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer; if ((Object)(object)currentlyHeldObjectServer != (Object)null && Plugin.instance.JuicesBuilder.hasJuiceProperty(currentlyHeldObjectServer)) { AddingJuiceServerRpc(Plugin.instance.JuicesBuilder.getJuiceProperty(currentlyHeldObjectServer)); player.DespawnHeldObject(); } } } [ServerRpc(RequireOwnership = false)] public void AddingJuiceServerRpc(JuiceProperty juice) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_007d: 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_0097: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(20618528u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<JuiceProperty>(ref juice, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 20618528u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; AddingJuiceClientRpc(juice); } } } [ClientRpc] public void AddingJuiceClientRpc(JuiceProperty juice) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_007d: 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_0097: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3953458859u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<JuiceProperty>(ref juice, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3953458859u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; ApplyAddingJuice(juice); } } } public void ApplyAddingJuice(JuiceProperty juice) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) hasBeenMixed = false; juiceContent.Add(juice); juiceRenderers[juiceContent.Count - 1].material.color = juice.Fruit.Color; sfxAudioSource.PlayOneShot(addJuiceSFX[Random.RandomRangeInt(0, addJuiceSFX.Count)]); SaveState(); } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(2905137838u, new RpcReceiveHandler(__rpc_handler_2905137838), "SetBlendingStateServerRpc"); ((NetworkBehaviour)this).__registerRpc(1829654523u, new RpcReceiveHandler(__rpc_handler_1829654523), "StartBlendingClientRpc"); ((NetworkBehaviour)this).__registerRpc(3335357439u, new RpcReceiveHandler(__rpc_handler_3335357439), "StopBlendingClientRpc"); ((NetworkBehaviour)this).__registerRpc(20618528u, new RpcReceiveHandler(__rpc_handler_20618528), "AddingJuiceServerRpc"); ((NetworkBehaviour)this).__registerRpc(3953458859u, new RpcReceiveHandler(__rpc_handler_3953458859), "AddingJuiceClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_2905137838(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_0044: 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 blendingStateServerRpc = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref blendingStateServerRpc, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((ShipJuiceBlenderBehaviour)(object)target).SetBlendingStateServerRpc(blendingStateServerRpc); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1829654523(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; ((ShipJuiceBlenderBehaviour)(object)target).StartBlendingClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3335357439(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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkObjectReference multifruit = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref multifruit, default(ForNetworkSerializable)); int scrapValue = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref scrapValue); target.__rpc_exec_stage = (__RpcExecStage)1; ((ShipJuiceBlenderBehaviour)(object)target).StopBlendingClientRpc(multifruit, scrapValue); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_20618528(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_0044: 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) { JuiceProperty juice = default(JuiceProperty); ((FastBufferReader)(ref reader)).ReadValueSafe<JuiceProperty>(ref juice, default(ForNetworkSerializable)); target.__rpc_exec_stage = (__RpcExecStage)1; ((ShipJuiceBlenderBehaviour)(object)target).AddingJuiceServerRpc(juice); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3953458859(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_0044: 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) { JuiceProperty juice = default(JuiceProperty); ((FastBufferReader)(ref reader)).ReadValueSafe<JuiceProperty>(ref juice, default(ForNetworkSerializable)); target.__rpc_exec_stage = (__RpcExecStage)1; ((ShipJuiceBlenderBehaviour)(object)target).AddingJuiceClientRpc(juice); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "ShipJuiceBlenderBehaviour"; } } public class ShipNeonAnimation : NetworkBehaviour { public List<Material> materials = new List<Material>(); public float minIntensity = 0f; public float maxIntensity = 1f; public NeonAnimation animation = NeonAnimation.Blink; public float animationSpeed = 1f; private Color[] originalColors; public void Awake() { originalColors = materials.Select((Material c) => c.GetColor("_EmissiveColor")).ToArray(); } public void Update() { //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: 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) int num = ((animation == NeonAnimation.Blink) ? 2 : ((animation == NeonAnimation.AppearBlinkDisapear) ? ((materials.Count + 5) * 2) : ((animation == NeonAnimation.OneByOne) ? materials.Count : 0))); float[] array = materials.Select((Material m) => 1f).ToArray(); float animationFrame = Time.time / animationSpeed % (float)num; if (animation == NeonAnimation.Blink) { array = array.Select((float l) => (animationFrame % 2f < 1f) ? 1f : 0f).ToArray(); } else if (animation == NeonAnimation.AppearBlinkDisapear) { array = ((animationFrame < (float)materials.Count) ? array.Select((float l, int i) => (animationFrame - 1f > (float)i) ? 1f : 0f).ToArray() : ((!(animationFrame < (float)(materials.Count + 10))) ? array.Select((float l, int i) => ((float)((materials.Count + 5) * 2) - animationFrame > (float)i) ? 1f : 0f).ToArray() : array.Select((float l) => (animationFrame % 1f < 0.5f) ? 1f : 0f).ToArray())); } else if (animation == NeonAnimation.OneByOne) { array = array.Select((float l, int i) => (Mathf.FloorToInt(animationFrame) == i) ? 1f : 0f).ToArray(); } float num2 = Random.Range(minIntensity, maxIntensity); for (int j = 0; j < materials.Count; j++) { materials[j].SetColor("_EmissiveColor", originalColors[j] * array[j] * num2); } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { ((NetworkBehaviour)this).__initializeRpcs(); } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "ShipNeonAnimation"; } } public enum NeonAnimation { Blink, AppearBlinkDisapear, OneByOne } public class ShipNeonFlickering : NetworkBehaviour { public List<Material> materials = new List<Material>(); public float minIntensity = 0f; public float maxIntensity = 1f; private Color[] originalColors; public void Awake() { originalColors = materials.Select((Material c) => c.GetColor("_EmissiveColor")).ToArray(); } public void Update() { //IL_0030: 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) float num = Random.Range(minIntensity, maxIntensity); for (int i = 0; i < materials.Count; i++) { materials[i].SetColor("_EmissiveColor", originalColors[i] * num); } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { ((NetworkBehaviour)this).__initializeRpcs(); } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "ShipNeonFlickering"; } } public class VitaminDetectorBehaviour : PhysicsProp { public float RadarMinDistance = 0f; public float RadarMaxDistance = 50f; public ParticleSystem RadarParticle; public AudioSource RadarAudio; public AudioSource ItemAudio; public AudioClip PowerOnClip; public AudioClip PowerOffClip; public AudioClip OutOfBatteriesClip; private bool activated = false; public override void Start() { ((GrabbableObject)this).Start(); ((GrabbableObject)this).insertedBattery.charge = 1f; } public override void ItemActivate(bool used, bool buttonDown = true) { ToggleState(!activated); if (activated) { RadarParticle.Play(); } else { RadarParticle.Stop(); } } public override void UseUpBatteries() { ((GrabbableObject)this).UseUpBatteries(); ToggleState(state: false); ItemAudio.PlayOneShot(OutOfBatteriesClip); } public void ToggleState(bool state) { activated = state; ItemAudio.PlayOneShot(activated ? PowerOnClip : PowerOffClip); } public override void Update() { //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) ((GrabbableObject)this).Update(); GrabbableObject[] array = (GrabbableObject[])(object)(from juice in Object.FindObjectsOfType<PhysicsProp>() where Plugin.instance.JuicesBuilder.hasJuiceProperty((GrabbableObject)(object)juice) || Plugin.instance.JuicesBuilder.isMultifruit((GrabbableObject)(object)juice) select juice).ToArray(); GrabbableObject[] source = array; if (!RadarParticle.isPlaying && activated && ((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null || (Object)(object)((GrabbableObject)this).playerHeldBy.currentlyHeldObjectServer == (Object)(object)this)) { RadarParticle.Play(); } else if (RadarParticle.isPlaying && (!activated || ((Object)(object)((GrabbableObject)this).playerHeldBy != (Object)null && (Object)(object)((GrabbableObject)this).playerHeldBy.currentlyHeldObjectServer != (Object)(object)this))) { RadarParticle.Stop(); } if (!RadarAudio.isPlaying && activated) { RadarAudio.Play(); } else if (RadarAudio.isPlaying && !activated) { RadarAudio.Stop(); } if (activated) { float num = (Mathf.Clamp((from juice in source where !juice.isPocketed select Vector3.Distance(((Component)this).transform.position, ((Component)juice).transform.position) into dist orderby dist select dist).DefaultIfEmpty(RadarMaxDistance).First(), RadarMinDistance, RadarMaxDistance) - RadarMinDistance) / (RadarMaxDistance - RadarMinDistance); EmissionModule emission = RadarParticle.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(Mathf.Lerp(4f, 0.25f, num)); RadarAudio.pitch = Mathf.Lerp(4f, 0.25f, num); Material material = ((Renderer)((Component)RadarParticle).GetComponent<ParticleSystemRenderer>()).material; material.SetColor("_EmissionColor", Color.Lerp(new Color(0f, 1.9766746f, 0f, 1f), new Color(1.9766746f, 0f, 0f, 1f), num)); } } protected override void __initializeVariables() { ((PhysicsProp)this).__initializeVariables(); } protected override void __initializeRpcs() { ((PhysicsProp)this).__initializeRpcs(); } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "VitaminDetectorBehaviour"; } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace Shlygly.JuicesMod.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }