|
|
|
@ -1,3 +1,4 @@ |
|
|
|
|
---@type Tinkr, Bastion |
|
|
|
|
local Tinkr, Bastion = ... |
|
|
|
|
|
|
|
|
|
local ObjectManager = Tinkr.Util.ObjectManager |
|
|
|
@ -10,19 +11,19 @@ local UnitManager = { |
|
|
|
|
units = {}, |
|
|
|
|
customUnits = {}, |
|
|
|
|
objects = {}, |
|
|
|
|
cache = {} |
|
|
|
|
cache = {}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function UnitManager:__index(k) |
|
|
|
|
if k == 'none' then |
|
|
|
|
return self:Get('none') |
|
|
|
|
if k == "none" then |
|
|
|
|
return self:Get("none") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
if UnitManager[k] then |
|
|
|
|
return UnitManager[k] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
local k = k or 'none' |
|
|
|
|
local k = k or "none" |
|
|
|
|
|
|
|
|
|
-- if custom unit exists, return it it's cache expired return a new one |
|
|
|
|
if self.customUnits[k] then |
|
|
|
@ -52,7 +53,7 @@ function UnitManager:__index(k) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
return self.objects['none'] |
|
|
|
|
return self.objects["none"] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
-- Constructor |
|
|
|
@ -65,7 +66,6 @@ function UnitManager:New() |
|
|
|
|
return self |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Get or create a unit |
|
|
|
|
---@param token string |
|
|
|
|
---@return Unit |
|
|
|
@ -77,8 +77,8 @@ function UnitManager:Get(token) |
|
|
|
|
local tguid = ObjectGUID(token) |
|
|
|
|
|
|
|
|
|
if tguid and self.objects[tguid] == nil then |
|
|
|
|
if token == 'none' then |
|
|
|
|
self.objects['none'] = Unit:New() |
|
|
|
|
if token == "none" then |
|
|
|
|
self.objects["none"] = Unit:New() |
|
|
|
|
else |
|
|
|
|
self.objects[tguid] = Unit:New(Object(tguid)) |
|
|
|
|
end |
|
|
|
@ -88,8 +88,8 @@ function UnitManager:Get(token) |
|
|
|
|
local tguid = ObjectGUID(token) or "none" |
|
|
|
|
|
|
|
|
|
if self.objects[tguid] == nil then |
|
|
|
|
if token == 'none' then |
|
|
|
|
self.objects['none'] = Unit:New() |
|
|
|
|
if token == "none" then |
|
|
|
|
self.objects["none"] = Unit:New() |
|
|
|
|
else |
|
|
|
|
self.objects[tguid] = Unit:New(Object(tguid)) |
|
|
|
|
end |
|
|
|
@ -127,7 +127,7 @@ function UnitManager:CreateCustomUnit(token, cb) |
|
|
|
|
if self.customUnits[token] == nil then |
|
|
|
|
self.customUnits[token] = { |
|
|
|
|
unit = cachedUnit, |
|
|
|
|
cb = cb |
|
|
|
|
cb = cb, |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
@ -303,15 +303,7 @@ function UnitManager:FindFriendsCentroid(radius, range) |
|
|
|
|
return unit:GetPosition() |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
local _, _, z = TraceLine( |
|
|
|
|
centroid.x, |
|
|
|
|
centroid.y, |
|
|
|
|
centroid.z + 5, |
|
|
|
|
centroid.x, |
|
|
|
|
centroid.y, |
|
|
|
|
centroid.z - 5, |
|
|
|
|
0x100151 |
|
|
|
|
) |
|
|
|
|
local _, _, z = TraceLine(centroid.x, centroid.y, centroid.z + 5, centroid.x, centroid.y, centroid.z - 5, 0x100151) |
|
|
|
|
|
|
|
|
|
centroid.z = z + 0.01 |
|
|
|
|
|
|
|
|
@ -342,15 +334,7 @@ function UnitManager:FindEnemiesCentroid(radius, range) |
|
|
|
|
return unit:GetPosition() |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
local _, _, z = TraceLine( |
|
|
|
|
centroid.x, |
|
|
|
|
centroid.y, |
|
|
|
|
centroid.z + 5, |
|
|
|
|
centroid.x, |
|
|
|
|
centroid.y, |
|
|
|
|
centroid.z - 5, |
|
|
|
|
0x100151 |
|
|
|
|
) |
|
|
|
|
local _, _, z = TraceLine(centroid.x, centroid.y, centroid.z + 5, centroid.x, centroid.y, centroid.z - 5, 0x100151) |
|
|
|
|
|
|
|
|
|
centroid.z = z + 0.01 |
|
|
|
|
|
|
|
|
|