private void LoadTempData() { string scene = SaveManager.LoadFromSaveFile("mod/savestate/scene"); string room = SaveManager.LoadFromSaveFile("mod/savestate/room"); float posX = float.Parse(SaveManager.LoadFromSaveFile("mod/savestate/objects/PlayerEnt/position/x")); float posY = float.Parse(SaveManager.LoadFromSaveFile("mod/savestate/objects/PlayerEnt/position/y")); float posZ = float.Parse(SaveManager.LoadFromSaveFile("mod/savestate/objects/PlayerEnt/position/z")); float rotX = float.Parse(SaveManager.LoadFromSaveFile("mod/savestate/objects/PlayerEnt/rotation/x")); float rotY = float.Parse(SaveManager.LoadFromSaveFile("mod/savestate/objects/PlayerEnt/rotation/y")); float rotZ = float.Parse(SaveManager.LoadFromSaveFile("mod/savestate/objects/PlayerEnt/rotation/z")); // Update player transform Vector3 playerPos = new Vector3(posX, posY, posZ); // Teleport player Vector3 playerRot = new Vector3(rotX, rotY, rotZ); // Rotate player VarHelper.PlayerObj.GetComponent <Entity>().LoadState(); SceneAndRoomHelper.LoadRoom(scene, room, false, false, playerPos, playerRot, true); // Load scene/room DeleteTempData(); }
public override string Activate(string[] args) { // If args given if (args.Length > 0) { string wantedScene = args[0]; GotoData.SceneData sceneData = GotoData.GetSceneData(wantedScene); // If valid scene if (sceneData != null) { // If spawn is given if (args.Length > 1) { string wantedSpawn = args[1]; // If valid room for (int i = 0; i < sceneData.rooms.Count; i++) { GotoData.RoomData room = sceneData.rooms[i]; if (StringHelper.DoStringsMatch(room.roomName, wantedSpawn)) { // Load room SceneAndRoomHelper.LoadRoom(sceneData.realSceneName, room.roomName, true, true, room.spawnPosition, room.facingAngle); return("Now loading <in>" + sceneData.sceneName + "</in> room <in>" + room.roomName + "</in>..."); } } GotoData.SpawnData spawnData = GotoData.GetSpawnData(sceneData.realSceneName, wantedSpawn); // If valid spawn if (spawnData != null) { // Load scene at spawn point DoLoad(sceneData, spawnData); return("Now loading <in>" + sceneData.sceneName + "</in> at <in>" + spawnData.spawnName + "</in>..."); } // If invalid spawn, check if there's a 2nd scene sceneData = GotoData.GetSceneData(sceneData.realSceneName + "2"); if (sceneData != null) { spawnData = GotoData.GetSpawnData(sceneData.realSceneName, wantedSpawn); } // If valid spawn if (spawnData != null) { // Load scene at spawn point DoLoad(sceneData, spawnData); return("Now loading <in>" + sceneData.sceneName + "</in> at <in>" + spawnData.spawnName + "</in>..."); } // If invalid spawn return(DebugManager.LogToConsole("<in>" + wantedSpawn + "</in> is not a valid spawn or room for <in>" + wantedScene + "</in>. Use <out>help goto</out> for more info.", DebugManager.MessageType.Error)); } // If no spawn given else { // Load scene at fallback spawn DoLoad(sceneData); return("Now loading <in>" + sceneData.sceneName + "</in> at default spawn..."); } } // If invalid scene return(DebugManager.LogToConsole("<in>" + wantedScene + "</in> is not a valid scene. Use <out>help goto</out> for more info.", DebugManager.MessageType.Error)); } // Return help text if no args given return(DebugManager.LogToConsole(GetHelp())); }