Ejemplo n.º 1
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            int baseChance = GetValue <WitnessBaseChanceOption, int>();

            foreach (SimDescription sim in Sims.All)
            {
                bool forceCurfew;
                if (!IsUnderCurfew(this, this, sim, out forceCurfew))
                {
                    if (sim.CreatedSim != null)
                    {
                        sim.CreatedSim.BuffManager.RemoveElement(BuffNames.OutAfterCurfew);
                    }
                    continue;
                }

                if ((sim.CreatedSim != null) && (sim.TeenOrBelow))
                {
                    if (AddScoring("IgnoreCurfew", sim) > 0)
                    {
                        if (!sim.CreatedSim.BuffManager.HasElement(BuffNames.OutAfterCurfew))
                        {
                            sim.CreatedSim.BuffManager.AddElement(BuffNames.OutAfterCurfew, Origin.FromBreakingCurfew);
                            sim.CreatedSim.BuffManager.AddElement(BuffNames.FightThePower, Origin.FromBreakingCurfew);

                            IncStat("Added Buff");
                        }

                        EventTracker.SendEvent(EventTypeId.kTeenBreakingCurfew, sim.CreatedSim);
                    }
                    else
                    {
                        forceCurfew = true;
                    }
                }

                if ((!forceCurfew) && (!IsWitnessed(this, this, sim, baseChance)))
                {
                    IncStat("Not Witnessed");
                    continue;
                }

                if ((!forceCurfew) && (SimTypes.IsSelectable(sim)))
                {
                    Police instance = Police.Instance;
                    if (instance != null)
                    {
                        float chance = sim.HasTrait(TraitNames.Rebellious) ? Police.kChanceOfPoliceSpawnAfterCurfewRebellious : Police.kChanceOfPoliceSpawnAfterCurfew;
                        if (RandomUtil.RandomChance01(chance))
                        {
                            if ((!instance.IsAnySimActiveOnLot(sim.CreatedSim.LotCurrent)) && (!PoliceSituation.IsTeenBeingCaught(sim.CreatedSim)))
                            {
                                IncStat("Curfew Police");

                                instance.MakeServiceRequest(sim.CreatedSim.LotCurrent, true, sim.CreatedSim.ObjectId);
                            }
                        }
                        else
                        {
                            IncStat("Curfew Police Chance Fail");
                        }
                    }
                }
                else
                {
                    Situations.PushGoHome(this, sim);
                }
            }

            return(true);
        }