public static string Execute(params string[] args) { int x = 0; int y = 0; DaggerfallWorkshop.StreamingWorld streamingWorld = GameManager.Instance.StreamingWorld; //GameObject.FindObjectOfType<DaggerfallWorkshop.StreamingWorld>(); PlayerEnterExit playerEE = GameManager.Instance.PlayerEnterExit; //GameObject.FindObjectOfType<PlayerEnterExit>(); if (args == null || args.Length < 2) { return(HelpCommand.Execute(TeleportToMapPixel.name)); } else if (streamingWorld == null) { return("Could not locate Streaming world object"); } else if (playerEE == null || playerEE.IsPlayerInside) { return("PlayerEnterExit could not be found or player inside"); } else if (int.TryParse(args[0], out x) && int.TryParse(args[1], out y)) { if (x <= 0 || y <= 0) { return("Invalid Coordinates"); } else if (x >= MapsFile.MaxMapPixelX || y >= MapsFile.MaxMapPixelY) { return("Invalid coordiantes"); } else { streamingWorld.TeleportToCoordinates(x, y); } return(string.Format("Teleporting player to: {0} {1}", x, y)); } return("Invalid coordiantes"); }
public static string Execute(params string[] args) { int n = 0; DaggerfallWorkshop.StreamingWorld streamingWorld = GameManager.Instance.StreamingWorld; //GameObject.FindObjectOfType<DaggerfallWorkshop.StreamingWorld>(); PlayerEnterExit playerEE = GameManager.Instance.PlayerEnterExit; //GameObject.FindObjectOfType<PlayerEnterExit>(); if (args == null || args.Length < 1) { return(HelpCommand.Execute(GotoLocation.name)); } else if (streamingWorld == null) { return("Could not locate Streaming world object"); } else if (playerEE == null || playerEE.IsPlayerInside) { return("PlayerEnterExit could not be found or player inside"); } else if (int.TryParse(args[0], out n)) { if (n < 0 || n > 9) { return("Invalid location index"); } else { switch (n) { case 0: int xpos, ypos; while (true) { xpos = UnityEngine.Random.Range(0, MapsFile.MaxMapPixelX - 1); ypos = UnityEngine.Random.Range(0, MapsFile.MaxMapPixelY - 1); DaggerfallWorkshop.Utility.ContentReader.MapSummary mapSummary; if (DaggerfallWorkshop.DaggerfallUnity.Instance.ContentReader.HasLocation(xpos, ypos, out mapSummary)) { streamingWorld.TeleportToCoordinates(xpos + 1, ypos - 1); // random location - locations always seem to be one pixel to the northern east - so compensate for this (since locations are never at the border - there should not occur a index out of bounds...) return(string.Format("Teleported player to location at: {0}, {1}", xpos, ypos)); } } case 1: streamingWorld.TeleportToCoordinates(207, 213, StreamingWorld.RepositionMethods.RandomStartMarker); return("Teleported player to Daggerfall/Daggerfall"); case 2: streamingWorld.TeleportToCoordinates(859, 244, StreamingWorld.RepositionMethods.RandomStartMarker); return("Teleported player to Wayrest/Wayrest"); case 3: streamingWorld.TeleportToCoordinates(397, 343, StreamingWorld.RepositionMethods.RandomStartMarker); return("Teleported player to Sentinel/Sentinel"); case 4: streamingWorld.TeleportToCoordinates(892, 146, StreamingWorld.RepositionMethods.RandomStartMarker); return("Teleported player to Orsinium Area/Orsinium"); case 5: streamingWorld.TeleportToCoordinates(67, 119, StreamingWorld.RepositionMethods.RandomStartMarker); return("Teleported player to Tulune/The Old Copperham Place"); case 6: streamingWorld.TeleportToCoordinates(254, 408, StreamingWorld.RepositionMethods.RandomStartMarker); return("Teleported player to Pothago/The Stronghold of Cirden"); case 7: streamingWorld.TeleportToCoordinates(109, 158, StreamingWorld.RepositionMethods.RandomStartMarker); return("Teleported player to Daggerfall/Privateer's Hold"); case 8: streamingWorld.TeleportToCoordinates(860, 245, StreamingWorld.RepositionMethods.RandomStartMarker); return("Teleported player to Wayrest/Merwark Hollow"); case 9: streamingWorld.TeleportToCoordinates(718, 204, StreamingWorld.RepositionMethods.RandomStartMarker); return("Teleported player to Isle of Balfiera/Direnni Tower"); default: break; } return("Teleported successfully."); } } return("Invalid location index"); }