public override void Generate(Map map, GenStepParams parms)
        {
            MechClusterSketch sketch = MechClusterGenerator.GenerateClusterSketch(DefaultPointsRange.RandomInRange, map, startDormant: false);
            IntVec3           center = IntVec3.Invalid;

            if (MapGenerator.TryGetVar("RectOfInterest", out CellRect var))
            {
                center = var.ExpandedBy(20).MaxBy((IntVec3 x) => MechClusterUtility.GetClusterPositionScore(x, map, sketch));
            }
            if (!center.IsValid)
            {
                center = MechClusterUtility.FindClusterPosition(map, sketch);
            }
            List <Thing> list  = MechClusterUtility.SpawnCluster(center, map, sketch, dropInPods: false);
            List <Pawn>  list2 = new List <Pawn>();

            foreach (Thing item in list)
            {
                if (item is Pawn)
                {
                    list2.Add((Pawn)item);
                }
            }
            if (list2.Any())
            {
                GenStep_SleepingMechanoids.SendMechanoidsToSleepImmediately(list2);
            }
        }
Example #2
0
 public override void LordJobTick()
 {
     base.LordJobTick();
     if (isMechCluster && !mechClusterDefeated && !MechClusterUtility.AnyThreatBuilding(things))
     {
         OnDefeat();
     }
 }
Example #3
0
 protected override bool TryCastShot()
 {
     if (currentTarget.HasThing && currentTarget.Thing.Map != caster.Map)
     {
         return(false);
     }
     MechClusterUtility.SpawnCluster(currentTarget.Cell, caster.Map, MechClusterGenerator.GenerateClusterSketch_NewTemp(2500f, caster.Map, startDormant: true, forceNoConditionCauser: true));
     base.ReloadableCompSource?.UsedOnce();
     return(true);
 }
        public override bool TryResolveRaidSpawnCenter(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            if (!parms.spawnCenter.IsValid)
            {
                parms.spawnCenter = MechClusterUtility.FindClusterPosition(map, parms.mechClusterSketch, 100, 0.5f);
            }
            parms.spawnRotation = Rot4.Random;
            return(true);
        }
 public override void Notify_QuestSignalReceived(Signal signal)
 {
     base.Notify_QuestSignalReceived(signal);
     if (signal.tag == inSignal && mapParent != null && mapParent.HasMap)
     {
         spawnedClusterPos = MechClusterUtility.FindClusterPosition(mapParent.Map, sketch, 100, 0.5f);
         if (!(spawnedClusterPos == IntVec3.Invalid))
         {
             MechClusterUtility.SpawnCluster(spawnedClusterPos, mapParent.Map, sketch, dropInPods: true, canAssaultColony: false, tag);
             Find.LetterStack.ReceiveLetter("LetterLabelMechClusterArrived".Translate(), "LetterMechClusterArrived".Translate(), LetterDefOf.ThreatBig, new TargetInfo(spawnedClusterPos, mapParent.Map), null, quest);
         }
     }
 }
Example #6
0
 protected override bool TryCastShot()
 {
     if (currentTarget.HasThing && currentTarget.Thing.Map != caster.Map)
     {
         return(false);
     }
     MechClusterUtility.SpawnCluster(currentTarget.Cell, caster.Map, MechClusterGenerator.GenerateClusterSketch(2500f, caster.Map));
     if (base.EquipmentSource != null && !base.EquipmentSource.Destroyed)
     {
         base.EquipmentSource.Destroy();
     }
     return(true);
 }
 protected override bool TryExecuteWorker(IncidentParms parms)
 {
     Map map = (Map)parms.target;
     MechClusterSketch sketch = MechClusterGenerator.GenerateClusterSketch(parms.points, map);
     IntVec3 center = MechClusterUtility.FindClusterPosition(map, sketch, 100, 0.5f);
     if (!center.IsValid)
     {
         return false;
     }
     IEnumerable<Thing> targets = from t in MechClusterUtility.SpawnCluster(center, map, sketch, dropInPods: true, canAssaultColony: true, parms.questTag)
         where t.def != ThingDefOf.Wall && t.def != ThingDefOf.Barricade
         select t;
     SendStandardLetter(parms, new LookTargets(targets));
     return true;
 }
