Is it possible, using distributed objects, to split control between the remote owner, and the local client? Specifically:
I have an AI client that manages asteroids in my game. The AI client handles XYZ position, creation, destruction, and distributes mineral “loot” when a client mines it.
I would like to have the asteroids “tumbling” in space so that they don’t look so static. I don’t need the HPR data to be synchronized though, just the XYZ. Can I have the AI provide all the data as listed above, but let each client control the HPR locally?
Sure. Make the XYZ a distributed message. Don’t make the HPR a distributed message (or, if you’re inheriting from DistributedNode or some object that already defines HPR as a distributed message, don’t bother to use it). When the object is generated on each client, start a task to tumble the object locally.
I am looking at getDoList in DoCollectionManager as the method to get handles to all the asteroids in the same zone as the player client. I understand the zoneId, but what would I use for parentId? Render? Do they need to be parented to something else before I can use them?
Also, for classType: How do I pass in the asteroid class to filter out the avatar, timeSynch, planets, etc? Do I need to import the DistributedAsteroid file and pass it the DistributedAsteroid class? (DistributedAsteroid inherits from DistributedNode)? Or is there some better trick to getting it passed in?
Or maybe getDoList is not the best method? I have tried messing around with it some, and I tried iterating through cr.doId2do but i am having trouble accessing that directly. Is there an easy example of how to access the Do’s that are in there?
Thanks again for the info!
I would just iterate through cr.doId2do. What problems are you having with that? It’s just an ordinary Python dictionary.
Another answer is to have your DistributedAsteroid class add itself to a global list on generate, and remove itself on disable. Then you can just walk through that list to get all of your asteroids.
The problem I was having iterating was that I was having brain issues, apparently. All better now, and iterating properly.
Following up, how do I filter on class type? I tried creating an instance of DistributedAsteroid and comparing that to each of the objects when I iterate, but it only finds the local instance. ie: The comparison does not find the asteroids in the list.
Hard to explain, but here is the code:
for i,k in self.game.cr.doId2do.items():
Elsewhere in the program, I have:
self.dAsteroid = self.cr.createDistributedObject(
className = 'DistributedAsteroid', zoneId = 1)
Which is in a different class, which is why it is accessed as self.game.dAsteroid inside the iterator.
(as I am sure you probably know,
didn’t work either)
I have a time manager and a couple avatars in the doId2do dictionary, and plan on having many other types of objects as well. What is the best way to do the comparison and filter on the render/asteroid ( or whatever other object types I need to filter on ) objects?
The Python way to check if an object is an instance of a particular class is:
if isinstance(k, ClassType):