using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Peak.Afflictions;
using Photon.Pun;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("PEAK_GachaMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PEAK_GachaMod")]
[assembly: AssemblyTitle("PEAK_GachaMod")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace PEAK_GachaMod;
public enum GachaEntryType
{
GiveItem,
InfiniteStamina,
SpeedBuff,
Invincibility,
LowGravity,
RestoreStatus,
MoraleBoost,
ExtraStamina,
Bugle,
RandomLoot,
RandomItem,
Mythic,
Equipment,
Luggage,
Pandora,
AllBomb,
SpawnZombie,
SpawnBees,
SpawnDynamite,
Tornado,
Eruption,
SpawnFrog,
SpawnScorpion,
TickParasite,
IceBlind,
StatusPoison,
StatusSleep,
StatusRandom,
StatusAll,
SteamExplode,
SporeFog,
GhostBoom,
Revive
}
public class GachaEntry
{
public string id;
public GachaEntryType type;
public float p1;
public float p2;
public string s1;
public int weight = 10;
public int luckBias;
}
public static class GachaDraw
{
private static float Luck01(int luck)
{
return Mathf.Clamp01(((float)luck + 100f) / 200f);
}
private static float LuckWeightMult(GachaEntry e, int luck)
{
float num = Luck01(luck);
if (e.luckBias > 0)
{
return 1f + (float)e.luckBias * num;
}
if (e.luckBias < 0)
{
return 1f + (float)(-e.luckBias) * (1f - num);
}
return 1f;
}
private static int PickBigPool(int luck)
{
float num = Luck01(luck);
float num2 = Plugin.cfgPool1Weight.Value * (0.3f + 0.7f * num);
float num3 = Plugin.cfgPool2Weight.Value * (0.1f + 0.9f * num);
float num4 = Plugin.cfgPool3Weight.Value * (1.9f - 0.9f * num);
float num5 = num2 + num3 + num4;
float num6 = Random.value * num5;
if (num6 < num2)
{
return 1;
}
if (num6 < num2 + num3)
{
return 2;
}
return 3;
}
private static GachaEntry PickInPool(List<GachaEntry> pool, int luck)
{
float num = 0f;
foreach (GachaEntry item in pool)
{
num += Mathf.Max(0.1f, (float)item.weight) * LuckWeightMult(item, luck);
}
float num2 = Random.value * num;
foreach (GachaEntry item2 in pool)
{
num2 -= Mathf.Max(0.1f, (float)item2.weight) * LuckWeightMult(item2, luck);
if (num2 <= 0f)
{
return item2;
}
}
if (pool.Count <= 0)
{
return null;
}
return pool[pool.Count - 1];
}
public static GachaEntry Draw(int luck, Character c)
{
List<GachaEntry> list = Parse(Plugin.cfgPool1.Value, 1);
List<GachaEntry> list2 = Parse(Plugin.cfgPool2.Value, 2);
List<GachaEntry> list3 = Parse(Plugin.cfgPool3.Value, 3);
int num = PickBigPool(luck);
List<GachaEntry> list4 = num switch
{
2 => list2,
1 => list,
_ => list3,
};
if (!Plugin.cfgStatueModeA.Value && num == 2)
{
list4 = list4.FindAll((GachaEntry e) => e.type != GachaEntryType.Revive || HasRevivablePlayers());
}
Plugin.Log.LogInfo((object)$"[幸运罗盘] 命中大奖池{num},条目数 {list4.Count}");
return PickInPool(list4, luck);
}
public static GachaEntry MakeEntryFromType(GachaEntryType type)
{
return new GachaEntry
{
id = "Punish",
type = type,
p1 = 0f,
p2 = 0f,
s1 = "",
weight = 10,
luckBias = 0
};
}
public static bool HasRevivablePlayers()
{
foreach (Character allCharacter in Character.AllCharacters)
{
if ((Object)(object)allCharacter != (Object)null && (Object)(object)allCharacter.data != (Object)null && (allCharacter.data.dead || allCharacter.data.fullyPassedOut))
{
return true;
}
}
return false;
}
public static List<GachaEntry> Parse(string cfg, int poolIndex)
{
List<GachaEntry> list = new List<GachaEntry>();
if (string.IsNullOrEmpty(cfg))
{
return list;
}
string[] array = cfg.Split(new char[1] { ';' });
for (int i = 0; i < array.Length; i++)
{
string text = array[i].Trim();
if (text.Length != 0)
{
string[] array2 = text.Split(new char[1] { '|' });
if (array2.Length < 3)
{
WarnSkip(poolIndex, text, "字段数不足");
continue;
}
if (!TryParseType(array2[1].Trim(), out var t))
{
WarnSkip(poolIndex, text, "未知类型 " + array2[1]);
continue;
}
GachaEntry gachaEntry = new GachaEntry();
gachaEntry.id = array2[0].Trim();
gachaEntry.type = t;
gachaEntry.s1 = array2[2].Trim();
gachaEntry.p1 = ParseFloat(array2, 2);
gachaEntry.p2 = ParseFloat(array2, 3);
gachaEntry.weight = ((array2.Length > 4) ? ParseInt(array2[4]) : 10);
gachaEntry.luckBias = ((array2.Length > 5) ? ParseInt(array2[5]) : 0);
list.Add(gachaEntry);
}
}
return list;
}
private static bool TryParseType(string s, out GachaEntryType t)
{
foreach (GachaEntryType value in Enum.GetValues(typeof(GachaEntryType)))
{
if (string.Equals(value.ToString(), s, StringComparison.OrdinalIgnoreCase))
{
t = value;
return true;
}
}
t = GachaEntryType.GiveItem;
return false;
}
private static float ParseFloat(string[] f, int i)
{
if (f.Length <= i || !float.TryParse(f[i], out var result))
{
return 0f;
}
return result;
}
private static int ParseInt(string s)
{
if (!int.TryParse(s, out var result))
{
return 10;
}
return result;
}
private static void WarnSkip(int pool, string line, string why)
{
Plugin.Log.LogWarning((object)$"[幸运罗盘] 大奖池{pool} 条目解析失败已跳过({why}):{line}");
}
}
public static class GachaExecutor
{
private static bool _netInit = false;
private static readonly string[] MythicPool = new string[12]
{
"0_Items/Anti-Rope Spool", "0_Items/AncientIdol", "0_Items/BookOfBones", "0_Items/Bugle_Magic", "0_Items/Bugle_Scoutmaster Variant", "0_Items/Cure-All", "0_Items/Cursed Skull", "0_Items/Lantern_Faerie", "0_Items/PandorasBox", "0_Items/RopeShooterAnti",
"0_Items/ScoutEffigy", "0_Items/Warp Compass"
};
private static readonly string[] EquipmentPool = new string[7] { "0_Items/ChainShooter", "0_Items/ClimbingSpike", "0_Items/Energy Drink", "0_Items/Lollipop", "0_Items/RescueHook", "0_Items/RopeShooter", "0_Items/RopeSpool" };
private static readonly string[] LuggagePool = new string[4] { "0_Items/LuggageSmall", "0_Items/LuggageBig", "0_Items/LuggageEpic", "0_Items/LuggageAncient" };
private static readonly STATUSTYPE[] RandomStatusPool;
private static void EnsureNetworking()
{
if (_netInit)
{
return;
}
try
{
if (!((Object)(object)GameUtils.instance == (Object)null))
{
if ((Object)(object)((Component)GameUtils.instance).GetComponent<GachaNet>() == (Object)null)
{
((Component)GameUtils.instance).gameObject.AddComponent<GachaNet>();
}
if ((Object)(object)GachaNet.Instance == (Object)null)
{
GachaNet.Instance = ((Component)GameUtils.instance).GetComponent<GachaNet>();
}
_netInit = true;
Plugin.Log.LogInfo((object)"[幸运罗盘] 网络组件就绪");
}
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 网络初始化异常:" + ex.Message));
}
}
public static void InitNetworking()
{
EnsureNetworking();
}
public static void TriggerSeverePunishment(Character c)
{
try
{
int num = Random.Range(0, 5);
Plugin.Log.LogInfo((object)$"[幸运罗盘] 触发最严重惩罚,类型roll={num}");
switch (num)
{
case 0:
Execute(GachaDraw.MakeEntryFromType(GachaEntryType.Tornado), c, LuckSystem.GetLuck());
break;
case 1:
ApplyAllStatusForce(c);
Notify("【厄运降临】 所有负面状态!");
break;
case 2:
AddStatusSafe(c, (STATUSTYPE)13, 0.5f);
Notify("【石化】 石化条被填充一半!");
break;
case 3:
AddStatusSafe(c, (STATUSTYPE)6, 1f);
Notify("【强制倒地】 困意如山倒,你被迫倒地!");
break;
default:
Execute(GachaDraw.MakeEntryFromType(GachaEntryType.AllBomb), c, LuckSystem.GetLuck());
break;
}
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 严重惩罚异常:" + ex.Message));
}
}
private static bool IsWorldSpawn(GachaEntryType t)
{
switch (t)
{
case GachaEntryType.GiveItem:
case GachaEntryType.RandomLoot:
case GachaEntryType.RandomItem:
case GachaEntryType.Mythic:
case GachaEntryType.Equipment:
case GachaEntryType.Luggage:
case GachaEntryType.Pandora:
case GachaEntryType.AllBomb:
case GachaEntryType.SpawnZombie:
case GachaEntryType.SpawnBees:
case GachaEntryType.SpawnDynamite:
case GachaEntryType.SpawnFrog:
case GachaEntryType.SpawnScorpion:
case GachaEntryType.TickParasite:
case GachaEntryType.SporeFog:
return true;
default:
return false;
}
}
private static bool IsSevereNegative(GachaEntryType t)
{
if ((uint)(t - 14) <= 1u || (uint)(t - 19) <= 1u || t == GachaEntryType.StatusAll)
{
return true;
}
return false;
}
public static void Execute(GachaEntry e, Character c, int luck)
{
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Expected O, but got Unknown
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: 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_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Expected O, but got Unknown
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01fc: Expected O, but got Unknown
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
try
{
EnsureNetworking();
if (IsSevereNegative(e.type))
{
Plugin.Log.LogInfo((object)"[幸运罗盘] 触发最严重负面,所有玩家幸运值+5");
GachaNet.RestoreAllLuck(5);
}
if (IsWorldSpawn(e.type))
{
if (!PhotonNetwork.IsMasterClient)
{
RequestWorldSpawn(e.type, c, e.s1, luck);
return;
}
Vector3 pos = WorldSpawnPos(c, e.type);
ExecuteWorldSpawn(e.type, pos, e.s1, luck, c);
return;
}
switch (e.type)
{
case GachaEntryType.InfiniteStamina:
c.refs.afflictions.AddAffliction((Affliction)new Affliction_InfiniteStamina(e.p1), false);
Notify("获得【无限体力】 " + e.p1 + "秒");
break;
case GachaEntryType.SpeedBuff:
c.refs.afflictions.AddAffliction((Affliction)new Affliction_FasterBoi
{
moveSpeedMod = e.p1,
climbSpeedMod = e.p2,
totalTime = 12f,
climbDelay = 1f
}, false);
Notify("获得【迅捷效果】 移速x" + e.p1 + " 攀爬x" + e.p2 + "(12秒)");
break;
case GachaEntryType.Invincibility:
c.refs.afflictions.AddAffliction((Affliction)new Affliction_Invincibility
{
totalTime = e.p1
}, false);
Notify("获得【无敌】 " + e.p1 + "秒");
break;
case GachaEntryType.LowGravity:
c.refs.afflictions.AddAffliction((Affliction)new Affliction_LowGravity((int)e.p1, e.p2), false);
Notify("获得【低重力】 档位" + (int)e.p1 + " " + e.p2 + "秒");
break;
case GachaEntryType.RestoreStatus:
RestoreStatus(c, e.p1);
Notify("【状态恢复】 恢复" + e.p1 + "点负面状态");
break;
case GachaEntryType.MoraleBoost:
c.MoraleBoost(e.p1, 1);
Notify("【士气高涨】 体力回复");
break;
case GachaEntryType.ExtraStamina:
c.AddExtraStamina(e.p1);
Notify("【额外体力】 +" + e.p1);
break;
case GachaEntryType.Bugle:
c.MoraleBoost(0.25f, 1);
RestoreStatus(c, 0.5f);
Notify("【友谊喇叭】 士气高涨 + 清除负面状态");
break;
case GachaEntryType.Tornado:
SpawnTornado(c);
break;
case GachaEntryType.Eruption:
SpawnEruption(c);
break;
case GachaEntryType.IceBlind:
AddStatusSafe(c, (STATUSTYPE)2, 0.7f);
GachaHold.ShowIceBlind(6f);
Notify("【冰雪覆盖视野】 寒气刺骨,视野被冰雪遮蔽!");
break;
case GachaEntryType.StatusPoison:
AddStatusSafe(c, (STATUSTYPE)3, 0.6f);
Notify("【中毒】 你中毒了!");
break;
case GachaEntryType.StatusSleep:
AddStatusSafe(c, (STATUSTYPE)6, 0.8f);
Notify("【瞌睡】 困意袭来!");
break;
case GachaEntryType.StatusRandom:
ApplyRandomStatus(c);
break;
case GachaEntryType.StatusAll:
ApplyAllStatusGate(c);
break;
case GachaEntryType.SteamExplode:
SteamExplode(c);
break;
case GachaEntryType.Revive:
Revive(c);
break;
case GachaEntryType.RandomLoot:
case GachaEntryType.RandomItem:
case GachaEntryType.Mythic:
case GachaEntryType.Equipment:
case GachaEntryType.Luggage:
case GachaEntryType.Pandora:
case GachaEntryType.AllBomb:
case GachaEntryType.SpawnZombie:
case GachaEntryType.SpawnBees:
case GachaEntryType.SpawnDynamite:
case GachaEntryType.SpawnFrog:
case GachaEntryType.SpawnScorpion:
case GachaEntryType.TickParasite:
case GachaEntryType.SporeFog:
case GachaEntryType.GhostBoom:
break;
}
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 效果执行异常(已拦截,不影响运行):" + ex.Message));
}
}
public static int CountByLuck(int luck)
{
if (luck >= 0)
{
return 1;
}
if (luck >= -50)
{
return 2;
}
return 3;
}
private static void RequestWorldSpawn(GachaEntryType type, Character c, string s1, int luck)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)GameUtils.instance == (Object)null)
{
Plugin.Log.LogWarning((object)"[幸运罗盘] GameUtils不可用");
return;
}
PhotonView component = ((Component)GameUtils.instance).GetComponent<PhotonView>();
if ((Object)(object)component == (Object)null)
{
Plugin.Log.LogWarning((object)"[幸运罗盘] GameUtils无PhotonView");
return;
}
Vector3 val = WorldSpawnPos(c, type);
string text = "";
switch (type)
{
case GachaEntryType.SpawnFrog:
case GachaEntryType.SpawnScorpion:
text = CountByLuck(luck).ToString();
break;
case GachaEntryType.TickParasite:
text = "TICK:" + ((MonoBehaviourPun)c).photonView.ViewID;
break;
}
component.RPC("RPCA_GachaSpawn", (RpcTarget)2, new object[6]
{
(int)type,
val.x,
val.y,
val.z,
s1 ?? "",
text
});
Plugin.Log.LogInfo((object)$"[幸运罗盘] 已请求房主生成 {type}");
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 请求房主生成失败:" + ex.Message));
}
}
private static Vector3 WorldSpawnPos(Character c, GachaEntryType type)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: 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)
float num = 2f;
if (type == GachaEntryType.SpawnZombie || type == GachaEntryType.SpawnFrog || type == GachaEntryType.SpawnScorpion)
{
num = 3f;
}
if (type == GachaEntryType.SporeFog)
{
return c.Center + Vector3.up * 0.1f;
}
return c.Center + c.data.lookDirection * num + Vector3.up * 0.3f;
}
public static void ExecuteWorldSpawn(GachaEntryType type, Vector3 pos, string s1, int luck = 0, Character requester = null)
{
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: 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_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: 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_008f: Unknown result type (might be due to invalid IL or missing references)
switch (type)
{
case GachaEntryType.SpawnZombie:
SpawnZombieAt(pos);
break;
case GachaEntryType.SpawnBees:
SpawnBeesAt(pos);
break;
case GachaEntryType.SpawnDynamite:
SpawnDynamiteAt(pos);
break;
case GachaEntryType.Pandora:
SpawnPandoraAt(pos);
break;
case GachaEntryType.AllBomb:
SpawnAllBombsAt(pos);
break;
case GachaEntryType.SporeFog:
SporeFogAt(pos, requester);
break;
case GachaEntryType.Mythic:
SpawnFromPoolAt(pos, MythicPool, "神话");
break;
case GachaEntryType.Equipment:
SpawnFromPoolAt(pos, EquipmentPool, "装备");
break;
case GachaEntryType.Luggage:
SpawnLuggageAt(pos);
break;
case GachaEntryType.GiveItem:
GiveItemAt(pos, s1);
break;
case GachaEntryType.RandomLoot:
SpawnRandomItemAt(pos, allItems: false);
break;
case GachaEntryType.RandomItem:
SpawnRandomItemAt(pos, allItems: true);
break;
case GachaEntryType.SpawnFrog:
SpawnFrogsAt(pos, ParseCount(s1, luck), requester);
break;
case GachaEntryType.SpawnScorpion:
SpawnScorpionsAt(pos, ParseCount(s1, luck), requester);
break;
case GachaEntryType.TickParasite:
AttachTick(s1, requester);
break;
}
}
private static int ParseCount(string s1, int luck)
{
if (!string.IsNullOrEmpty(s1) && int.TryParse(s1, out var result) && result > 0)
{
return result;
}
return CountByLuck(luck);
}
private static void Notify(string msg)
{
Plugin.Log.LogInfo((object)("[幸运罗盘] " + msg));
}
private static void GiveItemAt(Vector3 pos, string name)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
if (string.IsNullOrEmpty(name))
{
return;
}
try
{
PhotonNetwork.Instantiate(name.StartsWith("0_Items/") ? name : ("0_Items/" + name), pos, Quaternion.identity, (byte)0, (object[])null);
Notify("房主生成物品:" + name);
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 房主生成物品失败:" + ex.Message));
}
}
private static void SpawnRandomItemAt(Vector3 pos, bool allItems)
{
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
try
{
GameObject[] array = Resources.LoadAll<GameObject>("0_Items");
List<Item> list = new List<Item>();
GameObject[] array2 = array;
foreach (GameObject val in array2)
{
if (!((Object)(object)val == (Object)null))
{
Item component = val.GetComponent<Item>();
if (!((Object)(object)component == (Object)null) && (allItems || !((Object)(object)val.GetComponent<LootData>() == (Object)null)))
{
list.Add(component);
}
}
}
if (list.Count == 0)
{
Plugin.Log.LogWarning((object)"[幸运罗盘] 房主:无可用物品");
return;
}
Item val2 = list[Random.Range(0, list.Count)];
PhotonNetwork.Instantiate("0_Items/" + ((Object)((Component)val2).gameObject).name, pos, Quaternion.identity, (byte)0, (object[])null);
Notify(string.Format("房主生成随机物品({0}池 {1}种):", allItems ? "全部" : "掉落", list.Count) + ((Object)((Component)val2).gameObject).name);
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 房主随机物品失败:" + ex.Message));
}
}
private static void SpawnFromPoolAt(Vector3 pos, string[] pool, string display)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
try
{
string text = pool[Random.Range(0, pool.Length)];
PhotonNetwork.Instantiate(text, pos, Quaternion.identity, (byte)0, (object[])null);
Notify("房主生成" + display + "物品:" + text);
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 房主生成" + display + "失败:" + ex.Message));
}
}
private static void SpawnLuggageAt(Vector3 pos)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
try
{
string text = LuggagePool[Random.Range(0, LuggagePool.Length)];
PhotonNetwork.Instantiate(text, pos, Quaternion.identity, (byte)0, (object[])null);
Notify("房主生成【行李箱】:" + text);
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 房主行李箱失败:" + ex.Message));
}
}
private static void SpawnPandoraAt(Vector3 pos)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
try
{
GameObject val = PhotonNetwork.Instantiate("0_Items/PandorasBox", pos, Quaternion.identity, (byte)0, (object[])null);
if ((Object)(object)val != (Object)null)
{
ItemCooking component = val.GetComponent<ItemCooking>();
if ((Object)(object)component != (Object)null)
{
component.FinishCooking();
}
Notify("【潘多拉魔盒】已触发!");
}
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 房主魔盒失败:" + ex.Message));
}
}
private static void SpawnAllBombsAt(Vector3 pos)
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
try
{
string text = Plugin.cfgDynamiteName.Value;
if (string.IsNullOrEmpty(text))
{
text = "0_Items/Dynamite";
}
string text2 = (text.StartsWith("0_Items/") ? text : ("0_Items/" + text));
int num = 0;
foreach (Character allCharacter in Character.AllCharacters)
{
if ((Object)(object)allCharacter == (Object)null)
{
continue;
}
GameObject val = PhotonNetwork.Instantiate(text2, allCharacter.Center + Vector3.up * 0.5f, Quaternion.identity, (byte)0, (object[])null);
if (!((Object)(object)val == (Object)null))
{
Item component = val.GetComponent<Item>();
if ((Object)(object)component != (Object)null && (Object)(object)((MonoBehaviourPun)allCharacter).photonView != (Object)null)
{
component.RequestPickup(((MonoBehaviourPun)allCharacter).photonView);
num++;
}
}
}
Notify($"【全玩家炸弹】 强制 {num} 名玩家手持炸药!");
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 全玩家炸弹失败:" + ex.Message));
}
}
private static void SpawnZombieAt(Vector3 pos)
{
//IL_0029: 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)
string text = Plugin.cfgZombieName.Value;
if (string.IsNullOrEmpty(text))
{
text = FindZombieName();
}
if (string.IsNullOrEmpty(text))
{
text = "MushroomZombie";
}
try
{
GameObject val = PhotonNetwork.Instantiate(text, pos, Quaternion.identity, (byte)0, (object[])null);
if (!((Object)(object)val == (Object)null))
{
MushroomZombie component = val.GetComponent<MushroomZombie>();
if ((Object)(object)component != (Object)null)
{
component.zombieSprintDistance = 15f;
component.zombieLungeDistance = 3f;
component.lungeRecoveryTime = 1f;
component.lifetime = 45f;
component.currentState = (State)0;
}
Notify("生成【僵尸】!");
}
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 房主僵尸失败:" + ex.Message));
}
}
private static void SpawnBeesAt(Vector3 pos)
{
//IL_0043: 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)
string text = Plugin.cfgBeeName.Value;
if (string.IsNullOrEmpty(text))
{
text = FindBeeName();
}
if (string.IsNullOrEmpty(text))
{
text = "0_Items/BeeSwarm";
}
try
{
PhotonNetwork.Instantiate(text.StartsWith("0_Items/") ? text : ("0_Items/" + text), pos, Quaternion.identity, (byte)0, (object[])null);
Notify("生成【蜜蜂群】!");
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 房主蜜蜂失败:" + ex.Message));
}
}
private static void SpawnDynamiteAt(Vector3 pos)
{
//IL_0036: 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)
string text = Plugin.cfgDynamiteName.Value;
if (string.IsNullOrEmpty(text))
{
text = "0_Items/Dynamite";
}
string text2 = (text.StartsWith("0_Items/") ? text : ("0_Items/" + text));
try
{
PhotonNetwork.Instantiate(text2, pos, Quaternion.identity, (byte)0, (object[])null);
Notify("面前生成【炸药】!小心:靠近会被点燃爆炸");
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 房主炸药失败:" + ex.Message));
}
}
private static void SpawnFrogsAt(Vector3 pos, int count, Character requester)
{
//IL_0039: 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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
string text = Plugin.cfgFrogName.Value;
if (string.IsNullOrEmpty(text))
{
text = "Frog";
}
string text2 = (text.StartsWith("0_Items/") ? text : ("0_Items/" + text));
try
{
for (int i = 0; i < count; i++)
{
Vector3 val = pos + new Vector3(Random.Range(-1f, 1f), 0.5f, Random.Range(-1f, 1f));
PhotonNetwork.Instantiate(text2, val, Quaternion.identity, (byte)0, (object[])null);
}
Notify($"生成【青蛙】x{count}!");
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 房主青蛙失败:" + ex.Message));
FallbackNegative(requester, "青蛙");
}
}
private static void SpawnScorpionsAt(Vector3 pos, int count, Character requester)
{
//IL_0039: 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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
string text = Plugin.cfgScorpionName.Value;
if (string.IsNullOrEmpty(text))
{
text = "0_Items/Scorpion";
}
string text2 = (text.StartsWith("0_Items/") ? text : ("0_Items/" + text));
try
{
for (int i = 0; i < count; i++)
{
Vector3 val = pos + new Vector3(Random.Range(-1f, 1f), 0.5f, Random.Range(-1f, 1f));
PhotonNetwork.Instantiate(text2, val, Quaternion.identity, (byte)0, (object[])null);
}
Notify($"生成【蝎子】x{count}!");
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 房主蝎子失败:" + ex.Message));
FallbackNegative(requester, "蝎子");
}
}
private static void AttachTick(string s1, Character requester)
{
//IL_0059: 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)
try
{
string text = Plugin.cfgTickName.Value;
if (string.IsNullOrEmpty(text))
{
text = "BugfixOnYou";
}
int result = -1;
if (!string.IsNullOrEmpty(s1) && s1.StartsWith("TICK:"))
{
int.TryParse(s1.Substring(5), out result);
}
if (result <= 0 && (Object)(object)requester != (Object)null)
{
result = ((MonoBehaviourPun)requester).photonView.ViewID;
}
GameObject val = PhotonNetwork.Instantiate(text, Vector3.zero, Quaternion.identity, (byte)0, (object[])null);
if ((Object)(object)val == (Object)null)
{
Plugin.Log.LogWarning((object)"[幸运罗盘] 房主:蜱虫生成失败");
return;
}
Bugfix component = val.GetComponent<Bugfix>();
if ((Object)(object)component != (Object)null && result > 0)
{
component.AttachBug(result);
Notify("【蜱虫寄生】 一只蜱虫寄生在抽取者身上!");
}
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 蜱虫失败:" + ex.Message));
}
}
private static void SporeFogAt(Vector3 pos, Character requester)
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
string text = Plugin.cfgSporeFogName.Value;
if (string.IsNullOrEmpty(text))
{
text = FindKeywordPrefab(new string[3] { "Spore", "Fungus", "Cloud" });
}
if (string.IsNullOrEmpty(text))
{
text = "0_Items/CloudFungus";
}
try
{
PhotonNetwork.Instantiate(text.StartsWith("0_Items/") ? text : ("0_Items/" + text), pos, Quaternion.identity, (byte)0, (object[])null);
foreach (Character allCharacter in Character.AllCharacters)
{
if (!((Object)(object)allCharacter == (Object)null))
{
AddStatusSafe(allCharacter, (STATUSTYPE)10, 0.5f);
AddStatusSafe(allCharacter, (STATUSTYPE)3, 0.3f);
}
}
Notify("【孢子云】 脚下爆开爆炸/毒气孢子!");
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 房主孢子云失败:" + ex.Message));
FallbackNegative(requester, "孢子云");
}
}
private static void TrySpawnPrefabAt(string name, Vector3 pos, string display, Character requester)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)PhotonNetwork.Instantiate(name.StartsWith("0_Items/") ? name : ("0_Items/" + name), pos, Quaternion.identity, (byte)0, (object[])null) == (Object)null)
{
FallbackNegative(requester, display);
}
else
{
Notify("生成【" + display + "】!");
}
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 房主生成" + display + "失败:" + ex.Message));
FallbackNegative(requester, display);
}
}
private static void FallbackNegative(Character target, string effectName)
{
if ((Object)(object)target != (Object)null)
{
AddStatusSafe(target, (STATUSTYPE)3, 0.6f);
AddStatusSafe(target, (STATUSTYPE)6, 0.8f);
Notify("【" + effectName + "生成失败】 转为中毒+瞌睡惩罚!");
}
else
{
Notify("【" + effectName + "生成失败】 无法定位目标玩家");
}
}
private static void SpawnTornado(Character c)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
try
{
float value = Plugin.cfgTornadoDelay.Value;
Vector3 fixedPos = c.Center;
GachaHold.ShowWarning("警告:龙卷风即将来袭!", value + 1f);
Plugin.Log.LogInfo((object)$"[幸运罗盘] 抽中龙卷风!{value}秒后生成于固定位置 {fixedPos}");
if (PhotonNetwork.IsMasterClient)
{
GachaNet.ShowAllWarning("警告:龙卷风即将来袭!", value + 1f);
Plugin.RunDelayed(value, delegate
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
SpawnTornadoAt(fixedPos);
});
}
else
{
GachaNet.RequestTornado(fixedPos);
}
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 龙卷风异常:" + ex.Message));
}
}
public static void SpawnTornadoAt(Vector3 pos)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
try
{
GameObject val = PhotonNetwork.Instantiate("Tornado", pos, Quaternion.identity, (byte)0, (object[])null);
if ((Object)(object)val == (Object)null)
{
Plugin.Log.LogWarning((object)"[幸运罗盘] 房主:龙卷风生成失败");
return;
}
Tornado component = val.GetComponent<Tornado>();
if ((Object)(object)component != (Object)null)
{
component.tornadoLifetimeMax = 20f;
component.tornadoLifetimeMin = 15f;
component.force = 20f;
}
Notify("【龙卷风】生成!");
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 房主龙卷风失败:" + ex.Message));
}
}
private static void SpawnEruption(Character c)
{
try
{
float value = Plugin.cfgEruptionDelay.Value;
GachaHold.ShowWarning("警告:火山喷发即将爆发!", value + 1f);
Plugin.Log.LogInfo((object)$"[幸运罗盘] 抽中火山喷发!{value}秒后爆发,快逃!");
Plugin.RunDelayed(value, delegate
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
EruptionSpawner val = Object.FindObjectOfType<EruptionSpawner>();
if ((Object)(object)val == (Object)null)
{
AddStatusSafe(c, (STATUSTYPE)8, 0.5f);
Notify("【火山喷发】 当前区域无火山生成器,施加过热状态");
}
else
{
PhotonView component = ((Component)val).GetComponent<PhotonView>();
if ((Object)(object)component != (Object)null)
{
component.RPC("RPCA_SpawnEruption", (RpcTarget)0, new object[1] { c.Center });
Notify("【火山喷发】岩浆涌出!");
}
}
});
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 火山喷发异常:" + ex.Message));
}
}
private unsafe static void AddStatusSafe(Character target, STATUSTYPE type, float amount)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
try
{
if (!((Object)(object)target == (Object)null) && target.refs != null && !((Object)(object)target.refs.afflictions == (Object)null))
{
target.refs.afflictions.AddStatus(type, amount, false, true, true);
}
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 加状态失败(" + ((object)(*(STATUSTYPE*)(&type))/*cast due to .constrained prefix*/).ToString() + "):" + ex.Message));
}
}
private static void ApplyAllStatusForce(Character c)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
STATUSTYPE[] randomStatusPool = RandomStatusPool;
foreach (STATUSTYPE type in randomStatusPool)
{
foreach (Character allCharacter in Character.AllCharacters)
{
if ((Object)(object)allCharacter != (Object)null)
{
AddStatusSafe(allCharacter, type, 0.6f);
}
}
}
}
private unsafe static void ApplyRandomStatus(Character c)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
STATUSTYPE type = RandomStatusPool[Random.Range(0, RandomStatusPool.Length)];
AddStatusSafe(c, type, 0.5f);
Notify("【随机负面状态】 " + ((object)(*(STATUSTYPE*)(&type))/*cast due to .constrained prefix*/).ToString());
}
private static void ApplyAllStatusGate(Character c)
{
if (Random.value < Plugin.cfgStatusAllChance.Value)
{
Plugin.Log.LogInfo((object)"[幸运罗盘] 触发【全部负面状态】!!");
ApplyAllStatusForce(c);
Notify("【厄运降临】 所有负面状态!");
}
else
{
ApplyRandomStatus(c);
}
}
private static void SteamExplode(Character c)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: 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_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
try
{
Rigidbody val = (((Object)(object)c.refs.hip != (Object)null) ? c.refs.hip.Rig : null);
if ((Object)(object)val != (Object)null)
{
Vector3 val2 = ((Vector3)(ref c.data.lookDirection)).normalized * 10f + Vector3.up * 7f;
c.AddForceToBodyPart(val, val2, val2);
Notify("【蒸气爆炸】 你被炸飞了!");
}
else
{
Notify("【蒸气爆炸】 爆炸冲击!");
}
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 蒸气爆炸弹飞失败:" + ex.Message));
}
}
private static void RestoreStatus(Character c, float amount)
{
CharacterAfflictions afflictions = c.refs.afflictions;
afflictions.SubtractStatus((STATUSTYPE)1, amount, false, false);
afflictions.SubtractStatus((STATUSTYPE)0, amount, false, false);
afflictions.SubtractStatus((STATUSTYPE)3, amount, false, false);
afflictions.SubtractStatus((STATUSTYPE)2, amount, false, false);
afflictions.SubtractStatus((STATUSTYPE)6, amount, false, false);
afflictions.SubtractStatus((STATUSTYPE)10, amount, false, false);
}
private static string FindKeywordPrefab(string[] keywords)
{
try
{
GameObject[] array = Resources.LoadAll<GameObject>("0_Items");
foreach (GameObject val in array)
{
if ((Object)(object)val == (Object)null)
{
continue;
}
string name = ((Object)val).name;
foreach (string value in keywords)
{
if (name.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0)
{
return name;
}
}
}
}
catch
{
}
return null;
}
private static string FindZombieName()
{
try
{
MushroomZombieSpawner[] array = Object.FindObjectsOfType<MushroomZombieSpawner>();
foreach (MushroomZombieSpawner val in array)
{
if ((Object)(object)val != (Object)null && (Object)(object)val.mushroomZombiePrefab != (Object)null)
{
return ((Object)((Component)val.mushroomZombiePrefab).gameObject).name;
}
}
if ((Object)(object)ZombieManager.Instance != (Object)null && ZombieManager.Instance.spawners != null)
{
foreach (MushroomZombieSpawner spawner in ZombieManager.Instance.spawners)
{
if ((Object)(object)spawner != (Object)null && (Object)(object)spawner.mushroomZombiePrefab != (Object)null)
{
return ((Object)((Component)spawner.mushroomZombiePrefab).gameObject).name;
}
}
}
MushroomZombie[] array2 = Object.FindObjectsOfType<MushroomZombie>();
foreach (MushroomZombie val2 in array2)
{
if ((Object)(object)val2 != (Object)null)
{
return ((Object)((Component)val2).gameObject).name;
}
}
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 探测僵尸名异常:" + ex.Message));
}
return null;
}
private static string FindBeeName()
{
try
{
foreach (Beehive aLL_BEEHIVE in Beehive.ALL_BEEHIVES)
{
if ((Object)(object)aLL_BEEHIVE != (Object)null && (Object)(object)aLL_BEEHIVE.beeSwarmPrefab != (Object)null)
{
return ((Object)((Component)aLL_BEEHIVE.beeSwarmPrefab).gameObject).name;
}
}
Beehive[] array = Object.FindObjectsOfType<Beehive>();
foreach (Beehive val in array)
{
if ((Object)(object)val != (Object)null && (Object)(object)val.beeSwarmPrefab != (Object)null)
{
return ((Object)((Component)val.beeSwarmPrefab).gameObject).name;
}
}
BeeSwarm[] array2 = Object.FindObjectsOfType<BeeSwarm>();
foreach (BeeSwarm val2 in array2)
{
if ((Object)(object)val2 != (Object)null)
{
return ((Object)((Component)val2).gameObject).name;
}
}
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 探测蜜蜂名异常:" + ex.Message));
}
return null;
}
private static void Revive(Character c)
{
//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_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: 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_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.cfgStatueModeA.Value)
{
if (PhotonNetwork.IsMasterClient)
{
try
{
Vector3 val = c.Center + c.data.lookDirection * 2f + Vector3.up * 0.3f;
PhotonNetwork.Instantiate("0_Items/ScoutEffigy", val, Quaternion.identity, (byte)0, (object[])null);
Notify("面前生成【童军雕像】(ScoutEffigy)");
return;
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 生成童军雕像失败:" + ex.Message));
return;
}
}
RequestWorldSpawn(GachaEntryType.Mythic, c, "", LuckSystem.GetLuck());
return;
}
int num = 0;
foreach (Character allCharacter in Character.AllCharacters)
{
if (!((Object)(object)allCharacter == (Object)null) && !((Object)(object)allCharacter.data == (Object)null) && (allCharacter.data.dead || allCharacter.data.fullyPassedOut))
{
((MonoBehaviourPun)allCharacter).photonView.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[3]
{
allCharacter.Center + Vector3.up,
true,
-1
});
num++;
}
}
Notify((num > 0) ? $"【复活】 共复活 {num} 名玩家" : "【复活】 当前无待复活玩家");
}
static GachaExecutor()
{
STATUSTYPE[] array = new STATUSTYPE[8];
RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
RandomStatusPool = (STATUSTYPE[])(object)array;
}
}
public class GachaNet : MonoBehaviourPunCallbacks
{
public static GachaNet Instance;
private static bool _compassGivenThisRun;
private static int _compassRetryCount;
private void Awake()
{
Instance = this;
}
private void OnDestroy()
{
if ((Object)(object)Instance == (Object)(object)this)
{
Instance = null;
}
}
[PunRPC]
public void RPCA_GachaSpawn(int type, float x, float y, float z, string s1, string extra)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
try
{
if (!PhotonNetwork.IsMasterClient)
{
return;
}
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(x, y, z);
Plugin.Log.LogInfo((object)$"[幸运罗盘] 房主执行生成:{(GachaEntryType)type} @ {val} extra={extra}");
Character requester = null;
if (!string.IsNullOrEmpty(extra) && extra.StartsWith("TICK:"))
{
if (int.TryParse(extra.Substring(5), out var result))
{
PhotonView photonView = PhotonNetwork.GetPhotonView(result);
if ((Object)(object)photonView != (Object)null)
{
requester = ((Component)photonView).GetComponent<Character>();
}
}
extra = "";
}
GachaExecutor.ExecuteWorldSpawn((GachaEntryType)type, val, s1, 0, requester);
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 房主RPC生成异常:" + ex.ToString()));
}
}
[PunRPC]
public void RPCA_GachaTornado(float x, float y, float z)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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)
try
{
if (PhotonNetwork.IsMasterClient)
{
Vector3 pos = new Vector3(x, y, z);
float value = Plugin.cfgTornadoDelay.Value;
Plugin.Log.LogInfo((object)$"[幸运罗盘] 房主收到龙卷风请求,固定位置 {pos},广播警告");
ShowAllWarning("警告:龙卷风即将来袭!", value + 1f);
Plugin.RunDelayed(value, delegate
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
GachaExecutor.SpawnTornadoAt(pos);
});
}
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 房主龙卷风请求异常:" + ex.Message));
}
}
[PunRPC]
public void RPCA_GiveCompass()
{
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
try
{
if (!PhotonNetwork.IsMasterClient || _compassGivenThisRun)
{
return;
}
_compassGivenThisRun = true;
HashSet<int> hashSet = new HashSet<int>();
foreach (Character allCharacter in Character.AllCharacters)
{
if ((Object)(object)allCharacter == (Object)null || (Object)(object)((MonoBehaviourPun)allCharacter).photonView == (Object)null || ((MonoBehaviourPun)allCharacter).photonView.Owner == null)
{
continue;
}
int actorNumber = ((MonoBehaviourPun)allCharacter).photonView.Owner.ActorNumber;
if (hashSet.Add(actorNumber))
{
GameObject val = PhotonNetwork.Instantiate("0_Items/Compass", allCharacter.Center + Vector3.up * 0.5f, Quaternion.identity, (byte)0, (object[])null);
Item val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<Item>() : null);
if ((Object)(object)val2 != (Object)null)
{
val2.RequestPickup(((MonoBehaviourPun)allCharacter).photonView);
}
}
}
Plugin.Log.LogInfo((object)$"[幸运罗盘] 房主已给 {hashSet.Count} 名玩家发放罗盘");
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 发放罗盘失败:" + ex.Message));
}
}
public static void ResetCompassFlag()
{
_compassGivenThisRun = false;
}
public static void GiveCompassToAll()
{
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)Instance == (Object)null)
{
GachaExecutor.InitNetworking();
int num = ++_compassRetryCount;
Plugin.Log.LogInfo((object)$"[幸运罗盘] 网络组件未就绪,将重试({num}/3)");
if (num < 3)
{
Plugin.RunDelayed(2f, GiveCompassToAll);
}
else
{
_compassRetryCount = 0;
}
return;
}
_compassRetryCount = 0;
if (PhotonNetwork.InRoom && (Object)(object)((MonoBehaviourPun)Instance).photonView != (Object)null)
{
((MonoBehaviourPun)Instance).photonView.RPC("RPCA_GiveCompass", (RpcTarget)2, Array.Empty<object>());
}
else if ((Object)(object)Character.localCharacter != (Object)null)
{
GameObject val = PhotonNetwork.Instantiate("0_Items/Compass", Character.localCharacter.Center + Vector3.up * 0.5f, Quaternion.identity, (byte)0, (object[])null);
Item val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<Item>() : null);
if ((Object)(object)val2 != (Object)null && (Object)(object)((MonoBehaviourPun)Character.localCharacter).photonView != (Object)null)
{
val2.RequestPickup(((MonoBehaviourPun)Character.localCharacter).photonView);
}
}
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 发放罗盘异常:" + ex.Message));
}
}
[PunRPC]
public void RPCA_ShowWarning(string text, float seconds)
{
GachaHold.ShowWarning(text, seconds);
}
[PunRPC]
public void RPCA_SyncLuck(int actor, int luck)
{
}
[PunRPC]
public void RPCA_RestoreLuck(int amount)
{
LuckSystem.AddLuck(amount);
}
public static void BroadcastLuck()
{
if (!((Object)(object)Instance == (Object)null))
{
int num = ((PhotonNetwork.LocalPlayer != null) ? PhotonNetwork.LocalPlayer.ActorNumber : (-1));
int luck = LuckSystem.GetLuck();
if (PhotonNetwork.InRoom && (Object)(object)((MonoBehaviourPun)Instance).photonView != (Object)null)
{
((MonoBehaviourPun)Instance).photonView.RPC("RPCA_SyncLuck", (RpcTarget)0, new object[2] { num, luck });
}
}
}
public static void RestoreAllLuck(int amount)
{
if ((Object)(object)Instance == (Object)null)
{
LuckSystem.AddLuck(amount);
}
else if (PhotonNetwork.InRoom && (Object)(object)((MonoBehaviourPun)Instance).photonView != (Object)null)
{
((MonoBehaviourPun)Instance).photonView.RPC("RPCA_RestoreLuck", (RpcTarget)0, new object[1] { amount });
}
else
{
LuckSystem.AddLuck(amount);
}
}
public static void ShowAllWarning(string text, float seconds)
{
if ((Object)(object)Instance == (Object)null)
{
GachaHold.ShowWarning(text, seconds);
}
else if (PhotonNetwork.InRoom && (Object)(object)((MonoBehaviourPun)Instance).photonView != (Object)null)
{
((MonoBehaviourPun)Instance).photonView.RPC("RPCA_ShowWarning", (RpcTarget)0, new object[2] { text, seconds });
}
else
{
GachaHold.ShowWarning(text, seconds);
}
}
public static void RequestTornado(Vector3 pos)
{
//IL_006d: 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)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)Instance == (Object)null))
{
if (PhotonNetwork.InRoom && (Object)(object)((MonoBehaviourPun)Instance).photonView != (Object)null)
{
((MonoBehaviourPun)Instance).photonView.RPC("RPCA_GachaTornado", (RpcTarget)2, new object[3] { pos.x, pos.y, pos.z });
}
else
{
GachaExecutor.SpawnTornadoAt(pos);
}
}
}
}
public class GachaHold : MonoBehaviour
{
internal static bool Charging;
internal static string warningText = "";
internal static float warningTimeLeft = 0f;
internal static float iceBlindTimeLeft = 0f;
private int _lastWindow = -1;
private int _minuteDrawCount;
private bool _rejected;
private float _hold;
private bool _started;
private static GUIStyle _warningStyle;
private static GUIStyle _luckStyle;
private static GUIStyle _barStyle;
private static GUIStyle _textStyle;
private void Start()
{
SceneManager.sceneLoaded += OnSceneLoaded;
}
private void OnDestroy()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
try
{
if (((Scene)(ref scene)).name.StartsWith("Level"))
{
Plugin.Log.LogInfo((object)("[幸运罗盘] 进入游戏地图 " + ((Scene)(ref scene)).name + ",本局幸运值重置为 100/100"));
LuckSystem.ResetForNewRun();
ResetMinuteCounter();
GachaNet.ResetCompassFlag();
Plugin.RunDelayed(3f, GachaNet.GiveCompassToAll);
}
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] 场景切换处理异常(已拦截):" + ex.Message));
}
}
private void ResetMinuteCounter()
{
_lastWindow = -1;
_minuteDrawCount = 0;
_rejected = false;
}
private int CurrentWindow()
{
return Mathf.FloorToInt(Time.time / 60f);
}
private void CheckMinuteRefresh()
{
int num = CurrentWindow();
if (num != _lastWindow)
{
_lastWindow = num;
_minuteDrawCount = 0;
_rejected = false;
Plugin.Log.LogInfo((object)$"[幸运罗盘] 进入新的60秒窗口(#{num}),抽奖计数已刷新");
}
}
private void Update()
{
try
{
if (Input.GetKeyDown((KeyCode)290))
{
DebugDumpHeldItem();
}
if (Input.GetKeyDown((KeyCode)291))
{
LuckSystem.ResetForNewRun();
}
if (Input.GetKeyDown((KeyCode)292))
{
DebugListCreaturePrefabs();
}
LuckSystem.TickRegen();
CheckMinuteRefresh();
Character localCharacter = Character.localCharacter;
if ((Object)(object)localCharacter == (Object)null || (Object)(object)localCharacter.data == (Object)null || localCharacter.refs == null)
{
ResetHold();
return;
}
if (LoadingScreenHandler.loading || GUIManager.InPauseMenu)
{
ResetHold();
return;
}
Item currentItem = localCharacter.data.currentItem;
if (!((Object)(object)currentItem != (Object)null) || !IsGachaItem(currentItem))
{
ResetHold();
}
else if (localCharacter.data.dead || localCharacter.data.fullyPassedOut)
{
ResetHold();
}
else if (localCharacter.input.interactIsPressed)
{
_hold += Time.deltaTime;
_started = true;
Charging = true;
if (_hold >= Plugin.cfgHoldTime.Value)
{
_hold = 0f;
_started = false;
Charging = false;
TriggerDraw(localCharacter, currentItem);
}
}
else
{
ResetHold();
}
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] Update异常(已拦截):" + ex.Message));
ResetHold();
}
}
private void ResetHold()
{
_hold = 0f;
_started = false;
Charging = false;
}
private static bool IsGachaItem(Item it)
{
try
{
if ((Object)(object)it == (Object)null)
{
return false;
}
string text = ((Object)((Component)it).gameObject).name;
if (text.EndsWith("(Clone)"))
{
text = text.Substring(0, text.Length - 7);
}
if (text.StartsWith("Compass"))
{
return true;
}
if (it.itemID == 23)
{
return true;
}
return false;
}
catch
{
return false;
}
}
internal static void ShowWarning(string text, float seconds)
{
warningText = text;
warningTimeLeft = Mathf.Max(warningTimeLeft, seconds);
}
internal static void ShowIceBlind(float seconds)
{
iceBlindTimeLeft = Mathf.Max(iceBlindTimeLeft, seconds);
}
private void TriggerDraw(Character c, Item held)
{
CheckMinuteRefresh();
if (_rejected)
{
ShowWarning("罗盘拒绝了你!", 2f);
Plugin.Log.LogWarning((object)"[幸运罗盘] 本60秒窗口抽奖次数已用尽,罗盘拒绝(等待窗口刷新)");
return;
}
_minuteDrawCount++;
if (_minuteDrawCount == 5)
{
Plugin.Log.LogWarning((object)"[幸运罗盘] 本分钟已抽5次,触发最严重惩罚!");
ShowWarning("罗盘警告:滥用抽奖,触发最严重惩罚!", 3f);
GachaExecutor.TriggerSeverePunishment(c);
return;
}
if (_minuteDrawCount >= 10)
{
Plugin.Log.LogWarning((object)"[幸运罗盘] 本60秒窗口已抽10次,达到上限!");
ShowWarning("罗盘拒绝了你!", 3f);
_rejected = true;
return;
}
int luck = LuckSystem.GetLuck();
Plugin.Log.LogInfo((object)$"[幸运罗盘] 抽取触发!当前幸运值 {luck}/100(本分钟第{_minuteDrawCount}次)");
GachaEntry gachaEntry = GachaDraw.Draw(luck, c);
if (gachaEntry != null)
{
Plugin.Log.LogInfo((object)$"[幸运罗盘] 抽中 [{gachaEntry.id}] 类型 {gachaEntry.type}");
GachaExecutor.Execute(gachaEntry, c, luck);
LuckSystem.ApplyDrawPenalty(gachaEntry.type);
Plugin.Log.LogInfo((object)$"[幸运罗盘] 抽中[{gachaEntry.id}]({gachaEntry.type}) 扣幸运后当前值 {LuckSystem.GetLuck()}/100");
}
else
{
Plugin.Log.LogWarning((object)"[幸运罗盘] 本次未抽中任何条目(奖池可能为空)");
}
}
private void DebugListCreaturePrefabs()
{
try
{
string[] array = new string[16]
{
"Ghost", "Wraith", "Phantom", "Spirit", "Banshee", "Boom", "Spore", "Fungus", "Cloud", "Mushroom",
"Frog", "Scorpion", "Bugfix", "Tick", "Eruption", "Tornado"
};
Plugin.Log.LogInfo((object)"[幸运罗盘][F11] 开始列出含关键字的prefab名...");
GameObject[] array2 = Resources.LoadAll<GameObject>("0_Items");
foreach (GameObject val in array2)
{
if ((Object)(object)val == (Object)null)
{
continue;
}
string[] array3 = array;
foreach (string value in array3)
{
if (((Object)val).name.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0)
{
Plugin.Log.LogInfo((object)("[幸运罗盘][F11] 找到: " + ((Object)val).name));
break;
}
}
}
Plugin.Log.LogInfo((object)"[幸运罗盘][F11] 列出完毕。");
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] F11异常:" + ex.Message));
}
}
private void DebugDumpHeldItem()
{
try
{
Character localCharacter = Character.localCharacter;
if ((Object)(object)localCharacter == (Object)null || (Object)(object)localCharacter.data == (Object)null || (Object)(object)localCharacter.data.currentItem == (Object)null)
{
Plugin.Log.LogInfo((object)"[幸运罗盘][F9] 当前没有手持物品");
return;
}
Item currentItem = localCharacter.data.currentItem;
string text = "";
Component[] components = ((Component)currentItem).GetComponents<Component>();
foreach (Component val in components)
{
text = text + ((object)val).GetType().Name + ", ";
}
Plugin.Log.LogInfo((object)$"[幸运罗盘][F9] 物品名={((Object)((Component)currentItem).gameObject).name} itemID={currentItem.itemID} 组件=[{text}]");
Plugin.Log.LogInfo((object)$"[幸运罗盘][F9] 是否指南针(CompassPointer)={(Object)(object)((Component)currentItem).GetComponent<CompassPointer>() != (Object)null}");
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("[幸运罗盘] F9调试异常:" + ex.Message));
}
}
private void OnGUI()
{
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: 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_0278: 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_02b4: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
try
{
if (warningTimeLeft > 0f && !string.IsNullOrEmpty(warningText))
{
float num = 700f;
float num2 = ((float)Screen.width - num) * 0.5f;
float num3 = (float)Screen.height * 0.35f;
GUI.Label(new Rect(num2, num3, num, 60f), warningText, WarningStyle());
warningTimeLeft -= Time.deltaTime;
}
if (iceBlindTimeLeft > 0f)
{
GUI.color = new Color(1f, 1f, 1f, Mathf.Clamp01(iceBlindTimeLeft / 2f) * 0.6f);
GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)MakeTex(Color.white));
GUI.color = Color.white;
iceBlindTimeLeft -= Time.deltaTime;
}
if (Plugin.cfgShowLuckUI.Value)
{
float num4 = (float)Screen.height * 0.8f;
int minuteDrawCount = _minuteDrawCount;
bool flag = minuteDrawCount == 5 || minuteDrawCount >= 10;
float num5 = 60f - Time.time % 60f;
bool rejected = _rejected;
GUI.color = (Color)((flag || rejected) ? new Color(1f, 0.2f, 0.2f) : Color.white);
GUI.Label(new Rect(10f, num4 - 22f, 420f, 20f), string.Format("本窗口抽取: {0} / 10 刷新: {1}秒 {2}", minuteDrawCount, Mathf.CeilToInt(num5), rejected ? "罗盘拒绝中" : (flag ? "警告" : "正常")), LuckStyle());
GUI.color = Color.white;
GUI.Label(new Rect(10f, num4, 300f, 20f), "幸运值: " + LuckSystem.GetLuck(), LuckStyle());
}
}
catch
{
}
if (!_started || !Charging)
{
return;
}
try
{
float num6 = Mathf.Clamp01(_hold / Mathf.Max(0.01f, Plugin.cfgHoldTime.Value));
float num7 = 300f;
float num8 = 14f;
float num9 = ((float)Screen.width - num7) * 0.5f;
float num10 = (float)Screen.height * 0.72f;
GUI.Box(new Rect(num9 - 2f, num10 - 2f, num7 + 4f, num8 + 4f), "");
GUI.Box(new Rect(num9, num10, num7 * num6, num8), "", BarStyle());
GUI.Label(new Rect(num9, num10 - 22f, num7, 20f), "幸运罗盘抽取中…", TextStyle());
}
catch
{
}
}
private static GUIStyle WarningStyle()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
if (_warningStyle == null)
{
_warningStyle = new GUIStyle();
_warningStyle.fontSize = 42;
_warningStyle.normal.textColor = new Color(1f, 0.25f, 0.1f);
}
return _warningStyle;
}
private static GUIStyle LuckStyle()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
if (_luckStyle == null)
{
_luckStyle = new GUIStyle();
_luckStyle.fontSize = 16;
_luckStyle.normal.textColor = Color.white;
}
return _luckStyle;
}
private static GUIStyle BarStyle()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
if (_barStyle == null)
{
_barStyle = new GUIStyle();
_barStyle.normal.background = MakeTex(new Color(0.2f, 0.9f, 0.3f, 0.9f));
}
return _barStyle;
}
private static GUIStyle TextStyle()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
if (_textStyle == null)
{
_textStyle = new GUIStyle(GUI.skin.label);
_textStyle.fontSize = 18;
_textStyle.normal.textColor = Color.white;
}
return _textStyle;
}
private static Texture2D MakeTex(Color c)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(2, 2);
for (int i = 0; i < ((Texture)val).width; i++)
{
for (int j = 0; j < ((Texture)val).height; j++)
{
val.SetPixel(i, j, c);
}
}
val.Apply();
return val;
}
}
[HarmonyPatch(typeof(Interaction))]
public static class InteractionPatch
{
[HarmonyPatch("LateUpdate")]
[HarmonyPrefix]
private static bool Prefix()
{
return !GachaHold.Charging;
}
}
public static class LuckSystem
{
public const int LUCK_MAX = 100;
public const int LUCK_MIN = -100;
private static int _luck = 100;
private static float _regenTimer = 0f;
private static float _negTimer = 0f;
public static int GetLuck()
{
return _luck;
}
public static void ResetForNewRun()
{
_luck = 100;
_regenTimer = 0f;
_negTimer = 0f;
GachaNet.BroadcastLuck();
}
public static void AddLuck(int delta)
{
_luck = Mathf.Clamp(_luck + delta, -100, 100);
GachaNet.BroadcastLuck();
}
public static void ApplyDrawPenalty(GachaEntryType t)
{
switch (t)
{
case GachaEntryType.Mythic:
AddLuck(-Plugin.cfgMythicPenalty.Value);
break;
case GachaEntryType.Equipment:
case GachaEntryType.Luggage:
AddLuck(-Plugin.cfgEpicPenalty.Value);
break;
default:
AddLuck(-1);
break;
}
}
public static void TickRegen()
{
if (Plugin.cfgLuckRegenSeconds.Value > 0f)
{
_regenTimer += Time.deltaTime;
if (_regenTimer >= Plugin.cfgLuckRegenSeconds.Value)
{
_regenTimer = 0f;
if (_luck < 100)
{
AddLuck(1);
}
}
}
if (_luck < 0)
{
_negTimer += Time.deltaTime;
if (_negTimer >= 15f)
{
_negTimer = 0f;
AddLuck(2);
}
}
}
}
[BepInPlugin("com.scout.gachamod", "PEAK幸运罗盘抽奖模组", "2.1.0")]
public class Plugin : BaseUnityPlugin
{
internal static Plugin Instance;
internal static ManualLogSource Log;
internal static ConfigEntry<float> cfgHoldTime;
internal static ConfigEntry<bool> cfgSuppressInteract;
internal static ConfigEntry<float> cfgLuckRegenSeconds;
internal static ConfigEntry<int> cfgMythicPenalty;
internal static ConfigEntry<int> cfgEpicPenalty;
internal static ConfigEntry<bool> cfgShowLuckUI;
internal static ConfigEntry<string> cfgPool1;
internal static ConfigEntry<float> cfgPool1Weight;
internal static ConfigEntry<string> cfgPool2;
internal static ConfigEntry<float> cfgPool2Weight;
internal static ConfigEntry<string> cfgPool3;
internal static ConfigEntry<float> cfgPool3Weight;
internal static ConfigEntry<bool> cfgStatueModeA;
internal static ConfigEntry<string> cfgZombieName;
internal static ConfigEntry<string> cfgBeeName;
internal static ConfigEntry<string> cfgDynamiteName;
internal static ConfigEntry<string> cfgSporeFogName;
internal static ConfigEntry<string> cfgGhostName;
internal static ConfigEntry<string> cfgFrogName;
internal static ConfigEntry<string> cfgScorpionName;
internal static ConfigEntry<string> cfgTickName;
internal static ConfigEntry<float> cfgTornadoDelay;
internal static ConfigEntry<float> cfgEruptionDelay;
internal static ConfigEntry<float> cfgStatusAllChance;
internal static ConfigEntry<float> cfgFatigueWindow;
internal static ConfigEntry<int> cfgFatigueLimit;
internal static ConfigEntry<string> cfgFatiguePunishment;
private void Awake()
{
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
LoadConfig();
Harmony.CreateAndPatchAll(typeof(InteractionPatch), (string)null);
((Component)this).gameObject.AddComponent<GachaHold>();
GachaExecutor.InitNetworking();
Log.LogInfo((object)"[幸运罗盘] 模组 v2.1 已加载。开局幸运值固定100。F9=物品信息 F10=重置幸运值 F11=列出prefab名。");
}
internal static void RunDelayed(float seconds, Action action)
{
if (!((Object)(object)Instance == (Object)null))
{
((MonoBehaviour)Instance).StartCoroutine(DelayedRoutine(seconds, action));
}
}
private static IEnumerator DelayedRoutine(float seconds, Action action)
{
yield return (object)new WaitForSeconds(seconds);
try
{
action();
}
catch (Exception ex)
{
Log.LogWarning((object)("[幸运罗盘] 延迟动作异常(已拦截):" + ex.Message));
}
}
private void LoadConfig()
{
cfgHoldTime = ((BaseUnityPlugin)this).Config.Bind<float>("触发", "长按互动键时长(秒)", 1f, "手持幸运罗盘时,按住游戏【互动键】达到该时长后触发抽取。支持玩家改键。");
cfgSuppressInteract = ((BaseUnityPlugin)this).Config.Bind<bool>("触发", "蓄力时屏蔽普通互动", true, "为true时:长按互动键蓄力期间,不触发对世界物体/队友的普通互动。");
cfgLuckRegenSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("幸运值", "幸运值回复间隔(秒)", 30f, "每抽一次幸运值-1(神话-10/史诗-5/普通-1)。经过该秒数回复+1(上限100)。设为0关闭回复。\n幸运值范围:-100 ~ 100,每局开局固定100。负幸运时每15秒额外+2。\n抽到最严重负面效果时,所有玩家幸运值+5。");
cfgMythicPenalty = ((BaseUnityPlugin)this).Config.Bind<int>("幸运值", "神话级惩罚", 10, "抽到神话级物品时幸运值扣除数。");
cfgEpicPenalty = ((BaseUnityPlugin)this).Config.Bind<int>("幸运值", "史诗级惩罚", 5, "抽到史诗级物品(装备/行李箱)时幸运值扣除数。");
cfgShowLuckUI = ((BaseUnityPlugin)this).Config.Bind<bool>("幸运值", "显示幸运值UI", true, "为true时:在屏幕左下角状态条上方实时显示【自己】的幸运值。");
cfgPool1 = ((BaseUnityPlugin)this).Config.Bind<string>("大奖池1-正面增益", "奖池内容", "Buff1|InfiniteStamina|20|0|14|1;Buff2|SpeedBuff|0.5|1.5|10|1;Buff3|Invincibility|8|0|9|2;Buff4|LowGravity|3|15|8|1;Buff5|RestoreStatus|0.4|0|12|1;Buff6|MoraleBoost|0.25|0|10|1;Buff7|ExtraStamina|0.6|0|8|1", "大奖池1(正面增益)条目。格式:条目ID|类型|参数1|参数2|权重|幸运偏向\n类型:InfiniteStamina|秒数;SpeedBuff|移速,攀爬(12秒);Invincibility|秒数;\nLowGravity|档位(1~3),秒数;RestoreStatus|恢复量;MoraleBoost|体力回复;ExtraStamina|额外体力\n幸运偏向:>0幸运越高越易抽中;<0越低越易;0不受影响。");
cfgPool1Weight = ((BaseUnityPlugin)this).Config.Bind<float>("大奖池1-正面增益", "奖池权重", 40f, "第一次抽取时,该大奖池基础权重。仅受幸运值降低影响。");
cfgPool2 = ((BaseUnityPlugin)this).Config.Bind<string>("大奖池2-稀有奖励", "奖池内容", "Rare1|Revive|0|0|3|5;Rare2|Bugle|0|0|5|3;Rare3|RandomLoot|0|0|6|2;Rare4|RandomItem|0|0|5|2;Rare5|Mythic|0|0|5|5;Rare6|Equipment|0|0|5|2;Rare7|Luggage|0|0|3|2;Rare8|GiveItem|Guidebook|0|2|1;Rare9|GiveItem|Frisbee|0|2|1", "大奖池2(稀有奖励)条目。类型:RandomLoot/RandomItem/Mythic/Equipment/Luggage/GiveItem/Bugle/Revive。\n幸运降低时该池权重被大幅压低。");
cfgPool2Weight = ((BaseUnityPlugin)this).Config.Bind<float>("大奖池2-稀有奖励", "奖池权重", 20f, "第一次抽取时,该大奖池基础权重。仅受幸运值降低影响。");
cfgPool3 = ((BaseUnityPlugin)this).Config.Bind<string>("大奖池3-负面危机", "奖池内容", "Bad1|SpawnZombie|0|0|9|-1;Bad2|SpawnBees|0|0|8|-1;Bad3|SpawnDynamite|0|0|7|-1;Bad4|Pandora|0|0|6|-2;Bad5|AllBomb|0|0|6|-3;Bad6|Tornado|0|0|5|-2;Bad7|Eruption|0|0|5|-2;Bad8|SpawnFrog|0|0|6|-2;Bad9|SpawnScorpion|0|0|6|-2;Bad10|TickParasite|0|0|4|-2;Bad11|IceBlind|0|0|5|-1;Bad12|StatusPoison|0|0|6|-1;Bad13|StatusSleep|0|0|6|-1;Bad14|StatusRandom|0|0|5|-1;Bad15|StatusAll|0|0|2|-3;Bad16|SteamExplode|0|0|5|-2;Bad17|SporeFog|0|0|5|-1;Bad18|GhostBoom|0|0|4|-2", "大奖池3(负面危机)条目。类型:\nSpawnZombie|生成僵尸;SpawnBees|生成蜜蜂;SpawnDynamite|面前生成炸药(靠近自动点燃);\nPandora|潘多拉魔盒瞬爆;AllBomb|所有玩家获得炸弹;Tornado|固定位置龙卷风;\nEruption|延迟火山喷发;SpawnFrog|按幸运值生成青蛙(高1只/0~-50两只/<-50三只);\nSpawnScorpion|按幸运值生成蝎子(同青蛙数量规则);TickParasite|一只蜱虫寄生在抽取者身上;\nIceBlind|雪山寒冰果式冰雪覆盖视野;StatusPoison|中毒;StatusSleep|瞌睡;\nStatusRandom|随机单一负面;StatusAll|极小概率(1%)所有负面;SteamExplode|蒸气爆炸弹飞;\nSporeFog|脚下生成爆炸/毒气孢子;GhostBoom|自爆大幽灵。\n生成类失败自动改为负面状态惩罚。最严重负面(AllBomb/Pandora/Tornado/Eruption/StatusAll/GhostBoom)触发时所有玩家幸运+5。");
cfgPool3Weight = ((BaseUnityPlugin)this).Config.Bind<float>("大奖池3-负面危机", "奖池权重", 30f, "第一次抽取时,该大奖池基础权重。幸运降低时权重大幅提高。");
cfgStatueModeA = ((BaseUnityPlugin)this).Config.Bind<bool>("童军雕像", "生成道具模式(方案A)", false, "false=方案B(默认):抽奖时先扫描场上有无待复活玩家,有则把【复活】条目纳入,没有则屏蔽;\ntrue=方案A:改为在你面前生成一个复活道具(ScoutEffigy)。");
cfgZombieName = ((BaseUnityPlugin)this).Config.Bind<string>("负面生成物", "僵尸prefab名", "MushroomZombie", "僵尸prefab名。默认 MushroomZombie。留空则自动探测场景。");
cfgBeeName = ((BaseUnityPlugin)this).Config.Bind<string>("负面生成物", "蜜蜂prefab名", "0_Items/BeeSwarm", "蜜蜂prefab名。默认 0_Items/BeeSwarm。若失败自动探测,再失败改负面状态惩罚。");
cfgDynamiteName = ((BaseUnityPlugin)this).Config.Bind<string>("负面生成物", "炸药prefab名", "0_Items/Dynamite", "炸药prefab名。默认 0_Items/Dynamite。生成后玩家靠近会自动点燃。");
cfgSporeFogName = ((BaseUnityPlugin)this).Config.Bind<string>("负面生成物", "孢子生成物prefab名", "0_Items/CloudFungus", "孢子云生成物prefab名。默认 0_Items/CloudFungus(云蕈,落地爆开成爆炸/毒气孢子)。");
cfgGhostName = ((BaseUnityPlugin)this).Config.Bind<string>("负面生成物", "大幽灵prefab名", "", "自爆大幽灵的prefab名。留空自动探测含Ghost/Wraith/Phantom/Spirit/Banshee关键字。");
cfgFrogName = ((BaseUnityPlugin)this).Config.Bind<string>("负面生成物", "青蛙prefab名", "", "青蛙prefab名。留空自动探测含Frog关键字。若找不到则改负面状态惩罚。");
cfgScorpionName = ((BaseUnityPlugin)this).Config.Bind<string>("负面生成物", "蝎子prefab名", "0_Items/Scorpion", "蝎子prefab名。默认 0_Items/Scorpion(幸运方块验证可用)。");
cfgTickName = ((BaseUnityPlugin)this).Config.Bind<string>("负面生成物", "蜱虫prefab名", "BugfixOnYou", "寄生蜱虫prefab名。默认 BugfixOnYou(游戏原生,AttachBug后持续给毒)。");
cfgTornadoDelay = ((BaseUnityPlugin)this).Config.Bind<float>("延迟生成", "龙卷风延迟秒数", 3f, "抽到龙卷风后延迟该秒数再生成(警告同步给所有玩家,生成位置在警告发布瞬间固定)。");
cfgEruptionDelay = ((BaseUnityPlugin)this).Config.Bind<float>("延迟生成", "火山喷发延迟秒数", 3f, "抽到火山喷发后延迟该秒数再触发(期间屏幕中央显示警告文字)。");
cfgStatusAllChance = ((BaseUnityPlugin)this).Config.Bind<float>("负面状态", "全负面触发概率", 0.01f, "抽中【所有负面状态】条目时,实际触发全负面的概率(0~1)。默认0.01即1%,不受幸运值影响。");
cfgFatigueWindow = ((BaseUnityPlugin)this).Config.Bind<float>("频率限制", "疲劳检测窗口(秒)", 120f, "在该秒数内连续抽奖达到上限次数,将触发最严重负面惩罚。默认120秒=2分钟。");
cfgFatigueLimit = ((BaseUnityPlugin)this).Config.Bind<int>("频率限制", "窗口内抽奖次数上限", 5, "在检测窗口内连续抽奖达到该次数,第上限次时触发惩罚。");
cfgFatiguePunishment = ((BaseUnityPlugin)this).Config.Bind<string>("频率限制", "疲劳惩罚效果", "Pandora", "触发疲劳惩罚时执行的效果类型。可选:Pandora/AllBomb/Tornado/GhostBoom/StatusAll/SpawnZombie。");
}
}
internal static class DefaultPools
{
public const string POOL1 = "Buff1|InfiniteStamina|20|0|14|1;Buff2|SpeedBuff|0.5|1.5|10|1;Buff3|Invincibility|8|0|9|2;Buff4|LowGravity|3|15|8|1;Buff5|RestoreStatus|0.4|0|12|1;Buff6|MoraleBoost|0.25|0|10|1;Buff7|ExtraStamina|0.6|0|8|1";
public const string POOL2 = "Rare1|Revive|0|0|3|5;Rare2|Bugle|0|0|5|3;Rare3|RandomLoot|0|0|6|2;Rare4|RandomItem|0|0|5|2;Rare5|Mythic|0|0|5|5;Rare6|Equipment|0|0|5|2;Rare7|Luggage|0|0|3|2;Rare8|GiveItem|Guidebook|0|2|1;Rare9|GiveItem|Frisbee|0|2|1";
public const string POOL3 = "Bad1|SpawnZombie|0|0|9|-1;Bad2|SpawnBees|0|0|8|-1;Bad3|SpawnDynamite|0|0|7|-1;Bad4|Pandora|0|0|6|-2;Bad5|AllBomb|0|0|6|-3;Bad6|Tornado|0|0|5|-2;Bad7|Eruption|0|0|5|-2;Bad8|SpawnFrog|0|0|6|-2;Bad9|SpawnScorpion|0|0|6|-2;Bad10|TickParasite|0|0|4|-2;Bad11|IceBlind|0|0|5|-1;Bad12|StatusPoison|0|0|6|-1;Bad13|StatusSleep|0|0|6|-1;Bad14|StatusRandom|0|0|5|-1;Bad15|StatusAll|0|0|2|-3;Bad16|SteamExplode|0|0|5|-2;Bad17|SporeFog|0|0|5|-1;Bad18|GhostBoom|0|0|4|-2";
}