Example #8
0
        /*
         * // Token: 0x06000EA8 RID: 3752 RVA: 0x0006C2D0 File Offset: 0x0006A6D0
         * protected override bool TryExecuteWorker(IncidentParms parms)
         * {
         *  Map map = (Map)parms.target;
         *  int num = 0;
         *  int countToSpawn = this.CountToSpawn;
         *  List<TargetInfo> list = new List<TargetInfo>();
         *  float shrapnelDirection = Rand.Range(0f, 360f);
         *  Faction faction = null;
         *  Building building_CrashedShipPart = null;
         *  building = (Building)ThingMaker.MakeThing(this.def.mechClusterBuilding, null);
         *  if (faction == null)
         *  {
         *      faction = building_CrashedShipPart.GetComp<CompPawnSpawnerOnDamaged>().OfFaction;
         *  }
         *  for (int i = 0; i < countToSpawn; i++)
         *  {
         *      IntVec3 intVec;
         *      if (!CellFinderLoose.TryFindSkyfallerCell(ThingDefOf.CrashedShipPartIncoming, map, out intVec, 14, default(IntVec3), -1, false, true, true, true, true, false, null))
         *      {
         *          break;
         *      }
         *      building_CrashedShipPart.SetFaction(faction, null);
         *      building_CrashedShipPart.GetComp<CompPawnSpawnerOnDamaged>().pointsLeft = Mathf.Max(parms.points * 0.9f, 300f);
         *
         *      ThingDef faller = building_CrashedShipPart.GetComp<CompPawnSpawnerOnDamaged>().Props.skyFaller != null ? building_CrashedShipPart.GetComp<CompPawnSpawnerOnDamaged>().Props.skyFaller : ThingDefOf.CrashedShipPartIncoming ;
         *      Skyfaller skyfaller = SkyfallerMaker.MakeSkyfaller(faller, building_CrashedShipPart);
         *      skyfaller.shrapnelDirection = shrapnelDirection;
         *      GenSpawn.Spawn(skyfaller, intVec, map, WipeMode.Vanish);
         *      num++;
         *      list.Add(new TargetInfo(intVec, map, false));
         *  }
         *  if (num > 0)
         *  {
         *      base.SendStandardLetter(list, null, new string[0]);
         *  }
         *  return num > 0;
         *
         * }
         */
        // Token: 0x06003A73 RID: 14963 RVA: 0x001328DC File Offset: 0x00130ADC
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;
            List <TargetInfo> list        = new List <TargetInfo>();
            ThingDef          shipPartDef = this.def.mechClusterBuilding;
            IntVec3           intVec      = MechClusterUtility.FindDropPodLocation(map, (IntVec3 spot) => !spot.Fogged(map) && GenConstruct.CanBuildOnTerrain(shipPartDef, spot, map, Rot4.North, null, null) && GenConstruct.CanBuildOnTerrain(shipPartDef, new IntVec3(spot.x - Mathf.CeilToInt((float)shipPartDef.size.x / 2f), spot.y, spot.z), map, Rot4.North, null, null), 500, 0f);

            if (intVec == IntVec3.Invalid)
            {
                return(false);
            }
            float    points = Mathf.Max(parms.points * 0.9f, 300f);
            Thing    thing  = ThingMaker.MakeThing(shipPartDef, null);
            Building building_CrashedShipPart = (Building)thing;
            CompPawnSpawnerOnDamaged damaged  = building_CrashedShipPart.TryGetComp <CompPawnSpawnerOnDamaged>();
            Faction faction = damaged.faction ?? Faction.OfMechanoids;

            thing.SetFaction(faction, null);

            /*
             * List<Pawn> list2 = PawnGroupMakerUtility.GeneratePawns(new PawnGroupMakerParms
             * {
             *  groupKind = PawnGroupKindDefOf.Combat,
             *  tile = map.Tile,
             *  faction = faction,
             *  points = points
             * }, true).ToList<Pawn>();
             * LordMaker.MakeNewLord(faction, new LordJob_SleepThenMechanoidsDefend(new List<Thing>
             * {
             *  thing
             * }, faction, 28f, intVec, false, false), map, list2);
             * DropPodUtility.DropThingsNear(intVec, map, list2.Cast<Thing>(), 110, false, false, true, true);
             * foreach (Pawn thing2 in list2)
             * {
             *  CompCanBeDormant compCanBeDormant = thing2.TryGetComp<CompCanBeDormant>();
             *  if (compCanBeDormant != null)
             *  {
             *      compCanBeDormant.ToSleep();
             *  }
             * }
             * list.AddRange(from p in list2
             *            select new TargetInfo(p));
             */
            GenSpawn.Spawn(SkyfallerMaker.MakeSkyfaller(ThingDefOf.CrashedShipPartIncoming, thing), intVec, map, WipeMode.Vanish);
            list.Add(new TargetInfo(intVec, map, false));
            base.SendStandardLetter(parms, list, Array.Empty <NamedArgument>());
            return(true);
        }
Example #9
0
 public override List <Pawn> SpawnThreats(IncidentParms parms)
 {
     return(MechClusterUtility.SpawnCluster(parms.spawnCenter, (Map)parms.target, parms.mechClusterSketch, dropInPods: true, canAssaultColony: true, parms.questTag).OfType <Pawn>().ToList());
 }