Kbengine Defining entities

Source: Internet
Author: User

Defining entities

When to define an entity:

需要进行数据存储。能够方便的远程访问。需要引擎管理和监控, 例如: AOI、Trap、等等。当灾难发生后服务端可以自动进行灾难的恢复。

When to define attributes for an entity:

需要进行数据存储。实体被迁移后数据仍然有效(仅cellapp会迁移实体,比如跳转场景)。当灾难发生后服务端可以自动进行灾难的恢复。

When to define a method for an entity:

能够方便的远程访问。
You need to perform the following steps:
    1. Registering entities

      Directory Address:demo/scripts/entities.xml

      Example:

       <root>     <Account/>     <Avatar/>     <Spaces/>     <Space/>     <Monster/>     <NPC/>     <Gate/> </root>
    2. demo/scripts/entity_defsCreate a definition file under the directory

      Example: Account.def

    3. You may need to define some properties and methods

      1. demo/scripts/There are three subdirectories (base, cell, client) under the directory, and you can add account.py as needed.

      2. Not every entity exists (client, base, cell) These three parts, you can make some choices as needed.

Define the format of the file
<root><properties>//Property Name <accountname>//property type <type>unicode</type>//(optional)// The custom protocol ID of the property, if the client does not use the KBE Companion SDK to develop, the client needs to develop the protocol with KBE docking,//developers can define the ID of the attribute is easy to identify, the C + + protocol layer uses a uint16 to describe, if the ID is not defined the engine will use// The protocol ID generated by the rule itself, which must be scoped to the unique <utype>1000</utype>//attribute in all def files (see below: Attribute scope section) <flags>base</flags >//(optional)//whether to store to database <persistent>true</persistent>//(optional)//maximum length to be stored in the database <DatabaseLength> 100< /databaselength>//(optional, not clear best not set)//default value <default>kbengine</default>//(optional)//database index, support unique and index <index>unique</index></accountname>......</properties><clientmethods>// The remote method name exposed by the client <onreqavatarlist>//the parameters of the remote method <arg>avatar_infos_list</arg><utype>1001</ utype></onreqavatarlist>......</clientmethods><basemethods>//Baseapp Exposed Remote method name < reqavatarlist>//cell exposure method must present this marker <Exposed/> <utype>1002</utype></reqavatarlist> </basemethods>< cellmethods>//Cellapp Exposed Remote method name 

Example: Call the base method in the client to get the list of roles (account.py):

 self.base.reqAvatarList()
Attribute scope
[类型][client][base][cell]BASE-*-BASE_AND_CLIENT**-CELL_PRIVATE--*(cell)CELL_PUBLIC--*(cells)CELL_PUBLIC_AND_OWN*(client)-*(cells)ALL_CLIENTS*(clients)-*(cells)OWN_CLIENT*(client)-*(cell)OTHER_CLIENTS*(other clients)-*(cells)

Kbengine Defining entities

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.