entity
简介
实体工厂
组件接口
FEntityBase.gs
实体组件基类
函数原型 | 函数作用 |
---|---|
string get_rid() | 获取RID |
void set_rid(string rid) | 设置RID |
string get_name() | 获取名称 |
void set_name(string name) | 设置名称 |
int get_class_id() | 获取配置ID |
void set_class_id(int class_id) | 设置配置ID |
bool is_comm() | 是否可以网络通信 |
void set_comm(bool is_comm) | 设置网络通信 |
bool is_cast() | 是否可以广播 |
void set_cast(bool is_cast) | 设置广播 |
bool is_inner() | 是否是内部对象 |
void set_inner(bool is_inner) | 设置内部对象 |
string pure_name() | 获取对象脚本名称 |
void sync_field(string d, mixed key, mixed val) | 同步字段 |
void send(string cmd, ...) | 发送消息 |
void send_ex(string cmd, ...) | 发送消息扩展 |
void set_comm_ob(object comm_ob) | 设置绑定通信对象 |
void send_alone(string cmd, ...) | 通过通信对象发送 |
void send_to_me(string cmd, ...) | 发送给自己 |
void send_to_server(string cmd, ...) | 发送给所在游戏服 |
map get_info() | 获取实体信息 |
string desc() | 获取实体描述 |
void sync_data() | 同步所有节点的数据到客户端 |
EntityD.gs
默认实体工厂
函数原型 | 函数作用 |
---|---|
object create_entity_by_class_id(mixed class_id_or_alias, map param, domain d) | 根据配置创建实体对象 |
object create_entity(string ob_name, map param, domain d) | 创建实体对象 |
entity.gs
函数原型 | 函数作用 |
---|---|
object impl() | 获取实例 |
void setup(object impl_ob) | 设置实体管理器 |
object create_entity_by_class_id(mixed class_id_or_alias, map param, domain d) | 根据配置创建实体对象 |
object create_entity(string ob_name, map param, domain d) | 创建实体对象 |
void start_db(string db_name) | 启动数据库 |
object load_entity_by_dbase(map dbase, domain d) | 根据dbase加载entity |
object load_entity(map condition, domain d, string db_collection) | 加载entity对象(同时加载所有其子对象) |
object load_entity_by_rid(string rid, domain d, string db_collection) | 根据rid加载entity对象(自动根据class id创建对应等级的域) |
void load_child_entities(object ent) | 加载某个对象的所有子对象 |
void set_data_cache(bool use_cache) | 设置数据缓存 |
void add_entity_cache(object ent) | 添加实体数据缓存 |
void remove_entity_cache(object ent) | 移除实体数据缓存 |
dynobject.gs
动态创建对象
函数原型 | 函数作用 |
---|---|
object create_object(string name, mixed param, domain d) | 创建对象 |
entity_domain.gs
基于权重分配的entity域管理器,处理游戏服务器中实体对象的域分配
- 通过entity_domain分配出来的域,关联着一个资源对象
- 相同的域共享资源对象所提供的资源:心跳对象、延迟处理对象等
- 域的分配策略: 优先获取权重值最小的资源对象所在的域
函数原型 | 函数作用 |
---|---|
void setup(map para) | 设置 |
void register_asset_ob(string type, string ob_name) | 注册资源对象 |
domain create_entity_domain(mixed class_id, string entity_rid) | 为一个有class id的实体申请域 |
void release_entity_domain(mixed entity_ob_or_rid) | 实体归还所在的域 |
domain exclusive_allocate_domain(string rid) | 实体以独占模式分配一个域 |
domain allocate_domain(string rid, int weight) | 实体以普通模式(权重)分配一个域 |
void release_domain(string rid) | 实体归还域 |
object find_asset_ob(domain d, string type) | 查找域对应的资源对象 |
map find_asset_obs(domain d) | 查找域对应的资源对象 |
object find_asset_ob_by_rid(string rid, string type) | 根据rid查找对应的资源对象 |
Asset new_asset_by_domain(domain d) | 根据域分配一个资源对象 |
void dump_all() | 调试接口: 输出所有资源池信息 |