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); }
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); }
private void InitiateInstalledTurrets() { foreach (ShipWeaponSlot current in this.compShip.weaponSlots) { if (current.slotType == WeaponSystemType.LightCaliber) { this.installedTurrets.Add(current, null); } if (current.slotType == WeaponSystemType.Bombing) { this.Payload.Add(current, null); } if (this.assignedTurrets.Count > 0) { Building_ShipTurret turret = this.assignedTurrets.Find(x => x.assignedSlotName == current.SlotName); if (turret != null) { turret.AssignParentShip(this); this.installedTurrets[current] = turret; } } else { } if (this.loadedBombs.Count > 0) { WeaponSystemShipBomb bomb = (WeaponSystemShipBomb)this.loadedBombs.First(x => x.assignedSlotName == current.SlotName); if (bomb != null) { this.Payload[current] = bomb; } } if (this.assignedSystemsToModify.Count > 0) { KeyValuePair <WeaponSystem, bool> entry = this.assignedSystemsToModify.First(x => x.Key.assignedSlotName == current.SlotName); this.TryModifyWeaponSystem(current, entry.Key, entry.Value); } } }
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, 10, 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 (comp != null) { switch (comp.SProps.weaponSystemType) { case WeaponSystemType.LightCaliber: { if (ship.TryInstallTurret(comp)) { this.pawn.carryTracker.GetDirectlyHeldThings().Remove(TargetA.Thing); ship.weaponsToInstall.Remove(comp.slotToInstall); } break; } case WeaponSystemType.HeavyCaliber: { break; } case WeaponSystemType.Bombing: { WeaponSystemShipBomb bomb = thing as WeaponSystemShipBomb; if (ship.TryInstallPayload(bomb, comp)) { this.pawn.carryTracker.GetDirectlyHeldThings().Remove(TargetA.Thing); ship.weaponsToInstall.Remove(comp.slotToInstall); } break; } } } }; action(); }, defaultCompleteMode = ToilCompleteMode.Instant }); yield break; }