Beispiel #1
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            int count = 0;

            List <GameObject> objs = sim.LotCurrent.GetObjectsInRoom <GameObject>(sim.RoomId);

            while ((count < mMaximum) && (objs.Count > 0))
            {
                GameObject obj = RandomUtil.GetRandomObjectFromList(objs);
                count++;

                RepairableComponent repairable = obj.Repairable;
                if (repairable == null)
                {
                    continue;
                }

                if (!repairable.CanBreak())
                {
                    continue;
                }

                repairable.BreakObject(sim, true);
            }
        }
Beispiel #2
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            List <GameObject> breakables = new List <GameObject>();

            foreach (Lot lot in ManagerLot.GetOwnedLots(Target))
            {
                foreach (GameObject obj in lot.GetObjects <GameObject>())
                {
                    if (obj == null)
                    {
                        continue;
                    }

                    if (obj.InUse)
                    {
                        continue;
                    }

                    if (!obj.InWorld)
                    {
                        continue;
                    }

                    if (!obj.IsRepairable)
                    {
                        continue;
                    }

                    RepairableComponent component = obj.Repairable;
                    if (component == null)
                    {
                        continue;
                    }

                    if (component.Broken)
                    {
                        continue;
                    }

                    if (!component.CanBreak())
                    {
                        continue;
                    }

                    breakables.Add(obj);
                }
            }

            if (breakables.Count == 0)
            {
                return(false);
            }

            if (!base.PrivateUpdate(frame))
            {
                return(false);
            }

            mVictim = RandomUtil.GetRandomObjectFromList(breakables);

            RepairableComponent repair = mVictim.Repairable;

            repair.BreakObject(Sim.CreatedSim, true);

            mFail = IsFail(Sim, Target);

            if (mFail)
            {
                int cost = (int)(mVictim.Value * 1.5);

                Money.AdjustFunds(Sim, "Damages", -cost);

                Money.AdjustFunds(Target, "Insurance", cost);
            }

            Add(frame, new ExistingEnemyManualScenario(Sim, Target, Delta, 0, GetTitlePrefix(PrefixType.Story)), ScenarioResult.Start);

            if (OnInvestigateScenario != null)
            {
                OnInvestigateScenario(this, frame);
            }

            return(true);
        }