PLAYER_TDCLS = tdcls(DBASE_TDCLS, RID_TDCLS, AGENT_TDCLS, HEARTBEAT_TDCLS, ATTRIB_TDCLS);
PLAYER_TDCLS.name = "PLAYER_TDCLS";
function PLAYER_TDCLS:create(value)
assert(type(value) == "table", "player::create para not corret");
self:replace_dbase(value);
self:set("ob_type", OB_TYPE_USER);
self:freeze_dbase()
self.carry = {}
end
function PLAYER_TDCLS:destruct()
for _,v in pairs(self.carry) do
destruct_object(v)
end
end
function PLAYER_TDCLS:get_ob_id()
return (string.format("PLAYER_TDCLS:%s:%s", save_string(self:query("rid")),
save_string(self:query("account_rid"))));
end
function PLAYER_TDCLS:accept_relay(agent)
agent:relay_comm(self)
self:enter_world()
end
function PLAYER_TDCLS:enter_world()
self:set_temp("entered_world", true)
trace("玩家(%o/%s)进入游戏世界。", self:query("name"), get_ob_rid(self));
trace("玩家等级: %d\r\n玩家金币: %d\r\n玩家钻石: %d", self:query("lv"), self:query("gold"), self:query("stone"))
end
function PLAYER_TDCLS:get_ob_class()
return "PLAYER_TDCLS";
end
function PLAYER_TDCLS:is_user()
return true;
end
function PLAYER_TDCLS:load_property(object)
self.carry[object:query("pos")] = object
end
function PLAYER_TDCLS:unload_property(object)
if not is_object(object) then
return
end
local pos = object:query("pos")
if pos then
self.carry[pos] = nil
end
destruct_object(object)
end
function PLAYER_TDCLS:get_page_carry(page)
local arr = {};
local x, y;
local read_pos = READ_POS;
for pos, ob in pairs(self.carry) do
x, y = read_pos(pos);
if x == page then
arr[#arr + 1] = ob;
end
end
return arr;
end