using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using YamlDotNet.Serialization; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("InverseGift")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("InverseGift")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("2acb810c-a0ab-455f-a9bd-1658317c49aa")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace InverseGift { [BepInPlugin("InverseGift", "chuxia.InverseGift", "1.1.4")] public class InverseGiftPlugin : BaseUnityPlugin { public const string PLUGIN_GUID = "chuxia.InverseGift"; public static readonly string config = Utility.CombinePaths(new string[2] { Paths.ConfigPath, "chuxia.InverseGift.yml" }); public const string PLUGIN_NAME = "InverseGift"; public const string PLUGIN_VERSION = "1.1.4"; public static ManualLogSource ManualLog = null; public static readonly Harmony _harmony = new Harmony("chuxia.InverseGift"); public static InverseGiftConfig InverseConfig { get; set; } = new InverseGiftConfig(); public void Awake() { ManualLog = ((BaseUnityPlugin)this).Logger; LoadConfig(); _harmony.PatchAll(typeof(Patches)); } public static void LoadConfig() { if (!File.Exists(config)) { InverseConfig = new InverseGiftConfig { Gift = new List { new GiftConfig { Message = "{player}:女士们先生们!一起来看流星雨!", Rarity = 2, Items = new List { new ItemConfig { Name = "Meteor" } } }, new GiftConfig { Rarity = 5, Items = new List { new ItemConfig { Name = "GoldBar", Value = "1000-9999" } }, Message = "{player}:找到了价值连城的传世宝藏!({values} 元)" }, new GiftConfig { Rarity = 1, Items = new List { new ItemConfig { Name = "Candy", Value = "999" } } }, new GiftConfig { Rarity = 10, Items = new List { new ItemConfig { Name = "Key" } } }, new GiftConfig { Rarity = 5, Items = new List { new ItemConfig { Name = "Turret" } } }, new GiftConfig { Rarity = 5, Items = new List { new ItemConfig { Name = "Landmine" } } }, new GiftConfig { Rarity = 10, Items = new List { new ItemConfig { Name = "Nutcracker" } } }, new GiftConfig { Rarity = 10, Items = new List { new ItemConfig { Name = "HoarderBug" } } }, new GiftConfig { Rarity = 30 } }, Items = new List { new ItemConfig { Name = "GiftBox", Count = "1" }, new ItemConfig { Name = "Shovel", Count = "1" }, new ItemConfig { Name = "ProFlashlight", Count = "1" } } }; File.WriteAllText(config, SerializeHelper.YamlSerialize(InverseConfig)); ManualLog.LogInfo((object)"Init InverseConfig"); return; } try { InverseConfig = SerializeHelper.YamlDeserialize(File.ReadAllText(config)); ManualLog.LogInfo((object)$"Load InverseConfig Success(Items:{InverseConfig.Items.Count})"); } catch (Exception ex) { ManualLog.LogError((object)("Load Config Fail -> " + ex.ToString())); InverseConfig = new InverseGiftConfig(); } } public static void LogInfo(object data) { ManualLog.LogInfo((object)$"{data}"); } } public static class Patches { [CompilerGenerated] private sealed class d__18 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private Exception 5__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__18(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; break; } try { doCheckForChanges(); } catch (Exception ex) { 5__1 = ex; InverseGiftPlugin.LogInfo($"Exception in coroutine: {5__1}"); } <>2__current = (object)new WaitForSeconds(5f); <>1__state = 1; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__24 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public string value; public int count; private List 5__1; private PlayerControllerB[] 5__2; private GameObject[] 5__3; private int 5__4; private PlayerControllerB 5__5; private int 5__6; private Vector3 5__7; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__24(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; 5__3 = null; 5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; return true; case 1: <>1__state = -1; 5__1 = new List(); 5__2 = StartOfRound.Instance.allPlayerScripts; 5__4 = 0; while (5__4 < 5__2.Length) { 5__5 = 5__2[5__4]; if (5__5.isPlayerControlled && !5__5.isPlayerDead) { 5__1.Add(5__5); } 5__5 = null; 5__5 = null; int num = 5__4 + 1; 5__4 = num; } 5__2 = null; 5__3 = GameObject.FindGameObjectsWithTag("OutsideAINode"); 5__6 = 0; break; case 2: { <>1__state = -1; int num = 5__6 + 1; 5__6 = num; break; } } if (5__6 < 5__1.Count * 10) { 5__7 = 5__3[Random.Range(0, 5__3.Length)].transform.position; SpawnObject(GameObjects["maskedplayerenemy"], 5__7, 5__7, 5__7, ref value); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 2; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static DateTime _lastModifiedTime; private static FileInfo _fileInfo; private static Coroutine checkForChangesCoroutine; private static Dictionary enemyTran = new Dictionary { { "dressgirl", "小女孩" }, { "lassoman", "lassoman" }, { "sandspider", "蜘蛛" }, { "centipede", "抱脸虫" }, { "blob", "史莱姆" }, { "flowerman", "小黑" }, { "springman", "弹簧头" }, { "crawler", "半身鱼" }, { "hoarderbug", "囤积虫" }, { "jester", "八音盒" }, { "puffer", "孢子蜥蜴" }, { "nutcracker", "胡桃夹子" }, { "maskedplayerenemy", "假人" }, { "butler", "管家" }, { "claysurgeon", "理发师" }, { "cavedweller", "食人魔" }, { "forestgiant", "森林巨人" }, { "mouthdog", "寻声猎犬" }, { "sandworm", "地球利维坦" }, { "radmech", "机械鸟" }, { "baboonhawk", "狒狒鹰" }, { "doublewing", "四翼鸟" }, { "docilelocustbees", "漫游蝗虫" }, { "flowersnake", "花蛇" }, { "giantkiwi", "巨型啄木鸟" }, { "redlocustbees", "电击蜜蜂" } }; private static Dictionary GameObjects { get; set; } private static Dictionary RandomMap { get; set; } private static List GiftInstanceIds { get; set; } = new List(); [HarmonyPostfix] [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] [HarmonyWrapSafe] public static void ConnectClientToPlayerObjectPostfix(PlayerControllerB __instance) { if (((NetworkBehaviour)StartOfRound.Instance).IsHost && checkForChangesCoroutine == null) { _fileInfo = new FileInfo(InverseGiftPlugin.config); _lastModifiedTime = _fileInfo.LastWriteTime; checkForChangesCoroutine = ((MonoBehaviour)__instance).StartCoroutine(CheckForChanges()); } } [HarmonyPrefix] [HarmonyPatch(typeof(GameNetworkManager), "Disconnect")] [HarmonyWrapSafe] public static void OnDestroy(PlayerControllerB __instance) { if (checkForChangesCoroutine != null) { ((MonoBehaviour)__instance).StopCoroutine(checkForChangesCoroutine); checkForChangesCoroutine = null; } } [IteratorStateMachine(typeof(d__18))] private static IEnumerator CheckForChanges() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__18(0); } private static void doCheckForChanges() { _fileInfo.Refresh(); if (_fileInfo.LastWriteTime > _lastModifiedTime) { _lastModifiedTime = _fileInfo.LastWriteTime; InverseGiftPlugin.LogInfo("Config file changed, reloading..."); InverseGiftPlugin.LoadConfig(); } } [HarmonyPatch(typeof(ShipTeleporter), "TeleportPlayerOutWithInverseTeleporter")] [HarmonyPostfix] [HarmonyWrapSafe] public static void Postfix(Vector3 teleportPos) { //IL_065b: Unknown result type (might be due to invalid IL or missing references) //IL_065c: Unknown result type (might be due to invalid IL or missing references) //IL_065d: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)StartOfRound.Instance).IsHost) { return; } if (GameObjects == null) { RandomMap = new Dictionary(); GameObjects = new Dictionary(); List list = new List(); List list2 = new List(); foreach (Item items in StartOfRound.Instance.allItemsList.itemsList) { if ((Object)(object)items.spawnPrefab != (Object)null && !GameObjects.ContainsKey(((Object)items).name.ToLower())) { if (items.isScrap) { list.Add(((Object)items).name.ToLower()); } else { list2.Add(((Object)items).name.ToLower()); } GameObjects.Add(((Object)items).name.ToLower(), items.spawnPrefab); } } RandomMap.Add("randomscrap", list.ToArray()); RandomMap.Add("randomtool", list2.ToArray()); List list3 = new List(); List list4 = new List(); SelectableLevel[] levels = StartOfRound.Instance.levels; foreach (SelectableLevel val in levels) { foreach (SpawnableEnemyWithRarity enemy in val.Enemies) { if ((Object)(object)enemy.enemyType != (Object)null && (Object)(object)enemy.enemyType.enemyPrefab != (Object)null && !GameObjects.ContainsKey(((Object)enemy.enemyType).name.ToLower()) && !((Object)enemy.enemyType).name.Equals("lassoman", StringComparison.OrdinalIgnoreCase)) { list3.Add(((Object)enemy.enemyType).name.ToLower()); GameObjects.Add(((Object)enemy.enemyType).name.ToLower(), enemy.enemyType.enemyPrefab); } } SpawnableMapObject[] spawnableMapObjects = val.spawnableMapObjects; foreach (SpawnableMapObject val2 in spawnableMapObjects) { if ((Object)(object)val2.prefabToSpawn != (Object)null && !GameObjects.ContainsKey(((Object)val2.prefabToSpawn).name.ToLower())) { list4.Add(((Object)val2.prefabToSpawn).name.ToLower()); GameObjects.Add(((Object)val2.prefabToSpawn).name.ToLower(), val2.prefabToSpawn); } } } RandomMap.Add("randomenemy", list3.ToArray()); RandomMap.Add("randomobject", list4.ToArray()); File.WriteAllText(Utility.CombinePaths(new string[2] { Paths.ConfigPath, "chuxia.InverseGiftItems.txt" }), string.Join(Environment.NewLine, GameObjects.Select(delegate(KeyValuePair x) { string key = x.Key; GameObject value2 = x.Value; return key + ":" + ((value2 != null) ? ((Object)value2).name : null); }))); } foreach (ItemConfig item in InverseGiftPlugin.InverseConfig.Items) { string text = item.Name.ToLower().ToString(); switch (text) { case "randomscrap": { int num4 = Random.Range(0, RandomMap["randomscrap"].Length); text = RandomMap["randomscrap"][num4]; InverseGiftPlugin.LogInfo($"RandomScrap -> {text}({num4})"); break; } case "randomtool": { int num3 = Random.Range(0, RandomMap["randomtool"].Length); text = RandomMap["randomtool"][num3]; InverseGiftPlugin.LogInfo($"RandomTool -> {text}({num3})"); break; } case "randomenemy": { int num2 = Random.Range(0, RandomMap["randomenemy"].Length); text = RandomMap["randomenemy"][num2]; InverseGiftPlugin.LogInfo($"RandomEnemy -> {text}({num2})"); break; } case "randomobject": { int num = Random.Range(0, RandomMap["randomobject"].Length); text = RandomMap["randomobject"][num]; InverseGiftPlugin.LogInfo($"RandomObject -> {text}({num})"); break; } } if (GameObjects != null && GameObjects.TryGetValue(text.ToLower(), out var value)) { string text2 = (string.IsNullOrWhiteSpace(item.Count) ? "1" : item.Count.Trim()); int num5; if (int.TryParse(text2, out var result)) { num5 = result; } else if (text2.Contains("-")) { string[] array = text2.Split(new char[1] { '-' }); if (array.Length == 2 && int.TryParse(array[0], out var result2) && int.TryParse(array[1], out var result3) && result2 <= result3) { num5 = Random.Range(result2, result3 + 1); } else { num5 = 1; InverseGiftPlugin.ManualLog.LogInfo((object)("Count Parse Error -> Item: " + item.Name + " | Count: " + text2)); } } else { num5 = 1; InverseGiftPlugin.ManualLog.LogInfo((object)("Count Parse Error -> Item: " + item.Name + " | Count: " + text2)); } for (int k = 0; k < num5; k++) { string Value = "0"; SpawnObject(value, teleportPos, teleportPos, teleportPos, ref Value); } } else { InverseGiftPlugin.ManualLog.LogInfo((object)("InverseConfig Error -> Items: " + item.Name + " ConvertGameObjectFail.")); } } } private static bool GoHomeAllMethod() { int targetTransformIndex = StartOfRound.Instance.mapScreen.targetTransformIndex; bool flag = false; ShipTeleporter val = (from x in Object.FindObjectsOfType() where !x.isInverseTeleporter select x).FirstOrDefault(); if ((Object)(object)val == (Object)null) { return false; } for (int i = 0; i < StartOfRound.Instance.mapScreen.radarTargets.Count; i++) { TransformAndName val2 = StartOfRound.Instance.mapScreen.radarTargets[i]; if (!val2.isNonPlayer) { PlayerControllerB component = ((Component)val2.transform).gameObject.GetComponent(); if ((Object)(object)component != (Object)null && component.isPlayerControlled) { InverseGiftPlugin.LogInfo("GoHomeAll -> " + component.playerUsername); StartOfRound.Instance.mapScreen.SwitchRadarTargetAndSync(i); StartOfRound.Instance.mapScreen.SwitchRadarTargetClientRpc(i); val.PressTeleportButtonClientRpc(); flag = true; } } } if (!flag) { return false; } StartOfRound.Instance.mapScreen.SwitchRadarTargetClientRpc(targetTransformIndex); return true; } private static bool GoHomeMethod(PlayerControllerB player) { int targetTransformIndex = StartOfRound.Instance.mapScreen.targetTransformIndex; bool flag = false; for (int i = 0; i < StartOfRound.Instance.mapScreen.radarTargets.Count; i++) { TransformAndName val = StartOfRound.Instance.mapScreen.radarTargets[i]; if (!val.isNonPlayer) { PlayerControllerB component = ((Component)val.transform).gameObject.GetComponent(); if ((Object)(object)component != (Object)null && component.isPlayerControlled && component.actualClientId == player.actualClientId) { InverseGiftPlugin.LogInfo("GoHome -> " + component.playerUsername); StartOfRound.Instance.mapScreen.SwitchRadarTargetAndSync(i); StartOfRound.Instance.mapScreen.SwitchRadarTargetClientRpc(i); flag = true; } } } if (!flag) { return false; } ShipTeleporter val2 = (from x in Object.FindObjectsOfType() where !x.isInverseTeleporter select x).FirstOrDefault(); if ((Object)(object)val2 == (Object)null) { return false; } val2.PressTeleportButtonClientRpc(); StartOfRound.Instance.mapScreen.SwitchRadarTargetAndSync(targetTransformIndex); StartOfRound.Instance.mapScreen.SwitchRadarTargetClientRpc(targetTransformIndex); return true; } [HarmonyPatch(typeof(GiftBoxItem), "OpenGiftBoxServerRpc")] [HarmonyPrefix] [HarmonyWrapSafe] public static bool OpenGiftBoxServerRpc(GiftBoxItem __instance) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) //IL_04d7: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04dc: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_04e8: Unknown result type (might be due to invalid IL or missing references) //IL_04f3: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)StartOfRound.Instance).IsHost || GiftInstanceIds.Contains(((Object)__instance).GetInstanceID())) { return true; } if (GiftInstanceIds.Count > 20) { GiftInstanceIds.Clear(); } GiftInstanceIds.Add(((Object)__instance).GetInstanceID()); AccessTools.DeclaredField(typeof(GiftBoxItem), "objectInPresent").SetValue(__instance, null); PlayerControllerB val = (PlayerControllerB)AccessTools.DeclaredField(typeof(GiftBoxItem), "previousPlayerHeldBy").GetValue(__instance); if (!val.isInsideFactory) { return true; } GiftConfig randomGiftNormalized = GetRandomGiftNormalized(InverseGiftPlugin.InverseConfig); InverseGiftPlugin.LogInfo($"{val?.playerUsername}|OpenGift|{randomGiftNormalized.Rarity}"); List list = new List(); Dictionary valueMap = new Dictionary(StringComparer.OrdinalIgnoreCase); Dictionary countMap = new Dictionary(StringComparer.OrdinalIgnoreCase); List list2 = new List(); List list3 = new List(); if (randomGiftNormalized.Items == null || randomGiftNormalized.Items.Count == 0) { randomGiftNormalized.Items = new List(); } NavMeshHit val3 = default(NavMeshHit); foreach (ItemConfig item in randomGiftNormalized.Items) { string text = item.Name?.ToLower(); string Value = item.Value; string text2 = (string.IsNullOrEmpty(item.Count) ? "1" : item.Count); int num2; if (int.TryParse(text2, out var result)) { num2 = result; } else if (text2.Contains("-")) { string[] array = text2.Split(new char[1] { '-' }); if (array.Length == 2 && int.TryParse(array[0], out var result2) && int.TryParse(array[1], out var result3) && result2 <= result3) { num2 = Random.Range(result2, result3 + 1); } else { InverseGiftPlugin.ManualLog.LogInfo((object)("InverseGift SetCount Error -> Item: " + item.Name + " | Count: " + text2)); num2 = 1; } } else { InverseGiftPlugin.ManualLog.LogInfo((object)("InverseGift SetCount Error -> Item: " + item.Name + " | Count: " + text2)); num2 = 1; } string text3 = item.Name?.Trim(); for (int i = 0; i < num2; i++) { bool flag = false; string text4 = text; switch (text) { case "maskevent": flag = true; ((MonoBehaviour)StartOfRound.Instance.localPlayerController).StartCoroutine(MaskEvent(Value, num2)); break; case "meteor": flag = true; TimeOfDay.Instance.meteorShowerAtTime = 0.1f; break; case "randomscrap": text4 = RandomMap["randomscrap"][Random.Range(0, RandomMap["randomscrap"].Length)]; break; case "randomtool": text4 = RandomMap["randomtool"][Random.Range(0, RandomMap["randomtool"].Length)]; break; case "randomenemy": text4 = RandomMap["randomenemy"][Random.Range(0, RandomMap["randomenemy"].Length)]; break; case "randomobject": text4 = RandomMap["randomobject"][Random.Range(0, RandomMap["randomobject"].Length)]; break; } if (!(string.IsNullOrWhiteSpace(text4) || flag)) { if (GameObjects != null && GameObjects.TryGetValue(text4.ToLower(), out var value)) { list.Add(text4); float num3 = (float)i * (360f / (float)num2) * ((float)Math.PI / 180f); float valueOrDefault = item.radius.GetValueOrDefault(0.5f); Vector3 val2 = new Vector3(Mathf.Cos(num3), 0f, Mathf.Sin(num3)) * valueOrDefault; Vector3 pos = (NavMesh.SamplePosition(((Component)__instance).transform.position + val2, ref val3, 5f, -1) ? ((NavMeshHit)(ref val3)).position : ((!NavMesh.SamplePosition(((Component)__instance).transform.position, ref val3, 10f, -1)) ? ((Component)__instance).transform.position : ((NavMeshHit)(ref val3)).position)); SpawnObject(value, pos, ((Component)__instance).transform.position, ((Component)val).transform.position, ref Value); } else { InverseGiftPlugin.ManualLog.LogInfo((object)("InverseConfig Error -> Item: " + text + " ConvertGameObjectFail.")); } if (!string.IsNullOrEmpty(text3)) { valueMap[text3] = Value ?? "0"; } list2.Add(Value ?? "0"); } } if (!string.IsNullOrEmpty(text3)) { countMap[text3] = num2; } list3.Add(num2); } if (!string.IsNullOrWhiteSpace(randomGiftNormalized.Message)) { InverseGiftPlugin.LogInfo("Gift Message -> " + randomGiftNormalized.Message); string str3; int num; string text5 = Regex.Replace(Regex.Replace(randomGiftNormalized.Message.Replace("{player}", val.playerUsername).Replace("{result}", string.Join("、", list)).Replace("{values}", list2.Sum((string x) => decimal.Parse(x)).ToString("0")) .Replace("{counts}", list3.Sum((int x) => x).ToString("0")), "\\{value:(.+?)\\}", (Match match) => valueMap.TryGetValue(match.Groups[1].Value.Trim(), out str3) ? str3 : ""), "\\{count:(.+?)\\}", (Match match) => countMap.TryGetValue(match.Groups[1].Value.Trim(), out num) ? num.ToString() : "0"); InverseGiftPlugin.LogInfo("Final Message -> " + text5); HUDManager.Instance.AddTextToChatOnServer(text5, -1); } return true; } [IteratorStateMachine(typeof(d__24))] private static IEnumerator MaskEvent(string value, int count) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__24(0) { value = value, count = count }; } public static GiftConfig GetRandomGiftNormalized(InverseGiftConfig config) { if (config?.Gift == null || config.Gift.Count == 0) { throw new ArgumentException("Gift configuration is null or empty"); } int num = config.Gift.Sum((GiftConfig g) => g.Rarity); if (num <= 0) { throw new ArgumentException("Total Rarity must be positive"); } int num2 = Random.Range(1, num + 1); int num3 = 0; foreach (GiftConfig item in config.Gift) { num3 += item.Rarity; if (num2 <= num3) { return item; } } return config.Gift.Last(); } public static void SpawnObject(GameObject spawn, Vector3 pos, Vector3 itempos, Vector3 playerPos, ref string Value) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: 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_02eb: 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_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) GrabbableObject val = default(GrabbableObject); EnemyAI val2 = default(EnemyAI); NetworkObject val3 = default(NetworkObject); if (spawn.TryGetComponent(ref val)) { GrabbableObject component = Object.Instantiate(spawn, RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(pos, 1f, RoundManager.Instance.navHit, RoundManager.Instance.AnomalyRandom, -1, 1f) + Vector3.up * val.itemProperties.verticalOffset, Quaternion.identity, (Transform)null).GetComponent(); ((Component)component).transform.rotation = Quaternion.Euler(component.itemProperties.restingRotation); component.fallTime = 0f; component.isInFactory = true; if (Value != null) { if (int.TryParse(Value, out var result)) { component.SetScrapValue(result); } else if (Value.Contains("-")) { string[] array = Value.Split(new char[1] { '-' }); string text = array[0]; string text2 = array[1]; if (int.TryParse(text, out var result2) && int.TryParse(text2, out var result3) && result2 < result3) { Random.InitState(Guid.NewGuid().GetHashCode()); int scrapValue = Random.Range(result2, result3 + 1); component.SetScrapValue(scrapValue); Value = scrapValue.ToString(); } else { InverseGiftPlugin.ManualLog.LogInfo((object)("InverseGift SetValue Error -> Gift: " + ((Object)spawn).name + " | Value1: " + text + " | Value2: " + text2 + ".")); } } else { InverseGiftPlugin.ManualLog.LogInfo((object)("InverseGift SetValue Error -> Gift: " + ((Object)spawn).name + " | Value: " + Value + ".")); component.SetScrapValue(0); } } ((NetworkBehaviour)component).NetworkObject.Spawn(false); } else if (spawn.TryGetComponent(ref val2)) { EnemyAI component2 = Object.Instantiate(spawn, pos, Quaternion.identity).GetComponent(); ((Component)component2).GetComponentInChildren().Spawn(true); RoundManager.Instance.SpawnedEnemies.Add(component2); } else if (spawn.TryGetComponent(ref val3)) { ((Vector3)(ref pos))..ctor(pos.x, itempos.y, pos.z); pos -= Vector3.up * 1.8f; NetworkObject component3 = Object.Instantiate(spawn, pos, Quaternion.identity, RoundManager.Instance.mapPropsContainer.transform).GetComponent(); ((Component)component3).transform.position = pos; if (((Object)component3).name == "TurretContainer") { Transform transform = ((Component)component3).transform; Vector3 val4 = playerPos - pos; Vector3 normalized = ((Vector3)(ref val4)).normalized; transform.forward = normalized; } else { ((Component)component3).transform.forward = new Vector3(1f, 0f, 0f); } ((Component)component3).GetComponent().Spawn(true); } } } public class InverseGiftConfig { public List Items { get; set; } public List Gift { get; set; } } public class GiftConfig { public int Rarity { get; set; } public string Message { get; set; } public List Items { get; set; } } public class ItemConfig { public string Name { get; set; } public string Count { get; set; } public string Value { get; set; } public float? radius { get; set; } } public static class SerializeHelper { public static string YamlSerialize(object obj) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return new SerializerBuilder().ConfigureDefaultValuesHandling((DefaultValuesHandling)1).Build().Serialize(obj); } public static T YamlDeserialize(string input) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) try { return new DeserializerBuilder().Build().Deserialize(input); } catch (Exception ex) { InverseGiftPlugin.ManualLog.LogError((object)ex.ToString()); return default(T); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "InverseGift"; public const string PLUGIN_NAME = ""; public const string PLUGIN_VERSION = "1.0.0.0"; } }