Decompiled source of BeeCreative v1.2.0

BeeCreative.dll

Decompiled 2 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using Landfall.TABS;
using Landfall.TABS.AI.Components.Modifiers;
using Landfall.TABS.UnitEditor;
using Landfall.TABS.Workshop;
using Properties;
using TGCore;
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("BeeCreative")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BeeCreative")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("88340db7-6a58-4c75-bfe6-146162399d67")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("BeeCreative.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static byte[] creative
		{
			get
			{
				object obj = ResourceManager.GetObject("creative", resourceCulture);
				return (byte[])obj;
			}
		}

		internal Resources()
		{
		}
	}
}
namespace Creative
{
	[BepInPlugin("teamgrad.beecreative", "BeeCreative", "1.2.0")]
	public class BCLauncher : TGMod
	{
		public override void Launch()
		{
			new BCMain();
		}

		public override void SceneManager(Scene scene, LoadSceneMode loadSceneMode)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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<MovementTypeWrapper> list = new List<MovementTypeWrapper>(component.MovementTypes);
			list.Add(new MovementTypeWrapper
			{
				DisplayName = "Keep Running"
			});
			component.MovementTypes = list.ToArray();
			List<IMovementComponent> list2 = new List<IMovementComponent>(component.MovementTypesComponents);
			list2.Add((IMovementComponent)(object)default(NeverStopRunning));
			component.MovementTypesComponents = list2;
			List<UnitBaseWrapper> list3 = new List<UnitBaseWrapper>(component.UnitBases);
			UnitBlueprint[] array = BCMain.creative.LoadAllAssets<UnitBlueprint>();
			foreach (UnitBlueprint val in array)
			{
				UnitBaseWrapper wrapper = new UnitBaseWrapper
				{
					BaseDisplayName = val.Entity.Name,
					UnitBaseBlueprint = val,
					UnitBaseRestriction = (UnitBaseRestrictions)0
				};
				val.Entity.GetSpriteIconAsync((Action<Sprite>)delegate(Sprite sprite)
				{
					wrapper.BaseIcon = sprite;
				});
				list3.Add(wrapper);
			}
			component.UnitBases = list3.ToArray();
		}
	}
	public class BCMain
	{
		public static AssetBundle creative = AssetBundle.LoadFromMemory(Resources.creative);

		public BCMain()
		{
			Material[] array = creative.LoadAllAssets<Material>();
			foreach (Material val in array)
			{
				if (Object.op_Implicit((Object)(object)Shader.Find(((Object)val.shader).name)))
				{
					val.shader = Shader.Find(((Object)val.shader).name);
				}
			}
			foreach (UnitBlueprint unit in from x in creative.LoadAllAssets<UnitBlueprint>()
				where (Object)(object)x.UnitBase != (Object)null
				select x)
			{
				foreach (GameObject item in from unitBase in TGMain.landfallDb.GetUnitBases().ToList()
					where ((Object)unitBase).name == ((Object)unit.UnitBase).name
					select unitBase)
				{
					unit.UnitBase = item;
				}
			}
			GameObject[] source = creative.LoadAllAssets<GameObject>();
			TGAddons.AddItems((IEnumerable<UnitBlueprint>)creative.LoadAllAssets<UnitBlueprint>(), (IEnumerable<Faction>)creative.LoadAllAssets<Faction>(), (IEnumerable<TABSCampaignAsset>)creative.LoadAllAssets<TABSCampaignAsset>(), (IEnumerable<TABSCampaignLevelAsset>)creative.LoadAllAssets<TABSCampaignLevelAsset>(), (IEnumerable<VoiceBundle>)creative.LoadAllAssets<VoiceBundle>(), (IEnumerable<FactionIcon>)creative.LoadAllAssets<FactionIcon>(), source.Select((GameObject x) => x.GetComponent<Unit>()), source.Select((GameObject x) => x.GetComponent<PropItem>()), source.Select((GameObject x) => x.GetComponent<SpecialAbility>()), source.Select((GameObject x) => x.GetComponent<WeaponItem>()), source.Select((GameObject x) => x.GetComponent<ProjectileEntity>()));
			TGMain.newSounds.AddRange(creative.LoadAllAssets<SoundBank>());
		}
	}
}