-
Notifications
You must be signed in to change notification settings - Fork 171
/
Copy pathEntityCall.cs
82 lines (66 loc) · 1.6 KB
/
EntityCall.cs
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
namespace KBEngine
{
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
/*
实体的EntityCall
关于EntityCall请参考API手册中对它的描述
https://github.com/kbengine/kbengine/tree/master/docs/api
*/
public class EntityCall
{
// EntityCall的类别
public enum ENTITYCALL_TYPE
{
ENTITYCALL_TYPE_CELL = 0, // CELL_ENTITYCALL
ENTITYCALL_TYPE_BASE = 1 // BASE_ENTITYCALL
}
public Int32 id = 0;
public string className = "";
public ENTITYCALL_TYPE type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL;
private NetworkInterface networkInterface_;
public Bundle bundle = null;
public EntityCall()
{
networkInterface_ = KBEngineApp.app.networkInterface();
}
public virtual void __init__()
{
}
bool isBase()
{
return type == ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE;
}
bool isCell()
{
return type == ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL;
}
/*
创建新的call
*/
public Bundle newCall()
{
if(bundle == null)
bundle = Bundle.createObject();
if(type == EntityCall.ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL)
bundle.newMessage(Message.messages["Baseapp_onRemoteCallCellMethodFromClient"]);
else
bundle.newMessage(Message.messages["Entity_onRemoteMethodCall"]);
bundle.writeInt32(this.id);
return bundle;
}
/*
向服务端发送这个call
*/
public void sendCall(Bundle inbundle)
{
if(inbundle == null)
inbundle = bundle;
inbundle.send(networkInterface_);
if(inbundle == bundle)
bundle = null;
}
}
}