blob: 7369bd37ce5cf0f109a1d85a0bf6e27496e259e6 (
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
|
using System;
using System.Collections.Generic;
using UnityEngine;
using XUtliPoolLib;
namespace XMainClient
{
internal sealed class XManipulationComponent : XComponent
{
public override uint ID
{
get
{
return XManipulationComponent.uuID;
}
}
public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("XManipulation");
private Dictionary<long, XManipulationData> _item = new Dictionary<long, XManipulationData>();
protected override void EventSubscribe()
{
base.RegisterEvent(XEventDefine.XEvent_Manipulation_On, new XComponent.XEventHandler(this.ManipulationOn));
base.RegisterEvent(XEventDefine.XEvent_Manipulation_Off, new XComponent.XEventHandler(this.ManipulationOff));
}
public override void OnAttachToHost(XObject host)
{
base.OnAttachToHost(host);
}
public override void OnDetachFromHost()
{
this._item.Clear();
base.OnDetachFromHost();
}
public override void Update(float fDeltaT)
{
bool flag = this._item.Count == 0;
if (!flag)
{
foreach (KeyValuePair<long, XManipulationData> keyValuePair in this._item)
{
XManipulationData value = keyValuePair.Value;
List<XEntity> list = value.TargetIsOpponent ? XSingleton<XEntityMgr>.singleton.GetOpponent(this._entity) : XSingleton<XEntityMgr>.singleton.GetAlly(this._entity);
Vector3 vector = this._entity.EngineObject.Position + this._entity.EngineObject.Rotation * new Vector3(value.OffsetX, 0f, value.OffsetZ);
for (int i = 0; i < list.Count; i++)
{
XEntity xentity = list[i];
bool flag2 = !XEntity.ValideEntity(xentity);
if (!flag2)
{
Vector3 vector2 = vector - xentity.EngineObject.Position;
vector2.y = 0f;
float magnitude = vector2.magnitude;
bool flag3 = magnitude < value.Radius && (magnitude == 0f || Vector3.Angle(-vector2, this._entity.EngineObject.Forward) <= value.Degree * 0.5f);
if (flag3)
{
float num = value.Force * Time.deltaTime;
xentity.ApplyMove(vector2.normalized * Mathf.Min(magnitude, num));
}
}
}
}
}
}
private bool ManipulationOn(XEventArgs e)
{
XManipulationOnEventArgs xmanipulationOnEventArgs = e as XManipulationOnEventArgs;
bool flag = !this._item.ContainsKey(xmanipulationOnEventArgs.Token);
if (flag)
{
this._item.Add(xmanipulationOnEventArgs.Token, xmanipulationOnEventArgs.data);
}
return true;
}
private bool ManipulationOff(XEventArgs e)
{
XManipulationOffEventArgs xmanipulationOffEventArgs = e as XManipulationOffEventArgs;
bool flag = xmanipulationOffEventArgs.DenyToken == 0L;
if (flag)
{
this._item.Clear();
}
else
{
this._item.Remove(xmanipulationOffEventArgs.DenyToken);
}
return true;
}
}
}
|