DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
PluginMessageManager.c
См. документацию.
1
4class PluginMessageManager extends PluginBase
5{
6 int channelsUsed = 0;
8
10 {
11 for (int i = 0; i < NUM_OF_CHANNELS; i++)
12 {
14 }
15 }
16
18 void Broadcast(int index)
19 {
20 //Debug.Log("Broadcasting message on a channel: "+ ToString(index), "Messaging System");
22 //int test = channelList[index].Count();
23 for(int i = 0; i < x.Count(); i++)
24 {
25 MessageReceiverBase mrb = x.Get(i);
26
27 if( mrb != NULL )
28 {
29 //string s = "Broadcasting message to: "+ToString(mrb);
30 //Log(s, LogTemplates.TEMPLATE_BROADCAST);
31 mrb.OnReceive(index);
32 }
33 }
34 }
35
37 void BroadcastInt(int index, int value)
38 {
39 //Debug.Log("Broadcasting message on a channel: "+ ToString(index), "Messaging System");
41 //int test = channelList[index].Count();
42 for(int i = 0; i < x.Count(); i++)
43 {
44 MessageReceiverBase mrb = x.Get(i);
45
46 if( mrb )
47 {
48 //string s = "Broadcasting message to: "+ToString(mrb);
49 //Log(s, LogTemplates.TEMPLATE_BROADCAST);
50 mrb.OnReceiveInt(index, value);
51 }
52
53 }
54 }
55
56 void BroadcastFloat(int index, float value)
57 {
58 //Debug.Log("Broadcasting message on a channel: "+ ToString(index), "Messaging System");
60 //int test = channelList[index].Count();
61 for(int i = 0; i < x.Count(); i++)
62 {
63 MessageReceiverBase mrb = x.Get(i);
64
65 if( mrb )
66 {
67 //string s = "Broadcasting message to: "+ToString(mrb);
68 //Log(s, LogTemplates.TEMPLATE_BROADCAST);
69 mrb.OnReceiveFloat(index, value);
70 }
71
72 }
73 }
74
75 void BroadcastString(int index, string value)
76 {
77 //Debug.Log("Broadcasting message on a channel: "+ ToString(index), "Messaging System");
79 //int test = channelList[index].Count();
80 for(int i = 0; i < x.Count(); i++)
81 {
82 if( x.Get(i) )
83 {
84 Print("broadcasting message to: ");
85 Print(x.Get(i));
86 x.Get(i).OnReceiveString(index, value);
87 }
88 }
89 }
90
92 void BroadcastParam(int index, Param params)
93 {
94 //Debug.Log("Broadcasting message on a channel: "+ ToString(index), "Messaging System");
96 //int test = channelList[index].Count();
97 for(int i = 0; i < x.Count(); i++)
98 {
99
100 if( x.Get(i) )
101 {
102 x.Get(i).OnReceiveParam(index, params);
103 }
104
105 }
106 }
107
109 void Subscribe(MessageReceiverBase receiver, int index)
110 {
111 if(index > channelsUsed) //this is used to speed up the unsubscribeAll method, instead of all channels, we sweep just those in usage
112 {
113 channelsUsed = index;
114 }
116 if( chan.Find(receiver) >= 0 ) return;
117 chan.Insert(receiver);
118 }
119
120 void Unsubscribe(MessageReceiverBase receiver, int index)
121 {
123 int i = chan.Find(receiver);
124 if( i >= 0 )
125 {
126 chan.Remove(i);
127 }
128 }
129
130 void UnsubscribeAll(MessageReceiverBase receiver)//REWORK.V: this is slow, should be made quicker(by registering all subscribers in a separate array upon their subscription and then going through this array instead)
131 {
132 //GetGame().ProfilerStart("UnsubscribeAll");
133 for (int i = 0; i <= channelsUsed; i++)
134 {
136 int c = chan.Find(receiver);
137 if( c >= 0 )
138 {
139 chan.Remove(c);
140 }
141 }
142 //GetGame().ProfilerStop("UnsubscribeAll");
143 }
144}
Icon x
void OnReceive(int channel)
Определения MessageReceiverBase.c:7
void OnReceiveInt(int channel, int value)
Определения MessageReceiverBase.c:8
void OnReceiveFloat(int channel, float value)
Определения MessageReceiverBase.c:9
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Определения param.c:12
void BroadcastFloat(int index, float value)
Определения PluginMessageManager.c:56
void Broadcast(int index)
Broadcasts an empty message on a channel provided in the 'index' parameter.
Определения PluginMessageManager.c:18
void BroadcastParam(int index, Param params)
Broadcasts a message on a channel provided in the 'index' parameter, passes the Param type object to ...
Определения PluginMessageManager.c:92
void PluginMessageManager()
Определения PluginMessageManager.c:9
void Unsubscribe(MessageReceiverBase receiver, int index)
Определения PluginMessageManager.c:120
void UnsubscribeAll(MessageReceiverBase receiver)
Определения PluginMessageManager.c:130
ref array< ref MessageReceiverBase > channelList[NUM_OF_CHANNELS]
Определения PluginMessageManager.c:7
int channelsUsed
Определения PluginMessageManager.c:6
void BroadcastString(int index, string value)
Определения PluginMessageManager.c:75
void BroadcastInt(int index, int value)
Broadcasts a message on a channel provided in the 'index' parameter, passes the Int variable.
Определения PluginMessageManager.c:37
void Subscribe(MessageReceiverBase receiver, int index)
Subscribes an object to listen to messages on a channel provided in the 'index' parameter.
Определения PluginMessageManager.c:109
Определения PluginBase.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto void Print(void var)
Prints content of variable to console/log.
const int NUM_OF_CHANNELS
Определения constants.c:335