Exemple #1
0
        // OVERRIDE METHODS //


        public override void Init()
        {
            base.Init();

            LordToilData_SetupCarnival data = (LordToilData_SetupCarnival)this.data;


            // Give em a wood for trash sign
            var log = ThingMaker.MakeThing(ThingDefOf.WoodLog);

            log.stackCount = 1;
            GenPlace.TryPlaceThing(log, Info.setupCentre, Map, ThingPlaceMode.Near);


            // Give chapiteau
            if (data.TryHaveWorkerCarry(_DefOf.Carn_Crate_TentHuge, 1, CarnUtils.RandomFabricByCheapness()) != 1)
            {
                Log.Error("[Carnivale] Could not give " + _DefOf.Carn_Crate_TentHuge + " to carnies of faction " + lord.faction + ". It will not be built.");
            }


            // Give lodging tents (currently 8 carnies per lodging tent)

            int numCarnies = this.lord.ownedPawns.Count - Info.pawnsWithRole[CarnivalRole.Carrier].Count;

            int numBedTents = numCarnies > 9 ? Mathf.CeilToInt(numCarnies / 8f) : 1;

            if (data.TryHaveWorkerCarry(_DefOf.Carn_Crate_TentLodge, numBedTents, CarnUtils.RandomFabricByCheapness()) != numBedTents)
            {
                Log.Error("[Carnivale] Could not give enough " + _DefOf.Carn_Crate_TentLodge + " to carnies of faction " + lord.faction + ". Some will not be built.");
            }

            if (Info.pawnsWithRole[CarnivalRole.Manager].Any())
            {
                if (data.TryHaveWorkerCarry(_DefOf.Carn_Crate_TentMan, 1, CarnUtils.RandomFabricByExpensiveness()) != 1)
                {
                    Log.Error("[Carnivale] Could not give " + _DefOf.Carn_Crate_TentMan + " to carnies of faction " + lord.faction + ". It will not be built.");
                }
            }


            // Give vendor stalls + entry sign
            int numStallCrates = Info.pawnsWithRole[CarnivalRole.Vendor].Count + _DefOf.Carn_SignEntry.costList.First().count;

            data.TryHaveWorkerCarry(_DefOf.Carn_Crate_Stall, numStallCrates, ThingDefOf.WoodLog);


            // Give game stalls
            data.TryHaveWorkerCarry(_DefOf.Carn_Crate_GameHighStriker, 1, ThingDefOf.WoodLog);


            // Place blueprints
            foreach (Blueprint bp in AIBlueprintsUtility.PlaceCarnivalBlueprints(Info))
            {
                data.blueprints.Add(bp);
            }

            // Find spots for carriers to chill + a guard spot
            var guardSpot = GetCarrierSpots().Average();

            // Assign guard spot at carriers
            Pawn guard = Info.GetBestGuard();

            if (guard != null)
            {
                //Info.rememberedPositions.Add(guard, guardSpot);
                Info.guardPositions.Add(guardSpot);

                // if can feed animals, give em kibble
                if (!guard.story.WorkTypeIsDisabled(WorkTypeDefOf.Handling))
                {
                    Thing kib = ThingMaker.MakeThing(ThingDefOf.Kibble);
                    kib.stackCount = 75;
                    guard.inventory.TryAddItemNotForSale(kib);
                }
            }
        }