public void selectionHandler(int objID) { int objIdx = getObjIdx(this.objIDs, objID); if (objIdx >= 0) // one of ours { NoisetagBehaviour selobj = registeredobjIDs[objIdx]; if (selobj != null) { selobj.OnSelection(); } } if (selectionEvent != null) { selectionEvent.Invoke(objID); } }
public void newPredictionHandler(PredictedTargetProb m) { int objIdx = getObjIdx(this.objIDs, m.Yest); if (objIdx >= 0) // one of ours { NoisetagBehaviour obj = registeredobjIDs[objIdx]; if (obj != null) { obj.OnPrediction(m.Perr); } } if (newPredictionEvent != null) { newPredictionEvent.Invoke(m); } }
internal int acquireObjID(NoisetagBehaviour gameobj) { // check if already registered // TODO []: correct search that the object reference also matches... int objID = -1; int objIdx = -1; if (gameobj.myobjID == 0) { // BODGE: [] Zero id is special and *cannot* be acquired or released! objID = gameobj.myobjID; objIdx = -1; } else if (gameobj.myobjID > 0) { objID = gameobj.myobjID; objIdx = getObjIdx(objIDs, gameobj.myobjID); if (registeredobjIDs[objIdx] == gameobj) { Debug.Log("Obj already registered as: " + gameobj.myobjID); return(objID); } } else { objIdx = findUnusedObjIdx(); objID = objIDs[objIdx]; } if (objIdx >= 0) { // mark this ID as used registeredobjIDs[objIdx] = gameobj; // tell the object that it's got an ID gameobj.myobjID = objID; // the the nt-controller it's used updateActiveObjIDs(); } return(objID); }