Пример #1
0
        public override void LordToilTick()
        {
            base.LordToilTick();

            // Check if everything is setup
            if (this.lord.ticksInToil % 919 == 0)
            {
                if (!(from frame in this.Frames
                      where !frame.DestroyedOrNull()
                      select frame).Any())
                {
                    LordToilData_SetupCarnival data = (LordToilData_SetupCarnival)this.data;
                    if (!(from blue in data.blueprints
                          where !blue.DestroyedOrNull()
                          select blue).Any())
                    {
                        bool anyBuildings = false;
                        foreach (Building building in from b in base.Map.listerThings.ThingsInGroup(ThingRequestGroup.BuildingArtificial)
                                 where b.Faction == this.lord.faction
                                 select b)
                        {
                            anyBuildings = true;
                            // Add buildings to CarnivalInfo
                            if (building is Building_Carn)
                            {
                                Info.AddBuilding(building);
                            }
                        }

                        if (anyBuildings)
                        {
                            Info.guardPositions.Add(Info.AverageLodgeTentPos);

                            // Buildings are there. Next toil.
                            if (Info.CanEntertainNow)
                            {
                                lord.ReceiveMemo("SetupDoneEntertain");
                            }
                            else
                            {
                                // rest the carnival
                                lord.ReceiveMemo("SetupDoneRest");
                            }
                            return;
                        }
                        else
                        {
                            // No frames, blueprints, OR buildings
                            // Nothing is buildable. Was the carnival attacked?
                            lord.ReceiveMemo("NoBuildings");
                            Log.Error("[Carnivale] LordToil_SetupCarnival found no frames, blueprints, or buildings after " + lord.ticksInToil + " ticks.");
                            return;
                        }
                    }
                }
            }
            // End check
        }