2023-12-22 22:51:17 +00:00
|
|
|
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;
|
|
|
|
}
|
2023-12-23 00:55:14 +00:00
|
|
|
if (other.tag.StartsWith("PlayerRagdoll"))
|
2023-12-22 22:51:17 +00:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|