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;
                        }
                    }
                }
            }
        }
        public override void turnTick(Unit unit)
        {
            if (unit.location.settlement != null)
            {
                unit.task = null;
                return;
            }

            dur += 1;
            if (dur >= unit.location.map.param.unit_establishNewSettlementTime || (!unit.location.map.burnInComplete))
            {
                unit.task = null;

                Location loc      = unit.location;
                int      c        = 0;
                Society  receiver = null;
                foreach (Location l2 in loc.getNeighbours())
                {
                    if (l2.soc != null && l2.soc is Society)
                    {
                        c += 1;
                        if (Eleven.random.Next(c) == 0)
                        {
                            receiver = (Society)l2.soc;
                        }
                    }
                }
                if (receiver == null)
                {
                    //foreach (SocialGroup sg in loc.map.socialGroups)
                    //{
                    //    if (sg is Society)
                    //    {
                    //        c += 1;
                    //        if (Eleven.random.Next(c) == 0)
                    //        {
                    //            receiver = (Society)sg;
                    //        }
                    //    }
                    //}
                    //Start a fully new colony.
                    //Maybe in time this could have a cool name, like "Merchant republic" and be a free port city or something
                    receiver = new Society(unit.location.map, loc);
                    receiver.setName(loc.shortName);
                    loc.soc = receiver;
                    unit.location.map.socialGroups.Add(receiver);
                }

                if (receiver != null)
                {
                    if (loc.isMajor)
                    {
                        loc.settlement = new Set_City(loc);
                    }
                    else
                    {
                        int      q       = 0;
                        double[] weights = new double[] { 2, 1, 2 };
                        double   roll    = 0;
                        for (int i = 0; i < weights.Length; i++)
                        {
                            roll += weights[i];
                        }
                        roll *= Eleven.random.NextDouble();
                        for (int i = 0; i < weights.Length; i++)
                        {
                            roll -= weights[i]; if (roll <= 0)
                            {
                                q = i; break;
                            }
                        }

                        if (q == 0)
                        {
                            loc.settlement = new Set_Abbey(loc);
                        }
                        else if (q == 1)
                        {
                            loc.settlement = new Set_University(loc);
                        }
                        else
                        {
                            loc.settlement = new Set_Fort(loc);
                        }
                    }

                    loc.soc = receiver;
                    SettlementHuman set = (SettlementHuman)loc.settlement;
                    set.population = 1;//Start at the start
                    loc.map.addMessage(loc.soc.getName() + " expands, add new settlement: " + loc.getName(), MsgEvent.LEVEL_RED, false, loc.hex);
                }
            }
        }