public void SetSpaceshipClass(SpaceShipClass ssClass)
 {
     MyContract.RequireArgument(
         ssClass != SpaceShipClass.NONE,
         "is not NONE",
         "ssClass"
         );
     CurrentSpaceshipClass = ssClass;
 }
 public void CmdRequestRespawn(SpaceShipClass newShipClass)
 {
     lock (SpawnRequestLock)
     {
         if (CanRespawn)
         {
             SpawnSpaceShip(newShipClass);
         }
     }
 }
 public void CmdSpawnStartingSpaceShip(SpaceShipClass ssType)
 {
     lock (SpawnRequestLock)
     {
         if (CanRespawn)
         {
             SpawnSpaceShip(ssType);
         }
     }
 }
        private void SpawnSpaceShip(SpaceShipClass spaceShipType)
        {
            lock (SpaceshipSpawnLock)
            {
                if (ShipSpawned)
                {
                    Debug.LogWarning(ShipAlreadySpawnedWarning);
                    return;
                }
                MyContract.RequireArgument(
                    spaceShipType != SpaceShipClass.NONE,
                    "is not NONE",
                    "spaceShipType"
                );
                MyContract.RequireFieldNotNull(
                    SpaceshipClassManager,
                    "Spaceship Class Manager"
                );
                GameObject SpaceshipPrefab
                    = SpaceshipClassManager.getSpaceShipPrefab(spaceShipType);
                MyContract.RequireFieldNotNull(SpaceshipPrefab, "Spaceship Prefab");

                // Should not remain null unless Unity.Instantiate can return null
                GameObject ServerSpaceship = null;
                if (CurrentSpaceship != null
                && ShipController.getSpaceshipClass() == spaceShipType)
                {
                    // current_spaceship was just despawned, not destroyed,
                    // so it simply needs to be respawned
                    ServerSpaceship = CurrentSpaceship;
                    ServerSpaceship.SetActive(true);
                    MyContract.RequireFieldNotNull(
                        ShipController,
                        "ShipController"
                    );
                    ShipController.Respawn();
                }
                else
                {
                    // Create the ship locally (local to the server)
                    // NB: the ship will be moved to an appropriate NetworkStartPosition
                    //     by the server so the location specified here is irrelevant
                    ServerSpaceship = (GameObject)Instantiate(
                        SpaceshipPrefab,
                        transform.TransformPoint(chooseSpawnLocation()),
                        transform.rotation);

                    ShipController = ServerSpaceship.GetComponent<PlayerShipController>();
                    ShipController.SetSpaceshipClass(spaceShipType);
                    ShipController.owner = PlayerIdentifier.CreateNew(this);
                    ShipController.EventDeath += ShipDestroyedServerAction;
                }
                MyContract.RequireFieldNotNull(
                    ServerSpaceship,
                    "Server Spaceship"
                );
                CanRespawn = false;
                ShipSpawned = true;

                // Spawn the ship on the clients
                NetworkServer.SpawnWithClientAuthority(
                    ServerSpaceship,
                    connectionToClient
                );
                CurrentSpaceship = ServerSpaceship; // Update [SyncVar]
                RpcPlayerShipSpawned(CurrentSpaceship);
            }
        }
 public void setCurrentShipChoice(SpaceShipClass new_choice)
 {
     CurrentShipClassChoice = new_choice;
 }
 public Vector3 getCameraEulerRotation(SpaceShipClass ss_class)
 {
     return(CameraEulerRotationOffsets[(int)ss_class]);
 }
 public Vector3 getCameraOffset(SpaceShipClass ss_class)
 {
     return(CameraTransformOffsets[(int)ss_class]);
 }
 public GameObject getSpaceShipPrefab(SpaceShipClass ss_class)
 {
     return(SpaceShipPrefabs[(int)ss_class]);
 }