Line | |
---|
1 | using System;
|
---|
2 |
|
---|
3 | namespace AllocsFixes.CustomCommands
|
---|
4 | {
|
---|
5 | public class GetTime : ConsoleCommand
|
---|
6 | {
|
---|
7 | public GetTime (ConsoleSdtd cons) : base(cons)
|
---|
8 | {
|
---|
9 | }
|
---|
10 |
|
---|
11 | public override string Description ()
|
---|
12 | {
|
---|
13 | return "retrieves current ingame time";
|
---|
14 | }
|
---|
15 |
|
---|
16 | public override string[] Names ()
|
---|
17 | {
|
---|
18 | return new string[] { "gettime", "gt" };
|
---|
19 | }
|
---|
20 |
|
---|
21 | public override void Run (string[] _params)
|
---|
22 | {
|
---|
23 | try {
|
---|
24 | ulong time = this.m_Console.gameManager.World.gameTime;
|
---|
25 | int day = (int)(time / 24000) + 1;
|
---|
26 | int hour = (int)(time % 24000) / 1000 + 8;
|
---|
27 | if (hour > 23) {
|
---|
28 | day++;
|
---|
29 | hour -= 24;
|
---|
30 | }
|
---|
31 | int min = (int)(time % 1000) * 60 / 1000;
|
---|
32 | m_Console.SendResult (String.Format ("Day {0}, {1:00}:{2:00} ", day, hour, min));
|
---|
33 | } catch (Exception e) {
|
---|
34 | Log.Out ("Error in GetTime.Run: " + e);
|
---|
35 | }
|
---|
36 | }
|
---|
37 | }
|
---|
38 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.