112 lines
2.9 KiB
C#
112 lines
2.9 KiB
C#
using Dalamud.Hooking;
|
|
using Dalamud.IoC;
|
|
using Dalamud.Plugin;
|
|
using Dalamud.Plugin.Services;
|
|
using Dalamud.Utility.Signatures;
|
|
using Ktisis.Structs.Env;
|
|
using Serilog;
|
|
using Serilog.Core;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Numerics;
|
|
using System.Reflection.Emit;
|
|
using System.Runtime.Intrinsics.Arm;
|
|
|
|
namespace VoidBox;
|
|
|
|
public sealed unsafe class Plugin : IDalamudPlugin
|
|
{
|
|
private readonly List<Cmd> _cmds;
|
|
|
|
public Plugin([RequiredVersion("1.0")] DalamudPluginInterface pluginInterface)
|
|
{
|
|
pluginInterface.Create<Service>();
|
|
|
|
Service.Plugin = this;
|
|
|
|
Service.Config = Service.PluginInterface.GetPluginConfig() as Configuration ?? new();
|
|
Service.Config.Initialize(Service.PluginInterface);
|
|
|
|
Service.PluginUI = new();
|
|
|
|
_cmds = typeof(Plugin).Assembly.GetTypes()
|
|
.Where(t => !t.IsAbstract && typeof(Cmd).IsAssignableFrom(t))
|
|
.Select(t => (Cmd) Activator.CreateInstance(t)!)
|
|
.ToList();
|
|
|
|
foreach (Cmd cmd in _cmds)
|
|
{
|
|
cmd.Register(Service.CommandManager);
|
|
}
|
|
|
|
Service.GameInteropProvider.InitializeFromAttributes(this);
|
|
|
|
EnvStateCopyHook?.Enable();
|
|
}
|
|
|
|
public string Name => "VoidBox";
|
|
|
|
public void Dispose()
|
|
{
|
|
EnvStateCopyHook?.Dispose();
|
|
|
|
foreach (Cmd cmd in _cmds)
|
|
{
|
|
cmd.Dispose();
|
|
}
|
|
|
|
Service.PluginUI.Dispose();
|
|
|
|
Service.Plugin = null!;
|
|
}
|
|
|
|
private void Replace(EnvState* env)
|
|
{
|
|
if (!Service.Config.IsEnabled)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (env->SkyId != 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
env->SkyId = 1;
|
|
env->Clouds.CloudTexture = 10;
|
|
env->Clouds.CloudSideTexture = 48;
|
|
env->Clouds.CloudColor = new Vector3(0f, 0f, 0f);
|
|
env->Clouds.Color2 = new Vector3(1f, 1f, 1f);
|
|
env->Clouds.Gradient = 0.5f;
|
|
env->Clouds.SideHeight = 2f;
|
|
|
|
env->Fog.Color = new Vector4(0.4f, 0.4f, 0.4f, 1f);
|
|
env->Fog.Distance = 50f;
|
|
env->Fog.Thickness = 5f;
|
|
env->Fog.Opacity = 0.231f;
|
|
env->Fog.SkyVisibility = 0.254f;
|
|
|
|
env->Stars.Stars = 20f;
|
|
env->Stars.StarIntensity = 1.104f;
|
|
env->Stars.Constellations = 4.686f;
|
|
env->Stars.ConstellationIntensity = 1.172f;
|
|
env->Stars.GalaxyIntensity = 5.628f;
|
|
env->Stars.MoonColor = new Vector4(1f, 1f, 1f, 1f);
|
|
env->Stars.MoonBrightness = 0.603f;
|
|
}
|
|
|
|
private unsafe delegate nint EnvStateCopyDelegate(EnvState* dest, EnvState* src);
|
|
|
|
[Signature("E8 ?? ?? ?? ?? 49 3B F5", DetourName = nameof(EnvStateCopyDetour))]
|
|
private Hook<EnvStateCopyDelegate> EnvStateCopyHook = null!;
|
|
private unsafe nint EnvStateCopyDetour(EnvState* dest, EnvState* src)
|
|
{
|
|
var exec = EnvStateCopyHook.Original(dest, src);
|
|
|
|
Replace(dest);
|
|
|
|
return exec;
|
|
}
|
|
}
|