예제 #1
0
            public virtual void Perform(Event e, DiseaseVector vector)
            {
                if (!mTest.IsSuccess(e))
                {
                    return;
                }

                vector.AlterResistance(Delta);

                ScoringLog.sLog.AddStat(Guid + " Resistance", Delta);
            }
예제 #2
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            if (mAffectOther)
            {
                foreach (DiseaseVector disease in Vector.Settings.GetVectors(sim))
                {
                    if (!mAffectSelf)
                    {
                        if (disease == vector)
                        {
                            continue;
                        }
                    }

                    disease.AlterResistance(RandomUtil.GetInt(mMinimum, mMaximum));
                }
            }
            else if (mAffectSelf)
            {
                vector.AlterResistance(RandomUtil.GetInt(mMinimum, mMaximum));
            }
        }
예제 #3
0
            protected override void OnPerform()
            {
                if (mHouse == Household.ActiveHousehold)
                {
                    return;
                }

                List <SimDescription> babies         = new List <SimDescription>();
                List <SimDescription> teens          = new List <SimDescription>();
                List <SimDescription> adults         = new List <SimDescription>();
                List <SimDescription> teensAndAdults = new List <SimDescription>();

                foreach (SimDescription sim in Households.All(mHouse))
                {
                    if ((sim.IsPet) || (sim.ToddlerOrBelow))
                    {
                        babies.Add(sim);
                    }
                    else if (sim.YoungAdultOrAbove)
                    {
                        adults.Add(sim);
                        teensAndAdults.Add(sim);
                    }
                    else if (sim.Teen)
                    {
                        teens.Add(sim);
                        teensAndAdults.Add(sim);
                    }
                }

                if (adults.Count == 0)
                {
                    adults = teens;
                }

                bool purchaseInoculation = false;

                foreach (SimDescription sim in adults)
                {
                    if (ScoringLookup.GetScore("NRaasVectorPurchaseInoculation", sim) > 0)
                    {
                        purchaseInoculation = true;
                        break;
                    }
                }

                if (purchaseInoculation)
                {
                    List <DiseaseVector> potentials = new List <DiseaseVector>();

                    foreach (SimDescription sim in babies)
                    {
                        GetInoculates(sim, potentials, false);
                    }

                    while (potentials.Count > 0)
                    {
                        DiseaseVector potential = RandomUtil.GetRandomObjectFromList(potentials);
                        potentials.Remove(potential);

                        DiseaseVector inoculate = null;

                        List <SimDescription> potentialDonors = new List <SimDescription>();

                        foreach (SimDescription sim in teensAndAdults)
                        {
                            DiseaseVector vector = Vector.Settings.GetVector(sim, potential.Guid);
                            if (vector == null)
                            {
                                continue;
                            }

                            if (!vector.IsInoculationUpToDate)
                            {
                                potentialDonors.Add(sim);
                            }

                            if (!vector.IsInoculated)
                            {
                                continue;
                            }

                            inoculate = vector;
                            break;
                        }

                        if (inoculate == null)
                        {
                            if (mHouse.FamilyFunds < potential.InoculationCost)
                            {
                                continue;
                            }

                            inoculate = new DiseaseVector(potential.Data, Vector.Settings.GetCurrentStrain(potential.Data));
                            inoculate.Inoculate(potential.Data.InoculationStrain, true);

                            if (potentialDonors.Count > 0)
                            {
                                SimDescription donor = RandomUtil.GetRandomObjectFromList(potentialDonors);
                                VectorControl.Inoculate(donor, inoculate, true, false);
                            }

                            mHouse.ModifyFamilyFunds(-potential.InoculationCost);

                            Common.DebugNotify("Donor Inoculate: " + mHouse.Name + Common.NewLine + "Cost: " + potential.InoculationCost + Common.NewLine + potential.GetUnlocalizedDescription());
                        }
                        else
                        {
                            Common.DebugNotify("Existing Inoculate: " + mHouse.Name + Common.NewLine + "Cost: " + potential.InoculationCost + Common.NewLine + potential.GetUnlocalizedDescription());
                        }

                        if (inoculate != null)
                        {
                            foreach (SimDescription child in babies)
                            {
                                VectorControl.Inoculate(child, inoculate, false, false);
                            }

                            return;
                        }
                    }

                    potentials.Clear();

                    foreach (SimDescription sim in Households.All(mHouse))
                    {
                        // Babies were handled earlier
                        if (sim.ToddlerOrBelow)
                        {
                            continue;
                        }

                        GetInoculates(sim, potentials, true);
                    }

                    while (potentials.Count > 0)
                    {
                        DiseaseVector potential = RandomUtil.GetRandomObjectFromList(potentials);
                        potentials.Remove(potential);

                        if (mHouse.FamilyFunds < potential.InoculationCost)
                        {
                            continue;
                        }

                        potential.Inoculate(potential.Data.InoculationStrain, true);

                        mHouse.ModifyFamilyFunds(-potential.InoculationCost);

                        if (Common.kDebugging)
                        {
                            Common.DebugNotify("Inoculate: " + mHouse.Name + Common.NewLine + "Cost: " + potential.InoculationCost + Common.NewLine + potential.GetUnlocalizedDescription());
                        }

                        return;
                    }
                }

                List <SimDescription> choices = new List <SimDescription>(adults);

                while (choices.Count > 0)
                {
                    SimDescription choice = RandomUtil.GetRandomObjectFromList(choices);
                    choices.Remove(choice);

                    if (ScoringLookup.GetScore("NRaasVectorPurchaseResistance", choice) > 0)
                    {
                        List <DiseaseVector> potentials = new List <DiseaseVector>();

                        GetResisters(choice, potentials);

                        if (potentials.Count > 0)
                        {
                            DiseaseVector potential = RandomUtil.GetRandomObjectFromList(potentials);

                            mHouse.ModifyFamilyFunds(-potential.ResistanceCost);

                            potential.AlterResistance(Vector.Settings.mResistanceBoost);

                            potential.SetToIdentified();

                            if (Common.kDebugging)
                            {
                                Common.DebugNotify("Boost: " + mHouse.Name + Common.NewLine + "Cost: " + potential.ResistanceCost + Common.NewLine + potential.GetUnlocalizedDescription());
                            }
                        }
                    }

                    /*
                     * if (ScoringLookup.GetScore("NRaasVectorPurchaseProtection", choice) > 0)
                     * {
                     *  purchaseProtection = true;
                     * }
                     */
                }
            }
예제 #4
0
            public virtual void Perform(Event e, DiseaseVector vector)
            {
                if (!mTest.IsSuccess(e)) return;

                vector.AlterResistance(Delta);

                ScoringLog.sLog.AddStat(Guid + " Resistance", Delta);
            }