summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XActor.cs
blob: 9843032081117a258b9db97936c84b424bce2b66 (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
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
using System;
using KKSG;
using UnityEngine;
using XUtliPoolLib;

namespace XMainClient
{
	internal sealed class XActor : XObject
	{
		public uint Fashion
		{
			get
			{
				return this._fashion_id;
			}
			set
			{
				this._fashion_id = value;
			}
		}

		public XDummy Dummy
		{
			get
			{
				return this._dummy;
			}
		}

		public override XGameObject EngineObject
		{
			get
			{
				return this._actor;
			}
		}

		private XGameObject _actor = null;

		private XAnimator _ator = null;

		private XDummy _dummy = null;

		private uint _fashion_id = 0u;

		private string _clip = null;

		public bool Replaced = false;

		public XActor(Vector3 pos, string clip)
		{
			XPlayer player = XSingleton<XEntityMgr>.singleton.Player;
			bool flag = XSingleton<XGlobalConfig>.singleton.BlockFashionProfs.Contains(player.Attributes.TypeID % 10u);
			XOutlookData xoutlookData;
			if (flag)
			{
				xoutlookData = new XOutlookData();
				xoutlookData.SetProfType(player.Attributes.TypeID);
				xoutlookData.CalculateOutLookFashion();
			}
			else
			{
				xoutlookData = player.Attributes.Outlook;
			}
			xoutlookData.uiAvatar = false;
			this._dummy = XSingleton<XEntityMgr>.singleton.CreateDummy(player.PresentID, player.BasicTypeID, xoutlookData, false, false, false);
			this._dummy.EngineObject.Position = pos;
			this._actor = this._dummy.EngineObject;
			this._ator = this._dummy.Ator;
			this.OverrideAnim(clip);
			this.TurnOnSkinnedMesh(this._actor);
		}

		public XActor(uint id, Vector3 pos, string clip)
		{
			XEntityStatistics.RowData byID = XSingleton<XEntityMgr>.singleton.EntityStatistics.GetByID(id);
			XOutlookData xoutlookData = new XOutlookData();
			xoutlookData.SetDefaultFashion(byID.FashionTemplate);
			xoutlookData.uiAvatar = false;
			this._dummy = XSingleton<XEntityMgr>.singleton.CreateDummy(byID.PresentID, (uint)byID.FashionTemplate, xoutlookData, false, false, false);
			this._dummy.EngineObject.Position = pos;
			this._actor = this._dummy.EngineObject;
			this._ator = this._dummy.Ator;
			this.OverrideAnim(clip);
			this.TurnOnSkinnedMesh(this._actor);
		}

		public XActor(string prefab, Vector3 pos, Quaternion face, string clip)
		{
			this._actor = XGameObject.CreateXGameObject(prefab, pos, face, false, true);
			this._ator = this._actor.InitAnim();
			this.OverrideAnim(clip);
		}

		public void OverrideAnim(string clip)
		{
			this._clip = clip;
			bool flag = this._ator != null;
			if (flag)
			{
				this._ator.OverrideAnim("Idle", clip, null, false);
			}
		}

		public void ReplaceActor(XDummy dummy)
		{
			bool flag = dummy == this._dummy;
			if (!flag)
			{
				dummy.EngineObject.Position = this._dummy.EngineObject.Position;
				dummy.EngineObject.Tag = this._dummy.EngineObject.Tag;
				dummy.EngineObject.EnableCC = this._dummy.EngineObject.EnableCC;
				dummy.EngineObject.EnableBC = this._dummy.EngineObject.EnableBC;
				string clip = this._clip;
				this.OverrideAnim("");
				XSingleton<XEntityMgr>.singleton.DestroyEntity(this._dummy);
				this._dummy = dummy;
				this._actor = this._dummy.EngineObject;
				this._ator = this._dummy.Ator;
				this._ator.cullingMode = 0;
				this.OverrideAnim(clip);
				this.TurnOnSkinnedMesh(this._actor);
			}
		}

		public void PlayAnimation(string clip)
		{
			this._dummy.OverrideAnimClip("Idle", clip, false, false);
		}

		public override bool Initilize(int flag)
		{
			XSingleton<XComponentMgr>.singleton.CreateComponent(this, XAudioComponent.uuID);
			bool flag2 = this._ator != null;
			if (flag2)
			{
				this._ator.cullingMode = 0;
			}
			this._actor.EnableCC = false;
			bool flag3 = XSingleton<XGame>.singleton.CurrentStage != null && XSingleton<XGame>.singleton.CurrentStage.Stage != EXStage.SelectChar && XSingleton<XGame>.singleton.CurrentStage.Stage != EXStage.Login;
			if (flag3)
			{
				this._actor.EnableBC = false;
			}
			else
			{
				this._actor.EnableBC = true;
			}
			return true;
		}

		public override void Uninitilize()
		{
			this.TurnOffSkinnedMesh(this._actor);
			bool flag = this._dummy == null;
			if (flag)
			{
				bool flag2 = this._actor != null;
				if (flag2)
				{
					XGameObject.DestroyXGameObject(this._actor);
					this._actor = null;
				}
			}
			else
			{
				bool flag3 = !this._dummy.Deprecated;
				if (flag3)
				{
					XSingleton<XEntityMgr>.singleton.DestroyEntity(this._dummy);
				}
				this._dummy = null;
			}
			base.Uninitilize();
		}

		private void TurnOnSkinnedMesh(XGameObject o)
		{
			bool flag = XSingleton<XScene>.singleton.SceneType != SceneType.SCENE_LOGIN;
			if (flag)
			{
				this._actor.UpdateWhenOffscreen = true;
			}
		}

		private void TurnOffSkinnedMesh(XGameObject o)
		{
			this._actor.UpdateWhenOffscreen = false;
		}

		public void GetCurrentAnimLength(OverrideAnimCallback overrideAnimCb)
		{
			bool flag = this._ator != null;
			if (flag)
			{
				this._ator.SetAnimLoadCallback("Idle", overrideAnimCb);
			}
		}
	}
}