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 BepInEx;
using DM;
using HarmonyLib;
using Landfall.TABS;
using Landfall.TABS.UnitEditor;
using SLMA;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("UnitAppearanceReset")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("UnitAppearanceReset")]
[assembly: AssemblyProduct("UnitAppearanceReset")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7acfaef0-7669-4401-8bff-5a9a02e18c75")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace UnitAppearanceReset;
public static class UManager
{
public class Utility : MonoBehaviour
{
public static class PrimitiveHelper
{
private static Dictionary<PrimitiveType, Mesh> primitiveMeshes;
public static GameObject CreatePrimitive(PrimitiveType type, bool withCollider)
{
//IL_0017: 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)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
if (withCollider)
{
return GameObject.CreatePrimitive(type);
}
GameObject val = new GameObject(((object)(PrimitiveType)(ref type)).ToString());
val.AddComponent<MeshFilter>().sharedMesh = GetPrimitiveMesh(type);
val.AddComponent<MeshRenderer>();
return val;
}
public static Mesh GetPrimitiveMesh(PrimitiveType type)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
if (!primitiveMeshes.ContainsKey(type))
{
CreatePrimitiveMesh(type);
}
return primitiveMeshes[type];
}
private static Mesh CreatePrimitiveMesh(PrimitiveType type)
{
//IL_0000: 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)
GameObject obj = GameObject.CreatePrimitive(type);
Mesh sharedMesh = obj.GetComponent<MeshFilter>().sharedMesh;
Object.Destroy((Object)(object)obj);
primitiveMeshes[type] = sharedMesh;
return sharedMesh;
}
static PrimitiveHelper()
{
primitiveMeshes = new Dictionary<PrimitiveType, Mesh>();
}
}
public static GameObject LoadBundleGameObject(string name)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
return (GameObject)bundle.LoadAsset(name);
}
public static Material LoadBundleMaterial(string name)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
return (Material)bundle.LoadAsset(name);
}
public static Sprite LoadBundleTextureToSprite(string name)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0031: 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)
Texture2D val = (Texture2D)bundle.LoadAsset(name);
((Texture)val).filterMode = (FilterMode)0;
return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
}
}
private static string comment;
public static AssetBundle bundle;
public static UnitBlueprint[] unitBasesBlueprints;
public static void SetBlueprint(UnitBlueprint unit, LandfallContentDatabase db)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Expected O, but got Unknown
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Expected O, but got Unknown
if ((Object)(object)unit == (Object)(UnitBlueprint)SLMALoader.SDic["blueprints"]["UNIT_VIKING_JARL"])
{
unit.UnitBase = UPool.MyPool.GetObject("Humanoid_Jarl");
unit.m_props = (GameObject[])(object)new GameObject[1] { UPool.MyPool.GetObject("NewJarlSuit") };
}
if ((Object)(object)unit == (Object)(UnitBlueprint)SLMALoader.SDic["blueprints"]["UNIT_VIKING_BERSERKER"])
{
unit.UnitBase = UPool.MyPool.GetObject("Humanoid_Berserker");
unit.LeftWeapon = UPool.MyPool.GetObject("SturdierBerserkerAxe");
unit.RightWeapon = UPool.MyPool.GetObject("SturdierBerserkerAxe");
unit.m_props = (GameObject[])(object)new GameObject[1] { UPool.MyPool.GetObject("NewBerserkerSuit") };
}
if ((Object)(object)unit == (Object)(UnitBlueprint)SLMALoader.SDic["blueprints"]["UNIT_ASIA_MONK"])
{
unit.UnitBase = UPool.MyPool.GetObject("Humanoid_Monk");
unit.RightWeapon = UPool.MyPool.GetObject("MonkNaginata");
unit.m_props = (GameObject[])(object)new GameObject[2]
{
UPool.MyPool.GetObject("NewMonkSuit"),
UPool.MyPool.GetObject("NewMonkClothSuit")
};
}
if ((Object)(object)unit == (Object)(UnitBlueprint)SLMALoader.SDic["blueprints"]["UNIT_MEDIEVAL_KNIGHT"])
{
unit.UnitBase = UPool.MyPool.GetObject("Humanoid_Berserker");
unit.LeftWeapon = UPool.MyPool.GetObject("NewKnightShield");
unit.RightWeapon = UPool.MyPool.GetObject("NewKnightSword");
unit.m_propData = (PropItemData[])(object)new PropItemData[0];
unit.m_props = (GameObject[])(object)new GameObject[1] { UPool.MyPool.GetObject("KnightClothes") };
}
if (unit.Entity.Name == "Reskinned Jarl")
{
unit.UnitBase = UPool.MyPool.GetObject("Humanoid_Jarl");
s.SetField<UnitBlueprint>(unit, "VocalRef", (object)"Viking Attack Vocals/Jarl");
s.SetField<UnitBlueprint>(unit, "DeathRef", (object)"Viking Death Vocals/Jarl");
}
if (unit.Entity.Name == "Reskinned Berserker")
{
unit.UnitBase = UPool.MyPool.GetObject("Humanoid_Berserker");
s.SetField<UnitBlueprint>(unit, "VocalRef", (object)"Viking Attack Vocals/Berserker");
s.SetField<UnitBlueprint>(unit, "DeathRef", (object)"Viking Death Vocals/Berserker");
}
if (unit.Entity.Name == "Reskinned Monk")
{
unit.UnitBase = UPool.MyPool.GetObject("Humanoid_Monk");
s.SetField<UnitBlueprint>(unit, "VocalRef", (object)"Asia Attack Vocals/Monk");
s.SetField<UnitBlueprint>(unit, "DeathRef", (object)"Asia Death Vocals/Monk");
}
}
public static void SetClothes(GameObject cloth, CharacterItem item, PropItemData data, LandfallContentDatabase db)
{
}
public static void SetMoves(GameObject move, LandfallContentDatabase db)
{
}
public static void SetUnits(Unit unit, LandfallContentDatabase db)
{
if (((Object)((Component)unit).gameObject).name == ((Object)UPool.MyPool.GetObject("Humanoid_Jarl")).name)
{
SkinnedMeshRenderer[] componentsInChildren = ((Component)unit).GetComponentsInChildren<SkinnedMeshRenderer>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
((Component)componentsInChildren[i]).gameObject.tag = "UnitMesh";
}
}
if (((Object)((Component)unit).gameObject).name == ((Object)UPool.MyPool.GetObject("Humanoid_Berserker")).name)
{
SkinnedMeshRenderer[] componentsInChildren2 = ((Component)unit).GetComponentsInChildren<SkinnedMeshRenderer>();
for (int j = 0; j < componentsInChildren2.Length; j++)
{
((Component)componentsInChildren2[j]).gameObject.tag = "UnitMesh";
}
}
}
public static void Init(LandfallContentDatabase db)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
//IL_0276: Unknown result type (might be due to invalid IL or missing references)
//IL_0281: Expected O, but got Unknown
//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
//IL_02b1: Expected O, but got Unknown
//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
//IL_02e1: Expected O, but got Unknown
LoadBundle("unitappearanceresetbundle");
Sprite val = (Sprite)SLMALoader.SDic["sprites"]["Icons_128x128_Giant"];
comment = "----------------------------------------------------------------------------------------------------------------------------";
comment = "Custom Weapon Items";
comment = "----------------------------------------------------------------------------------------------------------------------------";
UPool.MyPool.AddObject("NewKnightShield", Utility.LoadBundleGameObject("NewKnightShield"), true, (HideFlags)52, val, 625432423, true);
UPool.MyPool.AddObject("NewKnightSword", Utility.LoadBundleGameObject("NewKnightSword"), true, (HideFlags)52, val, 62323234, true);
UPool.MyPool.AddObject("SturdierBerserkerAxe", Utility.LoadBundleGameObject("SturdierBerserkerAxe"), true, (HideFlags)52, val, 6345243, true);
UPool.MyPool.AddObject("MonkNaginata", Utility.LoadBundleGameObject("MonkNaginata"), true, (HideFlags)52, val, 73453454, true);
comment = "----------------------------------------------------------------------------------------------------------------------------";
comment = "Custom Clothes Items";
comment = "----------------------------------------------------------------------------------------------------------------------------";
UPool.MyPool.AddObject("NewBerserkerSuit", Utility.LoadBundleGameObject("NewBerserkerSuit"), true, (HideFlags)52, val, 7253234, true);
UPool.MyPool.AddObject("NewMonkSuit", Utility.LoadBundleGameObject("NewMonkSuit"), true, (HideFlags)52, val, 7642433, true);
UPool.MyPool.AddObject("NewMonkClothSuit", Utility.LoadBundleGameObject("NewMonkClothSuit"), true, (HideFlags)52, val, 1251232, true);
UPool.MyPool.AddObject("KnightClothes", Utility.LoadBundleGameObject("KnightClothes"), true, (HideFlags)52, val, 7645324, true);
UPool.MyPool.AddObject("NewJarlSuit", Utility.LoadBundleGameObject("NewJarlSuit"), true, (HideFlags)52, val, 1254123, true);
comment = "----------------------------------------------------------------------------------------------------------------------------";
comment = "Custom Unit Bases Items";
comment = "----------------------------------------------------------------------------------------------------------------------------";
UPool.MyPool.AddObject("Humanoid_Jarl", Utility.LoadBundleGameObject("Humanoid_Jarl"), true, (HideFlags)52, val, 63454342, true);
UPool.MyPool.AddObject("Humanoid_Berserker", Utility.LoadBundleGameObject("Humanoid_Berserker"), true, (HideFlags)52, val, 6363342, true);
UPool.MyPool.AddObject("Humanoid_Monk", Utility.LoadBundleGameObject("Humanoid_Monk"), true, (HideFlags)52, val, 7345454, true);
comment = "----------------------------------------------------------------------------------------------------------------------------";
comment = "Inserting Unit Bases";
comment = "----------------------------------------------------------------------------------------------------------------------------";
unitBasesBlueprints = new List<UnitBlueprint>
{
SLMATool.CreateUnit("Reskinned Jarl", (UnitBlueprint)null, (Faction)SLMALoader.SDic["factions"]["Subunits"], val),
SLMATool.CreateUnit("Reskinned Berserker", (UnitBlueprint)null, (Faction)SLMALoader.SDic["factions"]["Subunits"], val),
SLMATool.CreateUnit("Reskinned Monk", (UnitBlueprint)null, (Faction)SLMALoader.SDic["factions"]["Subunits"], val)
}.ToArray();
}
public static void SetWeapon(GameObject weapon, MeleeWeapon melee, RangeWeapon range, LandfallContentDatabase db)
{
}
public static void SetEffects(GameObject effect)
{
}
public static void LoadBundle(string assetBundleName)
{
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(assetBundleName);
bundle = AssetBundle.LoadFromStream(stream);
}
public static void SetExplosion(GameObject explosion)
{
}
public static void SetProjectile(GameObject proj, ProjectileHit projhit, LandfallContentDatabase db)
{
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("GeeztJeez.UnitAppearanceReset", "UnitAppearanceReset", "1.0.3")]
internal class Loader : BaseUnityPlugin
{
private void Awake()
{
((MonoBehaviour)this).StartCoroutine("Call");
}
private IEnumerator Call()
{
yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)Object.FindObjectOfType<ServiceLocator>() != (Object)null));
yield return (object)new WaitUntil((Func<bool>)(() => ServiceLocator.GetService<ISaveLoaderService>() != null));
Debug.Log((object)"Loading UnitAppearanceReset!");
SLMALoader.GetInstance();
SceneManager.sceneLoaded += SceneLoaded;
LandfallContentDatabase landfallContentDatabase = ContentDatabase.Instance().LandfallContentDatabase;
UManager.Init(landfallContentDatabase);
new Harmony("UnitAppearanceReset").PatchAll();
GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
for (int i = 0; i < array.Length; i++)
{
if (Object.op_Implicit((Object)(object)array[i].GetComponent<Explosion>()))
{
UManager.SetExplosion(array[i]);
}
if (Object.op_Implicit((Object)(object)array[i].GetComponent<ProjectileHit>()))
{
UManager.SetProjectile(array[i], array[i].GetComponent<ProjectileHit>(), landfallContentDatabase);
}
if (Object.op_Implicit((Object)(object)array[i].GetComponent<Unit>()))
{
UManager.SetUnits(array[i].GetComponent<Unit>(), landfallContentDatabase);
}
if (Object.op_Implicit((Object)(object)array[i].GetComponent<WeaponItem>()))
{
UManager.SetWeapon(array[i], array[i].GetComponent<MeleeWeapon>(), array[i].GetComponent<RangeWeapon>(), landfallContentDatabase);
}
if (Object.op_Implicit((Object)(object)array[i].GetComponent<PlaySoundEffect>()))
{
UManager.SetEffects(array[i]);
}
if (Object.op_Implicit((Object)(object)array[i].GetComponent<SpecialAbility>()))
{
UManager.SetMoves(array[i], landfallContentDatabase);
}
if (Object.op_Implicit((Object)(object)array[i].GetComponent<PropItem>()))
{
UManager.SetClothes(array[i], array[i].GetComponent<CharacterItem>(), array[i].GetComponent<PropItemData>(), landfallContentDatabase);
}
}
UnitBlueprint[] array2 = Resources.FindObjectsOfTypeAll<UnitBlueprint>();
for (int j = 0; j < array2.Length; j++)
{
UManager.SetBlueprint(array2[j], landfallContentDatabase);
array2[j].Validate();
}
Debug.Log((object)"Loaded UnitAppearanceReset Successfully!");
}
public void SceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: 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)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Expected O, but got Unknown
if (!(((Scene)(ref scene)).name == "UnitCreator_GamepadUI"))
{
return;
}
UnitEditorManager component = ((Scene)(ref scene)).GetRootGameObjects().ToList().Find((GameObject x) => Object.op_Implicit((Object)(object)x.GetComponent<UnitEditorManager>()))
.GetComponent<UnitEditorManager>();
List<UnitBaseWrapper> list = new List<UnitBaseWrapper>(component.UnitBases);
UnitBlueprint[] unitBasesBlueprints = UManager.unitBasesBlueprints;
foreach (UnitBlueprint val in unitBasesBlueprints)
{
UnitBaseWrapper wrapper = new UnitBaseWrapper
{
BaseDisplayName = val.Entity.Name,
UnitBaseBlueprint = val,
UnitBaseRestriction = (UnitBaseRestrictions)0
};
val.Entity.GetSpriteIconAsync((Action<Sprite>)delegate(Sprite sprite)
{
wrapper.BaseIcon = sprite;
});
list.Add(wrapper);
}
component.UnitBases = list.ToArray();
}
}