Example #1
0
        public static bool Inoculate(SimDescription sim, DiseaseVector vector, bool paid, bool testExisting)
        {
            if (vector.InoculationCost <= 0)
            {
                return(false);
            }

            DiseaseVector newVector = Vector.Settings.GetVector(sim, vector.Guid);

            if (newVector == null)
            {
                newVector = new DiseaseVector(vector, sim);
                newVector.Inoculate(vector.InoculationStrain, paid);

                Vector.Settings.AddVector(sim, newVector);
                return(true);
            }
            else
            {
                if (testExisting)
                {
                    if (newVector.IsInoculationUpToDate)
                    {
                        return(false);
                    }
                }

                if (!newVector.CanInoculate)
                {
                    return(false);
                }

                return(newVector.Inoculate(vector.InoculationStrain, paid));
            }
        }
Example #2
0
        public static bool Inoculate(SimDescription sim, VectorBooter.Data vector, bool paid, bool testExisting)
        {
            DiseaseVector inoculate = new DiseaseVector(vector, Vector.Settings.GetCurrentStrain(vector));

            inoculate.Inoculate(vector.InoculationStrain, paid);

            return(Inoculate(sim, inoculate, paid, testExisting));
        }
Example #3
0
        public static bool Inoculate(SimDescription sim, DiseaseVector vector, bool paid, bool testExisting)
        {
            if (vector.InoculationCost <= 0) return false;

            DiseaseVector newVector = Vector.Settings.GetVector(sim, vector.Guid);
            if (newVector == null)
            {
                newVector = new DiseaseVector(vector, sim);
                newVector.Inoculate(vector.InoculationStrain, paid);

                Vector.Settings.AddVector(sim, newVector);
                return true;
            }
            else
            {
                if (testExisting)
                {
                    if (newVector.IsInoculationUpToDate) return false;
                }

                if (!newVector.CanInoculate) return false;

                return newVector.Inoculate(vector.InoculationStrain, paid);
            }
        }
Example #4
0
        public static bool Inoculate(SimDescription sim, VectorBooter.Data vector, bool paid, bool testExisting)
        {
            DiseaseVector inoculate = new DiseaseVector(vector, Vector.Settings.GetCurrentStrain(vector));
            inoculate.Inoculate(vector.InoculationStrain, paid);

            return Inoculate(sim, inoculate, paid, testExisting);
        }
Example #5
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;
                     * }
                     */
                }
            }
Example #6
0
        public override bool InRabbitHole()
        {
            try
            {
                StartStages();
                BeginCommodityUpdates();

                bool succeeded = false;

                try
                {
                    succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached));
                    if (succeeded)
                    {
                        List <VectorBooter.Item> items = new List <VectorBooter.Item>();

                        foreach (VectorBooter.Data vector in VectorBooter.Vectors)
                        {
                            bool booster = false;
                            int  cost    = vector.InoculationCost;

                            DiseaseVector disease = Vector.Settings.GetVector(Actor, vector.Guid);
                            if (disease != null)
                            {
                                if (!disease.CanInoculate)
                                {
                                    continue;
                                }

                                if (disease.IsInoculated)
                                {
                                    if (vector.InoculationStrain >= vector.InoculationStrain)
                                    {
                                        continue;
                                    }

                                    cost   /= 2;
                                    booster = true;
                                }
                            }
                            else
                            {
                                if (vector.InoculationCost <= 0)
                                {
                                    continue;
                                }
                            }

                            items.Add(new VectorBooter.Item(vector, Actor.IsFemale, cost, booster));
                        }

                        if (items.Count == 0)
                        {
                            Common.Notify(Actor, Common.Localize("GetInoculation:None", Actor.IsFemale));
                        }
                        else
                        {
                            CommonSelection <VectorBooter.Item> .Results choices = new CommonSelection <VectorBooter.Item>(GetInteractionName(), items, new CostColumn()).SelectMultiple();
                            if ((choices == null) || (choices.Count == 0))
                            {
                                return(false);
                            }

                            int cost = 0;

                            foreach (VectorBooter.Item item in choices)
                            {
                                cost += item.Value.InoculationCost;
                            }

                            if (Actor.FamilyFunds < cost)
                            {
                                Common.Notify(Actor, Common.Localize("GetInoculation:Cost", Actor.IsFemale, new object[] { cost }));
                            }
                            else
                            {
                                foreach (VectorBooter.Item item in choices)
                                {
                                    DiseaseVector vector = Vector.Settings.GetVector(Actor, item.Value.Guid);
                                    if (vector != null)
                                    {
                                        vector.Inoculate(item.Value.InoculationStrain, true);
                                    }
                                }

                                Common.Notify(Actor, Common.Localize("GetInoculation:Success", Actor.IsFemale, new object[] { cost }));

                                Actor.ModifyFunds(-cost);
                            }
                        }
                    }
                }
                finally
                {
                    EndCommodityUpdates(succeeded);
                }
                return(succeeded);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Example #7
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;
                    }
                    */
                }
            }