Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
pluginmessagemanager.c
Go to the documentation of this file.
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 //g_Game.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 //g_Game.ProfilerStop("UnsubscribeAll");
143 }
144}
void OnReceiveFloat(int channel, float value)
void OnReceive(int channel)
void OnReceiveInt(int channel, int value)
Base Param Class with no parameters.
Definition param.c:12
Class PluginMessageManager provides some basic Message Distribution mechanics, if you get instance of...
Definition pluginbase.c:2
void Subscribe(MessageReceiverBase receiver, int index)
Subscribes an object to listen to messages on a channel provided in the 'index' parameter.
void PluginMessageManager()
void Broadcast(int index)
Broadcasts an empty message on a channel provided in the 'index' parameter.
void BroadcastFloat(int index, float value)
void BroadcastInt(int index, int value)
Broadcasts a message on a channel provided in the 'index' parameter, passes the Int variable.
void Unsubscribe(MessageReceiverBase receiver, int index)
ref array< ref MessageReceiverBase > channelList[NUM_OF_CHANNELS]
void BroadcastParam(int index, Param params)
Broadcasts a message on a channel provided in the 'index' parameter, passes the Param type object to ...
void BroadcastString(int index, string value)
void UnsubscribeAll(MessageReceiverBase receiver)
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
Definition constants.c:335
Icon x