local ____lualib = require("lualib_bundle") local __TS__Class = ____lualib.__TS__Class local Map = ____lualib.Map local __TS__New = ____lualib.__TS__New local __TS__Iterator = ____lualib.__TS__Iterator local ____exports = {} --- Менеджер для отслеживания состояний альтернативного каста способностей ____exports.AbilityAltCastManager = __TS__Class() local AbilityAltCastManager = ____exports.AbilityAltCastManager AbilityAltCastManager.name = "AbilityAltCastManager" AbilityAltCastManager.____file_path = "scripts/vscripts/ability_alt_cast_manager.lua" function AbilityAltCastManager.prototype.____constructor(self) self.altCastStates = __TS__New(Map) if IsServer() and type(CustomGameEventManager) ~= "nil" and CustomGameEventManager ~= nil then CustomGameEventManager:RegisterListener( "ability_alt_cast_state", function(_, event) local playerId = event.PlayerID or event.playerId local abilityName = event.abilityName local isAltCast = event.isAltCast == 1 or event.isAltCast == true self:updateAltCastState(playerId, abilityName, isAltCast) end ) end end function AbilityAltCastManager.getInstance(self) if not ____exports.AbilityAltCastManager.instance then ____exports.AbilityAltCastManager.instance = __TS__New(____exports.AbilityAltCastManager) end return ____exports.AbilityAltCastManager.instance end function AbilityAltCastManager.prototype.updateAltCastState(self, playerId, abilityName, isAltCast) if playerId == nil or playerId == nil or playerId < 0 then return end local playerStates = self.altCastStates:get(playerId) if not playerStates then playerStates = __TS__New(Map) self.altCastStates:set(playerId, playerStates) end playerStates:set(abilityName, isAltCast) self:pushPlayerStatesToNetTable(playerId) end function AbilityAltCastManager.prototype.getAltCastState(self, playerId, abilityName) local playerStates = self.altCastStates:get(playerId) if not playerStates then return false end if playerStates:has(abilityName) then local state = playerStates:get(abilityName) or false return state end return false end function AbilityAltCastManager.prototype.clearPlayerStates(self, playerId) self.altCastStates:delete(playerId) if type(CustomNetTables) ~= "nil" and CustomNetTables ~= nil then CustomNetTables:SetTableValue( "ability_alt_cast_states", tostring(playerId), {} ) end end function AbilityAltCastManager.prototype.syncPlayerStatesToClient(self, playerId) self:pushPlayerStatesToNetTable(playerId) end function AbilityAltCastManager.prototype.pushPlayerStatesToNetTable(self, playerId) if type(CustomNetTables) == "nil" or CustomNetTables == nil then return end local playerStates = self.altCastStates:get(playerId) local payload = {} if playerStates then for ____, ____value in __TS__Iterator(playerStates:entries()) do local abilityName = ____value[1] local enabled = ____value[2] payload[abilityName] = enabled and 1 or 0 end end CustomNetTables:SetTableValue( "ability_alt_cast_states", tostring(playerId), payload ) end return ____exports