public Transform GetLocalSpawnTransform() { Transform spawnTransform = null; Transform defaultTransform = null; foreach (TeleportLocation tele in TeleportLocation.GetAll()) { if (tele != null && tele.spawnPtName.LastIndexOf(GameManager.Inst.LastLevel.ToString()) != -1) { spawnTransform = tele.gameObject.transform; } Door lastRoomDoor; if (spawnTransform == null && Door.GetDoorForReEntry(GameManager.Inst.LastLevel, GameManager.Inst.LastRoomID, out lastRoomDoor)) { if (teleportDoorLocationHelperGO == null) { teleportDoorLocationHelperGO = new GameObject("TeleportDoorLocationHelper"); DontDestroyOnLoad(teleportDoorLocationHelperGO); } teleportDoorLocationHelperGO.transform.rotation = lastRoomDoor.transform.rotation; teleportDoorLocationHelperGO.transform.position = lastRoomDoor.transform.position + 4f * lastRoomDoor.transform.forward; spawnTransform = teleportDoorLocationHelperGO.transform; } if (tele != null && defaultTransform == null && tele.spawnPtName.LastIndexOf('*') == tele.spawnPtName.Length - 1) { defaultTransform = tele.gameObject.transform; } } if (spawnTransform == null) { spawnTransform = defaultTransform != null ? defaultTransform : TeleportLocation.GetAll()[0].gameObject.transform; } return((avoidOtherUsersWhenSpawning) ? GetClosestTransformAvoidingPlayers(spawnTransform) : spawnTransform); }
public static TeleportLocation GetByName(string name) { TeleportLocation tele = null; locationsByName.TryGetValue(name, out tele); return(tele); }
public void TeleportTo(TeleportLocation location) { Debug.Log("teleporting to " + location.Position.ToString("f4")); var t = reference; if (t == null) { return; } //Vector3 headPosOnGround = new Vector3(SteamVR_Render.Top().head.localPosition.x, 0.0f, SteamVR_Render.Top().head.localPosition.z); //t.rotation = location.rotation; t.position = location.Position; if (location.ForceRotation) { float eyeAngle = SteamVR_Render.Top().head.eulerAngles.y; float targetAngle = location.Rotation.eulerAngles.y; t.Rotate(0, targetAngle - eyeAngle, 0); //t.rotation = location.Rotation; } else { t.rotation = Quaternion.identity; } //t.position = position.position - new Vector3(t.GetChild(0).localPosition.x, 0f, t.GetChild(0).localPosition.z) - headPosOnGround; }
public void TeleportTo() { Debug.Log("Teleport to " + locationIndex); int index = locationIndex; GameObject player = GameObject.FindGameObjectWithTag("Player"); TeleportLocation location = TeleportSystem.Locations[index]; player.transform.position = location.teleportPad.transform.position + location.positionOffset; player.transform.eulerAngles = location.rotation; }
protected override void Initialize() { GameObject.Find("Tools/Chair").transform.position = this.transform.position; _teleport = GameObject.Find("Tools").transform.Find("TeleportLocation").GetComponent <TeleportLocation>(); Body = this.transform.parent; CanMove = true; _deltaTime = Time.deltaTime; InitStats(); InitComponent(); InitWeapon(); InitUI(); InvokeRepeating("RecoveryMana", 0.0f, 0.1f); }
private void AddTeleportLocation([FromSource] Player source, string locationJson) { TeleportLocation location = JsonConvert.DeserializeObject <TeleportLocation>(locationJson); if (GetTeleportLocationsData().Any(loc => loc.name == location.name)) { Log("A teleport location with this name already exists, location was not saved.", LogLevel.error); return; } var locs = GetLocations(); locs.teleports.Add(location); if (!SaveResourceFile(GetCurrentResourceName(), "config/locations.json", JsonConvert.SerializeObject(locs, Formatting.Indented), -1)) { Log("Could not save locations.json file, reason unknown.", LogLevel.error); } TriggerClientEvent("vChar:UpdateTeleportLocations", JsonConvert.SerializeObject(locs.teleports)); }
public void DrawGUI(int x, int y) { if (!this.enabled) { return; } if (GameGUI.Inst.ButtonWithSound(new Rect(x, y, width, height), "Teleport")) { showList = !showList; } if (showList) { List <TeleportLocation> locations = TeleportLocation.GetAll(); for (int i = 0; i < locations.Count; ++i) { int verticalPos = Screen.height - height - ((height + spaceHeight) * (i + 1)); if (GameGUI.Inst.ButtonWithSound(new Rect(x, verticalPos, width, height), locations[i].name)) { GetComponent <PlayerManager>().SetLocalPlayerTransform(locations[i].transform); } } } }
public bool TeleportToLocation(TeleportLocation location) { if (location != null) { TeleportToPosition(location.Position); LastLocation = location; return true; } return false; }
private static void SetupMenu() { if (setupDone) { return; } setupDone = true; MenuItem teleportToWaypoint = new MenuItem("Teleport to Waypoint", "Teleport to the currently set waypoint."); if (PermissionsManager.IsAllowed(Permission.TMTeleportToWaypoint)) { menu.AddMenuItem(teleportToWaypoint); } if (PermissionsManager.IsAllowed(Permission.TMLocations)) { MenuItem locations = new MenuItem("Locations", "A list of locations to teleport to.") { RightIcon = MenuItem.Icon.ARROW_RIGHT }; MenuController.AddSubmenu(menu, locationsMenu); menu.AddMenuItem(locations); MenuController.BindMenuItem(menu, locationsMenu, locations); foreach (var location in data.TeleportData.TeleportLocations) { MenuItem item = new MenuItem(location.Name); locationsMenu.AddMenuItem(item); } locationsMenu.OnItemSelect += (m, item, index) => { TeleportLocation loc = data.TeleportData.TeleportLocations[index]; int ped = GetTeleportTarget(); FreezeEntityPosition(ped, true); SetEntityCoords(ped, loc.X, loc.Y, loc.Z, false, false, false, false); SetEntityHeading(ped, loc.H); FreezeEntityPosition(ped, false); }; } menu.OnItemSelect += (m, item, index) => { if (item == teleportToWaypoint) { if (IsWaypointActive()) { int ped = GetTeleportTarget(); FreezeEntityPosition(ped, true); Vector3 waypoint = GetWaypointCoords(); SetEntityCoords(ped, waypoint.X, waypoint.Y, 1000.0f, false, false, false, false); Vector3 coords = GetEntityCoords(ped, false, false); float groundz = GetHeightmapBottomZForPosition(coords.X, coords.Y); SetEntityInvincible(ped, true); SetEntityCoords(ped, coords.X, coords.Y, groundz + 10.0f, false, false, false, false); FreezeEntityPosition(ped, false); Wait(3000); if (PermissionsManager.IsAllowed(Permission.PMGodMode) && UserDefaults.PlayerGodMode) { SetEntityInvincible(ped, true); } else { SetEntityInvincible(ped, false); } } } }; }