summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/Buff/XBuffMob.cs
blob: 5425bb30c4779edfa314c60714c962444fa44a9a (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
using System;
using XUtliPoolLib;

namespace XMainClient
{
	internal class XBuffMob : BuffEffect
	{
		private XEntity _entity;

		private XEntity _Mob = null;

		private XBuff _Buff;

		private uint _MobTemplateID = 0u;

		public static bool TryCreate(BuffTable.RowData rowData, XBuff buff)
		{
			bool flag = rowData.MobID == 0u;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				buff.AddEffect(new XBuffMob(rowData.MobID, buff));
				result = true;
			}
			return result;
		}

		public XBuffMob(uint templateID, XBuff buff)
		{
			this._MobTemplateID = templateID;
			this._Buff = buff;
		}

		public override void OnAdd(XEntity entity, CombatEffectHelper pEffectHelper)
		{
			this._entity = entity;
			XEntity entity2 = XSingleton<XEntityMgr>.singleton.GetEntity(this._Buff.CasterID);
			bool flag = XEntity.ValideEntity(entity2);
			if (flag)
			{
				this._Mob = XSingleton<XEntityMgr>.singleton.CreateEntity(this._MobTemplateID, this._entity.EngineObject.Position, this._entity.EngineObject.Rotation, true, (entity2.Attributes != null) ? entity2.Attributes.FightGroup : uint.MaxValue);
				XSingleton<XSkillEffectMgr>.singleton.SetMobProperty(this._Mob, entity2, 0u);
				this._Buff.EffectData.MobID = this._Mob.ID;
				bool isBoss = entity2.IsBoss;
				if (isBoss)
				{
					XSecurityAIInfo xsecurityAIInfo = XSecurityAIInfo.TryGetStatistics(entity2);
					bool flag2 = xsecurityAIInfo != null;
					if (flag2)
					{
						xsecurityAIInfo.OnExternalCallMonster();
					}
				}
			}
		}

		public override void OnRemove(XEntity entity, bool IsReplaced)
		{
			XSingleton<XEntityMgr>.singleton.DestroyEntity(this._Mob);
			this._Mob = null;
		}

		public override void OnUpdate()
		{
			bool flag = !XEntity.ValideEntity(this._Mob);
			if (flag)
			{
				XBuffRemoveEventArgs @event = XEventPool<XBuffRemoveEventArgs>.GetEvent();
				@event.xBuffID = this._Buff.ID;
				@event.Firer = this._entity;
				XSingleton<XEventMgr>.singleton.FireEvent(@event);
			}
		}
	}
}