コード例 #1
0
        /// <summary>
        /// Tries to execute the worker.
        /// </summary>
        /// <param name="parms">The parms.</param>
        /// <returns></returns>
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            var      map             = (Map)parms.target;
            var      targetInfoList  = new List <TargetInfo>();
            ThingDef shipPartDef     = def.mechClusterBuilding;
            IntVec3  dropPodLocation = MechClusterUtility.FindDropPodLocation(map, spot =>
            {
                if (!spot.Fogged(map) && GenConstruct.CanBuildOnTerrain(shipPartDef, spot, map, Rot4.North))
                {
                    return(GenConstruct.CanBuildOnTerrain(shipPartDef,
                                                          new IntVec3(spot.x - Mathf.CeilToInt(shipPartDef.size.x / 2f), spot.y,
                                                                      spot.z), map, Rot4.North));
                }
                return(false);
            });

            if (dropPodLocation == IntVec3.Invalid)
            {
                return(false);
            }
            float num       = Mathf.Max(parms.points * 0.9f, 300f);
            var   genParams = new PawnGroupMakerParms
            {
                groupKind = PawnGroupKindDefOf.Combat,
                tile      = map.Tile,
                faction   = Faction.OfMechanoids,
                points    = num
            };
            List <Pawn> list = PawnGroupMakerUtility.GeneratePawns(genParams)
                               .ToList();
            Thing innerThing = ThingMaker.MakeThing(shipPartDef);

            innerThing.SetFaction(Faction.OfMechanoids);
            LordMaker.MakeNewLord(Faction.OfMechanoids, new LordJob_SleepThenMechanoidsDefend(new List <Thing>
            {
                innerThing
            }, Faction.OfMechanoids, 28f, dropPodLocation, false, false), map, list);
            DropPodUtility.DropThingsNear(dropPodLocation, map, list);
            foreach (Thing thing in list)
            {
                thing.TryGetComp <CompCanBeDormant>()?.ToSleep();
            }
            targetInfoList.AddRange(list.Select(p => new TargetInfo(p)));
            GenSpawn.Spawn(SkyfallerMaker.MakeSkyfaller(PMThingDefOf.CrashedMutagenicShipPartIncoming, innerThing), dropPodLocation, map);
            targetInfoList.Add(new TargetInfo(dropPodLocation, map));
            SendStandardLetter(parms, targetInfoList, Array.Empty <NamedArgument>());
            return(true);
        }
コード例 #2
0
        private static void SpawnMechCluster()
        {
            List <DebugMenuOption> list = new List <DebugMenuOption>();

            foreach (float item in PointsMechCluster())
            {
                float localPoints = item;
                list.Add(new DebugMenuOption(item + " points", DebugMenuOptionMode.Action, delegate
                {
                    List <DebugMenuOption> options = new List <DebugMenuOption>
                    {
                        new DebugMenuOption("In pods, click place", DebugMenuOptionMode.Tool, delegate
                        {
                            MechClusterSketch sketch4 = MechClusterGenerator.GenerateClusterSketch(localPoints, Find.CurrentMap);
                            MechClusterUtility.SpawnCluster(UI.MouseCell(), Find.CurrentMap, sketch4);
                        }),
                        new DebugMenuOption("In pods, autoplace", DebugMenuOptionMode.Action, delegate
                        {
                            MechClusterSketch sketch3 = MechClusterGenerator.GenerateClusterSketch(localPoints, Find.CurrentMap);
                            MechClusterUtility.SpawnCluster(MechClusterUtility.FindClusterPosition(Find.CurrentMap, sketch3), Find.CurrentMap, sketch3);
                        }),
                        new DebugMenuOption("Direct spawn, click place", DebugMenuOptionMode.Tool, delegate
                        {
                            MechClusterSketch sketch2 = MechClusterGenerator.GenerateClusterSketch(localPoints, Find.CurrentMap);
                            MechClusterUtility.SpawnCluster(UI.MouseCell(), Find.CurrentMap, sketch2, dropInPods: false);
                        }),
                        new DebugMenuOption("Direct spawn, autoplace", DebugMenuOptionMode.Action, delegate
                        {
                            MechClusterSketch sketch = MechClusterGenerator.GenerateClusterSketch(localPoints, Find.CurrentMap);
                            MechClusterUtility.SpawnCluster(MechClusterUtility.FindClusterPosition(Find.CurrentMap, sketch), Find.CurrentMap, sketch, dropInPods: false);
                        })
                    };
                    Find.WindowStack.Add(new Dialog_DebugOptionListLister(options));
                }));
            }
            Find.WindowStack.Add(new Dialog_DebugOptionListLister(list));
        }