70 lines
1.5 KiB
C#
70 lines
1.5 KiB
C#
using GameNetcodeStuff;
|
|
using UnityEngine;
|
|
|
|
public class OutOfBoundsTrigger : MonoBehaviour
|
|
{
|
|
private StartOfRound playersManager;
|
|
|
|
public bool disableWhenRoundStarts;
|
|
|
|
private void Start()
|
|
{
|
|
playersManager = Object.FindObjectOfType<StartOfRound>();
|
|
}
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (disableWhenRoundStarts && !playersManager.inShipPhase)
|
|
{
|
|
return;
|
|
}
|
|
if (other.tag == "PlayerRagdoll")
|
|
{
|
|
DeadBodyInfo componentInParent = other.GetComponentInParent<DeadBodyInfo>();
|
|
if (componentInParent != null)
|
|
{
|
|
componentInParent.timesOutOfBounds++;
|
|
if (componentInParent.timesOutOfBounds > 2)
|
|
{
|
|
componentInParent.SetBodyPartsKinematic();
|
|
}
|
|
else
|
|
{
|
|
componentInParent.ResetRagdollPosition();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!(other.tag == "Player"))
|
|
{
|
|
return;
|
|
}
|
|
PlayerControllerB component = other.GetComponent<PlayerControllerB>();
|
|
if (GameNetworkManager.Instance.localPlayerController != component)
|
|
{
|
|
return;
|
|
}
|
|
component.ResetFallGravity();
|
|
if (component != null)
|
|
{
|
|
if (!playersManager.shipDoorsEnabled)
|
|
{
|
|
playersManager.ForcePlayerIntoShip();
|
|
}
|
|
else if (component.isInsideFactory)
|
|
{
|
|
component.TeleportPlayer(RoundManager.FindMainEntrancePosition(getTeleportPosition: true));
|
|
}
|
|
else if (component.isInHangarShipRoom)
|
|
{
|
|
component.TeleportPlayer(playersManager.playerSpawnPositions[0].position);
|
|
}
|
|
else
|
|
{
|
|
component.TeleportPlayer(playersManager.outsideShipSpawnPosition.position);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|