static bool Prefix()
        {
            if (Multiplayer.Client == null)
            {
                return(true); // Not in multiplayer mode
            }
            Player?simulationOwner = Multiplayer.Client.SimulationManager.GetSimulationOwner();

            if (simulationOwner == null || simulationOwner.Value != Multiplayer.Client.LocalPlayer) // Player isn't the simulation owner
            {
                MessageToast.Show($"Only the simulation owner can control time!", 3f);
                return(false);
            }

            PlanetbaseMultiplayer.Client.Time.TimeManager timeManager = Multiplayer.Client.TimeManager;
            float timeScale = timeManager.GetCurrentSpeed();

            timeScale /= 2f;

            if (timeScale < 1f)
            {
                timeScale = 1f;
            }

            MessageToast.Show(StringList.get("speed_set") + " x" + timeScale, 3f);
            TimeManager.getInstance().decreaseSpeed();
            return(false);
        }
Example #2
0
    public static List <Line> OpenFile(string fileName)
    {
        List <Line> l = new List <Line>();

        string fullPath = directory + fileName + fileExtension;

        l = JsonUtility.FromJson <LineContents>(File.ReadAllText(fullPath)).lines;

        MessageToast.Show("File loaded");

        currentFilename = fileName;

        return(l);
    }
Example #3
0
    public static bool SaveFile(string fileName)
    {
        string fullPath = directory + fileName + fileExtension;

        string str = "{}";

        if (LineWorld.main.lines.Count > 0)
        {
            LineContents lc = new LineContents();
            lc.lines = LineWorld.main.lines;

            str = JsonUtility.ToJson(lc);
        }

        currentFilename = fileName;

        File.WriteAllText(fullPath, str);
        MessageToast.Show("Save successful");
        return(true);
    }
Example #4
0
        public static void ShowMessageToast(string message, List <MyUICommand> commands, int seconds = 15)
        {
            MessageToast ms = new MessageToast(message, TimeSpan.FromSeconds(seconds), commands);

            ms.Show();
        }
Example #5
0
        public static void ShowMessageToast(string message, int seconds = 2)
        {
            MessageToast ms = new MessageToast(message, TimeSpan.FromSeconds(seconds));

            ms.Show();
        }
Example #6
0
        public static void ShowMessageToast(string message, int time)
        {
            MessageToast ms = new MessageToast(message, TimeSpan.FromMilliseconds(time));

            ms.Show();
        }
Example #7
0
 public static bool DeleteFile(string str)
 {
     File.Delete(str);
     MessageToast.Show("File Deleted");
     return(true);
 }