using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AwesomeTechnologies.VegetationSystem;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Bossa.Cinematika;
using Bossa.Dynamika.Character;
using Coherence;
using Coherence.Common;
using Expanse;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Microsoft.CodeAnalysis;
using Steamworks;
using UnityEngine;
using WildSkies.IslandExport;
using WildSkies.Service;
using WildSkies.Service.Data;
using WildSkies.World;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Headless")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Nines (Natives)")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("Headless")]
[assembly: AssemblyTitle("Headless")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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 Headless
{
[BepInPlugin("Headless", "Headless", "1.0.2")]
public class Plugin : BasePlugin
{
internal static ManualLogSource Log;
internal static Harmony harmonyInstance;
private static int CreateLobby_MaxMembers;
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>("Headless");
((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(InputService), "InventoryKeyDown")]
[HarmonyPatch(typeof(CameraManager), "CameraUpdate")]
[HarmonyPatch(typeof(ApvWindSampler), "SampleAPV")]
[HarmonyPatch(typeof(IslandTextureData), "GenerateWorldTextureArrays")]
[HarmonyPatch(typeof(CloudManager), "GetSceneManager")]
[HarmonyPatch(typeof(VegetationSystemPro), "OnEnable")]
[HarmonyPatch(typeof(VegetationSystemPro), "OnDisable")]
[HarmonyPatch(typeof(PlayerLootParticleController), "UpdateLootParticles")]
[HarmonyPrefix]
public static bool DisableIfBatchMode()
{
return !Application.isBatchMode;
}
[HarmonyPatch(typeof(EntityRendererService), "Initialise")]
[HarmonyPrefix]
public static bool EntityRendererService_Initialise(EntityRendererService __instance, ref int __result)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
if (!Application.isBatchMode)
{
return true;
}
foreach (EffectSource item in (Il2CppArrayBase<EffectSource>)(object)__instance._effectSources)
{
__instance._effectSourceMap.Add(item.Alignment, item);
}
__result = 0;
return false;
}
[HarmonyPatch(typeof(SceneService), "LoadLobby")]
[HarmonyPrefix]
public static bool SceneService_LoadLobby()
{
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Expected O, but got Unknown
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
if (!Application.isBatchMode)
{
return true;
}
try
{
ProjectContextInstaller.ResolveObject<AudioService>().SetMasterVolume(0f);
string[] commandLineArgs = Environment.GetCommandLineArgs();
int num = Array.FindIndex(commandLineArgs, 1, (string x) => x.Equals("-player", StringComparison.OrdinalIgnoreCase));
int num2 = Array.FindIndex(commandLineArgs, 1, (string x) => x.Equals("-world", StringComparison.OrdinalIgnoreCase));
int num3 = Array.FindIndex(commandLineArgs, 1, (string x) => x.Equals("-maxPlayers", StringComparison.OrdinalIgnoreCase));
string text = ((num > 0 && num + 1 < commandLineArgs.Length) ? commandLineArgs[num + 1] : "Host");
string text2 = ((num2 > 0 && num2 + 1 < commandLineArgs.Length) ? commandLineArgs[num2 + 1] : "World");
CreateLobby_MaxMembers = ((num3 > 0 && num3 + 1 < commandLineArgs.Length) ? int.Parse(commandLineArgs[num3 + 1]) : 6);
PlatformService val = ProjectContextInstaller.ResolveObject<PlatformService>();
string text3 = Path.Combine(val.GetSaveDataCharactersPath(), val.MakeValidFileName(text) + ".lsc").Replace('/', '\\');
if (!((Il2CppArrayBase<string>)(object)val.GetAllSavedCharacters()).Contains(text3))
{
CharacterSaveData val2 = new CharacterSaveData();
val2.CharacterName = text;
val2.Version = 4;
val2.TimeStamp = DateTime.UtcNow;
val2.LastSaved = val2.TimeStamp;
val.SaveCharacterData(text3, val2);
}
SceneContextInstaller.ResolveObject<CharacterDataService>().SetCharacterSaveData(text3, val.LoadCharacterData(text3));
WorldDBService val3 = SceneContextInstaller.ResolveObject<WorldDBService>();
string text4 = Path.Combine(val.GetSaveDataWorldsPath(), val.MakeValidFileName(text2) + ".db").Replace('/', '\\');
if (!((Il2CppArrayBase<string>)(object)val.GetAllSavedWorlds()).Contains(text4))
{
val3.CreateWorldDatabase(text4, text2);
}
val3.InitDatabase(text4);
NetworkService obj = SceneContextInstaller.ResolveObject<NetworkService>();
obj.StartReplicationServer();
obj.JoinNewRoomWithTag(text2, new string[3] { "public", "local", text2 });
}
catch
{
Application.Quit();
}
return false;
}
[HarmonyPatch(typeof(SteamMatchmaking), "CreateLobbyAsync")]
[HarmonyPrefix]
public static void SteamMatchmaking_CreateLobbyAsync(ref int maxMembers)
{
if (Application.isBatchMode && CreateLobby_MaxMembers > 0)
{
maxMembers = CreateLobby_MaxMembers;
}
}
[HarmonyPatch(typeof(HostControl), "HostStartup")]
[HarmonyPostfix]
public static void HostControl_HostStartup()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: 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_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
if (Application.isBatchMode)
{
PlayersService val = SceneContextInstaller.ResolveObject<PlayersService>();
val.SetInvincible(true);
FloatingWorldOriginService val2 = SceneContextInstaller.ResolveObject<FloatingWorldOriginService>();
DynamikaCharacter dynamikaCharacter = val.LocalPlayer.DynamikaCharacter;
Vector3d val3 = CoherenceToUnityConverters.ToVector3d(Vector3.zero) - val2.CurrentFloatingWorldOrigin;
dynamikaCharacter.Teleport(CoherenceToUnityConverters.ToUnityVector3(((Vector3d)(ref val3)).ToCoreVector3()), ((Component)val.LocalPlayer.DynamikaCharacter).transform.rotation, false, true);
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "Headless";
public const string PLUGIN_NAME = "Headless";
public const string PLUGIN_VERSION = "1.0.2";
}
}