public override void turnTick(Unit unit)
        {
            List <Location> locs = new List <Location>();

            locs.Add(unit.location);
            foreach (Location loc in unit.location.getNeighbours())
            {
                locs.Add(loc);
            }

            bool hadEffect = false;

            foreach (Location loc in locs)
            {
                if (loc.settlement == null || (loc.settlement is SettlementHuman == false))
                {
                    continue;
                }
                bool hasDisease = false;
                foreach (Property pr in loc.properties)
                {
                    if (pr.proto.isDisease)
                    {
                        hasDisease = true;
                    }
                }
                if (hasDisease)
                {
                    hadEffect = true;
                    SettlementHuman set = (SettlementHuman)loc.settlement;
                    set.population -= 1;
                    if (set.population <= 0)
                    {
                        if (set.title != null && set.title.heldBy != null)
                        {
                            set.title.heldBy.die("Died of a lethal strain of disease, caused by " + unit.getName(), true);
                            set.title.heldBy = null;
                        }
                        set.fallIntoRuin();
                    }
                }
            }
            if (!hadEffect)
            {
                unit.location.map.world.prefabStore.popMsgAgent(unit, unit, unit.getName() + " can no longer increase the lethality of surrounding diseases, " +
                                                                "as there are no longer any infected human settlements in their location or surrounding.");
                unit.task = null;
            }
        }
Ejemplo n.º 2
0
        public override void turnTick(Property p, Location location)
        {
            base.turnTick(p, location);

            bool underQuarantine = false;

            foreach (Property p2 in location.properties)
            {
                if (p2.proto is Pr_Quarantine)
                {
                    underQuarantine = true; break;
                }
            }

            if (location.settlement != null && location.settlement is SettlementHuman)
            {
                SettlementHuman set = (SettlementHuman)location.settlement;
                set.population -= 1;
                if (set.population <= 0)
                {
                    location.map.addMessage(set.location.getName() + " has been eradicated by the Red Death", MsgEvent.LEVEL_RED, true, location.hex);
                    if (set.title != null && set.title.heldBy != null)
                    {
                        set.title.heldBy.die("Died of the Red Death", true);
                    }
                    set.fallIntoRuin();
                }
            }

            foreach (Location l2 in location.getNeighbours())
            {
                if (l2.settlement != null && l2.settlement.isHuman && l2.soc != null && l2.soc is Society)
                {
                    bool canApply = true;
                    foreach (Property p2 in l2.properties)
                    {
                        if (p2.proto is Pr_RedDeath || p2.proto is Pr_RedDeathImmunity)
                        {
                            canApply = false;
                            break;
                        }
                    }
                    double pSpread = World.staticMap.param.unit_rd_redDeathPlaguePSpread;
                    if (underQuarantine)
                    {
                        pSpread /= 2;
                    }
                    if (canApply && Eleven.random.NextDouble() < pSpread)
                    {
                        Property.addProperty(World.staticMap, l2, "Red Death");
                        Society soc = (Society)l2.soc;
                        if (location.map.turn - soc.lastPlagueCrisis > location.map.param.society_crisis_plagueCrisisCooldown)
                        {
                            soc.crisisPlague     = "The Red Death Plague";
                            soc.crisisPlagueLong = "The Red Death plague is spreading in our lands, we must deal with this new crisis. " +
                                                   "We can either quarantine the disased settlements, treat infected patients, or we could deploy our agents as disease curing specialists.";
                            soc.lastPlagueCrisis = location.map.turn;
                        }
                    }
                }
            }
        }