private static bool Perform(SimDescription sim, bool force) { try { FixInvisibleTask.Approach approach = FixInvisibleTask.Perform(sim, force); if (approach != FixInvisibleTask.Approach.None) { DebugEnabler.Notify(sim.CreatedSim, Common.Localize("FixInvisibleSims:Success", sim.IsFemale, new object[] { Common.Localize("FixInvisibleSims:" + approach), sim })); } return(true); } catch (Exception e) { Common.Exception(sim, e); return(false); } }
public static int OnRestartMotives(object[] parameters) { try { foreach (SimDescription sim in Household.EverySimDescription()) { Sim createdSim = sim.CreatedSim; if (createdSim == null) { continue; } if (sim.Household == null) { continue; } if (sim.Household.IsSpecialHousehold) { continue; } if (createdSim.Autonomy == null) { DebugEnabler.Notify("No Autonomy", sim.CreatedSim.ObjectId); continue; } bool success = false; if (createdSim.Autonomy.mLastTime > SimClock.ElapsedTime(TimeUnit.Minutes)) { createdSim.Autonomy.mLastTime = 0; success = true; } if (createdSim.Autonomy.Motives == null) { createdSim.Autonomy.mMotives = new Motives(createdSim, createdSim.Autonomy.mInteractionScorer); success = true; } if (createdSim.Autonomy.Motives.GetMotive(CommodityKind.Hunger) == null) { createdSim.Autonomy.RecreateAllMotives(); success = true; } if (success) { DebugEnabler.Notify("Restarted Motive", sim.CreatedSim.ObjectId); } } } catch (Exception e) { Common.Exception("OnRestartMotives", e); } return(0); }