コード例 #1
0
        public override IEnumerable <Thing> GenerateThings(int forTile, Faction faction = null)
        {
            var count          = this.countRange.RandomInRange;
            var validPawnKinds = DefDatabase <PawnKindDef> .AllDefsListForReading.Where(def => def.race.HasModExtension <RSPeacekeeperModExt>());

            if (validPawnKinds == null || validPawnKinds.Count() == 0)
            {
                yield break;
            }
            for (int i = 0; i < count; i++)
            {
                validPawnKinds.TryRandomElementByWeight(new Func <PawnKindDef, float>(this.SelectionWeight), out var pawnKind);
                var robot = PeacekeeperUtility.GeneratePeacekeeper(pawnKind, forTile);
                if (robot == null)
                {
                    continue;
                }
                robot.SetFaction(Faction.OfMechanoids);
                var gun = ThingMaker.MakeThing(pawnKind.race.GetModExtension <RSPeacekeeperModExt>().gunDef) as ThingWithComps;
                if (gun != null)
                {
                    robot.equipment.MakeRoomFor(gun);
                    robot.equipment.AddEquipment(gun);
                }
                yield return(robot);
            }
            yield break;
        }
コード例 #2
0
        public override void CompTick()
        {
            var robot      = PeacekeeperUtility.GeneratePeacekeeper(Props.pawnKind, this.parent.Tile);
            var spawnedBot = GenSpawn.Spawn(robot, this.parent.Position, this.parent.Map, Rot4.South) as Pawn;
            var gun        = ThingMaker.MakeThing(Props.weaponDef) as ThingWithComps;

            spawnedBot.equipment.MakeRoomFor(gun);
            spawnedBot.equipment.AddEquipment(gun);
            //AddCape(spawnedBot);
            this.parent.Destroy();
        }