Hi there, I am facing an odd situation here. Lets say we have 5 objects:
1.object A
2.object B
3.object C
4.object D
5.master object
Let us classify a bit. A,B,C,D is called dummy.
If master object’s code run, then it processes all A,B,C,D objects; prepares data and sets data into some fields of A,B,C,D each of dummy objects. Now code within master object is pretty heavy. I think it is not a good idea to run master object’s code on every frame. Master object’s code will only run when A or B or C or D object need it to run. At any time more than one dummy objects may need master object’s code to run. Lets say A,B,C all three, need to run master object’s code on a certain frame. Now all of three, should not invoke master object’s code, only one(A or B or C. NOT A and B, or such!) dummy object will invoke master object’s code even though all three, need to run master object’s code.
How do I implement this, guys?
Edit:
Guys I think I need to elaborate my problem a bit further, I am feeling to have some sort of information gap. Basically master object is a gameobject, with which a nominator script is attached. All it does, are the following respectively:
1.get all gameobjects tagged as enemy.
2.process all necessary information of each enemy.
3.nominate action/actions for each enemy.
4.pack them as a container of states
5.Send the container to each enemy gameobject(aka set "stateContainerList" of each enemy)
Nominator will not run on every frame as it involves processing a lot of information for each enemy.
Now nominator will only nominates certain type of states,lets say action states.
Enemy AI first see if it needs those type of states now. If it does not,then nominator will not be invoked. If it does need, then it will invoke the code within nominator and nominator will process-pack-send data to every enemy. Now lets say enemy A needs actions, enemy B too needs actions. But nominator should be run only once on this frame. If we do not count this matter, then consider this situation:
Program counter is within enemy A gameobject’s code realm, then nominator will be called and necessary data are sent to every enemy gameobjects. With data from nominator and other factors,then enemy A can choose its behavior. Lets say immediately then, PC is within enemy B gameobject’s code realm, then again nominator will be called. But do we need it? We already called nominator and enemy B gameobject’s respective attached class already have the list(list of nominated states for enemy B) fully filled up. We are both wasting our resource and we are confusing the system with new calculated nominated values. This could posses huge security vulnerability which I do not want.
That is why this part is so important.
The asset structures are:
gameobjects:
1.master
2.enemyA
2.enemyB
3.enemyN
Classes:
1.nominator.cs---attached with master
2.coreAI.cs---attached with enemyA, enemyB.....enemyN
Inside coreAI.cs, there should be read/write both enabled property called say “listOfNominatedStates”.
responsibility:
nominator.cs will collect all necessary info of enemyA,B,C,D…N. For each enemy it will add necessary states to “listOfNominatedStates”.
coreAI.cs will decide final state from “listOfNominatedStates” and other info.
Interesting, I think now I'm starting to understand what you're up to) I'll edit the code right away, stay tuned
– Kumo-KairoCheck it out
– Kumo-KairoI have updated my situation on original post, could you see a bit please?
– kaiyum