protected override bool Allow(SimDescription sim) { if (Sim.CreatedSim == null) { IncStat("Hibernating"); return(false); } else { InteractionInstance instance = null; try { instance = CareerPushScenario.GetWorkInteraction(Job); } catch (Exception e) { Common.DebugException(Sim, e); } if (instance == null) { IncStat("No Interaction"); return(false); } else if (Situations.HasInteraction(Sim.CreatedSim, instance.InteractionDefinition, true)) { IncStat("At Work"); return(false); } } return(base.Allow(sim)); }
protected bool Test(Sim sim, List <InteractionDefinition> interactions) { if (InteractionsEx.HasInteraction <ICountsAsWorking>(sim)) { IncStat("At Work"); return(false); } else if (Situations.HasInteraction(sim, interactions, true)) { IncStat("At Work"); return(false); } else { if (Situations.DebuggingLevel >= Common.DebugLevel.High) { if (sim.InteractionQueue == null) { IncStat("Interaction Queue = null"); } else { if (sim.InteractionQueue.Count == 0) { IncStat("Interaction Queue empty"); } else { foreach (InteractionInstance instance2 in sim.InteractionQueue.InteractionList) { IncStat("Interaction: " + instance2.ToString()); } } } } VisitSituation.AnnounceTimeToGoToWork(sim); if (SimTypes.IsSpecial(Sim)) { IncStat("Special Pushed to Work"); } else { IncStat("Pushed to Work"); } try { // Don't queue stomp on their birthday if (sim.SimDescription.YearsSinceLastAgeTransition != 0) { sim.InteractionQueue.CancelAllInteractions(); IncStat("Queue Stomped"); if ((!SimTypes.IsSelectable(sim.SimDescription)) && (sim.LotCurrent != null) && (sim.LotCurrent.CanSimTreatAsHome(sim))) { Callbox callbox = sim.LotHome.FindCallbox(); if (callbox != null) { Vector3 fwd = Vector3.Invalid; Vector3 pos = Vector3.Invalid; World.FindGoodLocationParams fglParams = new World.FindGoodLocationParams(callbox.Position); fglParams.BooleanConstraints = FindGoodLocationBooleans.Routable | FindGoodLocationBooleans.PreferEmptyTiles; if (GlobalFunctions.FindGoodLocation(sim, fglParams, out pos, out fwd)) { sim.ResetBindPoseWithRotation(); sim.SetPosition(pos); sim.SetForward(fwd); sim.RemoveFromWorld(); sim.AddToWorld(); sim.SetHiddenFlags(HiddenFlags.Nothing); sim.SetOpacity(1f, 0f); IncStat("Bounce to Mailbox"); } } } } } catch (Exception e) { Common.DebugException(sim, e); IncStat("Cancel Fail"); } sim.InteractionQueue.RemoveGoHomeInteractions(true); return(true); } }