protected void reevaluationAfterForcesHaveArrivedEventHandler(object sender, EventArgs e) { clsGroundAtom refGroundAtom = ((clsGroundAtomEventArgs)e).groundAtom; refGroundAtom.currentSpeed = refGroundAtom.baselineSpeed; // if in social comparison state and not stuck stay in social comparison - things seems to be moving if (refGroundAtom.currentState.GetType() == typeof(SOCIAL_COMPARISON_STATE)) { SOCIAL_COMPARISON_STATE sc = (SOCIAL_COMPARISON_STATE)refGroundAtom.currentState; bool stuck = refGroundAtom.currentSpeed <= (float)sc.baselineSpeed / 10.0; if (stuck) { clsActivityMovement barrierMovement = RouteUtils.createActivityAndStart(refGroundAtom, (int)refGroundAtom.currentSpeed, null); refGroundAtom.ChangeState(new GO_TO_POLICE_BARRIER_STATE(barrierMovement)); } } if (refGroundAtom.currentState.GetType() != typeof(GO_TO_POLICE_BARRIER_STATE)) { clsActivityMovement barrierMovement = RouteUtils.createActivityAndStart(refGroundAtom, (int)refGroundAtom.currentSpeed, null); refGroundAtom.ChangeState(new GO_TO_POLICE_BARRIER_STATE(barrierMovement)); return; } }
protected void reevaluationAfterEarthquakeEndedEventHandler(object sender, EventArgs e) { clsGroundAtom refGroundAtom = ((clsGroundAtomEventArgs)e).groundAtom; List <clsGroundAtom> atomsNearby = refGroundAtom.m_GameObject.m_GameManager.QuadTreeGroundAtom.SearchEntities(refGroundAtom.curr_X, refGroundAtom.curr_Y, 20, isPrecise: true); // if in social comparison state and not stuck stay in social comparison - things seem to be moving if (refGroundAtom.currentState.GetType() == typeof(SOCIAL_COMPARISON_STATE)) { SOCIAL_COMPARISON_STATE sc = (SOCIAL_COMPARISON_STATE)refGroundAtom.currentState; bool stuck = refGroundAtom.currentSpeed <= (float)sc.baselineSpeed / 10.0; if (!stuck) { return; } else { // stuck in social comparison - first return to baseline speed refGroundAtom.currentSpeed = sc.baselineSpeed; getBackToRegularMovement(refGroundAtom); } } else { refGroundAtom.currentSpeed = refGroundAtom.baselineSpeed; // check for casualties nearby List <clsGroundAtom> casualtiesNearby = new List <clsGroundAtom>(); foreach (clsGroundAtom atom in atomsNearby) { if (atom.healthStatus.isIncapacitated || atom.healthStatus.isDead) { casualtiesNearby.Add(atom); } } // check if already handled the specific trigger foreach (clsGroundAtom casualty in casualtiesNearby) { bool casualtyHandled = false; foreach (Trigger trigger in refGroundAtom.triggers) { if (trigger.type != Trigger.Type.DEAD_OR_INCAPACITATED) { continue; } DeadOrIncapacitatedTrigger doiTrigger = (DeadOrIncapacitatedTrigger)trigger; if (doiTrigger.atomName == casualty.MyName) { casualtyHandled = true; break; } } if (!casualtyHandled) { // decide whether to help casualty or not double helpOrNot = Util.random.NextDouble(); if (helpOrNot < 0.2) { // decide individually to help clsActivityMovement helpActivity = RouteUtils.createActivityAndStart(refGroundAtom, (int)refGroundAtom.currentSpeed, null); refGroundAtom.ChangeState(new HELP_OTHER_STATE(helpActivity, casualty)); refGroundAtom.triggers.Add(new DeadOrIncapacitatedTrigger(casualty.MyName)); return; } else if (helpOrNot >= 0.2 && helpOrNot < 0.3) { // decide individually just to look clsActivityMovement curiosityActivity = RouteUtils.createActivityAndStart(refGroundAtom, (int)refGroundAtom.currentSpeed, null); refGroundAtom.ChangeState(new CURIOSITY_MOVEMENT_STATE(curiosityActivity, casualty)); refGroundAtom.triggers.Add(new DeadOrIncapacitatedTrigger(casualty.MyName)); return; } else if (helpOrNot >= 0.3 && helpOrNot < 0.5) { // decide by socially comparing behavior if (moveToSocialComparisonStateIfCan(refGroundAtom)) { refGroundAtom.triggers.Add(new DeadOrIncapacitatedTrigger(casualty.MyName)); return; } } else { refGroundAtom.triggers.Add(new DeadOrIncapacitatedTrigger(casualty.MyName)); } } } } }