2
0

AIDGameObjectAI.py 1.0 KB

12345678910111213141516171819202122232425
  1. from direct.distributed.DistributedObjectAI import DistributedObjectAI
  2. class AIDGameObjectAI(DistributedObjectAI):
  3. def __init__(self, aiRepository):
  4. DistributedObjectAI.__init__(self, aiRepository)
  5. def messageRoundtripToAI(self, data):
  6. """ The client sent us some data to process. So work with it and send
  7. changed data back to the requesting client """
  8. requesterId = self.air.getAvatarIdFromSender()
  9. print("Got client data:", data, "from client with ID", requesterId)
  10. # do something with the data
  11. aiChangedData = (
  12. data[0] + " from the AI",
  13. data[1] + 1,
  14. data[2])
  15. print("Sending modified game data back:", aiChangedData)
  16. self.d_messageRoundtripToClient(aiChangedData, requesterId)
  17. def d_messageRoundtripToClient(self, data, requesterId):
  18. """ Send the given data to the requesting client """
  19. print("Send message to back to:", requesterId)
  20. self.sendUpdateToAvatarId(requesterId, 'messageRoundtripToClient', [data])