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

namespace XMainClient
{
	internal class XPresentComponent : XComponent
	{
		public override uint ID
		{
			get
			{
				return XPresentComponent.uuID;
			}
		}

		public string SkillPrefix
		{
			get
			{
				return this._skill_prefix;
			}
		}

		public string ActionPrefix
		{
			get
			{
				return this._action_prefix;
			}
		}

		public string CurvePrefix
		{
			get
			{
				return this._curve_prefix;
			}
		}

		public bool IsShowUp { get; set; }

		public Vector3 RadiusOffset
		{
			get
			{
				return this._radius_offset;
			}
		}

		public XEntityPresentation.RowData PresentLib
		{
			get
			{
				return this._present_data;
			}
		}

		public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("Presentation");

		private XEntityPresentation.RowData _present_data = null;

		private uint _show_up_token = 0u;

		private string _skill_prefix = null;

		private string _action_prefix = null;

		private string _curve_prefix = null;

		protected Vector3 _radius_offset = Vector3.zero;

		public override void OnAttachToHost(XObject host)
		{
			base.OnAttachToHost(host);
			this.IsShowUp = false;
			this.InitPresent(this._entity.PresentID);
		}

		public override void Attached()
		{
			this._entity.Scale = this._present_data.Scale;
			bool flag = this._present_data.BoundRadiusOffset != null && this._present_data.BoundRadiusOffset.Length != 0;
			if (flag)
			{
				this._radius_offset.Set(this._present_data.BoundRadiusOffset[0], 0f, this._present_data.BoundRadiusOffset[1]);
			}
			else
			{
				this._radius_offset.Set(0f, 0f, 0f);
			}
			bool flag2 = this._entity.EngineObject != null;
			if (flag2)
			{
				Vector3 localScale = Vector3.one * this._entity.Scale;
				this._entity.EngineObject.LocalScale = localScale;
			}
		}

		public void InitPresent(uint present_id)
		{
			this._present_data = XSingleton<XEntityMgr>.singleton.EntityInfo.GetByPresentID(present_id);
			this._skill_prefix = "SkillPackage/" + this._present_data.SkillLocation;
			this._action_prefix = "Animation/" + this._present_data.AnimLocation;
			this._curve_prefix = "Curve/" + this._present_data.CurveLocation;
			bool flag = XStateMachine._EnableAtor && this._entity.EngineObject != null;
			if (flag)
			{
				this._entity.EngineObject.InitAnim();
			}
			bool flag2 = this._entity.Attributes != null && this._entity.Attributes.TypeID == XSingleton<XSceneMgr>.singleton.GetDriveID(XSingleton<XScene>.singleton.SceneID);
			if (flag2)
			{
				XSingleton<XScene>.singleton.Dirver = this._entity;
			}
		}

		public void ShowUp()
		{
			bool flag = this._entity.HasComeOnPresent() && !this._entity.Attributes.MidwayEnter;
			if (flag)
			{
				this.IsShowUp = true;
				XSingleton<XEntityMgr>.singleton.Puppets(this._entity, false, true);
				this._entity.Net.ReportSkillAction(null, this._entity.SkillMgr.GetAppearIdentity(), -1);
				this._show_up_token = XSingleton<XTimerMgr>.singleton.SetTimer(0.5f, new XTimerMgr.ElapsedEventHandler(this.OnReadyFight), null);
			}
			else
			{
				XSingleton<XEntityMgr>.singleton.Puppets(this._entity, false, false);
			}
		}

		public override void OnDetachFromHost()
		{
			this._present_data = null;
			this._entity.EngineObject.LocalScale = Vector3.one;
			XSingleton<XTimerMgr>.singleton.KillTimer(this._show_up_token);
			base.OnDetachFromHost();
		}

		public void OnReadyFight(object o)
		{
			XSingleton<XEntityMgr>.singleton.Puppets(this._entity, false, false);
			this.IsShowUp = false;
		}

		public void OnTransform(XEntity src, bool to)
		{
			if (to)
			{
				float num = src.Scale / src.Present.PresentLib.Scale * this._present_data.Scale;
				this._entity.Scale = num;
				bool flag = this._entity.EngineObject != null;
				if (flag)
				{
					Vector3 localScale = Vector3.one * num;
					this._entity.EngineObject.LocalScale = localScale;
				}
			}
			else
			{
				bool flag2 = this._entity.EngineObject != null;
				if (flag2)
				{
					this._entity.Scale = this._present_data.Scale;
					Vector3 localScale2 = Vector3.one * this._present_data.Scale;
					this._entity.EngineObject.LocalScale = localScale2;
				}
			}
		}
	}
}