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 ---@class Bastion.ObjectManager
---@field _lists table<string, {list: Bastion.List, cb:fun(Object: WowGameObject): any}> ---@field _lists table<string, {list: Bastion.List, cb:fun(Object: WowGameObject): any}>
---@field objects WowGameObject[]
local ObjectManager = {} local ObjectManager = {}
ObjectManager.__index = ObjectManager ObjectManager.__index = ObjectManager
@ -12,6 +13,7 @@ function ObjectManager:New()
---@class Bastion.ObjectManager ---@class Bastion.ObjectManager
local self = setmetatable({}, ObjectManager) local self = setmetatable({}, ObjectManager)
self._lists = {} self._lists = {}
self.objects = {}
self.activeEnemies = Bastion.List:New() self.activeEnemies = Bastion.List:New()
self.afflicted = Bastion.List:New() self.afflicted = Bastion.List:New()
@ -51,6 +53,8 @@ function ObjectManager:ResetLists()
end end
function ObjectManager:Reset() function ObjectManager:Reset()
self.objects = {}
self.activeEnemies:clear() self.activeEnemies:clear()
self.afflicted:clear() self.afflicted:clear()
self.critters:clear() self.critters:clear()
@ -87,8 +91,8 @@ function ObjectManager:Refresh()
self:Reset() self:Reset()
local objects = Objects() local objects = Objects()
for _, object in pairs(objects) do for _, object in pairs(objects) do
table.insert(self.objects, object)
self:EnumLists(object) self:EnumLists(object)
local objectType = ObjectType(object) local objectType = ObjectType(object)
if ({ [5] = true, [6] = true, [7] = true })[objectType] then if ({ [5] = true, [6] = true, [7] = true })[objectType] then
@ -100,8 +104,7 @@ function ObjectManager:Refresh()
Bastion.UnitManager:SetObject(unit) Bastion.UnitManager:SetObject(unit)
end end
local creatureType = ObjectCreatureType(object) if objectType == 5 and ObjectCreatureType(object) == 8 then
if objectType == 5 and creatureType == 8 then
self.critters:push(unit) self.critters:push(unit)
elseif unit:GetID() == 204560 then elseif unit:GetID() == 204560 then
self.incorporeal:push(unit) self.incorporeal:push(unit)
@ -109,7 +112,7 @@ function ObjectManager:Refresh()
self.afflicted:push(unit) self.afflicted:push(unit)
elseif unit:GetID() == 120651 then elseif unit:GetID() == 120651 then
self.explosives:push(unit) 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) self.friends:push(unit)
elseif unit:IsEnemy() then elseif unit:IsEnemy() then
self.enemies:push(unit) self.enemies:push(unit)

@ -254,8 +254,7 @@ function Spell:Cast(unit, condition)
end end
-- Check if the mouse was looking -- Check if the mouse was looking
---@type boolean self.wasLooking = IsMouselooking() --[[@as boolean]]
self.wasLooking = IsMouselooking()
-- if unit:GetOMToken() contains 'nameplate' then we need to use Object wrapper to cast -- if unit:GetOMToken() contains 'nameplate' then we need to use Object wrapper to cast
@ -287,7 +286,7 @@ end
---@return boolean ---@return boolean
function Spell:ForceCast(unit) function Spell:ForceCast(unit)
-- Check if the mouse was looking -- 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 -- 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" 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 return GetUnitSpeed(self:GetOMToken()) > 0
end end
---@return TinkrMovementFlags ---@return MovementFlags
function Unit:GetMovementFlag() function Unit:GetMovementFlag()
return ObjectMovementFlag(self:GetOMToken()) return ObjectMovementFlag(self:GetOMToken())
end end

Loading…
Cancel
Save