diff --git a/Resources/doomlab_pcvr.pack b/Resources/doomlab_pcvr.pack index 8771582..096bbf8 100644 Binary files a/Resources/doomlab_pcvr.pack and b/Resources/doomlab_pcvr.pack differ diff --git a/Resources/doomlab_quest.pack b/Resources/doomlab_quest.pack index eb5ae27..4db626f 100644 Binary files a/Resources/doomlab_quest.pack and b/Resources/doomlab_quest.pack differ diff --git a/src/BuildInfo.gen.cs b/src/BuildInfo.gen.cs index 9add387..77e91e3 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 = 1696211914; - public const string GitCommit = "227216e22af1157829a6af1c619a49298c935660"; + public const int Epoch = 1696279013; + public const string GitCommit = "f8997a61d9a38dcf302ece79289f913ef5d65e30"; } } \ No newline at end of file diff --git a/src/Main.cs b/src/Main.cs index da80865..3d504ed 100644 --- a/src/Main.cs +++ b/src/Main.cs @@ -15,6 +15,8 @@ using BoneLib.BoneMenu.Elements; using BoneLib.BoneMenu; +using SLZ.Marrow.Warehouse; +using UnityEngine.SearchService; namespace NEP.DOOMLAB { @@ -39,6 +41,8 @@ public class Main : MelonMod public static readonly string ModDirectory = Path.Combine(TeamDirectory, "DOOMLAB"); public static readonly string IWADDirectory = Path.Combine(ModDirectory, "IWADS"); public static readonly string PWADDirectory = Path.Combine(ModDirectory, "PWADS"); + + public static Texture2D MissingSprite; private static AssetBundle GetEmbeddedBundle() { @@ -46,7 +50,7 @@ private static AssetBundle GetEmbeddedBundle() string fileName = HelperMethods.IsAndroid() ? "doomlab_quest.pack" : "doomlab_pcvr.pack"; - using (Stream resourceStream = assembly.GetManifestResourceStream("NEP.DOOMLAB." + fileName)) + using (Stream resourceStream = assembly.GetManifestResourceStream("NEP.DOOMLAB.Resources." + fileName)) { using (MemoryStream memoryStream = new MemoryStream()) { @@ -65,6 +69,8 @@ public override void OnInitializeMelon() bundle = GetEmbeddedBundle(); mobjTemplate = bundle.LoadAsset("[MOBJ] - Null").Cast(); mobjTemplate.hideFlags = HideFlags.DontUnloadUnusedAsset; + MissingSprite = bundle.LoadAsset("faila0").Cast(); + MissingSprite.hideFlags = HideFlags.DontUnloadUnusedAsset; new WADManager(); WADManager.Instance.LoadWAD(WADManager.Instance.GetIWAD()); diff --git a/src/Mobj/MobjBrain.cs b/src/Mobj/MobjBrain.cs index fe01719..7bfb6ce 100644 --- a/src/Mobj/MobjBrain.cs +++ b/src/Mobj/MobjBrain.cs @@ -445,16 +445,23 @@ public bool CheckSight(Mobj other) return false; } - Vector3 direction = other.transform.position - mobj.transform.position; + // MobjInteraction.LineAttack(mobj, mobj.transform.position + Vector3.up, mobj.target.transform.position, damage / 10, 128); - if (Physics.Raycast(mobj.transform.position + Vector3.up, direction, out RaycastHit hit, float.PositiveInfinity, 0, QueryTriggerInteraction.Ignore)) + Vector3 origin = mobj.transform.position + Vector3.up; + Vector3 direction = other.transform.position; + Ray ray = new Ray(origin, direction - origin); + + if (Physics.Raycast(ray, out RaycastHit hit, 20)) { - if (hit.collider) + Mobj hitMobj = hit.collider.GetComponent(); + + if(hitMobj != null && hitMobj == other) { - return false; + return true; } } + MelonLogger.Msg("Can see target"); return true; } diff --git a/src/Rendering/MobjRenderer.cs b/src/Rendering/MobjRenderer.cs index f582c3f..0b11dde 100644 --- a/src/Rendering/MobjRenderer.cs +++ b/src/Rendering/MobjRenderer.cs @@ -27,6 +27,9 @@ public MobjRenderer(System.IntPtr ptr) : base(ptr) { } private Camera camera; + private static WAD.DataTypes.Patch missingPatch; + private static SpriteFrame missingFrame; + private void Awake() { meshRenderer = GetComponentInChildren(); @@ -34,6 +37,28 @@ private void Awake() game = DoomGame.Instance; camera = Camera.main; drawQuad = transform.GetChild(0); + + missingPatch = new WAD.DataTypes.Patch("FAILA0", 32, 32, 16, 38); + missingPatch.output = Main.MissingSprite; + + missingFrame = new SpriteFrame() + { + canRotate = false, + flipBits = new bool[8], + mirrorSprite = new bool[8], + numRotations = 0, + patches = new WAD.DataTypes.Patch[8] + { + missingPatch, + missingPatch, + missingPatch, + missingPatch, + missingPatch, + missingPatch, + missingPatch, + missingPatch + } + }; } private void Start() @@ -74,7 +99,14 @@ public void UpdateSprite() } SpriteDef spriteDef = spriteDefs[(int)mobj.sprite]; - SpriteFrame spriteFrame = spriteDef.GetFrame(stateFrame); + + if(spriteDef.spriteFrames == null || stateFrame > spriteDef.spriteFrames.Length) + { + SetSprite(missingFrame, 0); + return; + } + + SpriteFrame spriteFrame = spriteDef.spriteFrames[stateFrame]; // absolutely do NOT render anything if // the patch array is null/empty @@ -102,7 +134,7 @@ private void SetSprite(SpriteFrame spriteFrame, int rotation) float leftOffset = patch.leftOffset / 32f; float topOffset = patch.topOffset / 32f; - + meshRenderer.material.mainTexture = patch.output; transform.localScale = new Vector3(width * xScale, height, 1f); drawQuad.localPosition = new Vector3(leftOffset / 100f, (topOffset / 100f) + 0.5f); diff --git a/src/Rendering/SpriteDef.cs b/src/Rendering/SpriteDef.cs index e3bb492..c46e81f 100644 --- a/src/Rendering/SpriteDef.cs +++ b/src/Rendering/SpriteDef.cs @@ -1,6 +1,6 @@ namespace NEP.DOOMLAB.Rendering { - public struct SpriteDef + public class SpriteDef { public int numFrames; public SpriteFrame[] spriteFrames; @@ -9,21 +9,5 @@ public void ResetFrames() { numFrames = 0; } - - public SpriteFrame GetFrame(int frame) - { - if(spriteFrames == null) - { - // return an empty sprite frame - return new SpriteFrame(); - } - - if (frame > spriteFrames.Length - 1) - { - return spriteFrames[spriteFrames.Length - 1]; - } - - return spriteFrames[frame]; - } } }