private static void SuppressResponseUnwrapper(SuppressActorResponse sar) { //Suppress response reached-> inform accordingly GameObject actorConcerned = Actors.allActors[sar.actorId]; //Make the send message threadsafe SendMessageContext context = new SendMessageContext(actorConcerned, "SuppressOnOff", sar, SendMessageOptions.RequireReceiver); SendMessageHelper.RegisterSendMessage(context); }
public void SuppressOnOff(SuppressActorResponse sar) { if (sar.toSuppress) { isSuprressed = true; //Place an indicator to show it suppressionIndicator = Instantiate(prefabSuppressionIndicator); suppressionIndicator.transform.parent = transform; //Who's the daddy? suppressionIndicator.transform.position = transform.position + new Vector3(0f, 0.5f, 0f); } else { isSuprressed = false; Destroy(suppressionIndicator); //Delete indicator to show it } }
public static void Handle(ActorCreated currEvent) { GameObject go; if (currEvent.resourceId == "" || currEvent.resourceId == null) { go = Instantiate(VisualizationHandler.modelDictionary["Cube"]); //If type is not set, we want a cube } else { go = Instantiate(VisualizationHandler.modelDictionary[currEvent.resourceId]); } go.transform.name = currEvent.actorId; go.transform.parent = TraceImplement.rootOfActors.transform;//Add it to the root G.O. //Add this to the dictionary Actors.allActors.Add(currEvent.actorId, go); if (VisualizationHandler.sysActorNames.Any(go.transform.name.Contains)) //System actors are different { go.transform.position = new Vector3(Random.Range(3.5f, 4.5f), 1f, Random.Range(-2.5f, -3.5f)); //A separate area->Marked in the inspector } else { go.transform.position = new Vector3(Random.Range(0f, 3.5f), Random.Range(1.25f, 1.9f), Random.Range(-1.5f, 1.5f)); if (logCreateForEvent) { //Create a Log of it Log newLog = new Log(0, "Actor created : " + currEvent.actorId); VisualizationHandler.Handle(newLog); } } SuppressActorResponse sar = new SuppressActorResponse(go.transform.name, true); SendMessageContext context = new SendMessageContext(go, "SuppressOnOff", sar, SendMessageOptions.RequireReceiver); SendMessageHelper.RegisterSendMessage(context); }
public static void HandleResponseReceived(string jsonResponse) { requestResponseBalance = true; //Just got a response to our request Debug.Log("Debugger sent us " + jsonResponse); QueryResponse currResponse = (JsonUtility.FromJson <QueryResponse>(jsonResponse)); switch (currResponse.responseType) { case "ACTION_RESPONSE": //Debug.Log("Received an action response"); ActionResponse curr = (JsonUtility.FromJson <ActionResponse>(jsonResponse)); //One ActionResponse includes a list of events for one atomic step List <ActorEvent> tempList1 = new List <ActorEvent>(); foreach (string ev in curr.events) { tempList1.Add(EventUnwrapper(ev)); } if (tempList1.Count > 0) { int stepNum = curr.stepNum; Trace.visualizationToDispatcherIndexMapper.Add(Trace.allEvents.Count, stepNum); //stepNum may be -1 for invalid dispatcher steps Trace.allEvents.Add(tempList1); } foreach (State st in curr.states) { StateUnwrapper(st); } break; case "TOPOGRAPHY_RESPONSE": TopographyResponse tr = (JsonUtility.FromJson <TopographyResponse>(jsonResponse)); //One TopographyResponse includes the type and ordered list of actors, which need to be unwrapped TopographyUnwrapper(tr); break; case "TAG_RESPONSE": TagActorResponse tar = (JsonUtility.FromJson <TagActorResponse>(jsonResponse)); TagResponseUnwrapper(tar); break; case "TAG_REACHED_RESPONSE": TagReachedResponse trr = (JsonUtility.FromJson <TagReachedResponse>(jsonResponse)); TagReachedResponseUnwrapper(trr); break; case "EOT_RESPONSE": EOTResponseUnwrapper(); break; case "SUPPRESS_ACTOR_RESPONSE": SuppressActorResponse sar = JsonUtility.FromJson <SuppressActorResponse>(jsonResponse); SuppressResponseUnwrapper(sar); break; case "STEP_RESPONSE": StepResponse sr = (JsonUtility.FromJson <StepResponse>(jsonResponse)); int id = sr.stepNum; //Store the StepNum Debug.Log("Received response of step " + (id + 1)); List <ActorEvent> listOfEvents = new List <ActorEvent>(); //This list consists of the net difference we need to do //Unwrap specific parts in the same way foreach (string ev in sr.events) { Trace.stepEvents.Add(EventUnwrapper(ev)); //Send these events to a special list } //State unwrapping is done later as the actors at prior stepNum are not the same as current stepNum //StateUnwrapping done in TraceImplement //Send message to Reevaluate log- newer logs need to be deleted SendMessageContext context = new SendMessageContext(VisualizationHandler.logHead, "ReevaluateList", id + 1, SendMessageOptions.RequireReceiver); SendMessageHelper.RegisterSendMessage(context); //state at n -1 is sent break; default: Debug.LogError("Unable to resolve to a particular class"); break; } }