using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using WildSkies.Gameplay.Building;
using WildSkies.Gameplay.ShipBuilding;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ResizeFlags")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Nines (Natives)")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("ResizeFlags")]
[assembly: AssemblyTitle("ResizeFlags")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ResizeFlags
{
[BepInPlugin("ResizeFlags", "ResizeFlags", "1.0.1")]
public class Plugin : BasePlugin
{
private class ResizeFlagsSimpleChatCommands
{
public static string Scale(float value)
{
if (value <= 0f)
{
ResizeFlags_Scale.Value = (float)((ConfigEntryBase)ResizeFlags_Scale).DefaultValue;
}
else
{
ResizeFlags_Scale.Value = value;
}
return $"Flag scale now set to {value}.";
}
}
internal static ManualLogSource Log;
internal static Harmony harmonyInstance;
private static ConfigEntry<float> ResizeFlags_Scale;
private static readonly string[] PartFilter = new string[3] { "ship.part.decoration.flag.", "ship.part.decoration.sp.gallflag.", "ship.part.decoration.wa.foundersflag." };
public override void Load()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
Log = ((BasePlugin)this).Log;
ManualLogSource log = Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("ResizeFlags");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
log.LogInfo(val);
ResizeFlags_Scale = ((BasePlugin)this).Config.Bind<float>("ResizeFlags", "Scale", 3f, "ResizeFlags.Scale");
harmonyInstance = Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
}
public override bool Unload()
{
Harmony obj = harmonyInstance;
if (obj != null)
{
obj.UnpatchSelf();
}
return true;
}
private static void resizeFlag(Transform transform)
{
//IL_0027: 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_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: 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_007d: Unknown result type (might be due to invalid IL or missing references)
object obj;
if (transform == null)
{
obj = null;
}
else
{
Transform obj2 = transform.Find("dynamic_flag");
obj = ((obj2 != null) ? ((Component)obj2).gameObject : null);
}
GameObject val = (GameObject)obj;
if (Object.op_Implicit((Object)(object)val))
{
Vector3 localScale = Vector3.one * ResizeFlags_Scale.Value;
val.transform.localScale = localScale;
Vector3 localPosition = val.transform.localPosition;
localPosition.y = -5.4f * (val.transform.localScale.y - 1f);
val.transform.localPosition = localPosition;
}
}
[HarmonyPatch(typeof(ShipFrameBuilder), "UpdateHullObjectDetails")]
[HarmonyPostfix]
public static void ShipFrameBuilder_UpdateHullObjectDetails(ShipFrameBuilder __instance, GameObject shipPartGameObject)
{
string itemId = shipPartGameObject.GetComponent<BuildableAsset>().Id;
if (PartFilter.Any((string x) => itemId.StartsWith(x)))
{
resizeFlag(shipPartGameObject.transform);
}
}
[HarmonyPatch(typeof(CraftingToolController), "SetBuildableItemToPlace")]
[HarmonyPrefix]
public static void CraftingToolController_UpdatePlacementStamp(CraftingToolController __instance, BuildableItemDefinition assetData, PlacementStampController placementStamp)
{
string itemId = assetData.ItemId;
if (PartFilter.Any((string x) => itemId.StartsWith(x)))
{
resizeFlag(((Component)placementStamp).transform.Find("Prefab Container/DynamicallyGenerated " + ((Object)assetData.AssetPrefab).name));
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "ResizeFlags";
public const string PLUGIN_NAME = "ResizeFlags";
public const string PLUGIN_VERSION = "1.0.1";
}
}