protected override bool CommonAllow(SimDescription sim) { if (Sims.HasEnough(this, sim)) { IncStat("Maximum Reached"); return(false); } else if (sim.IsPregnant) { IncStat("Couple Pregnant"); return(false); } else if (SimTypes.InServicePool(sim, ServiceType.GrimReaper)) { IncStat("Reaper"); return(false); } else if (sim.IsMummy) { IncStat("Mummy"); return(false); } return(base.CommonAllow(sim)); }
/// <summary> /// Refreshes the catalog and initializes all simulators with the host (Telemetry class). /// </summary> private void Refresh() { try { var catalog = new DirectoryCatalog(Telemetry.m.binaryDirectory + "simulators/", "SimTelemetry.Game.*.dll"); catalog.Refresh(); var container = new CompositionContainer(catalog); container.ComposeParts(this); foreach (ISimulator sim in Sims) { sim.Host = Telemetry.m; sim.Initialize(); } if (Network != null) { throw new Exception("Network already added"); } Network = new NetworkGame { Host = Telemetry.m }; Network.Initialize(); Sims.Add(Network); } catch (Exception ex) { Debug.WriteLine("Failed loading assemblies"); Debug.WriteLine(ex.Message); Debug.WriteLine(ex.StackTrace); } }
protected override bool CommonAllow(SimDescription sim) { if (Sims.HasEnough(this, sim)) { IncStat("Maximum Reached"); return(false); } else if (sim.IsPregnant) { IncStat("Couple Pregnant"); return(false); } else if (!Pregnancies.Allow(this, sim)) { IncStat("User Denied"); return(false); } if (GetValue <MaximumNumberOfChildrenOption, int>(sim) > 0) { if (AddScoring("PreferredBabyCount", sim) <= Relationships.GetChildren(sim).Count) { IncStat("Enough"); return(false); } } return(base.CommonAllow(sim)); }
protected override bool Allow(SimDescription sim) { if (sim.TraitManager == null) { IncStat("No Manager"); return(false); } else if (!Sims.Allow(this, sim, Managers.Manager.AllowCheck.None)) { IncStat("User Denied"); return(false); } else if (sim.AgingState == null) { IncStat("No AgingState"); return(false); } else if (!HasAnyValue <ForceTraitOption, TraitNames>(sim)) { IncStat("Unnecessary"); return(false); } else if (sim.IsEP11Bot) { IncStat("Plumbot"); return(false); } return(base.Allow(sim)); }
public bool MoveSim(SimDescription sim, Household moveTo) { if (sim.Household == moveTo) { return(true); } if (sim.Household != null) { if (sim.CreatedSim != null) { try { if ((sim.CreatedSim.Autonomy != null) && (sim.CreatedSim.Autonomy.Motives == null)) { sim.CreatedSim.Autonomy.RecreateAllMotives(); IncStat("Motives Recreated"); } if (sim.CreatedSim.LotCurrent == null) { sim.CreatedSim.InternalOnSetLotCurrent(null); } } catch (Exception e) { Common.DebugException(sim, e); Sims.Reset(sim); } } Household oldHouse = sim.Household; ProcessAbandonHouse(oldHouse, moveTo); sim.Household.Remove(sim); foreach (SimDescription member in HouseholdsEx.All(oldHouse)) { GetData(member).InvalidateCache(); } } moveTo.Add(sim); foreach (SimDescription member in HouseholdsEx.All(moveTo)) { GetData(member).InvalidateCache(); } ManagerSim.ForceRecount(); SetValue <InspectedOption, bool>(moveTo, false); Sims.Instantiate(sim, moveTo.LotHome, true); return(sim.Household == moveTo); }
protected override bool Allow(SimDescription sim) { if (sim.LotHome == null) { IncStat("Not Resident"); return(false); } else if (sim.AdultOrAbove) { IncStat("Too Old"); return(false); } else if (sim.TraitManager == null) { IncStat("No Manager"); return(false); } else if (!Sims.MatchesAlertLevel(sim)) { IncStat("No Match"); return(false); } return(base.Allow(sim)); }
protected override bool Allow(SimDescription sim) { if (sim.ToddlerOrBelow) { IncStat("Too Young"); return(false); } else if (sim.CreatedSim == null) { IncStat("Hibernating"); return(false); } else if (!Skills.Allow(this, sim)) { IncStat("Skill Denied"); return(false); } else if (!Sims.AllowInventory(this, sim, Managers.Manager.AllowCheck.None)) { IncStat("Inventory Denied"); return(false); } else if (!Situations.Allow(this, sim)) { IncStat("Situations Denied"); return(false); } else if ((sim.IsEP11Bot) && (!sim.HasTrait(TraitNames.FisherBotChip))) { IncStat("Chip Denied"); return(false); } return(base.Allow(sim)); }
protected override bool Allow(SimDescription sim) { if (!GetValue <AllowHarvestOption, bool>(sim)) { IncStat("Harvest Denied"); return(false); } else if (sim.CreatedSim == null) { IncStat("Hibernating"); return(false); } else if (!Situations.Allow(this, sim)) { IncStat("Situation Denied"); return(false); } else if (!Sims.AllowInventory(this, sim, Managers.Manager.AllowCheck.None)) { IncStat("Inventory Denied"); return(false); } return(base.Allow(sim)); }
protected override bool Allow(SimDescription sim) { if (sim.ChildOrBelow) { IncStat("Too Young"); return(false); } else if (sim.CreatedSim == null) { IncStat("Hibernating"); return(false); } else if (sim.LotHome == null) { IncStat("Homeless"); return(false); } else if (!Skills.Allow(this, sim)) { IncStat("Skill Denied"); return(false); } else if (!Sims.AllowInventory(this, sim, Managers.Manager.AllowCheck.None)) { IncStat("Inventory Denied"); return(false); } else if (!Situations.Allow(this, sim)) { IncStat("Situations Denied"); return(false); } return(base.Allow(sim)); }
protected override bool Allow(SimDescription sim) { if (sim.Household == null) { IncStat("No Home"); return(false); } else if (sim.CreatedSim == null) { IncStat("Hibernating"); return(false); } else if (!Inventories.VerifyInventory(sim)) { IncStat("No Inventory"); return(false); } else if (!Sims.AllowInventory(this, sim, AllowActive ? Managers.Manager.AllowCheck.None : Managers.Manager.AllowCheck.Active)) { IncStat("Inventory Denied"); return(false); } /* Time consuming * else if (GetInventory(sim).Count == 0) * { * IncStat("Empty"); * return false; * } */ return(base.Allow(sim)); }
protected override bool PrivateUpdate(ScenarioFrame frame) { List <Manager> managers = new List <Manager>(); string body = null; int previousPressure = 0; foreach (KeyValuePair <Manager, int> value in Lots.ImmigrationPressure) { if (value.Value == 0) { continue; } AddStat("Pressure: " + value.Key.UnlocalizedName, value.Value); body += Localize("PressureElement", false, new object[] { value.Key.GetLocalizedName(), value.Value }); managers.Add(value.Key); previousPressure += value.Value; } AddStat("Total", previousPressure); Lots.PreviousPressure = previousPressure; if (ImmigrationGauge <= 0) { return(false); } mStory = Localize("PressureSummary", false, new object[] { body, previousPressure }); if (previousPressure <= ImmigrationGauge) { mStory += Localize("PressureInsufficient", false, new object[] { ImmigrationGauge }); return(true); } if (Sims.HasEnough(this, CASAgeGenderFlags.Human)) { mStory += Localize("PressureMaxResidents"); return(true); } foreach (Manager manager in managers) { Add(frame, manager.GetImmigrantRequirement(mRequirement), ScenarioResult.Start); } mStory = null; mRequirement.mRequired = true; return(false); }
protected override bool PrivateUpdate(ScenarioFrame frame) { Sim sim = Sim.CreatedSim; if (sim == null) { Sims.Instantiate(Sim, null, false); sim = Sim.CreatedSim; } if (sim == null) { IncStat("Hibernating"); return(false); } Career job = Occupation as Career; Careers.VerifyTone(job); if (!ManagerCareer.ValidCareer(job)) { IncStat("Career Invalidated"); return(false); } InteractionInstance instance = GetWorkInteraction(job); if (instance == null) { IncStat("No Interaction"); return(false); } else if (!Test(sim, instance.InteractionDefinition)) { return(false); } else { if (sim.InteractionQueue.Add(instance)) { if (GetValue <AllowGoHomePushOption, bool>(Sim)) { Manager.AddAlarm(new GoHomePushScenario(Sim)); } } else { IncStat("Failure"); } mReport = PostSlackerWarning(); return(true); } }
protected override void PrivatePerform(SimDescription sim, SimData data, ScenarioFrame frame) { PregnancySimData other = data.Get <PregnancySimData>(); if (sim.IsPregnant) { if ((other.mLastCheckPregnancy != 0) && (other.mLastCheckPregnancy < SimClock.ElapsedCalendarDays())) { if (!AllowProgression(sim)) { // Delay pregnancy indefinitely sim.Pregnancy.mHourOfPregnancy = other.mPregnancyHour; IncStat("Pregnancy Suspended"); } else { if (other.mPregnancyHour == sim.Pregnancy.mHourOfPregnancy) { IncStat(sim.FirstName + " " + sim.LastName + ": Stuck Pregnancy", Common.DebugLevel.High); if (!SimTypes.IsSelectable(sim)) { Sims.Reset(sim); if ((sim.CreatedSim != null) && (sim.LotHome != null)) { SimDescription dad = ManagerSim.Find(sim.Pregnancy.DadDescriptionId); if (dad != null) { Sims.Instantiate(dad, sim.LotHome, false); } if (sim.Pregnancy.PreggersAlarm != AlarmHandle.kInvalidHandle) { AlarmManager.Global.RemoveAlarm(sim.Pregnancy.PreggersAlarm); sim.Pregnancy.PreggersAlarm = AlarmHandle.kInvalidHandle; } sim.Pregnancy.Continue(sim.CreatedSim, true); IncStat("Pregnancy Reset"); } } } } } other.mPregnancyHour = sim.Pregnancy.mHourOfPregnancy; other.mLastCheckPregnancy = SimClock.ElapsedCalendarDays(); } else { other.mPregnancyHour = 0; other.mLastCheckPregnancy = 0; } }
protected override bool Allow() { if (!Sims.SatisfiesTownOccultRatio(mOccult)) { IncStat("Too Many"); return(false); } return(base.Allow()); }
protected override bool CommonAllow(SimDescription sim) { if (!Sims.Allow(this, sim)) { IncStat("User Denied"); return(false); } return(base.CommonAllow(sim)); }
protected CASAgeGenderFlags GetSpecies(SimDescription sim) { List <CASAgeGenderFlags> species = new List <CASAgeGenderFlags>(); if (mSpecies != CASAgeGenderFlags.None) { species.Add(mSpecies); } else { GetPossibleSpecies(sim.Household, species); } AddStat("Choices", species.Count); bool allowAnother = RandomUtil.RandomChance(GetValue <PetAdoptionBaseScenario.ChanceOfAnotherOptionV2, int>()); for (int i = species.Count - 1; i >= 0; i--) { CASAgeGenderFlags choice = species[i]; if (Sims.HasEnough(this, choice)) { IncStat("Maximum " + species); species.RemoveAt(i); } else if (HouseholdsEx.IsFull(this, sim.Household, choice, 0, true, allowAnother)) { species.RemoveAt(i); } } if (species.Count > 0) { if (mNewSim != null) { if (!species.Contains(mNewSim.Species)) { IncStat("House Wrong Species"); return(CASAgeGenderFlags.None); } else { return(mNewSim.Species); } } return(RandomUtil.GetRandomObjectFromList(species)); } else { return(CASAgeGenderFlags.None); } }
protected override GatherResult Gather(List <Scenario> list, ref int continueChance, ref int maximum, ref bool random) { int mAdditionalBabyCount = Sims.GetDepopulationDanger(false); if (mAdditionalBabyCount > 0) { mAdditionalBabyCount--; } return(base.Gather(list, ref continueChance, ref maximum, ref random)); }
public ISimulator Get(string sim) { if (Sims == null) { return(null); } else { return(Sims.Where(x => x.ProcessName.Equals(sim)).FirstOrDefault()); } }
protected override bool Allow(SimDescription sim) { if (sim.CreatedSim == null) { IncStat("Hibernating"); return(false); } else if (sim.LotHome == null) { IncStat("Not Resident"); return(false); } else if (sim.ToddlerOrBelow) { IncStat("Too Young"); return(false); } else if (Deaths.IsDying(sim)) { IncStat("Dying"); return(false); } else if (!Sims.AllowInventory(this, sim, AllowActive ? Managers.Manager.AllowCheck.None : Managers.Manager.AllowCheck.Active)) { IncStat("Inventory Denied"); return(false); } else if (!Money.Allow(this, sim)) { IncStat("Money Denied"); return(false); } else if (SimTypes.IsSpecial(sim)) { IncStat("Special"); return(false); } else if ((Funds - Minimum) < 0) { AddStat("No Money Funds", Funds); AddStat("No Money Minimum", Minimum); return(false); } else if (GetValue <DebtOption, int>(sim.Household) > 0) { IncStat("Debt"); return(false); } return(base.Allow(sim)); }
public bool RandomChanceOfAttempt(Common.IStatGenerator stats, float baseChance) { stats.AddStat("Base Chance", baseChance); baseChance += (Sims.GetDepopulationDanger(false) * 10); if (Households.FamiliesPacked && (Lots.FreeLotRatio < 0.2f)) { baseChance /= 3f; } stats.AddStat("Adjusted Chance", baseChance); return(RandomUtil.RandomChance(baseChance)); }
protected override bool Allow() { if (GetValue <ThresholdOption, int>() <= 0) { return(false); } if (!Sims.HasEnough(this, CASAgeGenderFlags.Human)) { IncStat("Not Full"); return(false); } return(base.Allow()); }
protected override bool Allow() { if (!GetValue <NewcomerGoneScenario.AllowHomelessMoveInOptionV2, bool>()) { IncStat("Move In Denied"); return(false); } else if (Sims.HasEnough(Movers)) { IncStat("Town Full"); return(false); } return(base.Allow()); }
protected override bool Allow(Household house) { if (house.LotHome != null) { IncStat("Resident"); return(false); } else if (Sims.HasEnough(house.SimDescriptions)) { IncStat("Town Full"); return(false); } return(base.Allow(house)); }
protected override bool PrivateUpdate(ScenarioFrame frame) { Sim createdSim = Sim.CreatedSim; if (createdSim == null) { return(false); } if (createdSim.LotCurrent == null) { return(false); } if (createdSim.LotCurrent.IsCommunityLot) { if (createdSim.LotCurrent != LotManager.ActiveLot) { if (Sims != null) { Sims.Reset(Sim); } if (createdSim.Motives != null) { createdSim.Motives.ForceSetMax(CommodityKind.Temperature); } if ((createdSim != null) && (createdSim.BuffManager != null)) { createdSim.BuffManager.RemoveElement(BuffNames.OnFire); createdSim.BuffManager.RemoveElement(BuffNames.Torched); } IncStat("Sim Reset"); } else { IncStat("Active Lot"); } return(true); } Add(frame, new ExtinguishScenario(createdSim.LotCurrent), ScenarioResult.Start); return(true); }
protected bool HouseholdHasAgelessBaby(Household house) { if (house == null) { return(false); } foreach (SimDescription sim in HouseholdsEx.All(house)) { if ((sim.ToddlerOrBelow) && (!Sims.AllowAging(this, sim))) { return(true); } } return(false); }
/// <summary> /// Gets the simulator that is running. If mutltiple are; the first one is picked. /// </summary> /// <returns></returns> public ISimulator GetRunning() { if (Sims == null) { return(null); } if (Network != null && Network.Attached) { return(Network); } if (Available) { return(Sims.Where(x => x.Attached).FirstOrDefault()); } return(null); }
public SimData GetSim(SimDescription sim) { SimID id = new SimID(sim); SimData data; if (!Sims.TryGetValue(id, out data)) { data = new SimData(sim); Sims.Add(id, data); mSimData.Add(data); } data.SetSimDescription(sim); return(data); }
protected override bool Allow(SimDescription sim) { if (sim.LotHome != null) { IncStat("Resident"); return(false); } else if (!Households.Allow(this, sim, 0)) { IncStat("User Denied"); return(false); } else if (Sims.HasEnough(this, sim)) { IncStat("Maximum Reached"); return(false); } return(base.Allow(sim)); }
protected override bool Allow() { if (Sims.HasEnough(this, CASAgeGenderFlags.Human)) { IncStat("Town Full"); return(false); } else if (!TestEmptyHomes(this)) { IncStat("Too Few Empty"); return(false); } else if (Lots.FindLot(this, null, 0, ManagerLot.FindLotFlags.Inspect | ManagerLot.FindLotFlags.CheapestHome, OnLotPriceCheck) == null) { IncStat("No Empty"); return(false); } return(base.Allow()); }
protected override bool Allow(SimDescription sim) { if (sim.TraitManager == null) { IncStat("No Manager"); return(false); } else if (!Sims.Allow(this, sim, Managers.Manager.AllowCheck.None)) { IncStat("User Denied"); return(false); } else if (sim.AgingState == null) { IncStat("No AgingState"); return(false); } return(base.Allow(sim)); }
protected static CASMode OnGetMode(SimDescription sim, ref OutfitCategories startCategory, ref int startIndex, ref Sims.CASBase.EditType editType) { return CASMode.Full; }