Updates to OM to add all objects to `self.objects`

main
jeffi 10 months ago
parent 250019a581
commit ab44f60401
  1. 11
      src/ObjectManager/ObjectManager.lua
  2. 5
      src/Spell/Spell.lua
  3. 2
      src/Unit/Unit.lua

@ -5,6 +5,7 @@ Bastion = ...
---@class Bastion.ObjectManager
---@field _lists table<string, {list: Bastion.List, cb:fun(Object: WowGameObject): any}>
---@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)

@ -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"

@ -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

Loading…
Cancel
Save