Ejemplo n.º 1
0
 public bool TryInstallTurret(CompShipWeapon comp)
 {
     if (comp.SProps.TurretToInstall != null)
     {
         ShipWeaponSlot      slot   = comp.slotToInstall;
         Building_ShipTurret turret = (Building_ShipTurret)ThingMaker.MakeThing(comp.SProps.TurretToInstall, null);
         turret.installedByWeaponSystem = comp.parent.def;
         this.installedTurrets[slot]    = turret;
         turret.AssignParentShip(this);
         turret.assignedSlotName = slot.SlotName;
         turret.SetFactionDirect(this.Faction);
         if (slot.turretMinSize.x != turret.def.size.x)
         {
             //           turret.def.size.x = slot.turretMinSize.x;
         }
         if (slot.turretMinSize.z != turret.def.size.z)
         {
             //            turret.def.size.z = slot.turretMinSize.z;
         }
         IntVec3 drawLoc = this.Position + DropShipUtility.AdjustedIntVecForShip(this, slot.turretPosOffset);
         if (!turret.Spawned)
         {
             GenSpawn.Spawn(turret, drawLoc, this.Map);
         }
         this.assignedTurrets.Add(turret);
         return(true);
     }
     return(false);
 }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDestroyedOrNull(TargetIndex.A);
            this.FailOnDestroyedNullOrForbidden(TargetIndex.B);
            yield return(Toils_Reserve.Reserve(TargetIndex.A, 1));

            yield return(Toils_Reserve.ReserveQueue(TargetIndex.A, 1));

            yield return(Toils_Reserve.Reserve(TargetIndex.B, 1));

            yield return(Toils_Reserve.ReserveQueue(TargetIndex.B, 1));

            Toil toil = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnSomeonePhysicallyInteracting(TargetIndex.A);

            yield return(toil);

            yield return(Toils_Haul.StartCarryThing(TargetIndex.A, false, true));

            yield return(Toils_Haul.JumpIfAlsoCollectingNextTargetInQueue(toil, TargetIndex.A));

            Toil toil2 = Toils_Goto.Goto(TargetIndex.B, PathEndMode.ClosestTouch);

            yield return(toil2);

            Toil toil3 = new Toil();

            toil3.defaultCompleteMode = ToilCompleteMode.Delay;
            toil3.defaultDuration     = 500;
            toil3.WithProgressBarToilDelay(TargetIndex.A, false, -0.5f);
            yield return(toil3);

            yield return(new Toil
            {
                initAction = delegate
                {
                    ShipBase ship = (ShipBase)TargetB.Thing;
                    ThingWithComps thing = (ThingWithComps)TargetA.Thing;
                    CompShipWeapon comp = thing.TryGetComp <CompShipWeapon>();

                    Action action = delegate
                    {
                        if (ship.TryInstallTurret(comp.slotToInstall, comp))
                        {
                            this.pawn.carryTracker.GetInnerContainer().Remove(TargetA.Thing);
                            ship.weaponsToInstall.Remove(comp.slotToInstall);
                        }
                    };

                    action();
                },

                defaultCompleteMode = ToilCompleteMode.Instant
            });

            yield break;
        }
Ejemplo n.º 3
0
 public bool TryInstallPayload(ShipWeaponSlot slot, CompShipWeapon comp)
 {
     if (comp.SProps.PayloadToInstall != null)
     {
         WeaponSystemShipBomb newBomb = (WeaponSystemShipBomb)ThingMaker.MakeThing(comp.SProps.PayloadToInstall, null);
         this.Payload.Add(slot, newBomb);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 4
0
 public bool TryInstallPayload(WeaponSystemShipBomb bomb, CompShipWeapon comp)
 {
     if (comp.SProps.PayloadToInstall != null)
     {
         ShipWeaponSlot slot = comp.slotToInstall;
         this.loadedBombs.Add(bomb);
         this.Payload[slot] = bomb;
         return(true);
     }
     return(false);
 }
Ejemplo n.º 5
0
        public static List <WeaponSystem> availableWeaponSystemsForSlot(Map map, ShipWeaponSlot slot)
        {
            List <Thing> list = map.listerThings.AllThings.FindAll(x => x.TryGetComp <CompShipWeapon>() != null);

            List <WeaponSystem> list2 = new List <WeaponSystem>();

            for (int i = 0; i < list.Count; i++)
            {
                CompShipWeapon comp = list[i].TryGetComp <CompShipWeapon>();
                if (comp.SProps.weaponSystemType == slot.slotType)
                {
                    list2.Add((WeaponSystem)list[i]);
                }
            }
            return(list2);
        }
Ejemplo n.º 6
0
 public override void PostMake()
 {
     base.PostMake();
     this.compWeapon = base.GetComp <CompShipWeapon>();
 }