Beispiel #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);
 }
Beispiel #2
0
 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);
         }
     }
 }