156 lines
6.2 KiB
Lua
156 lines
6.2 KiB
Lua
local ____lualib = require("lualib_bundle")
|
|
local __TS__Class = ____lualib.__TS__Class
|
|
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
|
|
local ____exports = {}
|
|
local getFileScope, toDotaClassInstance
|
|
function getFileScope(self)
|
|
return {
|
|
getfenv(3),
|
|
"unknown"
|
|
}
|
|
end
|
|
function toDotaClassInstance(self, instance, ____table)
|
|
local ____table_0 = ____table
|
|
local prototype = ____table_0.prototype
|
|
while prototype do
|
|
for key in pairs(prototype) do
|
|
if not (rawget(instance, key) ~= nil) then
|
|
instance[key] = prototype[key]
|
|
end
|
|
end
|
|
prototype = getmetatable(prototype)
|
|
end
|
|
end
|
|
____exports.BaseAbility = __TS__Class()
|
|
local BaseAbility = ____exports.BaseAbility
|
|
BaseAbility.name = "BaseAbility"
|
|
BaseAbility.____file_path = "scripts/vscripts/lib/dota_ts_adapter.lua"
|
|
function BaseAbility.prototype.____constructor(self)
|
|
end
|
|
function BaseAbility.prototype.IsAltCastAbility(self)
|
|
local caster = self:GetCaster()
|
|
if not caster then
|
|
print("[IsAltCastAbility] Caster is null")
|
|
return false
|
|
end
|
|
local playerId = caster:GetPlayerOwnerID()
|
|
if playerId == -1 or playerId == nil then
|
|
playerId = caster:GetPlayerID()
|
|
end
|
|
if playerId == -1 or playerId == nil then
|
|
print((("[IsAltCastAbility] Invalid playerId: " .. tostring(playerId)) .. ", caster=") .. caster:GetUnitName())
|
|
return false
|
|
end
|
|
local abilityName = self:GetAbilityName()
|
|
print((((("[IsAltCastAbility] Checking: playerId=" .. tostring(playerId)) .. ", abilityName=") .. abilityName) .. ", caster=") .. caster:GetUnitName())
|
|
if type(__abilityAltCastManager) == "nil" then
|
|
local AbilityAltCastManager = require("ability_alt_cast_manager").AbilityAltCastManager
|
|
__abilityAltCastManager = AbilityAltCastManager:getInstance()
|
|
end
|
|
return __abilityAltCastManager:getAltCastState(playerId, abilityName)
|
|
end
|
|
____exports.BaseItem = __TS__Class()
|
|
local BaseItem = ____exports.BaseItem
|
|
BaseItem.name = "BaseItem"
|
|
BaseItem.____file_path = "scripts/vscripts/lib/dota_ts_adapter.lua"
|
|
function BaseItem.prototype.____constructor(self)
|
|
end
|
|
function BaseItem.prototype.OnChargeCountChanged(self, _chargeCount, _previousChargeCount)
|
|
end
|
|
____exports.BaseModifier = __TS__Class()
|
|
local BaseModifier = ____exports.BaseModifier
|
|
BaseModifier.name = "BaseModifier"
|
|
BaseModifier.____file_path = "scripts/vscripts/lib/dota_ts_adapter.lua"
|
|
function BaseModifier.prototype.____constructor(self)
|
|
end
|
|
function BaseModifier.apply(self, target, caster, ability, modifierTable)
|
|
return target:AddNewModifier(caster, ability, self.name, modifierTable)
|
|
end
|
|
____exports.BaseModifierMotionHorizontal = __TS__Class()
|
|
local BaseModifierMotionHorizontal = ____exports.BaseModifierMotionHorizontal
|
|
BaseModifierMotionHorizontal.name = "BaseModifierMotionHorizontal"
|
|
BaseModifierMotionHorizontal.____file_path = "scripts/vscripts/lib/dota_ts_adapter.lua"
|
|
__TS__ClassExtends(BaseModifierMotionHorizontal, ____exports.BaseModifier)
|
|
____exports.BaseModifierMotionVertical = __TS__Class()
|
|
local BaseModifierMotionVertical = ____exports.BaseModifierMotionVertical
|
|
BaseModifierMotionVertical.name = "BaseModifierMotionVertical"
|
|
BaseModifierMotionVertical.____file_path = "scripts/vscripts/lib/dota_ts_adapter.lua"
|
|
__TS__ClassExtends(BaseModifierMotionVertical, ____exports.BaseModifier)
|
|
____exports.BaseModifierMotionBoth = __TS__Class()
|
|
local BaseModifierMotionBoth = ____exports.BaseModifierMotionBoth
|
|
BaseModifierMotionBoth.name = "BaseModifierMotionBoth"
|
|
BaseModifierMotionBoth.____file_path = "scripts/vscripts/lib/dota_ts_adapter.lua"
|
|
__TS__ClassExtends(BaseModifierMotionBoth, ____exports.BaseModifier)
|
|
setmetatable(____exports.BaseAbility.prototype, {__index = CDOTA_Ability_Lua or C_DOTA_Ability_Lua})
|
|
setmetatable(____exports.BaseItem.prototype, {__index = CDOTA_Item_Lua or C_DOTA_Item_Lua})
|
|
setmetatable(____exports.BaseModifier.prototype, {__index = CDOTA_Modifier_Lua or CDOTA_Modifier_Lua})
|
|
____exports.registerAbility = function(____, name) return function(____, ability, context)
|
|
if name ~= nil then
|
|
ability.name = name
|
|
end
|
|
if context.name then
|
|
name = context.name
|
|
else
|
|
error("Unable to determine name of this ability class!", 0)
|
|
end
|
|
local env = unpack(getFileScope(nil))
|
|
env[name] = {}
|
|
toDotaClassInstance(nil, env[name], ability)
|
|
local originalSpawn = env[name].Spawn
|
|
env[name].Spawn = function(self)
|
|
self:____constructor()
|
|
if originalSpawn then
|
|
originalSpawn(self)
|
|
end
|
|
end
|
|
end end
|
|
____exports.registerModifier = function(____, name) return function(____, modifier, context)
|
|
if name ~= nil then
|
|
modifier.name = name
|
|
end
|
|
if context.name then
|
|
name = context.name
|
|
else
|
|
error("Unable to determine name of this modifier class!", 0)
|
|
end
|
|
local fileName = modifier.____file_path
|
|
if not fileName then
|
|
error("Unable to determine file path of this modifier class!", 0)
|
|
end
|
|
local env = unpack(getFileScope(nil))
|
|
env[name] = {}
|
|
toDotaClassInstance(nil, env[name], modifier)
|
|
local originalOnCreated = env[name].OnCreated
|
|
env[name].OnCreated = function(self, parameters)
|
|
self:____constructor()
|
|
if originalOnCreated ~= nil then
|
|
originalOnCreated(self, parameters)
|
|
end
|
|
end
|
|
local ____type = LUA_MODIFIER_MOTION_NONE
|
|
local base = modifier.____super
|
|
while base do
|
|
if base == ____exports.BaseModifierMotionBoth then
|
|
____type = LUA_MODIFIER_MOTION_BOTH
|
|
break
|
|
elseif base == ____exports.BaseModifierMotionHorizontal then
|
|
____type = LUA_MODIFIER_MOTION_HORIZONTAL
|
|
break
|
|
elseif base == ____exports.BaseModifierMotionVertical then
|
|
____type = LUA_MODIFIER_MOTION_VERTICAL
|
|
break
|
|
end
|
|
base = base.____super
|
|
end
|
|
LinkLuaModifier(name, fileName, ____type)
|
|
end end
|
|
--- Use to expose top-level functions in entity scripts.
|
|
-- Usage: registerEntityFunction("OnStartTouch", (trigger: TriggerStartTouchEvent) => { <your code here> });
|
|
function ____exports.registerEntityFunction(self, name, f)
|
|
local env = unpack(getFileScope(nil))
|
|
env[name] = function(...)
|
|
f(nil, ...)
|
|
end
|
|
end
|
|
return ____exports
|