local ____lualib = require("lualib_bundle") local __TS__Class = ____lualib.__TS__Class local Map = ____lualib.Map local __TS__New = ____lualib.__TS__New local ____exports = {} --- Короткоживущий буфер вектор-каста с клиента. -- Храним данные только на одно ближайшее применение способности. ____exports.VectorTargetCastManager = __TS__Class() local VectorTargetCastManager = ____exports.VectorTargetCastManager VectorTargetCastManager.name = "VectorTargetCastManager" VectorTargetCastManager.____file_path = "scripts/vscripts/vector_target_cast_manager.lua" function VectorTargetCastManager.prototype.____constructor(self) self.casts = __TS__New(Map) self.ttl = 1.25 CustomGameEventManager:RegisterListener( "vector_target_cast_update", function(_, rawEvent) self:onVectorCast(rawEvent) end ) end function VectorTargetCastManager.getInstance(self) if not ____exports.VectorTargetCastManager.instance then ____exports.VectorTargetCastManager.instance = __TS__New(____exports.VectorTargetCastManager) end return ____exports.VectorTargetCastManager.instance end function VectorTargetCastManager.prototype.getKey(self, playerId, abilityName) return (tostring(playerId) .. ":") .. abilityName end function VectorTargetCastManager.prototype.onVectorCast(self, event) local playerId = event.PlayerID or event.playerId local abilityName = event.abilityName if playerId == nil or playerId < 0 or not abilityName then return end if event.startX == nil or event.startY == nil or event.endX == nil or event.endY == nil then return end local key = self:getKey(playerId, abilityName) self.casts:set( key, { start = Vector(event.startX, event.startY, 0), ["end"] = Vector(event.endX, event.endY, 0), expireAt = GameRules:GetGameTime() + self.ttl } ) end function VectorTargetCastManager.prototype.consumeCast(self, playerId, abilityName) local key = self:getKey(playerId, abilityName) local stored = self.casts:get(key) if not stored then return nil end self.casts:delete(key) if stored.expireAt < GameRules:GetGameTime() then return nil end return {start = stored.start, ["end"] = stored["end"]} end function VectorTargetCastManager.prototype.hasFreshCast(self, playerId, abilityName) local key = self:getKey(playerId, abilityName) local stored = self.casts:get(key) if not stored then return false end if stored.expireAt < GameRules:GetGameTime() then self.casts:delete(key) return false end return true end return ____exports