diff --git a/DOOMLAB.csproj b/DOOMLAB.csproj
index 9a65209..c276546 100644
--- a/DOOMLAB.csproj
+++ b/DOOMLAB.csproj
@@ -32,6 +32,9 @@
prompt
4
false
+
+
+ true
@@ -58,6 +61,7 @@
+
diff --git a/Resources/doomlab_pcvr.pack b/Resources/doomlab_pcvr.pack
index 7179aa7..568a3cb 100644
Binary files a/Resources/doomlab_pcvr.pack and b/Resources/doomlab_pcvr.pack differ
diff --git a/src/BuildInfo.gen.cs b/src/BuildInfo.gen.cs
index 12adbe9..d0de3f4 100644
--- a/src/BuildInfo.gen.cs
+++ b/src/BuildInfo.gen.cs
@@ -5,7 +5,7 @@ namespace NEP.DOOMLAB
{
static partial class BuildInfo
{
- public const int Epoch = 1697904181;
- public const string GitCommit = "a5bba7b30f40cb9046e7c684976a479b5dbbc613";
+ public const int Epoch = 1700279253;
+ public const string GitCommit = "ed056811e315911ab1b79dfd78dc91bb170c082c";
}
}
\ No newline at end of file
diff --git a/src/DoomGame.cs b/src/DoomGame.cs
index 3868f70..e88ce21 100644
--- a/src/DoomGame.cs
+++ b/src/DoomGame.cs
@@ -1,6 +1,7 @@
using System;
using MelonLoader;
using NEP.DOOMLAB.Data;
+using NEP.DOOMLAB.Entities;
using UnityEngine;
namespace NEP.DOOMLAB.Game
@@ -87,6 +88,16 @@ public DoomGame()
private float ticTimer;
+ public static void DeleteCorpses()
+ {
+ var corpses = MobjManager.Instance.mobjs.FindAll((mobj) => mobj.flags.HasFlag(MobjFlags.MF_CORPSE));
+
+ foreach(var corpse in corpses)
+ {
+ MobjManager.Instance.RemoveMobj(corpse);
+ }
+ }
+
public void Update()
{
try
diff --git a/src/Entities/Mobj.cs b/src/Entities/Mobj.cs
index d8a8d12..21da0de 100644
--- a/src/Entities/Mobj.cs
+++ b/src/Entities/Mobj.cs
@@ -83,9 +83,6 @@ public enum MoveDirection
private void Awake()
{
- info = Info.MobjInfos[(int)type];
- playerHealth = BoneLib.Player.rigManager.GetComponent();
-
if(ComponentCache == null)
{
ComponentCache = new Instances();
@@ -98,6 +95,9 @@ private void Awake()
private void Start()
{
+ info = Info.MobjInfos[(int)type];
+ playerHealth = BoneLib.Player.rigManager.GetComponent();
+
player.health = player.playerHealth.curr_Health;
DoomGame.Instance.OnTick += WorldTick;
}
diff --git a/src/Entities/MobjManager.cs b/src/Entities/MobjManager.cs
index bf797db..de8b42c 100644
--- a/src/Entities/MobjManager.cs
+++ b/src/Entities/MobjManager.cs
@@ -36,13 +36,6 @@ public Mobj SpawnMobj(Vector3 position, MobjType type, float angle = 0f)
GameObject mobjBase = GameObject.Instantiate(mobjPrefab, position, Quaternion.AngleAxis(angle, Vector3.up));
Mobj mobj = mobjBase.GetComponent();
mobj.brain = mobjBase.GetComponent();
-
- if(mobj.flags.HasFlag(MobjFlags.MF_SHOOTABLE) || mobj.flags.HasFlag(MobjFlags.MF_COUNTKILL))
- {
- var trpSphere = mobjBase.transform.GetChild(0).gameObject;
- trpSphere.AddComponent();
- }
-
mobj.rigidbody = mobjBase.GetComponent();
mobj.collider = mobjBase.GetComponent();
mobj.audioSource = mobjBase.GetComponent();
@@ -61,6 +54,12 @@ public Mobj SpawnMobj(Vector3 position, MobjType type, float angle = 0f)
mobj.collider.center = Vector3.up * (mobj.height / 32f) / 2f;
mobj.collider.size = new Vector3(mobj.radius / 32f, mobj.height / 32f, mobj.radius / 32f);
+ if(mobj.flags.HasFlag(MobjFlags.MF_SHOOTABLE) || mobj.flags.HasFlag(MobjFlags.MF_COUNTKILL))
+ {
+ var trpSphere = mobjBase.transform.GetChild(0).gameObject;
+ trpSphere.transform.localPosition = Vector3.up * mobj.height / 32f;
+ }
+
ImpactProperties impactProperties = mobjBase.GetComponent();
impactProperties.surfaceData = Main.mobjSurfaceData;
diff --git a/src/Main.cs b/src/Main.cs
index 455dbaa..fc97081 100644
--- a/src/Main.cs
+++ b/src/Main.cs
@@ -18,6 +18,7 @@
using SLZ.Data;
using SLZ.Combat;
using SLZ.Marrow.Warehouse;
+using NEP.DOOMLAB.Patches;
namespace NEP.DOOMLAB
{
@@ -120,7 +121,7 @@ internal void BoneMenuStuff()
MenuCategory menuCategory = MenuManager.CreateCategory("Not Enough Photons", Color.white);
var doomCategory = menuCategory.CreateCategory("DOOMLAB", Color.white);
- var gameFlagsCategory = doomCategory.CreateCategory("Game Flags", Color.white);
+ var gameFlagsCategory = doomCategory.CreateCategory("Game Settings", Color.white);
var debugCategory = doomCategory.CreateCategory("Debug", Color.white);
gameFlagsCategory.CreateBoolElement("Disable Thinking", Color.white, false, (value) => Settings.DisableAI = value);
@@ -131,6 +132,7 @@ internal void BoneMenuStuff()
DoomGame.Instance.UpdateFastMonsters(Settings.FastMonsters);
});
gameFlagsCategory.CreateBoolElement("Respawn Monsters", Color.white, false, (value) => Settings.RespawnMonsters = value);
+ gameFlagsCategory.CreateFunctionElement("Clear Corpses", Color.red, () => DoomGame.DeleteCorpses());
debugCategory.CreateFloatElement("Projectile Pruning Distance", Color.white, 128f, 32f, 0f, 4096f, (value) => Settings.ProjectilePruneDistance = value);
debugCategory.CreateBoolElement("MOBJ Debug Stats", Color.white, false, (value) => Settings.EnableMobjDebug = value);
diff --git a/src/Patches/AttackPatch.cs b/src/Patches/AttackPatch.cs
new file mode 100644
index 0000000..1a842d9
--- /dev/null
+++ b/src/Patches/AttackPatch.cs
@@ -0,0 +1,91 @@
+using System;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+using UnityEngine;
+
+using MelonLoader;
+
+using SLZ.AI;
+using SLZ.Combat;
+using SLZ.Marrow.Data;
+
+namespace NEP.DOOMLAB.Patches
+{
+ internal static class AttackPatch
+ {
+
+ public static Action OnAttackReceived;
+
+ private static AttackPatchDelegate _original;
+ private delegate void AttackPatchDelegate(IntPtr instance, IntPtr attack, IntPtr method);
+
+ public static unsafe void Patch()
+ {
+ AttackPatchDelegate patch = Patch;
+
+ string nativeInfoName = "NativeMethodInfoPtr_ReceiveAttack_Public_Virtual_Final_New_Void_Attack_0";
+ var tgtPtr = *(IntPtr*)(IntPtr)typeof(ImpactProperties).GetField(nativeInfoName, BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
+ var dstPtr = patch.Method.MethodHandle.GetFunctionPointer();
+
+ MelonUtils.NativeHookAttach((IntPtr)(&tgtPtr), dstPtr);
+ _original = Marshal.GetDelegateForFunctionPointer(tgtPtr);
+ }
+
+ public static void Patch(IntPtr instance, IntPtr attack, IntPtr method)
+ {
+ _original(instance, attack, method);
+
+ unsafe
+ {
+ try
+ {
+ Attack_ refAttack = *(Attack_*)attack;
+
+ Attack _attack = new Attack()
+ {
+ damage = refAttack.damage,
+ normal = refAttack.normal,
+ origin = refAttack.origin,
+ backFacing = refAttack.backFacing == 1 ? true : false,
+ OrderInPool = refAttack.OrderInPool,
+ collider = refAttack.Collider,
+ attackType = refAttack.attackType,
+ proxy = refAttack.Proxy
+ };
+
+ OnAttackReceived?.Invoke(_attack);
+ }
+ catch
+ {
+
+ }
+ }
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ public struct Attack_
+ {
+ public float damage;
+ public Vector3 normal;
+ public Vector3 origin;
+ public byte backFacing;
+ public int OrderInPool;
+ public IntPtr collider;
+ public AttackType attackType;
+ public IntPtr proxy;
+
+ public Collider Collider
+ {
+ get => new Collider(collider);
+ set => collider = value.Pointer;
+ }
+
+ public TriggerRefProxy Proxy
+ {
+ get => new TriggerRefProxy(proxy);
+ set => proxy = value.Pointer;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Patches/NPCPatches.cs b/src/Patches/NPCPatches.cs
index f4f7f3d..8b5cf02 100644
--- a/src/Patches/NPCPatches.cs
+++ b/src/Patches/NPCPatches.cs
@@ -7,16 +7,9 @@
using MelonLoader;
using PuppetMasta;
+using UnityEngine;
namespace NEP.DOOMLAB.Patches
{
- [HarmonyLib.HarmonyPatch(typeof(SubBehaviourSensors))]
- [HarmonyLib.HarmonyPatch(nameof(SubBehaviourSensors.AddThreat))]
- public static class BehaviourBaseNavPatches4
- {
- public static void Postfix(TriggerRefProxy trp, float threat)
- {
- MelonLoader.MelonLogger.Msg("Add threat: " + trp.name + " Threat: " + threat);
- }
- }
+
}