From ab44f60401b0d8e723b14e4a327f825e16349249 Mon Sep 17 00:00:00 2001 From: jeffi Date: Mon, 11 Mar 2024 19:04:13 -0500 Subject: [PATCH] Updates to OM to add all objects to `self.objects` --- src/ObjectManager/ObjectManager.lua | 11 +++++++---- src/Spell/Spell.lua | 5 ++--- src/Unit/Unit.lua | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/ObjectManager/ObjectManager.lua b/src/ObjectManager/ObjectManager.lua index 45beac0..31f516f 100644 --- a/src/ObjectManager/ObjectManager.lua +++ b/src/ObjectManager/ObjectManager.lua @@ -5,6 +5,7 @@ Bastion = ... ---@class Bastion.ObjectManager ---@field _lists table +---@field objects WowGameObject[] local ObjectManager = {} ObjectManager.__index = ObjectManager @@ -12,6 +13,7 @@ function ObjectManager:New() ---@class Bastion.ObjectManager local self = setmetatable({}, ObjectManager) self._lists = {} + self.objects = {} self.activeEnemies = Bastion.List:New() self.afflicted = Bastion.List:New() @@ -51,6 +53,8 @@ function ObjectManager:ResetLists() end function ObjectManager:Reset() + self.objects = {} + self.activeEnemies:clear() self.afflicted:clear() self.critters:clear() @@ -87,8 +91,8 @@ function ObjectManager:Refresh() self:Reset() local objects = Objects() - for _, object in pairs(objects) do + table.insert(self.objects, object) self:EnumLists(object) local objectType = ObjectType(object) if ({ [5] = true, [6] = true, [7] = true })[objectType] then @@ -100,8 +104,7 @@ function ObjectManager:Refresh() Bastion.UnitManager:SetObject(unit) end - local creatureType = ObjectCreatureType(object) - if objectType == 5 and creatureType == 8 then + if objectType == 5 and ObjectCreatureType(object) == 8 then self.critters:push(unit) elseif unit:GetID() == 204560 then self.incorporeal:push(unit) @@ -109,7 +112,7 @@ function ObjectManager:Refresh() self.afflicted:push(unit) elseif unit:GetID() == 120651 then self.explosives:push(unit) - elseif unit:IsPlayer() and (unit:IsInPartyOrRaid() or unit == Bastion.UnitManager["player"]) then + elseif (unit:IsInPartyOrRaid() or unit == Bastion.UnitManager["player"]) then self.friends:push(unit) elseif unit:IsEnemy() then self.enemies:push(unit) diff --git a/src/Spell/Spell.lua b/src/Spell/Spell.lua index e9c9d6e..4d33370 100644 --- a/src/Spell/Spell.lua +++ b/src/Spell/Spell.lua @@ -254,8 +254,7 @@ function Spell:Cast(unit, condition) end -- Check if the mouse was looking - ---@type boolean - self.wasLooking = IsMouselooking() + self.wasLooking = IsMouselooking() --[[@as boolean]] -- if unit:GetOMToken() contains 'nameplate' then we need to use Object wrapper to cast @@ -287,7 +286,7 @@ end ---@return boolean function Spell:ForceCast(unit) -- Check if the mouse was looking - self.wasLooking = IsMouselooking() + self.wasLooking = IsMouselooking() --[[@as boolean]] -- if unit:GetOMToken() contains 'nameplate' then we need to use Object wrapper to cast local u = unit and unit:GetOMToken() or self.traits.target.player and "none" or "none" diff --git a/src/Unit/Unit.lua b/src/Unit/Unit.lua index b1d7dcf..910b291 100644 --- a/src/Unit/Unit.lua +++ b/src/Unit/Unit.lua @@ -676,7 +676,7 @@ function Unit:IsMoving() return GetUnitSpeed(self:GetOMToken()) > 0 end ----@return TinkrMovementFlags +---@return MovementFlags function Unit:GetMovementFlag() return ObjectMovementFlag(self:GetOMToken()) end