[84] | 1 | using System;
|
---|
| 2 |
|
---|
| 3 | public class SetTimeReal : ConsoleCommand
|
---|
| 4 | {
|
---|
| 5 | public SetTimeReal (ConsoleSdtd cons) : base(cons)
|
---|
| 6 | {
|
---|
| 7 | }
|
---|
| 8 |
|
---|
| 9 | public override string Description ()
|
---|
| 10 | {
|
---|
| 11 | return "set current ingame time, params: <day> <hour> <min>";
|
---|
| 12 | }
|
---|
| 13 |
|
---|
| 14 | public override string[] Names ()
|
---|
| 15 | {
|
---|
| 16 | return new string[] { "settimereal", "str" };
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | public override void Run (string[] _params)
|
---|
| 20 | {
|
---|
| 21 | if (_params.Length != 3) {
|
---|
| 22 | m_Console.md000a ("Usage: settimereal <day> <hour> <min>");
|
---|
| 23 | return;
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | int day, hour, min;
|
---|
| 27 | if (!int.TryParse (_params [0], out day)) {
|
---|
| 28 | m_Console.md000a ("Could not parse day number \"" + _params [0] + "\"");
|
---|
| 29 | return;
|
---|
| 30 | }
|
---|
| 31 | if (day < 1) {
|
---|
| 32 | m_Console.md000a ("Day must be >= 1");
|
---|
| 33 | return;
|
---|
| 34 | }
|
---|
| 35 | if (!int.TryParse (_params [1], out hour)) {
|
---|
| 36 | m_Console.md000a ("Could not parse hour \"" + _params [1] + "\"");
|
---|
| 37 | return;
|
---|
| 38 | }
|
---|
| 39 | if (hour > 23) {
|
---|
| 40 | m_Console.md000a ("Hour must be <= 23");
|
---|
| 41 | return;
|
---|
| 42 | }
|
---|
| 43 | if (!int.TryParse (_params [2], out min)) {
|
---|
| 44 | m_Console.md000a ("Could not parse minute \"" + _params [2] + "\"");
|
---|
| 45 | return;
|
---|
| 46 | }
|
---|
| 47 | if (min > 59) {
|
---|
| 48 | m_Console.md000a ("Minute must be <= 59");
|
---|
| 49 | return;
|
---|
| 50 | }
|
---|
| 51 | if ((day < 1) || (hour < 8 && day < 1)) {
|
---|
| 52 | m_Console.md000a ("Time may not be prior to day 1, 8:00");
|
---|
| 53 | return;
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | ulong time = ((ulong)(day-1) * 24000) + ((ulong)hour * 1000) + ((ulong)min * 1000 / 60) - 8000;
|
---|
| 57 | this.m_Console.gameManager.World.gameTime = time;
|
---|
| 58 | m_Console.md000a (String.Format ("Set time to Day {0}, {1:00}:{2:00} = {3}", day, hour, min, time));
|
---|
| 59 | }
|
---|
| 60 | }
|
---|
| 61 |
|
---|