private void HandleOutOfBounds() { if (!TeleportIfOutOfBounds) { return; } var sceneController = SharedUtils.TryGetSceneController() as WorldSceneController; if (sceneController != null) { if (!sceneController.WorldBounds.Contains(transform.position)) { Debug.LogWarning("Player out of bounds, teleporting!"); Vector3 teleportPoint = sceneController.WorldBounds.center + new Vector3(0, 2f, 0); GameObject spawnPoint = WorldUtils.FindObjectByTID("DefaultPlayerSpawn"); if (spawnPoint != null) { teleportPoint = spawnPoint.transform.position; } transform.position = teleportPoint; } } }
public void Activate(string targetString) { //decode string and point camera if (targetString.StartsWith("Player", StringComparison.OrdinalIgnoreCase)) { //face player Transform playerTarget = WorldUtils.GetPlayerObject().transform; float distance = 1.0f; var dct = playerTarget.GetComponentInChildren <DialogueCameraTarget>(); if (dct != null) { playerTarget = dct.transform; if (dct.DistanceOverride > 0) { distance = dct.DistanceOverride; } } PointToTarget(playerTarget.position, playerTarget.forward, distance); } else if (targetString.StartsWith("FaceTarget", StringComparison.OrdinalIgnoreCase)) { string tid = targetString.Substring(targetString.IndexOf(':') + 1); //face target Transform t = WorldUtils.FindObjectByTID(tid).transform; float distance = 1.0f; var dct = t.GetComponentInChildren <DialogueCameraTarget>(); if (dct != null) { t = dct.transform; if (dct.DistanceOverride > 0) { distance = dct.DistanceOverride; } } PointToTarget(t.position, t.forward, distance); } else if (targetString.StartsWith("CopyTransform", StringComparison.OrdinalIgnoreCase)) { //copy transform string tid = targetString.Substring(targetString.IndexOf(':') + 1); Transform t = WorldUtils.FindObjectByTID(tid).transform; transform.position = t.position; transform.rotation = t.rotation; } else { throw new NotSupportedException(); } Camera.gameObject.SetActive(true); }
private void UnhideObjects(IEnumerable <string> objects) { foreach (var obj in objects) { try { var go = WorldUtils.FindObjectByTID(ResolveSpecialObjectName(obj)); go.SetActive(true); } catch (Exception e) { Debug.LogError($"[DialogueController] Failed to unhide object {obj} ({e.GetType().Name})"); if (ConfigState.Instance.UseVerboseLogging) { Debug.LogException(e); } } } }