summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/PTC/Process/Process_RpcC2G_DoEnterScene.cs
blob: ed1ff9c1ac9ae1116166ad8aa48283fd5a263584 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
using System;
using KKSG;
using UnityEngine;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient
{
	internal class Process_RpcC2G_DoEnterScene
	{
		public static uint runstate
		{
			get
			{
				return Process_RpcC2G_DoEnterScene._runstate;
			}
		}

		private static uint _runstate = 0u;

		public static void OnReply(DoEnterSceneArg oArg, DoEnterSceneRes oRes)
		{
			bool flag = oRes.errorcode == ErrorCode.ERR_INVALID_REQUEST;
			if (flag)
			{
				XSingleton<XDebug>.singleton.AddErrorLog("RpcC2G_DoEnterScene ERR_INVALID_REQUEST!", null, null, null, null, null);
			}
			else
			{
				bool flag2 = !XSingleton<XScene>.singleton.bSceneLoadedRpcSend;
				if (!flag2)
				{
					XSingleton<XScene>.singleton.bSceneServerReady = true;
					XSingleton<XScene>.singleton.bSceneLoadedRpcSend = false;
					XSingleton<XDebug>.singleton.AddLog("Enter scene ", XSingleton<XScene>.singleton.SceneID.ToString(), null, null, null, null, XDebugColor.XDebug_None);
					bool flag3 = oRes.errorcode == ErrorCode.ERR_DOENTERSCENE_FAILED;
					if (flag3)
					{
						XSingleton<XDebug>.singleton.AddLog("ERR_DOENTERSCENE_FAILED", null, null, null, null, null, XDebugColor.XDebug_None);
					}
					else
					{
						Process_RpcC2G_DoEnterScene._runstate = oRes.scenestate.runstate;
						Vector3 vector;
						vector = new Vector3(oRes.pos.x, oRes.pos.y, oRes.pos.z);
						Vector3 vector2 = XSingleton<XCommon>.singleton.FloatToAngle(oRes.face);
						Vector3 face = XSingleton<XCommon>.singleton.FloatToAngle(oRes.initface);
						XSingleton<XEntityMgr>.singleton.Player.Attributes.OnFightGroupChange((XSingleton<XGame>.singleton.SyncModeValue != 0) ? oRes.fightgroup : 1u);
						XSingleton<XEntityMgr>.singleton.Player.Attributes.AppearAt = vector;
						XSingleton<XEntityMgr>.singleton.Player.Net.CorrectNet(vector, face, 0u, true);
						XBattleDocument.MiniMapSetRotation(oRes.initface);
						GameObject gameObject = GameObject.Find("Scene/BattlePoint");
						XSingleton<XScene>.singleton.BattleTargetPoint = ((gameObject != null) ? gameObject.transform.position : Vector3.zero);
						gameObject = GameObject.Find("Scene/NestPoint");
						XSingleton<XScene>.singleton.NestTargetPoint = ((gameObject != null) ? gameObject.transform.position : Vector3.zero);
						XSingleton<XScene>.singleton.GameCamera.Root_R_Y_Default = XSingleton<XEntityMgr>.singleton.Player.EngineObject.Rotation.eulerAngles.y;
						XSingleton<XScene>.singleton.GameCamera.Root_R_Y = XSingleton<XScene>.singleton.GameCamera.Root_R_Y_Default;
						bool flag4 = XSingleton<XScene>.singleton.GameCamera.Wall != null;
						if (flag4)
						{
							XSingleton<XScene>.singleton.GameCamera.Wall.TargetY = XSingleton<XScene>.singleton.GameCamera.Root_R_Y_Default;
						}
						bool bSpectator = XSingleton<XScene>.singleton.bSpectator;
						if (bSpectator)
						{
							XSingleton<XEntityMgr>.singleton.Puppets(XSingleton<XEntityMgr>.singleton.Player, true, true);
							XSingleton<XInput>.singleton.Freezed = true;
							XSingleton<XEntityMgr>.singleton.Player.Attributes.OnFightGroupChange(2u);
						}
						else
						{
							bool flag5 = XSingleton<XEntityMgr>.singleton.Player.Nav != null;
							if (flag5)
							{
								XSingleton<XEntityMgr>.singleton.Player.Nav.Active();
							}
							bool flag6 = XSingleton<XEntityMgr>.singleton.Player.AI != null;
							if (flag6)
							{
								XSingleton<XEntityMgr>.singleton.Player.AI.Active();
							}
							bool flag7 = ((ulong)oRes.specialstate & (ulong)(1L << (XFastEnumIntEqualityComparer<UnitSpecialState>.ToInt(UnitSpecialState.Unit_Puppet) & 31))) > 0UL;
							bool flag8 = ((ulong)oRes.specialstate & (ulong)(1L << (XFastEnumIntEqualityComparer<UnitSpecialState>.ToInt(UnitSpecialState.Unit_Invisible) & 31))) > 0UL;
							bool flag9 = flag7 || flag8;
							if (flag9)
							{
								XSingleton<XEntityMgr>.singleton.Player.UpdateSpecialStateFromServer(oRes.specialstate, uint.MaxValue);
							}
							else
							{
								XSingleton<XEntityMgr>.singleton.Player.Present.ShowUp();
							}
						}
						bool bSpectator2 = XSingleton<XScene>.singleton.bSpectator;
						if (bSpectator2)
						{
							XSpectateSceneDocument specificDocument = XDocuments.GetSpecificDocument<XSpectateSceneDocument>(XSpectateSceneDocument.uuID);
							specificDocument.IsCrossServerBattle = oRes.is_cross;
						}
						else
						{
							XBattleDocument specificDocument2 = XDocuments.GetSpecificDocument<XBattleDocument>(XBattleDocument.uuID);
							specificDocument2.IsCrossServerBattle = oRes.is_cross;
						}
						for (int i = 0; i < XSingleton<XGame>.singleton.Doc.Components.Count; i++)
						{
							(XSingleton<XGame>.singleton.Doc.Components[i] as XDocComponent).OnEnterSceneFinally();
						}
						XOutlookHelper.SetStatusState(XSingleton<XEntityMgr>.singleton.Player.Attributes, XSingleton<XEntityMgr>.singleton.Player, oRes.state, true);
						XSingleton<XScene>.singleton.SceneStarted = oRes.scenestate.isready;
						bool flag10 = !XSingleton<XScene>.singleton.SceneStarted && DlgBase<BattleMain, BattleMainBehaviour>.singleton.IsLoaded() && DlgBase<BattleMain, BattleMainBehaviour>.singleton.IsVisible();
						if (flag10)
						{
							DlgBase<BattleMain, BattleMainBehaviour>.singleton.uiBehaviour.m_PromptFrame.gameObject.SetActive(true);
							DlgBase<BattleMain, BattleMainBehaviour>.singleton.SetLoadingPrompt(null, false);
						}
						bool flag11 = XSingleton<XScene>.singleton.bSpectator && oRes.iswatchend;
						if (flag11)
						{
							DlgBase<SpectateSceneView, SpectateSceneBehaviour>.singleton.ShowBackToMainCityTips();
						}
						XSingleton<XLevelFinishMgr>.singleton.LevelRewardToken = oRes.battlestamp;
						bool isViewGridScene = XSingleton<XScene>.singleton.IsViewGridScene;
						if (isViewGridScene)
						{
							XSingleton<XEntityMgr>.singleton.Player.Net.SetHallSequence();
						}
						bool flag12 = XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.World;
						if (flag12)
						{
							XSingleton<XEntityMgr>.singleton.Player.Attributes.SecurityStatistics.OnStart();
						}
						XSingleton<XReconnection>.singleton.SetLoginReconnectFlag(oRes.lrdata != null);
						bool flag13 = oRes.lrdata != null;
						if (flag13)
						{
							XSingleton<XReconnection>.singleton.StartLoginReconnectSync(oRes.lrdata, oRes.otherunits);
						}
						else
						{
							XSingleton<XReconnection>.singleton.StartEnterSceneSync(oRes.otherunits);
						}
					}
				}
			}
		}

		public static void OnTimeout(DoEnterSceneArg oArg)
		{
		}
	}
}