Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CoreSocialModule.cs
Go to the documentation of this file.
1using System;
4using System.Windows.Forms;
5using rail;
6using ReLogic.OS;
7
9
11{
12 private RailCallBackHelper _callbackHelper = new RailCallBackHelper();
13
14 private static object _railTickLock = new object();
15
16 private bool isRailValid;
17
18 public static event Action OnTick;
19
20 [DllImport("kernel32.dll", ExactSpelling = true)]
21 private static extern uint GetCurrentThreadId();
22
23 public void Initialize()
24 {
25 //IL_0000: Unknown result type (might be due to invalid IL or missing references)
26 //IL_0006: Expected O, but got Unknown
27 //IL_005d: Unknown result type (might be due to invalid IL or missing references)
28 //IL_0067: Expected O, but got Unknown
29 RailGameID val = new RailGameID();
30 ((RailComparableID)val).id_ = 2000328uL;
31 string[] array = ((!Main.dedServ) ? new string[1] { " " } : Environment.GetCommandLineArgs());
32 if (rail_api.RailNeedRestartAppForCheckingEnvironment(val, array.Length, array))
33 {
35 }
36 if (!rail_api.RailInitialize())
37 {
39 }
40 _callbackHelper.RegisterCallback((RAILEventID)2, new RailEventCallBackHandler(RailEventCallBack));
41 isRailValid = true;
43 Main.OnTickForThirdPartySoftwareOnly += RailEventTick;
44 }
45
46 public static void RailEventTick()
47 {
48 rail_api.RailFireEvents();
50 {
53 }
54 }
55
56 private void TickThread(object context)
57 {
59 while (isRailValid)
60 {
61 if (CoreSocialModule.OnTick != null)
62 {
64 }
66 }
68 }
69
70 public void Shutdown()
71 {
73 {
74 Application.ApplicationExit += delegate
75 {
76 isRailValid = false;
77 };
78 }
79 else
80 {
81 isRailValid = false;
82 AppDomain.CurrentDomain.ProcessExit += delegate
83 {
84 isRailValid = false;
85 };
86 }
87 _callbackHelper.UnregisterAllCallback();
88 rail_api.RailFinalize();
89 }
90
91 public static void RailEventCallBack(RAILEventID eventId, EventBase data)
92 {
93 //IL_0000: Unknown result type (might be due to invalid IL or missing references)
94 //IL_0002: Invalid comparison between Unknown and I4
95 //IL_0005: Unknown result type (might be due to invalid IL or missing references)
96 //IL_000a: Unknown result type (might be due to invalid IL or missing references)
97 if ((int)eventId == 2)
98 {
99 ProcessRailSystemStateChange(((RailSystemStateChanged)data).state);
100 }
101 }
102
103 public static void SaveAndQuitCallBack()
104 {
106 }
107
108 private static void ProcessRailSystemStateChange(RailSystemState state)
109 {
110 //IL_0000: Unknown result type (might be due to invalid IL or missing references)
111 //IL_0002: Invalid comparison between Unknown and I4
112 //IL_0004: Unknown result type (might be due to invalid IL or missing references)
113 //IL_0006: Invalid comparison between Unknown and I4
114 if ((int)state == 2 || (int)state == 3)
115 {
116 MessageBox.Show("检测到WeGame异常,游戏将自动保存进度并退出游戏", "Terraria--WeGame Error");
118 }
119 }
120}
static bool IsWindows
Definition Platform.cs:19
static string[] GetCommandLineArgs()
static void Exit(int exitCode)
static void Exit(object obj)
static bool Wait(object obj, int millisecondsTimeout)
Definition Monitor.cs:87
static bool TryEnter(object obj)
Definition Monitor.cs:36
static void Enter(object obj)
static void Pulse(object obj)
Definition Monitor.cs:103
static bool QueueUserWorkItem(WaitCallback callBack)
static bool dedServ
Definition Main.cs:1226
static void WeGameRequireExitGame()
Definition Main.cs:63231
static void ProcessRailSystemStateChange(RailSystemState state)
static void RailEventCallBack(RAILEventID eventId, EventBase data)
static void SaveAndQuit(Action callback=null)
Definition WorldGen.cs:3146