File size: 922 Bytes
b6a38d7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
MapVar("Players", false)
MapVar("UIPlayer", false)
----- Player
DefineClass.Player = {
__parents = { "CooldownObj", "LabelContainer" },
player = false,
}
function Player:Init()
self.player = self
end
----- PlayerObject
DefineClass.PlayerObject = {
__parents = { "Object" },
properties = {
{ id = "player", editor = "object", default = false, read_only = true, },
},
}
function PlayerObject:Done()
self.player = nil
end
function PlayerObject:PostLoad()
if IsEditorActive() then
self.player = UIPlayer
end
end
-----
function CreatePlayerObjects()
return { Player:new{ handle = 1 } }
end
function OnMsg.NewMap()
if not mapdata.GameLogic then return end
SetPlayers(CreatePlayerObjects())
end
function SetPlayers(players, ui_player)
Players = players or {}
UIPlayer = ui_player or players and players[1] or false
for _, player in ipairs(players) do
Msg("PlayerObjectCreated", player)
end
end |