Keeping track of object data

Started by
-1 comments, last by Dauntless 21 years, 1 month ago
While I was trying to work up some code, I came into a dilemma for my strategy game. I wanted to create a CommTest function that would test whether one object could establish a communication link with another object. The trouble was that of the parameters that I thought would be releveant...I wasn''t sure if some of these parameters should be inherent to the object, or if the object should run a test to determine the parameter value. For example, in a CommTest function, the function needs to know several pieces of data: 1. The target (a pointer to that object) 2. The sender''s comm range (a variable included within the object itelf...determined by its IntelligenceModule capability. I.e. this.IntelligenceModule.CommSend = 10) 3. The target''s comm range (i.e. NHobject->IntelligenceModule.CommReceive =5) 4. Any EW, Electronics Warfare being targeted at either the sender or reciever 5. Any ECW, Electronics Counter Warfare, being targeted at either object 6. Terrain for both objects (which may reduce the comm send or receive for each object) Herre''s what I was wondering though. Is it a better design it so that the object always knows what kind of terrain it is on, or only when necessary? Ditto for keeping track of things like whether it is under EW attack. Some kinds of data seem a little nebulous as to whether the data is internal to the object, or external. Which will have the worse overhead? I''d imagine it would be if the object always has to keep the data internal to itself, because it will always have to poll world data to see what terrain it is in, check to see if it is under attack, if it has EW on it, etc etc. If you only have to check when called for, say what kind of terrain its in...then you only need to test when it''s called for. Say for example, while it''s moving, when it is firing or being fired on, etc. The disadvantage to this is that as a local variable, it may need to make several tests at once (if for example it is moving, shooting, trying to make a commtest, and being targeted). In this scenario, the internal tracking is better, because it only makes a test once, and then as a data member variable, all the other functions can use this data...so only one test is run once).
The world has achieved brilliance without wisdom, power without conscience. Ours is a world of nuclear giants and ethical infants. We know more about war than we know about peace, more about killing than we know about living. We have grasped the mystery of the atom and rejected the Sermon on the Mount." - General Omar Bradley

This topic is closed to new replies.

Advertisement