コード例 #1
0
        void InitializeCMD()
        {
            if (DashCMD.IsCommandDefined("time"))
            {
                return;
            }

            DashCMD.SetCVar <float>("time_autoshift", 0);

            //DashCMD.AddCommand("saveworld", "Saves the current world to file", "saveworld <filename>",
            //    (args) =>
            //    {
            //        if (args.Length != 1)
            //            DashCMD.ShowSyntax("saveworld");
            //        else
            //        {
            //            string fileName = args[0];
            //            WorldIO.Save(fileName, new WorldDescription(Terrain));
            //            DashCMD.WriteImportant("Saved world: {0}.aosw", fileName);
            //        }
            //    });

            DashCMD.AddCommand("time", "Changes the time of day", "time [0-24]",
                               (args) =>
            {
                if (args.Length == 0)
                {
                    DashCMD.WriteLine("Current Time: {0}", timeOfDay);
                }
                else
                {
                    try
                    {
                        float newTime = float.Parse(args[0]);
                        newTime       = MathHelper.Clamp(newTime, 0, 24);

                        timeOfDay = newTime;
                    }
                    catch (Exception)
                    {
                        DashCMD.WriteError("Invalid time.");
                    }
                }
            });
        }