/
DistributedSignpostAI.py
50 lines (35 loc) · 1.27 KB
/
DistributedSignpostAI.py
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
from direct.distributed.DistributedNodeAI import DistributedNodeAI
from pandac.PandaModules import *
class DistributedSignpostAI(DistributedNodeAI):
""" This is the AI-side implementation of DistributedSignpost. """
def __init__(self, cr):
DistributedNodeAI.__init__(self, cr)
self.message = ''
self.color = (1, 1, 1)
def setMessage(self, message):
self.message = message
def d_setMessage(self, message):
self.sendUpdate('setMessage', [message])
def b_setMessage(self, message):
self.d_setMessage(message)
self.setMessage(message)
def getMessage(self):
return self.message
def setColor(self, r, g, b):
self.color = (r, g, b)
def d_setColor(self, r, g, b):
self.sendUpdate('setColor', [r, g, b])
def b_setColor(self, r, g, b):
self.d_setColor(r, g, b)
self.setColor(r, g, b)
def getColor(self):
return self.color
def touched(self, r, g, b):
""" This is called by the client when an avatar touches the
sign. """
self.d_react()
self.b_setColor(r, g, b)
self.b_setMessage("Don't touch me!")
def d_react(self):
""" This is sent by the AI to the clients. """
self.sendUpdate('react', [])