summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/WeaponLoadTask.cs
blob: 3f5aad7e3add30c10883577332089538b1ae38e3 (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
using System;
using UnityEngine;
using XUtliPoolLib;

namespace XMainClient
{
	internal class WeaponLoadTask : MountLoadTask
	{
		public XGameObject xgo2 = null;

		private static Quaternion _defaultSkinRot = Quaternion.Euler(new Vector3(-90f, 0f, 0f));

		private static CommandCallback secondWeaponLoaded = new CommandCallback(WeaponLoadTask._SecondWeaponLoaded);

		public WeaponLoadTask(EPartType p, MountLoadCallback mountPartLoadCb) : base(p, mountPartLoadCb)
		{
		}

		public override void Reset(XEntity e)
		{
			this.processStatus = EProcessStatus.ENotProcess;
			this.location = "";
			bool flag = this.xgo != null;
			if (flag)
			{
				XRenderComponent.RemoveObj(e, this.xgo.Get());
				XGameObject.DestroyXGameObject(this.xgo);
			}
			this.xgo = null;
			bool flag2 = this.xgo2 != null;
			if (flag2)
			{
				XRenderComponent.RemoveObj(e, this.xgo2.Get());
				XGameObject.DestroyXGameObject(this.xgo2);
			}
			this.xgo2 = null;
		}

		public override void ProcessEnable(bool enable, bool forceDisable, int layer)
		{
			base.ProcessEnable(enable, forceDisable, layer);
			bool flag = this.xgo2 != null;
			if (flag)
			{
				MountLoadTask.ProcessEnable(this.xgo2, enable, forceDisable, layer);
			}
		}

		public override void ProcessRenderQueue(int renderQueue)
		{
			base.ProcessRenderQueue(renderQueue);
			bool flag = this.xgo2 != null;
			if (flag)
			{
				MountLoadTask.ProcessRenderQueue(this.xgo2, renderQueue);
			}
		}

		public override void ProcessRenderComponent(XEntity e)
		{
			base.ProcessRenderComponent(e);
			bool flag = this.xgo2 != null;
			if (flag)
			{
				MountLoadTask.ProcessRenderComponent(this.xgo2, e);
			}
		}

		private static void _SecondWeaponLoaded(XGameObject gameObject, object o, int commandID)
		{
			XEntity xentity = o as XEntity;
			int layer = xentity.DefaultLayer;
			bool enable = true;
			bool flag = xentity.Equipment != null;
			if (flag)
			{
				bool isUIAvatar = xentity.Equipment.IsUIAvatar;
				if (isUIAvatar)
				{
					layer = XQualitySetting.UILayer;
				}
				enable = xentity.Equipment.IsRenderEnable;
			}
			MountLoadTask.ProcessRender(gameObject, xentity, layer, enable, -1, false);
		}

		public void PostProcess(Transform attachPoint0, Transform attachPoint1, XEntity e)
		{
			this.xgo.SetParentTrans(attachPoint0);
			bool isSkin = base.IsSkin;
			if (isSkin)
			{
				this.xgo.SetLocalPRS(Vector3.zero, true, WeaponLoadTask._defaultSkinRot, true, Vector3.one, true);
			}
			else
			{
				this.xgo.SetLocalPRS(Vector3.zero, true, Quaternion.identity, true, Vector3.one, true);
			}
			bool flag = attachPoint1 != null;
			if (flag)
			{
				bool flag2 = this.xgo2 == null;
				if (flag2)
				{
					this.xgo2 = XGameObject.CloneXGameObject(this.xgo, true);
					this.xgo2.CallCommand(WeaponLoadTask.secondWeaponLoaded, e, -1, false);
				}
				this.xgo2.SetParentTrans(attachPoint1);
				bool isSkin2 = base.IsSkin;
				if (isSkin2)
				{
					this.xgo2.SetLocalPRS(Vector3.zero, true, WeaponLoadTask._defaultSkinRot, true, Vector3.one, true);
				}
				else
				{
					this.xgo2.SetLocalPRS(Vector3.zero, true, Quaternion.identity, true, Vector3.one, true);
				}
			}
		}
	}
}