void OnHealthStateChanged(GameObject _SourcePlayer, CPlayerHealth.HealthState _eHealthCurrentState, CPlayerHealth.HealthState _eHealthPreviousState) { switch (_eHealthCurrentState) { case CPlayerHealth.HealthState.DOWNED: { s_cSerializeStream.Write((byte)ENetworkAction.EventDeath); break; } case CPlayerHealth.HealthState.ALIVE: { s_cSerializeStream.Write((byte)ENetworkAction.EventRevive); break; } } }
void RespawnPlayer(GameObject _SourcePlayer, CPlayerHealth.HealthState _eHealthCurrentState, CPlayerHealth.HealthState _eHealthPreviousState) { // If the previous health state was DEAD // And current health state is ALIVE if (_eHealthCurrentState == CPlayerHealth.HealthState.DEAD) { // Save a list of currently constructed spawners List <GameObject> aPlayerSpawners = CModuleInterface.FindModulesByType(CModuleInterface.EType.PlayerSpawner); // Iterate through every spawner foreach (GameObject cPlayerSpawner in aPlayerSpawners) { // If the spawner is not blocked if (!cPlayerSpawner.GetComponent <CPlayerSpawnerBehaviour>().IsBlocked) { //Ensure the collider is enabled! _SourcePlayer.rigidbody.collider.enabled = true; // "Board" the ship // Note: Does nothing unless the player 'dies' outside the ship _SourcePlayer.GetComponent <CActorBoardable>().BoardActor(); // Set the player's position and rotation based upon the spawner's position and rotation _SourcePlayer.GetComponent <CNetworkView>().SetPosition(cPlayerSpawner.GetComponent <CPlayerSpawnerBehaviour>().m_cSpawnPosition.transform.position); _SourcePlayer.GetComponent <CNetworkView>().SetRotation(cPlayerSpawner.GetComponent <CPlayerSpawnerBehaviour>().m_cSpawnPosition.transform.rotation); // Heal the player to max health _SourcePlayer.GetComponent <CPlayerHealth>().ApplyHeal(_SourcePlayer.GetComponent <CPlayerHealth>().MaxHealth); // TODO: Reset other variables such as suit atmosphere and equipped tools // Break loop break; } } } }