using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using DM;
using HarmonyLib;
using Landfall.TABS;
using Landfall.TABS.GameState;
using Landfall.TABS.Workshop;
using Newtonsoft.Json;
using SLMA;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FUZHUMOD")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("made in SFT by FhpSlime")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3a45c3cf-230c-4310-952f-0887d4266a22")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
public class Item : MonoBehaviour
{
public enum kind
{
Weapon,
Cloth,
Skill,
Unit,
Projectile,
Other
}
public string name;
public kind Kind;
}
[HarmonyPatch(typeof(UnitSpawner))]
[HarmonyPatch("Spawn")]
public static class UnitSpawner_Spawn_Postfix
{
[HarmonyPostfix]
public static void Spawn_Postfix(UnitSpawner __instance, Unit __result)
{
if ((Object)(object)__result == (Object)null)
{
return;
}
GameStateListener[] componentsInChildren = ((Component)__result).GetComponentsInChildren<GameStateListener>(true);
if (componentsInChildren == null || componentsInChildren.Length == 0)
{
return;
}
GameStateListener[] array = componentsInChildren;
foreach (GameStateListener val in array)
{
if ((Object)(object)val != (Object)null && ((Behaviour)val).isActiveAndEnabled)
{
val.OnEnterBattleState();
}
}
}
}
namespace FUZHUMOD;
[BepInPlugin("FUZHUMOD", "FUZHUMOD", "1.0.0")]
internal class Loader : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <call>d__1 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Loader <>4__this;
private float <后半段加载时间>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <call>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Expected O, but got Unknown
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Expected O, but got Unknown
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Expected O, but got Unknown
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitUntil((Func<bool>)(() => (Object)(object)Object.FindObjectOfType<ServiceLocator>() != (Object)null));
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<>2__current = (object)new WaitUntil((Func<bool>)(() => ServiceLocator.GetService<ISaveLoaderService>() != null));
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
<>2__current = (object)new WaitForSecondsRealtime(10f);
<>1__state = 3;
return true;
case 3:
<>1__state = -1;
SLMALoader.GetInstance();
UManager.开局加载();
<后半段加载时间>5__1 = 定制内容.ModData.ModLoadingtime;
<>2__current = (object)new WaitForSecondsRealtime(<后半段加载时间>5__1);
<>1__state = 4;
return true;
case 4:
<>1__state = -1;
正常加载33.主m();
正常加载33.加载定制礼物精灵方法();
UManager.Init(ContentDatabase.Instance().LandfallContentDatabase);
new Harmony(UManager.modname).PatchAll();
Debug.Log((object)("Loaded " + UManager.modname + " Successfully"));
Debug.Log((object)(UManager.modname + "is made in SFT by FhpSlime"));
Debug.Log((object)(UManager.modder + "wished you a pleasant trip"));
Debug.Log((object)"辅助mod已加载感谢游玩");
Debug.Log((object)"oooooooooooooooo");
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 void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"礼盒补丁注入中...");
Harmony.CreateAndPatchAll(typeof(UnitSpawner_Spawn_Postfix), (string)null);
((BaseUnityPlugin)this).Logger.LogInfo((object)"礼盒补丁注入完成!");
((MonoBehaviour)this).StartCoroutine(call());
}
[IteratorStateMachine(typeof(<call>d__1))]
private IEnumerator call()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <call>d__1(0)
{
<>4__this = this
};
}
}
public class MyModItems : MonoBehaviour
{
private static Dictionary<string, Item> items;
private static MyModItems instance { get; set; }
public static MyModItems GetInstance()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)instance == (Object)null)
{
instance = new GameObject("复制辅助mod物品").AddComponent<MyModItems>();
Object.DontDestroyOnLoad((Object)(object)instance);
}
return instance;
}
public void AddItem(Item item)
{
items.Add(item.name, item);
}
public Item GetItem(string name)
{
Item value = new Item
{
name = null,
Kind = Item.kind.Other
};
items.TryGetValue(name, out value);
return value;
}
}
[Serializable]
public class PresentModData
{
[Serializable]
public class CustomPresent
{
public string Name;
public UnitsCustomPresentData[] unitsCustomPresentDatas;
}
[Serializable]
public class UnitsCustomPresentData
{
public string UnitName;
public int Unitweight;
}
[JsonProperty(/*Could not decode attribute arguments.*/)]
public float ModLoadingtime = 120f;
public CustomPresent[] Presents;
}
public static class 定制内容
{
private static PresentModData _modData;
private static readonly object _lock = new object();
private static string _configFilePath;
public static PresentModData ModData
{
get
{
if (_modData == null)
{
lock (_lock)
{
if (_modData == null)
{
加载配置文件();
}
}
}
return _modData;
}
}
private static string 获取配置文件路径(string 文件名 = "PresentModData.json")
{
if (string.IsNullOrEmpty(_configFilePath))
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
_configFilePath = Path.Combine(directoryName, 文件名);
}
return _configFilePath;
}
public static void 加载配置文件()
{
//IL_0175: Expected O, but got Unknown
try
{
string text = 获取配置文件路径();
Debug.Log((object)("[MOD] 正在读取配置文件: " + text));
if (File.Exists(text))
{
string text2 = File.ReadAllText(text);
Debug.Log((object)$"[MOD] 配置文件读取成功,内容长度: {text2.Length}");
_modData = JsonConvert.DeserializeObject<PresentModData>(text2);
if (_modData != null && 验证配置数据())
{
Debug.Log((object)"[MOD] ✅ 配置加载成功!");
Debug.Log((object)$"[MOD] - 加载时间: {_modData.ModLoadingtime}秒");
PresentModData.CustomPresent[] presents = _modData.Presents;
Debug.Log((object)$"[MOD] - 礼物数量: {((presents != null) ? presents.Length : 0)}");
if (_modData.Presents != null)
{
for (int i = 0; i < _modData.Presents.Length; i++)
{
PresentModData.CustomPresent customPresent = _modData.Presents[i];
object arg = i;
string name = customPresent.Name;
PresentModData.UnitsCustomPresentData[] unitsCustomPresentDatas = customPresent.unitsCustomPresentDatas;
Debug.Log((object)$"[MOD] - 礼物[{arg}]: {name}, 单位数量: {((unitsCustomPresentDatas != null) ? unitsCustomPresentDatas.Length : 0)}");
}
}
}
else
{
Debug.LogError((object)"[MOD] ❌ 配置文件验证失败,使用默认配置");
创建默认配置文件(text);
}
}
else
{
Debug.LogWarning((object)("[MOD] ⚠\ufe0f 配置文件不存在: " + text));
创建默认配置文件(text);
}
}
catch (JsonException val)
{
JsonException val2 = val;
Debug.LogError((object)("[MOD] ❌ JSON解析错误: " + ((Exception)(object)val2).Message));
创建默认配置文件();
}
catch (Exception ex)
{
Debug.LogError((object)("[MOD] ❌ 读取配置文件时发生错误: " + ex.Message + "\n" + ex.StackTrace));
创建默认配置文件();
}
}
private static void 创建默认配置文件(string 路径 = null)
{
Debug.Log((object)"[MOD] 创建默认配置数据");
PresentModData presentModData = new PresentModData();
presentModData.ModLoadingtime = 110f;
presentModData.Presents = new PresentModData.CustomPresent[3]
{
new PresentModData.CustomPresent
{
Name = "定制内容示例部落礼物包",
unitsCustomPresentDatas = new PresentModData.UnitsCustomPresentData[3]
{
new PresentModData.UnitsCustomPresentData
{
UnitName = "UNIT_TRIBAL_CLUB",
Unitweight = 3
},
new PresentModData.UnitsCustomPresentData
{
UnitName = "UNIT_TRIBAL_PROTECTOR",
Unitweight = 2
},
new PresentModData.UnitsCustomPresentData
{
UnitName = "UNIT_TRIBAL_THROWER_SPEAR",
Unitweight = 1
}
}
},
new PresentModData.CustomPresent
{
Name = "定制内容示例中世纪礼物包",
unitsCustomPresentDatas = new PresentModData.UnitsCustomPresentData[2]
{
new PresentModData.UnitsCustomPresentData
{
UnitName = "UNIT_MEDIEVAL_KNIGHT",
Unitweight = 2
},
new PresentModData.UnitsCustomPresentData
{
UnitName = "UNIT_MEDIEVAL_THEKING",
Unitweight = 2
}
}
},
new PresentModData.CustomPresent
{
Name = "定制内容示例传奇礼物包",
unitsCustomPresentDatas = new PresentModData.UnitsCustomPresentData[1]
{
new PresentModData.UnitsCustomPresentData
{
UnitName = "UNIT_LEGACY_LEG_BOXER",
Unitweight = 1
}
}
}
};
_modData = presentModData;
if (string.IsNullOrEmpty(路径))
{
return;
}
try
{
保存配置文件(路径);
Debug.Log((object)("[MOD] ✅ 默认配置文件已创建: " + 路径));
if (File.Exists(路径))
{
string text = File.ReadAllText(路径);
Debug.Log((object)$"[MOD] 配置文件大小: {text.Length} 字节");
}
}
catch (Exception ex)
{
Debug.LogError((object)("[MOD] ❌ 创建默认配置文件失败: " + ex.Message));
}
}
private static bool 验证配置数据()
{
if (_modData == null)
{
return false;
}
bool result = true;
if (_modData.ModLoadingtime <= 0f)
{
Debug.LogWarning((object)"[MOD] Mod加载时间小于等于0,已设置为默认值120秒");
_modData.ModLoadingtime = 120f;
}
if (_modData.Presents == null || _modData.Presents.Length == 0)
{
Debug.LogWarning((object)"[MOD] 礼物列表为空");
result = false;
}
else
{
for (int i = 0; i < _modData.Presents.Length; i++)
{
PresentModData.CustomPresent customPresent = _modData.Presents[i];
if (string.IsNullOrEmpty(customPresent.Name))
{
Debug.LogWarning((object)$"[MOD] 礼物[{i}]没有名称,已设置为'未命名'");
customPresent.Name = "未命名";
}
if (customPresent.unitsCustomPresentDatas == null)
{
Debug.LogWarning((object)("[MOD] 礼物 '" + customPresent.Name + "' 的单位列表为空"));
customPresent.unitsCustomPresentDatas = new PresentModData.UnitsCustomPresentData[0];
}
else if (customPresent.unitsCustomPresentDatas.Length == 0)
{
Debug.LogWarning((object)("[MOD] 礼物 '" + customPresent.Name + "' 没有包含任何单位"));
}
}
}
return result;
}
public static void 保存配置文件(string 文件路径 = null)
{
//IL_0056: 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)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
try
{
if (_modData == null)
{
Debug.LogError((object)"[MOD] 没有配置数据可保存");
return;
}
string text = (string.IsNullOrEmpty(文件路径) ? 获取配置文件路径() : 文件路径);
string directoryName = Path.GetDirectoryName(text);
if (!Directory.Exists(directoryName))
{
Directory.CreateDirectory(directoryName);
}
JsonSerializerSettings val = new JsonSerializerSettings
{
Formatting = (Formatting)1,
NullValueHandling = (NullValueHandling)1,
DefaultValueHandling = (DefaultValueHandling)1
};
string text2 = JsonConvert.SerializeObject((object)_modData, val);
File.WriteAllText(text, text2, Encoding.UTF8);
Debug.Log((object)("[MOD] ✅ 配置文件已保存: " + text));
Debug.Log((object)$"[MOD] 文件大小: {text2.Length} 字节");
}
catch (Exception ex)
{
Debug.LogError((object)("[MOD] ❌ 保存配置文件失败: " + ex.Message));
}
}
public static void 重新加载配置()
{
lock (_lock)
{
_modData = null;
加载配置文件();
}
}
public static string[] 获取所有礼物名称()
{
if (_modData?.Presents == null)
{
return new string[0];
}
return _modData.Presents.Select((PresentModData.CustomPresent p) => p.Name).ToArray();
}
public static PresentModData.CustomPresent 获取礼物(string 礼物名称)
{
if (string.IsNullOrEmpty(礼物名称) || _modData?.Presents == null)
{
return null;
}
return _modData.Presents.FirstOrDefault((PresentModData.CustomPresent p) => p.Name == 礼物名称);
}
public static int 获取单位权重(string 礼物名称, string 单位名称)
{
PresentModData.CustomPresent customPresent = 获取礼物(礼物名称);
if (customPresent?.unitsCustomPresentDatas == null)
{
return 0;
}
return customPresent.unitsCustomPresentDatas.FirstOrDefault((PresentModData.UnitsCustomPresentData u) => u.UnitName == 单位名称)?.Unitweight ?? 0;
}
public static int 获取礼物总权重(string 礼物名称)
{
PresentModData.CustomPresent customPresent = 获取礼物(礼物名称);
if (customPresent?.unitsCustomPresentDatas == null)
{
return 0;
}
return customPresent.unitsCustomPresentDatas.Sum((PresentModData.UnitsCustomPresentData u) => u.Unitweight);
}
public static string 随机获取单位(string 礼物名称)
{
PresentModData.CustomPresent customPresent = 获取礼物(礼物名称);
if (customPresent?.unitsCustomPresentDatas == null)
{
return null;
}
int num = customPresent.unitsCustomPresentDatas.Sum((PresentModData.UnitsCustomPresentData u) => u.Unitweight);
if (num <= 0)
{
return null;
}
int num2 = Random.Range(0, num);
int num3 = 0;
PresentModData.UnitsCustomPresentData[] unitsCustomPresentDatas = customPresent.unitsCustomPresentDatas;
foreach (PresentModData.UnitsCustomPresentData unitsCustomPresentData in unitsCustomPresentDatas)
{
num3 += unitsCustomPresentData.Unitweight;
if (num2 < num3)
{
return unitsCustomPresentData.UnitName;
}
}
return customPresent.unitsCustomPresentDatas[0]?.UnitName;
}
}
public static class UManager
{
public static List<UnitBlueprint> 全兵种有兵编12;
public static GameObject 全兵种礼盒;
public static GameObject 模组兵种礼盒;
public static GameObject 兵编兵种礼盒;
public static Faction 这个派系;
public static Sprite tutututu;
public static string modname = "FUZHUMOD";
public static string modder = "FhpSlime";
private static string com;
public static Sprite LoadEmbeddedPngToSprite(string resourcePath)
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
Assembly executingAssembly = Assembly.GetExecutingAssembly();
using Stream stream = executingAssembly.GetManifestResourceStream(resourcePath);
if (stream == null)
{
Debug.LogError((object)("嵌入资源不存在: " + resourcePath));
return null;
}
byte[] array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
Texture2D val = new Texture2D(2, 2);
if (!ImageConversion.LoadImage(val, array))
{
Debug.LogError((object)("加载图片失败: " + resourcePath));
return null;
}
return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
}
public static void 开局加载()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Expected O, but got Unknown
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Expected O, but got Unknown
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Expected O, but got Unknown
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Expected O, but got Unknown
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Expected O, but got Unknown
Sprite val = LoadEmbeddedPngToSprite("FUZHUMOD.生成礼物盒子游戏图标.png");
tutututu = val;
Faction val2 = SLMATool.CreateFaction("礼物精灵分类派系", (UnitBlueprint[])null, (Sprite)null, 0);
这个派系 = val2;
模组兵种礼盒 = UPool.MyPool.AddObject("全兵种礼物盒(无兵编)", (GameObject)SLMALoader.SDic["weapons"]["Thrown_Present"], true, (HideFlags)52, (Sprite)null, 345839458, true);
UnitBlueprint val3 = 创建有id单位("全兵种礼物精灵(无兵编)", (UnitBlueprint)SLMALoader.SDic["blueprints"]["UNIT_SECRET_THROWER_PRESENT"], 这个派系, tutututu, 634545566);
val3.RightWeapon = 模组兵种礼盒;
val3.Validate();
全兵种礼盒 = UPool.MyPool.AddObject("全兵种礼物盒13(有兵编)", (GameObject)SLMALoader.SDic["weapons"]["Thrown_Present"], true, (HideFlags)52, (Sprite)null, 345839451, true);
UnitBlueprint val4 = 创建有id单位("全兵种礼物精灵(有兵编)1", (UnitBlueprint)SLMALoader.SDic["blueprints"]["UNIT_SECRET_THROWER_PRESENT"], 这个派系, tutututu, 634545567);
val4.RightWeapon = 全兵种礼盒;
val4.Validate();
兵编兵种礼盒 = UPool.MyPool.AddObject("全兵种礼物盒13(仅2兵编)", (GameObject)SLMALoader.SDic["weapons"]["Thrown_Present"], true, (HideFlags)52, (Sprite)null, 345839412, true);
UnitBlueprint val5 = 创建有id单位("全兵种礼物精灵(仅兵编)3", (UnitBlueprint)SLMALoader.SDic["blueprints"]["UNIT_SECRET_THROWER_PRESENT"], 这个派系, tutututu, 634545568);
val5.RightWeapon = 兵编兵种礼盒;
val5.Validate();
Debug.LogWarning((object)"完成内部加载");
}
public static void Init(LandfallContentDatabase db)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: 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_0288: Expected O, but got Unknown
//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0338: Unknown result type (might be due to invalid IL or missing references)
//IL_0348: Expected O, but got Unknown
Debug.Log((object)"已执行辅助工具");
new List<UnitBlueprint>();
GameObject val = UPool.MyPool.AddObject("全兵种礼物盒投掷物", (GameObject)SLMALoader.SDic["projectiles"]["B_Present"], true, (HideFlags)52, (Sprite)null, 0, true);
GameObject val2 = UPool.MyPool.AddObject("全兵种礼物盒(无兵编)召唤物", ((GameObject)SLMALoader.SDic["projectiles"]["B_Present"]).GetComponentInChildren<SpawnObject>().objectToSpawn, true, (HideFlags)52, (Sprite)null, 0, true);
((Component)val.transform.Find("SpawnUnit")).GetComponentInChildren<SpawnObject>().objectToSpawn = val2;
List<UnitBlueprint> list = ContentDatabase.Instance().GetAllUnitBlueprints().ToList();
list.First();
list.RemoveAll((UnitBlueprint unit) => unit.IsCustomUnit);
((Component)val2.transform.Find("Spawner")).GetComponentInChildren<UnitSpawner>().units = list;
模组兵种礼盒.GetComponentInChildren<RangeWeapon>().ObjectToSpawn = val;
List<Faction> list2 = ContentDatabase.Instance().GetAllFactions().ToList();
List<UnitBlueprint> list3 = new List<UnitBlueprint>();
for (int i = 0; i < list2.Count; i++)
{
for (int j = 0; j < list2[i].Units.Length; j++)
{
list3.Add(list2[i].Units[j]);
}
}
List<UnitBlueprint> list4 = new List<UnitBlueprint>();
list4 = list.Except(list3).ToList();
SLMATool.CreateFaction("无派系单位", (UnitBlueprint[])null, (Sprite)null, 0).Units = list4.ToArray();
List<UnitBlueprint> list5 = ContentDatabase.Instance().GetAllUnitBlueprints().ToList();
list5.First();
全兵种有兵编12 = list5;
List<UnitBlueprint> list6 = new List<UnitBlueprint>();
for (int k = 0; k < list5.Count; k++)
{
if (list5[k].IsCustomUnit)
{
list6.Add(list5[k]);
}
}
GameObject val3 = UPool.MyPool.AddObject("全兵种礼物盒(有兵编)召1唤物", ((GameObject)SLMALoader.SDic["projectiles"]["B_Present"]).GetComponentInChildren<SpawnObject>().objectToSpawn, true, (HideFlags)52, (Sprite)null, 0, true);
GameObject val4 = UPool.MyPool.AddObject("全兵种礼物盒(有兵编)投掷物", (GameObject)SLMALoader.SDic["projectiles"]["B_Present"], true, (HideFlags)52, (Sprite)null, 0, true);
((Component)val4.transform.Find("SpawnUnit")).GetComponentInChildren<SpawnObject>().objectToSpawn = val3;
((Component)val3.transform.Find("Spawner")).GetComponentInChildren<UnitSpawner>().units = list5;
全兵种礼盒.GetComponentInChildren<RangeWeapon>().ObjectToSpawn = val4;
GameObject val5 = UPool.MyPool.AddObject("全兵种礼物盒(仅兵编)召21唤物", ((GameObject)SLMALoader.SDic["projectiles"]["B_Present"]).GetComponentInChildren<SpawnObject>().objectToSpawn, true, (HideFlags)52, (Sprite)null, 0, true);
GameObject val6 = UPool.MyPool.AddObject("全兵种礼物盒(仅兵编)投2掷物", (GameObject)SLMALoader.SDic["projectiles"]["B_Present"], true, (HideFlags)52, (Sprite)null, 0, true);
((Component)val6.transform.Find("SpawnUnit")).GetComponentInChildren<SpawnObject>().objectToSpawn = val5;
((Component)val5.transform.Find("Spawner")).GetComponentInChildren<UnitSpawner>().units = list6;
兵编兵种礼盒.GetComponentInChildren<RangeWeapon>().ObjectToSpawn = val6;
Debug.Log((object)"加载完毕祝您游玩愉快");
}
public static UnitBlueprint 创建有id单位(string name, UnitBlueprint unit, Faction faction, Sprite sprite, int id111)
{
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Expected O, but got Unknown
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)unit != (Object)null)
{
Debug.LogWarning((object)"创建蓝图");
UnitBlueprint val = Object.Instantiate<UnitBlueprint>(unit);
((DatabaseEntity)s.GetField<UnitBlueprint>(s.SetField<UnitBlueprint>(val, "m_entity", (object)new DatabaseEntity((WorkshopContentType)0)), "m_entity")).GUID = new DatabaseID(id111);
Debug.LogWarning((object)"完成蓝图创建并指定id");
Dictionary<DatabaseID, UnitBlueprint> dictionary = (Dictionary<DatabaseID, UnitBlueprint>)s.GetField<LandfallContentDatabase>(ContentDatabase.Instance().LandfallContentDatabase, "m_unitBlueprints");
Debug.LogWarning((object)"找到字典");
dictionary.Add(val.Entity.GUID, val);
s.SetField<LandfallContentDatabase>(ContentDatabase.Instance().LandfallContentDatabase, "m_unitBlueprints", (object)dictionary);
Debug.LogWarning((object)"加入懒得发字典");
val.Entity.Name = name;
((Object)val).name = name;
val.Entity.SpriteIcon = sprite;
if ((Object)(object)faction != (Object)null && (Object)(object)val != (Object)null)
{
if (faction.Units == null)
{
faction.Units = (UnitBlueprint[])(object)new UnitBlueprint[1] { val };
}
else
{
List<UnitBlueprint> list = faction.Units.ToList();
list.Add(val);
faction.Units = list.ToArray();
}
}
return val;
}
Debug.LogWarning((object)"无发创建未指定值返回木棒兵");
return (UnitBlueprint)SLMALoader.SDic["blueprints"]["UNIT_TRIBAL_CLUB"];
}
}
internal static class 正常加载33
{
public static void 主m()
{
List<Faction> list = ContentDatabase.Instance().GetAllFactions().ToList();
list.First();
for (int i = 0; i < list.Count; i++)
{
if ((Object)(object)list[i] == (Object)null)
{
Debug.LogError((object)$"[错误] 派系索引 {i} 为空,跳过处理");
continue;
}
List<UnitBlueprint> list2 = list[i].Units.ToList();
if (list2 != null && list2.Count > 0)
{
string text = ((Object)list[i]).name;
if (string.IsNullOrEmpty(text))
{
text = 生成随机名称("派系");
Debug.LogWarning((object)$"[警告] 派系索引 {i} 的名称为空,已生成随机名称: {text}");
}
加载礼物精灵(text, list2, list[i]);
}
}
}
public static void 加载定制礼物精灵方法()
{
try
{
PresentModData modData = 定制内容.ModData;
if (modData == null)
{
Debug.LogError((object)"[加载定制礼物] 定制内容数据为空,请检查配置文件是否正确加载");
return;
}
Debug.Log((object)$"[加载定制礼物] 成功获取配置数据,加载时间: {modData.ModLoadingtime}");
ContentDatabase val = ContentDatabase.Instance();
if (val == null)
{
Debug.LogError((object)"[加载定制礼物] ContentDatabase实例为空");
return;
}
List<UnitBlueprint> list = val.GetAllUnitBlueprints()?.ToList();
if (list == null || list.Count == 0)
{
Debug.LogError((object)"[加载定制礼物] 全兵种列表为空,无法加载礼物数据");
return;
}
Debug.Log((object)$"[加载定制礼物] 获取到 {list.Count} 个兵种");
PresentModData.CustomPresent[] presents = modData.Presents;
if (presents == null || presents.Length == 0)
{
Debug.LogWarning((object)"[加载定制礼物] 礼物数据为空,没有需要加载的礼物");
return;
}
Debug.Log((object)$"[加载定制礼物] 开始加载 {presents.Length} 个礼物");
Dictionary<string, UnitBlueprint> dictionary = new Dictionary<string, UnitBlueprint>();
int num = 0;
foreach (UnitBlueprint item in list)
{
if ((Object)(object)item == (Object)null || item.Entity == null)
{
Debug.LogWarning((object)"[加载定制礼物] 发现空的兵种数据,已跳过");
continue;
}
string name = item.Entity.Name;
if (string.IsNullOrEmpty(name))
{
Debug.LogWarning((object)"[加载定制礼物] 发现兵种名称为空,已跳过");
continue;
}
if (!dictionary.ContainsKey(name))
{
dictionary.Add(name, item);
continue;
}
num++;
Debug.LogWarning((object)("[加载定制礼物] 发现重复的兵种名称: " + name + ",将使用第一个"));
}
Debug.Log((object)$"[加载定制礼物] 兵种字典构建完成,有效兵种: {dictionary.Count} 个,重复: {num} 个");
int num2 = 0;
int num3 = 0;
for (int i = 0; i < presents.Length; i++)
{
try
{
PresentModData.CustomPresent customPresent = presents[i];
if (customPresent == null)
{
Debug.LogWarning((object)$"[加载定制礼物] 第 {i + 1} 个礼物数据为空,已跳过");
num3++;
continue;
}
string name2 = customPresent.Name;
if (string.IsNullOrEmpty(name2))
{
Debug.LogWarning((object)$"[加载定制礼物] 第 {i + 1} 个礼物的名称为空,已跳过");
num3++;
continue;
}
PresentModData.UnitsCustomPresentData[] unitsCustomPresentDatas = customPresent.unitsCustomPresentDatas;
if (unitsCustomPresentDatas == null || unitsCustomPresentDatas.Length == 0)
{
Debug.LogWarning((object)("[加载定制礼物] 礼物 '" + name2 + "' 的召唤单位数据为空,已跳过"));
num3++;
continue;
}
Debug.Log((object)$"[加载定制礼物] 正在处理礼物 '{name2}',包含 {unitsCustomPresentDatas.Length} 种单位配置");
List<UnitBlueprint> list2 = new List<UnitBlueprint>();
int num4 = 0;
int num5 = 0;
for (int j = 0; j < unitsCustomPresentDatas.Length; j++)
{
PresentModData.UnitsCustomPresentData unitsCustomPresentData = unitsCustomPresentDatas[j];
if (unitsCustomPresentData == null)
{
Debug.LogWarning((object)$"[加载定制礼物] 礼物 '{name2}' 的第 {j + 1} 个单位配置为空");
num4++;
continue;
}
string unitName = unitsCustomPresentData.UnitName;
if (string.IsNullOrEmpty(unitName))
{
Debug.LogWarning((object)$"[加载定制礼物] 礼物 '{name2}' 的第 {j + 1} 个单位名称为空");
num4++;
continue;
}
int unitweight = unitsCustomPresentData.Unitweight;
UnitBlueprint value;
if (unitweight <= 0)
{
Debug.LogWarning((object)$"[加载定制礼物] 礼物 '{name2}' 的单位 '{unitName}' 的权重为 {unitweight},已跳过");
}
else if (dictionary.TryGetValue(unitName, out value))
{
if ((Object)(object)value == (Object)null)
{
Debug.LogWarning((object)("[加载定制礼物] 礼物 '" + name2 + "' 找到兵种 '" + unitName + "' 但数据为空"));
num4++;
}
else
{
for (int k = 0; k < unitweight; k++)
{
list2.Add(value);
}
num5 += unitweight;
Debug.Log((object)$"[加载定制礼物] 礼物 '{name2}' 添加了 {unitweight} 个 '{unitName}'");
}
}
else
{
Debug.LogWarning((object)("[加载定制礼物] 礼物 '" + name2 + "' 未找到兵种 '" + unitName + "'"));
num4++;
}
}
if (list2.Count == 0)
{
Debug.LogWarning((object)("[加载定制礼物] 礼物 '" + name2 + "' 没有成功添加任何兵种,已跳过加载"));
Debug.LogWarning((object)$" 未找到兵种数: {num4}, 成功添加: {num5}");
num3++;
}
else if ((Object)(object)UManager.这个派系 == (Object)null)
{
Debug.LogError((object)("[加载定制礼物] UManager.这个派系为空,无法加载礼物 '" + name2 + "'"));
num3++;
}
else
{
Debug.Log((object)$"[加载定制礼物] 正在加载礼物精灵 '{name2}',包含 {list2.Count} 个单位");
Debug.Log((object)$" 成功添加兵种: {num5}, 未找到兵种: {num4}");
加载礼物精灵(name2, list2, UManager.这个派系, 自动命名: false);
num2++;
Debug.Log((object)("[加载定制礼物] 礼物 '" + name2 + "' 加载成功!"));
}
}
catch (Exception ex)
{
Debug.LogError((object)$"[加载定制礼物] 处理第 {i + 1} 个礼物时发生异常: {ex.Message}\n堆栈信息: {ex.StackTrace}");
num3++;
}
}
Debug.Log((object)"[加载定制礼物] ========== 加载完成统计 ==========");
Debug.Log((object)$" 总礼物数: {presents.Length}");
Debug.Log((object)$" 成功加载: {num2}");
Debug.Log((object)$" 加载失败: {num3}");
Debug.Log((object)"=====================================");
if (num3 > 0)
{
Debug.LogWarning((object)$"[加载定制礼物] 有 {num3} 个礼物加载失败,请检查上述警告信息");
}
}
catch (Exception ex2)
{
Debug.LogError((object)("[加载定制礼物] 方法执行过程中发生严重异常: " + ex2.Message + "\n堆栈信息: " + ex2.StackTrace));
}
}
public static void 加载礼物精灵(string 礼物精灵名字, List<UnitBlueprint> 礼物精灵单位, Faction 所属派系, bool 自动命名 = true)
{
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Expected O, but got Unknown
//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
//IL_02b2: Expected O, but got Unknown
//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
//IL_04b8: Expected O, but got Unknown
if (string.IsNullOrEmpty(礼物精灵名字))
{
礼物精灵名字 = 生成随机名称("礼物精灵");
Debug.LogWarning((object)("[警告] 礼物精灵名字为空,已生成随机名称: " + 礼物精灵名字));
}
if (礼物精灵单位 == null || 礼物精灵单位.Count == 0)
{
Debug.LogError((object)("[错误] 礼物精灵单位列表为空,无法加载 " + 礼物精灵名字));
return;
}
if ((Object)(object)所属派系 == (Object)null)
{
Debug.LogError((object)("[错误] 所属派系为空,无法加载 " + 礼物精灵名字));
return;
}
string text = ((!自动命名) ? 礼物精灵名字 : (礼物精灵名字 + "THROWER_PRESENT"));
if (SLMALoader.SDic == null)
{
Debug.LogError((object)"[错误] SLMALoader.SDic 为空,无法加载");
return;
}
if (!SLMALoader.SDic.ContainsKey("projectiles") || SLMALoader.SDic["projectiles"] == null)
{
Debug.LogError((object)"[错误] projectiles 资源为空");
return;
}
if (!SLMALoader.SDic["projectiles"].ContainsKey("B_Present"))
{
Debug.LogError((object)"[错误] B_Present 资源不存在");
return;
}
GameObject val = (GameObject)SLMALoader.SDic["projectiles"]["B_Present"];
if ((Object)(object)val == (Object)null)
{
Debug.LogError((object)"[错误] B_Present GameObject 为空");
return;
}
SpawnObject componentInChildren = val.GetComponentInChildren<SpawnObject>();
if ((Object)(object)componentInChildren == (Object)null || (Object)(object)componentInChildren.objectToSpawn == (Object)null)
{
Debug.LogError((object)"[错误] B_Present 中的 SpawnObject 组件或其 objectToSpawn 为空");
return;
}
GameObject val2 = UPool.MyPool.AddObject(礼物精灵名字 + "自定义礼物精唤物", componentInChildren.objectToSpawn, true, (HideFlags)52, (Sprite)null, 0, true);
if ((Object)(object)val2 == (Object)null)
{
Debug.LogError((object)("[错误] 创建召唤组件对象失败: " + 礼物精灵名字));
return;
}
GameObject val3 = UPool.MyPool.AddObject(礼物精灵名字 + "自定义礼物精投2掷物", val, true, (HideFlags)52, (Sprite)null, 0, true);
if ((Object)(object)val3 == (Object)null)
{
Debug.LogError((object)("[错误] 创建投掷物失败: " + 礼物精灵名字));
return;
}
if (!SLMALoader.SDic.ContainsKey("weapons") || SLMALoader.SDic["weapons"] == null)
{
Debug.LogError((object)"[错误] weapons 资源为空");
return;
}
if (!SLMALoader.SDic["weapons"].ContainsKey("Thrown_Present"))
{
Debug.LogError((object)"[错误] Thrown_Present 资源不存在");
return;
}
GameObject val4 = (GameObject)SLMALoader.SDic["weapons"]["Thrown_Present"];
if ((Object)(object)val4 == (Object)null)
{
Debug.LogError((object)"[错误] Thrown_Present GameObject 为空");
return;
}
GameObject val5 = UPool.MyPool.AddObject(礼物精灵名字 + "自定义礼物精礼物盒13", val4, true, (HideFlags)52, (Sprite)null, 0, true);
if ((Object)(object)val5 == (Object)null)
{
Debug.LogError((object)("[错误] 创建礼物盒失败: " + 礼物精灵名字));
return;
}
Transform val6 = val3.transform.Find("SpawnUnit");
if ((Object)(object)val6 == (Object)null)
{
Debug.LogError((object)("[错误] 投掷物中找不到 SpawnUnit 节点: " + 礼物精灵名字));
return;
}
SpawnObject componentInChildren2 = ((Component)val6).GetComponentInChildren<SpawnObject>();
if ((Object)(object)componentInChildren2 == (Object)null)
{
Debug.LogError((object)("[错误] SpawnUnit 中找不到 SpawnObject 组件: " + 礼物精灵名字));
return;
}
componentInChildren2.objectToSpawn = val2;
Transform val7 = val2.transform.Find("Spawner");
if ((Object)(object)val7 == (Object)null)
{
Debug.LogError((object)("[错误] 召唤组件对象中找不到 Spawner 节点: " + 礼物精灵名字));
return;
}
UnitSpawner componentInChildren3 = ((Component)val7).GetComponentInChildren<UnitSpawner>();
if ((Object)(object)componentInChildren3 == (Object)null)
{
Debug.LogError((object)("[错误] Spawner 中找不到 UnitSpawner 组件: " + 礼物精灵名字));
return;
}
componentInChildren3.units = 礼物精灵单位;
RangeWeapon componentInChildren4 = val5.GetComponentInChildren<RangeWeapon>();
if ((Object)(object)componentInChildren4 == (Object)null)
{
Debug.LogError((object)("[错误] 礼物盒中找不到 RangeWeapon 组件: " + 礼物精灵名字));
return;
}
componentInChildren4.ObjectToSpawn = val3;
if (!SLMALoader.SDic.ContainsKey("blueprints") || SLMALoader.SDic["blueprints"] == null)
{
Debug.LogError((object)"[错误] blueprints 资源为空");
return;
}
if (!SLMALoader.SDic["blueprints"].ContainsKey("UNIT_SECRET_THROWER_PRESENT"))
{
Debug.LogError((object)"[错误] UNIT_SECRET_THROWER_PRESENT 蓝图不存在");
return;
}
UnitBlueprint val8 = (UnitBlueprint)SLMALoader.SDic["blueprints"]["UNIT_SECRET_THROWER_PRESENT"];
if ((Object)(object)val8 == (Object)null)
{
Debug.LogError((object)"[错误] UNIT_SECRET_THROWER_PRESENT 蓝图为空");
return;
}
if (!SLMALoader.SDic.ContainsKey("sprites") || SLMALoader.SDic["sprites"] == null)
{
Debug.LogError((object)"[错误] sprites 资源为空");
return;
}
if (!SLMALoader.SDic["sprites"].ContainsKey("Thrown_Present"))
{
Debug.LogError((object)"[错误] Thrown_Present 精灵不存在");
return;
}
Sprite tutututu = UManager.tutututu;
UnitBlueprint val9 = SLMATool.CreateUnit(text, val8, 所属派系, tutututu);
if ((Object)(object)val9 == (Object)null)
{
Debug.LogError((object)("[错误] 创建单位失败: " + text));
return;
}
val9.RightWeapon = val5;
Debug.Log((object)("[成功] 礼物精灵加载完成: " + 礼物精灵名字));
}
private static string 生成随机名称(string 前缀)
{
Random random = new Random();
StringBuilder stringBuilder = new StringBuilder(前缀);
stringBuilder.Append("_");
for (int i = 0; i < 8; i++)
{
stringBuilder.Append("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[random.Next("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".Length)]);
}
return stringBuilder.ToString();
}
}