using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem;
using Il2CppSystem.Collections;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using UnityEngine;
using WildSkies.Database;
using WildSkies.Service;
using WildSkies.Ship;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ShipRollbackFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Nines (Natives)")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("ShipRollbackFix")]
[assembly: AssemblyTitle("ShipRollbackFix")]
[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 ShipRollbackFix
{
[BepInPlugin("ShipRollbackFix", "ShipRollbackFix", "1.0.1")]
public class Plugin : BasePlugin
{
internal static ManualLogSource Log;
internal static Harmony harmonyInstance;
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>("ShipRollbackFix");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
log.LogInfo(val);
harmonyInstance = Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
}
public override bool Unload()
{
Harmony obj = harmonyInstance;
if (obj != null)
{
obj.UnpatchSelf();
}
return true;
}
[HarmonyPatch(typeof(WorldDBService), "InitDatabase")]
[HarmonyPostfix]
public static void WorldDBService_InitDatabase(WorldDBService __instance)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
if (__instance._worldData.Version != 7)
{
return;
}
List<string> val = new List<string>();
foreach (Object item in CollectionExtensions.WrapToManaged(((Il2CppObjectBase)__instance._ldsContainers.FindAll()).Cast<IEnumerable>()))
{
LDSEntityEntry val2 = ((Il2CppObjectBase)item).Cast<LDSEntityEntry>();
V7LDSInstanceData val3 = JsonConvert.DeserializeObject<V7LDSInstanceData>(JsonConvert.DeserializeObject<Dictionary<string, string>>(val2.InstanceData)["_5a574b2b6764eb9428c646bf7c778da0_7229481547701622468"]);
if (!(val2.RootUid == val3.RootUUID.ToString()))
{
Debug.LogWarning(Object.op_Implicit("LDS Container " + val2._id + " RootUid mismatch. Deleting."));
val.Add(val2._id);
}
}
__instance.DeleteLDSEntities(val);
}
[HarmonyPatch(typeof(ShipProjectileCollision), "OwnerDamage")]
[HarmonyPrefix]
public static bool ShipProjectileCollision_OwnerDamage(ShipProjectileCollision __instance)
{
return __instance._shipController._playersService.LocalPlayer.ActiveIslandSwitcher.DoesClosestIslandMatchCurrentIsland();
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "ShipRollbackFix";
public const string PLUGIN_NAME = "ShipRollbackFix";
public const string PLUGIN_VERSION = "1.0.1";
}
}