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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
|
using System;
using System.Collections.Generic;
using KKSG;
using ProtoBuf;
using UnityEngine;
using XUpdater;
using XUtliPoolLib;
namespace XMainClient
{
internal sealed class XScene : XSingleton<XScene>
{
public bool bSpectator
{
get
{
return this._bIsSpectator;
}
}
public bool FilterFx
{
get
{
return !this._bIsSpectator && XFxMgr.FilterFarFx && XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.World;
}
}
public bool SceneReady
{
get
{
return this._bSceneEntered;
}
}
public bool SceneStarted
{
get
{
return this._bStarted;
}
set
{
bool flag = this._bStarted == value;
if (!flag)
{
this._bStarted = value;
bool bStarted = this._bStarted;
if (bStarted)
{
this.OnSceneStarted();
}
}
}
}
public XEntity Dirver
{
get
{
return this._story_dirver;
}
set
{
this._story_dirver = value;
}
}
public Camera AssociatedCamera { get; set; }
public bool IsMustTransform
{
get
{
return this._scene_type == SceneType.SCENE_MOBA || this._scene_type == SceneType.SCENE_HEROBATTLE || this.m_IsMustTransform;
}
set
{
this.m_IsMustTransform = value;
}
}
public bool IsMobaScene
{
get
{
return this._scene_type == SceneType.SCENE_MOBA || this._scene_type == SceneType.SCENE_HEROBATTLE;
}
}
public bool CanFadeOnCreate
{
get
{
return this._scene_type != SceneType.SCENE_MOBA && this._scene_type != SceneType.SCENE_HEROBATTLE;
}
}
public bool IsViewGridScene { get; set; }
public SceneType SceneType
{
get
{
return this._scene_type;
}
}
public uint SceneID
{
get
{
return this._scene_id;
}
}
public SceneTable.RowData SceneData
{
get
{
return this._scene_data;
}
}
public XCameraEx GameCamera
{
get
{
return this._camera;
}
}
public bool IsPVPScene
{
get
{
bool flag = this.SceneData != null;
return !flag || this.SceneData.CombatType == 1;
}
}
public Terrain CurrentTerrain
{
get
{
return this._terrain;
}
set
{
this._terrain = value;
}
}
public SceneCfg SceneEntranceConfig
{
get
{
return this._scene_cfg;
}
}
public ErrorCode Error
{
get
{
return this._error;
}
set
{
this._error = value;
}
}
public string ErrorAddtional
{
get
{
return this._error_addtional;
}
set
{
this._error_addtional = value;
}
}
private XSceneLoader _loader = null;
private XSceneTransfer _transfer = null;
private int _next_sync_mode = 0;
private bool _next_is_spectator = false;
private string _scene_file = null;
private uint _scene_id = 0u;
private ErrorCode _error = ErrorCode.ERR_SUCCESS;
private string _error_addtional = null;
private SceneCfg _scene_cfg = null;
public SceneType _scene_type = SceneType.SCENE_LOGIN;
private SceneTable.RowData _scene_data = null;
private XEntity _story_dirver = null;
private bool _bSceneEntered = false;
private bool _bIsSpectator = false;
private bool _bStarted = false;
public bool bSceneServerReady = false;
public bool bSceneLoadedRpcSend = false;
private Terrain _terrain = null;
public Vector3 BattleTargetPoint;
public Vector3 NestTargetPoint;
private bool m_IsMustTransform = false;
private XCameraEx _camera = new XCameraEx();
public override bool Init()
{
this._loader = XUpdater.XUpdater.XGameRoot.AddComponent<XSceneLoader>();
this._transfer = XUpdater.XUpdater.XGameRoot.AddComponent<XSceneTransfer>();
return true;
}
public override void Uninit()
{
this._loader = null;
this._transfer = null;
}
public bool TryGetTerrainY(Vector3 pos, out float y)
{
return XCurrentGrid.grid.TryGetHeight(pos, out y);
}
public bool IsWalkable(Vector3 pos)
{
float num = 0f;
return XCurrentGrid.grid.TryGetHeight(pos, out num) && num >= 0f;
}
public bool IsWalkable(Vector3 pos, out float y)
{
bool flag = XCurrentGrid.grid.TryGetHeight(pos, out y);
if (flag)
{
bool flag2 = y >= 0f;
if (flag2)
{
bool flag3 = this._terrain != null;
if (flag3)
{
float num = this._terrain.SampleHeight(pos);
bool flag4 = y - num < 0.05f;
if (flag4)
{
y = num;
}
return true;
}
}
}
return false;
}
public float TerrainY(Vector3 pos)
{
float num = 0f;
bool flag = this._terrain != null;
if (flag)
{
num = this._terrain.SampleHeight(pos);
}
bool flag2 = XCurrentGrid.grid != null;
if (flag2)
{
float height = XCurrentGrid.grid.GetHeight(pos);
bool flag3 = height - num > 0.05f;
if (flag3)
{
num = height;
}
}
return num;
}
public void PauseBGM()
{
XSingleton<XAudioMgr>.singleton.PauseBGM();
}
public void ResumeBGM()
{
XSingleton<XAudioMgr>.singleton.ResumeBGM();
}
public bool TurnToTransfer(uint sceneid)
{
string unitySceneFile = XSingleton<XSceneMgr>.singleton.GetUnitySceneFile(sceneid);
return this._scene_file == unitySceneFile;
}
public void UntriggerScene()
{
this._bSceneEntered = false;
}
public void StoreSceneConfig(SceneCfg config)
{
this._scene_cfg = Serializer.DeepClone<SceneCfg>(config);
}
public void SceneEnterTo(SceneCfg config, bool fromserver = true)
{
uint sceneID = config.SceneID;
SceneType sceneType = XSingleton<XSceneMgr>.singleton.GetSceneType(sceneID);
this._next_sync_mode = config.SyncMode;
this._next_is_spectator = config.isWatcher;
bool flag = XSingleton<XSceneMgr>.singleton.GetSceneType(config.SceneID) == SceneType.SCENE_BOSSRUSH;
if (flag)
{
XLevelSpawnInfo spawnerBySceneID = XSingleton<XLevelSpawnMgr>.singleton.GetSpawnerBySceneID(config.SceneID);
XSingleton<XLevelSpawnMgr>.singleton.MonsterIDs.Clear();
XBossBushDocument specificDocument = XDocuments.GetSpecificDocument<XBossBushDocument>(XBossBushDocument.uuID);
XSingleton<XLevelSpawnMgr>.singleton.MonsterIDs.Add(specificDocument.entityRow.ID);
}
else
{
XSingleton<XLevelSpawnMgr>.singleton.CacheServerMonsterID(config.preloadEnemyIDs);
}
bool flag2 = config.SyncMode == 2;
if (flag2)
{
XSingleton<XLevelSpawnMgr>.singleton.CacheServerMonster(config.enemyWaves);
}
switch (sceneType)
{
case SceneType.SCENE_HALL:
if (fromserver)
{
EXStage stage = XSingleton<XGame>.singleton.CurrentStage.Stage;
if (stage != EXStage.SelectChar)
{
XSingleton<XGame>.singleton.SwitchTo(EXStage.Hall, sceneID);
}
else
{
XSingleton<XGame>.singleton.CurrentStage.Play();
this.StoreSceneConfig(config);
}
}
else
{
XSingleton<XGame>.singleton.SwitchTo(EXStage.Hall, sceneID);
}
goto IL_336;
case SceneType.SCENE_BATTLE:
if (fromserver)
{
EXStage stage2 = XSingleton<XGame>.singleton.CurrentStage.Stage;
if (stage2 != EXStage.SelectChar)
{
XSingleton<XGame>.singleton.SwitchTo(EXStage.World, sceneID);
}
else
{
XSingleton<XGame>.singleton.CurrentStage.Play();
this.StoreSceneConfig(config);
}
}
else
{
XSingleton<XGame>.singleton.SwitchTo(EXStage.World, sceneID);
}
goto IL_336;
case SceneType.SCENE_NEST:
case SceneType.SCENE_ARENA:
case SceneType.SCENE_WORLDBOSS:
case SceneType.SCENE_BOSSRUSH:
case SceneType.SCENE_GUILD_BOSS:
case SceneType.SCENE_PK:
case SceneType.SCENE_ABYSSS:
case SceneType.SCENE_TOWER:
case SceneType.SCENE_PVP:
case SceneType.SCENE_DRAGON:
case SceneType.SCENE_GMF:
case SceneType.SCENE_GODDESS:
case SceneType.SCENE_DRAGON_EXP:
case SceneType.SCENE_RISK:
case SceneType.SCENE_ENDLESSABYSS:
case SceneType.SKYCITY_FIGHTING:
case SceneType.SCENE_PROF_TRIALS:
case SceneType.SCENE_GPR:
case SceneType.SCENE_RESWAR_PVP:
case SceneType.SCENE_RESWAR_PVE:
case SceneType.SCENE_GUILD_CAMP:
case SceneType.SCENE_AIRSHIP:
case SceneType.SCENE_WEEK_NEST:
case SceneType.SCENE_HORSE_RACE:
case SceneType.SCENE_HEROBATTLE:
case SceneType.SCENE_INVFIGHT:
case SceneType.SCENE_CASTLE_WAIT:
case SceneType.SCENE_CASTLE_FIGHT:
case SceneType.SCENE_LEAGUE_BATTLE:
case SceneType.SCENE_ACTIVITY_ONE:
case SceneType.SCENE_ACTIVITY_TWO:
case SceneType.SCENE_ACTIVITY_THREE:
case SceneType.SCENE_ABYSS_PARTY:
case SceneType.SCENE_CUSTOMPK:
case SceneType.SCENE_PKTWO:
case SceneType.SCENE_MOBA:
case SceneType.SCENE_WEEKEND4V4_MONSTERFIGHT:
case SceneType.SCENE_WEEKEND4V4_GHOSTACTION:
case SceneType.SCENE_WEEKEND4V4_LIVECHALLENGE:
case SceneType.SCENE_WEEKEND4V4_CRAZYBOMB:
case SceneType.SCENE_WEEKEND4V4_HORSERACING:
case SceneType.SCENE_CUSTOMPKTWO:
case SceneType.SCENE_WEEKEND4V4_DUCK:
case SceneType.SCENE_BIGMELEE_FIGHT:
case SceneType.SCENE_CALLBACK:
case SceneType.SCENE_BIOHELL:
case SceneType.SCENE_DUCK:
case SceneType.SCENE_COUPLE:
case SceneType.SCENE_BATTLEFIELD_FIGHT:
case SceneType.SCENE_COMPETEDRAGON:
case SceneType.SCENE_SURVIVE:
case SceneType.SCENE_GCF:
case SceneType.SCENE_GUILD_WILD_HUNT:
case SceneType.SCENE_AWAKE:
XSingleton<XGame>.singleton.SwitchTo(EXStage.World, sceneID);
goto IL_336;
case SceneType.SCENE_GUILD_HALL:
case SceneType.SCENE_FAMILYGARDEN:
case SceneType.SKYCITY_WAITING:
case SceneType.SCENE_HORSE:
case SceneType.SCENE_BIGMELEE_READY:
case SceneType.SCENE_WEDDING:
case SceneType.SCENE_BATTLEFIELD_READY:
case SceneType.SCENE_LEISURE:
XSingleton<XGame>.singleton.SwitchTo(EXStage.Hall, sceneID);
goto IL_336;
case SceneType.SCENE_RIFT:
{
XRiftDocument specificDocument2 = XDocuments.GetSpecificDocument<XRiftDocument>(XRiftDocument.uuID);
bool flag3 = specificDocument2 != null;
if (flag3)
{
specificDocument2.stop_timer = false;
}
XSingleton<XGame>.singleton.SwitchTo(EXStage.World, sceneID);
goto IL_336;
}
}
XSingleton<XDebug>.singleton.AddErrorLog("can't process enter scene type: ", sceneType.ToString(), null, null, null, null);
IL_336:
XSingleton<XLevelDoodadMgr>.singleton.CacheDoodad(config.doodads);
}
public void SceneEnterTo(bool fromserver = true)
{
this.SceneEnterTo(this._scene_cfg, fromserver);
this._scene_cfg = null;
}
public void LoadSceneAsync(uint sceneid, EXStage eStage, bool prograss, bool transfer)
{
this._scene_file = XSingleton<XSceneMgr>.singleton.GetUnitySceneFile(sceneid);
bool flag = !string.IsNullOrEmpty(this._scene_file);
if (flag)
{
this._bSceneEntered = false;
this.bSceneServerReady = false;
this.bSceneLoadedRpcSend = false;
XSingleton<XEventMgr>.singleton.Clear();
XEquipDocument.CurrentVisibleRole = 0;
XDummy.visibleDummyCount = 0;
Shader.SetGlobalVector("uirim", new Vector4(1f, 1f, 1f, 0f));
if (transfer)
{
this._transfer.TransferScene(sceneid);
}
else
{
this._loader.LoadScene(this._scene_file, eStage, prograss, sceneid, this._scene_id);
}
}
else
{
XSingleton<XDebug>.singleton.AddErrorLog("No scene file found with id ", sceneid.ToString(), null, null, null, null);
}
}
public void OnSceneBeginLoad(uint sceneid)
{
this._bStarted = false;
this._scene_id = sceneid;
XFileLog.SceneID = sceneid;
this._scene_type = XSingleton<XSceneMgr>.singleton.GetSceneType(this._scene_id);
this._scene_data = XSingleton<XSceneMgr>.singleton.GetSceneData(this._scene_id);
XSingleton<XGame>.singleton.SyncModeValue = this._next_sync_mode;
this._bIsSpectator = this._next_is_spectator;
bool flag = this._scene_type != SceneType.SCENE_HALL;
if (flag)
{
XQualitySetting.EnterScene();
}
else
{
XQualitySetting.EnterHall();
}
this.IsViewGridScene = XSingleton<XGlobalConfig>.singleton.ViewGridScene.Contains(XFastEnumIntEqualityComparer<SceneType>.ToInt(this._scene_type));
}
public void OnSceneLoaded(uint sceneid)
{
this._next_sync_mode = 0;
this._next_is_spectator = false;
XSingleton<XSkillFactory>.singleton.OnSceneLoaded();
XSingleton<XLevelSpawnMgr>.singleton.OnSceneLoaded(sceneid);
XFightGroupDocument.OnSceneLoaded();
}
public void OnEnterScene(uint sceneid, bool transfer)
{
this._story_dirver = XSingleton<XEntityMgr>.singleton.Player;
XSingleton<XStageProgress>.singleton.OnEnterScene();
XSingleton<XPostEffectMgr>.singleton.OnEnterScene(sceneid);
XQualitySetting.PostSetting();
}
public void TriggerScene()
{
this._bSceneEntered = true;
XSingleton<XLevelSpawnMgr>.singleton.CreateRobot(this._scene_id);
string sceneConfigFile = XSingleton<XSceneMgr>.singleton.GetSceneConfigFile(this._scene_id);
bool flag = sceneConfigFile.Length != 0;
if (flag)
{
XSingleton<XLevelSpawnMgr>.singleton.InitGlobalAI(this._scene_id);
}
}
public void OnSceneStarted()
{
for (int i = 0; i < XSingleton<XGame>.singleton.Doc.Components.Count; i++)
{
(XSingleton<XGame>.singleton.Doc.Components[i] as XDocComponent).OnSceneStarted();
}
}
public void OnLeaveScene(bool transfer)
{
this._story_dirver = null;
this._bStarted = false;
XSingleton<XShell>.singleton.TimeMagicBack();
XSingleton<XTutorialMgr>.singleton.OnLeaveScene();
XSingleton<XCutScene>.singleton.OnLeaveScene();
XSingleton<XAudioMgr>.singleton.OnLeaveScene();
XSingleton<XGameSysMgr>.singleton.OnLeaveScene(transfer);
this._camera.Uninitilize();
XSingleton<XFxMgr>.singleton.OnLeaveScene();
XSingleton<XTimerMgr>.singleton.KillTimerAll();
XSingleton<XLevelSpawnMgr>.singleton.UnInitGlobalAI();
XHUDComponent.ResetCurrentCount();
bool flag = !transfer;
if (flag)
{
XSingleton<XCustomShadowMgr>.singleton.Clear();
}
ShadowMapInfo.ClearShadowRes();
XSyncDebug.OnLeaveScene();
}
public void PreUpdate(float fDeltaT)
{
bool bSceneEntered = this._bSceneEntered;
if (bSceneEntered)
{
XSingleton<XLevelScriptMgr>.singleton.Update();
bool flag = XSingleton<XEntityMgr>.singleton.Player != null;
if (flag)
{
XSingleton<XEntityMgr>.singleton.Player.PreUpdate();
}
}
}
public void Update(float fDeltaT)
{
bool bSceneEntered = this._bSceneEntered;
if (bSceneEntered)
{
XSingleton<XBulletMgr>.singleton.Update(fDeltaT);
XSingleton<XEntityMgr>.singleton.Update(fDeltaT);
XSingleton<XLevelFinishMgr>.singleton.Update(fDeltaT);
XSingleton<XLevelDoodadMgr>.singleton.Update();
this._camera.Update(fDeltaT);
XSingleton<XLevelStatistics>.singleton.Update();
bool flag = !XSingleton<XGame>.singleton.SyncMode;
if (flag)
{
XSingleton<XLevelSpawnMgr>.singleton.Update(fDeltaT);
}
bool needTutorail = XSingleton<XTutorialMgr>.singleton.NeedTutorail;
if (needTutorail)
{
XSingleton<XTutorialMgr>.singleton.Update();
}
}
}
public void PostUpdate(float fDeltaT)
{
bool bSceneEntered = this._bSceneEntered;
if (bSceneEntered)
{
this._camera.PostUpdate(fDeltaT);
XSingleton<XEntityMgr>.singleton.PostUpdate(fDeltaT);
XSingleton<XFxMgr>.singleton.PostUpdate();
XQualitySetting.Update();
}
}
public void FixedUpdate()
{
bool bSceneEntered = this._bSceneEntered;
if (bSceneEntered)
{
XSingleton<XEntityMgr>.singleton.FixedUpdate();
this._camera.FixedUpdate();
}
}
public bool CheckDynamicBlock(Vector3 from, Vector3 to)
{
List<XLevelInfo> levelScriptInfos = XSingleton<XLevelScriptMgr>.singleton.GetLevelScriptInfos();
for (int i = 0; i < levelScriptInfos.Count; i++)
{
bool enable = levelScriptInfos[i].enable;
if (enable)
{
float num = levelScriptInfos[i].width / 2f;
Vector3 vector;
vector= new Vector3(levelScriptInfos[i].x, 0f, levelScriptInfos[i].z);
Vector3 vector2 = XSingleton<XCommon>.singleton.HorizontalRotateVetor3(XSingleton<XCommon>.singleton.FloatToAngle(levelScriptInfos[i].face), 90f, true);
bool flag = XSingleton<XCommon>.singleton.IsLineSegmentCross(from, to, vector + num * vector2, vector - num * vector2);
if (flag)
{
bool flag2 = levelScriptInfos[i].height > from.y;
if (flag2)
{
return false;
}
}
}
}
return true;
}
public void ReqLeaveScene()
{
XStaticSecurityStatistics.OnEnd();
PtcC2G_LeaveSceneReq proto = new PtcC2G_LeaveSceneReq();
XSingleton<XClientNetwork>.singleton.Send(proto);
}
public void RefreshScenMustTransform()
{
this.m_IsMustTransform = false;
List<int> list = ListPool<int>.Get();
XSingleton<XGlobalConfig>.singleton.GetIntList("TransformSceneID", list);
for (int i = 0; i < list.Count; i++)
{
bool flag = (ulong)this._scene_id == (ulong)((long)list[i]);
if (flag)
{
this.m_IsMustTransform = true;
break;
}
}
ListPool<int>.Release(list);
}
}
}
|