예제 #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);
 }
예제 #2
0
        public override void SpawnSetup(Map map, bool respawningAfterLoad)
        {
            base.SpawnSetup(map, respawningAfterLoad);
            //this.shouldDeepSave = true;
            this.DeepsaveTurrets = false;
            if (shouldSpawnTurrets)
            {
                foreach (KeyValuePair <ShipWeaponSlot, Building_ShipTurret> current in this.installedTurrets)
                {
                    if (current.Value != null && !current.Value.Spawned)
                    {
                        IntVec3 drawLoc = this.Position + DropShipUtility.AdjustedIntVecForShip(this, current.Key.turretPosOffset);
                        GenSpawn.Spawn(current.Value, drawLoc, this.Map);
                    }
                }
            }
            this.shouldSpawnTurrets = false;
            if (shipState == ShipState.Incoming)
            {
                SoundDef.Named("ShipTakeoff_SuborbitalLaunch").PlayOneShotOnCamera();
            }

            if (this.ShouldSpawnFueled)
            {
                Thing initialFuel = ThingMaker.MakeThing(ShipNamespaceDefOfs.Chemfuel);
                initialFuel.stackCount = 800;
                this.refuelableComp.Refuel(initialFuel);
                this.ShouldSpawnFueled = false;
            }
            DropShipUtility.InitializeDropShipSpawn(this);
            this.FirstSpawned = false;
        }