Exemplo n.º 1
0
        public DiseaseVector(DiseaseVector vector, SimDescription sim)
        {
            mGuid = vector.mGuid;
            mNonPersistableData = vector.mNonPersistableData;
            mStrain             = new Variant(mNonPersistableData, vector.mStrain);

            Start(Notices.None);
        }
Exemplo n.º 2
0
        public void AddVector(SimDescription sim, DiseaseVector vector)
        {
            PrivateGetVectors(sim).Add(vector);

            if (!vector.IsInoculated)
            {
                if (Common.kDebugging)
                {
                    OutbreakControl.ShowNotice(sim, vector, "Infected: ");
                }
            }
        }
Exemplo n.º 3
0
        protected bool Infect(SimDescription sim, SimDescription source, VectorControl.Virulence type, Event e, bool force)
        {
            DiseaseVector existing = Vector.Settings.GetVector(sim, Guid);

            if (!force)
            {
                if (!IsContagious)
                {
                    ScoringLog.sLog.IncStat(UnlocalizedName + " " + type + ": Not Contagious");
                    return(false);
                }

                float chance = GetInfectionRate(type);
                if (chance == 0)
                {
                    ScoringLog.sLog.IncStat(UnlocalizedName + " " + type + ": Not Infectious");
                    return(false);
                }
                else
                {
                    if (type == VectorControl.Virulence.Woohoo)
                    {
                        if ((!IsProtected) && (!SimTypes.IsSelectable(sim)))
                        {
                            int rating = Vector.Settings.mHighProtectionRating;
                            int cost   = Data.HighProtectionCost;
                            if ((cost == 0) || (sim.FamilyFunds < cost))
                            {
                                rating = Vector.Settings.mLowProtectionRating;
                                cost   = Data.LowProtectionCost;
                            }

                            if (cost <= sim.FamilyFunds)
                            {
                                if (ScoringLookup.GetScore("NRaasVectorPurchaseProtection", sim, source) > 0)
                                {
                                    sim.ModifyFunds(-cost);

                                    SetProtection(rating, Vector.Settings.mProtectionDuration);

                                    chance = GetInfectionRate(type);

                                    ScoringLog.sLog.IncStat(UnlocalizedName + " " + type + ": Protection Purchased");

                                    if (Common.kDebugging)
                                    {
                                        Common.DebugNotify(UnlocalizedName + Common.NewLine + sim.FullName + Common.NewLine + "Protection Bought");
                                    }
                                }
                            }
                        }

                        if (sWoohooerIsRiskyOrTryForBaby.Valid)
                        {
                            if (!sWoohooerIsRiskyOrTryForBaby.Invoke <bool>(new object[] { e }))
                            {
                                chance /= 10;
                            }
                        }
                    }

                    ScoringLog.sLog.AddStat(UnlocalizedName + " " + type + ": Infection Rate", chance);

                    if (!RandomUtil.RandomChance01(chance))
                    {
                        ScoringLog.sLog.IncStat(UnlocalizedName + " " + type + ": Infection Failure");
                        return(false);
                    }

                    switch (type)
                    {
                    case VectorControl.Virulence.Outdoors:
                    case VectorControl.Virulence.Room:
                        break;

                    default:
                        AlterRelationship(sim, source, ((existing != null) && (existing.HadFirstSign)));
                        break;
                    }
                }
            }

            if (!mNonPersistableData.CanInfect(sim, source))
            {
                ScoringLog.sLog.IncStat(UnlocalizedName + " " + type + ": Infection Denied");
                return(false);
            }

            if (existing != null)
            {
                return(existing.Reconcile(type, mStrain, (source != null) ? source.SimDescriptionId : 0));
            }
            else
            {
                mStrain = Vector.Settings.GetNewStrain(Data, mStrain);

                if (source != null)
                {
                    mInfector = source.SimDescriptionId;
                }

                Vector.Settings.AddVector(sim, Clone(sim));

                ScoringLog.sLog.IncStat(UnlocalizedName + " " + type + ": New Infection");
                return(true);
            }
        }