From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- Client/Assets/Scripts/XMainClient/XBullet.cs | 932 +++++++++++++++++++++++++++ 1 file changed, 932 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XBullet.cs (limited to 'Client/Assets/Scripts/XMainClient/XBullet.cs') diff --git a/Client/Assets/Scripts/XMainClient/XBullet.cs b/Client/Assets/Scripts/XMainClient/XBullet.cs new file mode 100644 index 00000000..48fad516 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XBullet.cs @@ -0,0 +1,932 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using XUpdater; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XBullet + { + public XBulletCore BulletCore + { + get + { + return this._data; + } + } + + public ulong ID + { + get + { + return this._id; + } + } + + public ulong ExtraID + { + get + { + return this._extra_id; + } + set + { + this._extra_id = value; + } + } + + private ulong _id = 0UL; + + private ulong _extra_id = 0UL; + + private bool _active = true; + + private bool _effectual = true; + + private bool _pingpong = false; + + private bool _hit_triggered = false; + + private int _tail_results = 0; + + private uint _tail_results_token = 0u; + + private float _elapsed = 0f; + + private XFx _bullet = null; + + private XBulletCore _data; + + private Vector3 _origin = Vector3.zero; + + private SmallBuffer _hurt_target; + + private IXFmod _iFmod; + + public struct XBulletTarget + { + public ulong TargetID; + + public uint TimerToken; + + public bool Hurtable; + + public int HurtCount; + } + + public XBullet(ulong id, XBulletCore data) + { + this.Init(id, data); + } + + public void Deny() + { + this._effectual = false; + } + + private void LoadFinish(UnityEngine.Object obj, object cbOjb) + { + bool flag = this._iFmod != null; + if (flag) + { + this._iFmod.Destroy(); + XSingleton.singleton.XPlatform.ReturnClass(EClassType.ERuntimeFMOD, this._iFmod); + this._iFmod = null; + } + bool flag2 = !string.IsNullOrEmpty(this._data.Result.LongAttackData.Audio); + if (flag2) + { + this._iFmod = (XSingleton.singleton.XPlatform.CreateClass(EClassType.ERuntimeFMOD) as IXFmod); + Rigidbody rigidbody = null; + GameObject gameObject = obj as GameObject; + bool flag3 = gameObject != null; + if (flag3) + { + rigidbody = gameObject.GetComponent(); + } + bool flag4 = this._iFmod != null; + if (flag4) + { + this._iFmod.Init(gameObject, rigidbody); + XSingleton.singleton.PlaySound(this._iFmod, AudioChannel.Motion, this._data.Result.LongAttackData.Audio); + } + } + } + + private XFx FilterFx(string path) + { + bool flag = string.IsNullOrEmpty(path); + XFx result; + if (flag) + { + result = XSingleton.singleton.CreateFx("", new LoadCallBack(this.LoadFinish), true); + } + else + { + bool flag2 = XSingleton.singleton.FilterFx && (this._data.Firer == null || (!this._data.Firer.IsPlayer && !this._data.Firer.IsBoss && !(this._data.Firer is XDummy))) && (this._data.Target == null || !this._data.Target.IsPlayer); + if (flag2) + { + Vector3 position = XSingleton.singleton.Player.EngineObject.Position; + Vector3 origin = this._data.BulletRay.origin; + float num = XFxMgr.FilterFxDis4; + float num2 = (origin.x - position.x) * (origin.x - position.x) + (origin.z - position.z) * (origin.z - position.z); + bool flag3 = this._data.Result != null && this._data.Result.LongAttackData != null; + if (flag3) + { + num = this._data.Result.LongAttackData.Velocity * this._data.Result.LongAttackData.Runningtime; + } + bool flag4 = num2 < XFxMgr.FilterFxDis4 || num2 < num * num; + if (flag4) + { + result = XSingleton.singleton.CreateFx(this._data.Prefab, new LoadCallBack(this.LoadFinish), true); + } + else + { + result = XSingleton.singleton.CreateFx("", new LoadCallBack(this.LoadFinish), true); + } + } + else + { + result = XSingleton.singleton.CreateFx(path, null, true); + } + } + return result; + } + + public void Init(ulong id, XBulletCore data) + { + this._id = id; + this._extra_id = 0UL; + this._active = true; + this._effectual = true; + this._tail_results = 0; + this._pingpong = false; + this._hit_triggered = false; + this._elapsed = 0f; + this._data = data; + this._origin = Vector3.zero; + string path = XSingleton.singleton.PreFilterPrefab(this._data.Prefab); + this._bullet = this.FilterFx(path); + this._bullet.Play(this._data.BulletRay.origin, (this._data.Velocity > 0f) ? Quaternion.LookRotation(this._data.BulletRay.direction) : Quaternion.LookRotation(this._data.Firer.EngineObject.Forward), Vector3.one, 1f); + this._hurt_target.debugName = "XBullet._hurt_target"; + XSingleton.singleton.GetSmallBuffer(ref this._hurt_target, 4); + } + + private void OnRefined(object o) + { + ulong num = (ulong)o; + int i = 0; + int count = this._hurt_target.Count; + while (i < count) + { + XBullet.XBulletTarget xbulletTarget = this._hurt_target[i]; + bool flag = xbulletTarget.TargetID == num && xbulletTarget.HurtCount < this._data.Result.LongAttackData.Refine_Count; + if (flag) + { + xbulletTarget.Hurtable = true; + this._hurt_target[i] = xbulletTarget; + break; + } + i++; + } + } + + private void OnRefined() + { + int i = 0; + int count = this._hurt_target.Count; + while (i < count) + { + XBullet.XBulletTarget xbulletTarget = this._hurt_target[i]; + xbulletTarget.Hurtable = true; + xbulletTarget.HurtCount = 0; + XSingleton.singleton.KillTimer(xbulletTarget.TimerToken); + this._hurt_target[i] = xbulletTarget; + i++; + } + } + + private void OnPingPong() + { + this._pingpong = true; + bool autoRefine_at_Half = this._data.Result.LongAttackData.AutoRefine_at_Half; + if (autoRefine_at_Half) + { + this.OnRefined(); + } + } + + public void Expire() + { + this._active = false; + bool flag = this._tail_results != 0; + if (flag) + { + XSingleton.singleton.KillTimer(this._tail_results_token); + this._tail_results = this._data.Result.LongAttackData.TriggerAtEnd_Count; + } + } + + public bool IsExpired() + { + bool flag = !this._effectual || (!this._data.Demonstration && !XEntity.ValideEntity(this._data.Firer)); + bool result; + if (flag) + { + result = true; + } + else + { + bool flag2 = this._tail_results != 0; + if (flag2) + { + bool flag3 = this._tail_results >= this._data.Result.LongAttackData.TriggerAtEnd_Count; + result = flag3; + } + else + { + bool flag4 = this._data.Result.LongAttackData.IsPingPong && !this._pingpong; + if (flag4) + { + bool flag5 = XSingleton.singleton.IsGreater(this._elapsed, this._data.Life); + if (flag5) + { + this.OnPingPong(); + } + } + bool flag6 = !this._active || (!this._pingpong && XSingleton.singleton.IsGreater(this._elapsed, this._data.Life)); + bool flag7 = this._data.Result.LongAttackData.TriggerAtEnd_Count <= 0; + if (flag7) + { + result = flag6; + } + else + { + bool flag8 = flag6; + if (flag8) + { + this._active = false; + this.OnTailResult(null); + result = false; + } + else + { + result = flag6; + } + } + } + } + return result; + } + + private void OnTailResult(object o) + { + bool flag = o == null; + if (flag) + { + this._tail_results = 0; + this.FakeDestroyBulletObject(); + } + bool flag2 = this._tail_results < this._data.Result.LongAttackData.TriggerAtEnd_Count; + if (flag2) + { + this._tail_results++; + this.TailResult(this._tail_results == 1); + XSingleton.singleton.KillTimer(this._tail_results_token); + this._tail_results_token = XSingleton.singleton.SetTimer(this._data.Result.LongAttackData.TriggerAtEnd_Cycle, new XTimerMgr.ElapsedEventHandler(this.OnTailResult), this); + } + } + + public bool IsHurtEntity(ulong id) + { + int i = 0; + int count = this._hurt_target.Count; + while (i < count) + { + XBullet.XBulletTarget xbulletTarget = this._hurt_target[i]; + bool flag = xbulletTarget.TargetID == id; + if (flag) + { + return !xbulletTarget.Hurtable; + } + i++; + } + return false; + } + + private void TailResult(bool present) + { + bool triggerAtEnd = this._data.Result.LongAttackData.TriggerAtEnd; + if (triggerAtEnd) + { + bool warning = this._data.Warning; + if (warning) + { + this._bullet.Position = this._data.WarningPos; + } + bool flag = !this._data.Demonstration && !XSingleton.singleton.SyncMode; + if (flag) + { + this.Result(null, this._data.Result.LongAttackData.TriggerAtEnd_Count == 0); + } + } + bool flag2 = !present; + if (!flag2) + { + bool flag3 = !string.IsNullOrEmpty(this._data.Result.LongAttackData.End_Fx); + if (flag3) + { + Vector3 position = this._bullet.Position; + float num = 0f; + bool flag4 = this._data.Demonstration || XSingleton.singleton.TryGetTerrainY(position, out num); + if (flag4) + { + XFx xfx = XSingleton.singleton.CreateFx(this._data.Result.LongAttackData.End_Fx, null, true); + xfx.DelayDestroy = this._data.Result.LongAttackData.EndFx_LifeTime; + Quaternion rotation = this._bullet.Rotation; + bool endFx_Ground = this._data.Result.LongAttackData.EndFx_Ground; + if (endFx_Ground) + { + position.y = (this._data.Demonstration ? this._bullet.Position.y : num); + rotation = (this._data.Demonstration ? Quaternion.identity : XSingleton.singleton.RotateToGround(position, this._bullet.Forward)); + } + xfx.Play(position, rotation, Vector3.one, 1f); + XSingleton.singleton.LogEndFx(xfx); + XSingleton.singleton.DestroyFx(xfx, false); + } + } + bool flag5 = !string.IsNullOrEmpty(this._data.Result.LongAttackData.End_Audio); + if (flag5) + { + XSingleton.singleton.PlaySound(this._data.Firer, AudioChannel.Motion, this._data.Result.LongAttackData.End_Audio, this._bullet.Position); + } + } + } + + private void FakeDestroyBulletObject() + { + bool flag = this._bullet != null; + if (flag) + { + Vector3 position = this._bullet.Position; + Quaternion rotation = this._bullet.Rotation; + bool flag2 = this._iFmod != null; + if (flag2) + { + XSingleton.singleton.StopSound(this._iFmod); + this._iFmod.Destroy(); + XSingleton.singleton.XPlatform.ReturnClass(EClassType.ERuntimeFMOD, this._iFmod); + this._iFmod = null; + } + XSingleton.singleton.DestroyFx(this._bullet, true); + this._bullet = null; + this._bullet = XSingleton.singleton.CreateFx("", null, true); + this._bullet.Position = position; + this._bullet.Rotation = rotation; + this._bullet.SetActive(true); + } + } + + public void Destroy(bool leave = false) + { + XSingleton.singleton.KillTimer(this._tail_results_token); + bool flag = !leave && this._data.Result.LongAttackData.TriggerAtEnd_Count == 0 && (this._data.Demonstration || XEntity.ValideEntity(this._data.Firer)); + if (flag) + { + this.TailResult(true); + } + bool flag2 = this._bullet != null; + if (flag2) + { + bool flag3 = this._iFmod != null; + if (flag3) + { + XSingleton.singleton.StopSound(this._iFmod); + this._iFmod.Destroy(); + XSingleton.singleton.XPlatform.ReturnClass(EClassType.ERuntimeFMOD, this._iFmod); + this._iFmod = null; + } + XSingleton.singleton.DestroyFx(this._bullet, true); + this._bullet = null; + } + bool flag4 = this._data.Result.LongAttackData.Refine_Cycle > 0f; + if (flag4) + { + int i = 0; + int count = this._hurt_target.Count; + while (i < count) + { + XBullet.XBulletTarget xbulletTarget = this._hurt_target[i]; + XSingleton.singleton.KillTimer(xbulletTarget.TimerToken); + i++; + } + } + XSingleton.singleton.ReturnSmallBuffer(ref this._hurt_target); + } + + public void OnResult(XEntity target) + { + bool flag = XEntity.ValideEntity(target); + if (flag) + { + XBullet.XBulletTarget xbulletTarget; + xbulletTarget.HurtCount = 0; + xbulletTarget.TimerToken = 0u; + xbulletTarget.TargetID = 0UL; + int num = -1; + int i = 0; + int count = this._hurt_target.Count; + while (i < count) + { + xbulletTarget = this._hurt_target[i]; + bool flag2 = xbulletTarget.TargetID == target.ID; + if (flag2) + { + num = i; + break; + } + i++; + } + bool flag3 = num < 0; + if (flag3) + { + xbulletTarget = default(XBullet.XBulletTarget); + xbulletTarget.TargetID = target.ID; + num = this._hurt_target.Count; + this._hurt_target.Add(xbulletTarget); + } + XSingleton.singleton.KillTimer(xbulletTarget.TimerToken); + xbulletTarget.Hurtable = false; + xbulletTarget.HurtCount++; + xbulletTarget.TimerToken = ((this._data.Result.LongAttackData.Refine_Cycle > 0f) ? XSingleton.singleton.SetTimer(this._data.Result.LongAttackData.Refine_Cycle, new XTimerMgr.ElapsedEventHandler(this.OnRefined), target.ID) : 0u); + this._hurt_target[num] = xbulletTarget; + bool flag4 = this._data.TriggerMove && XEntity.ValideEntity(this._data.Firer); + if (flag4) + { + Vector3 vector = (this._data.Firer.EngineObject.Position - target.EngineObject.Position).normalized * target.RealEntity.Radius; + this._data.Firer.CorrectMe(target.EngineObject.Position + vector, this._data.Firer.EngineObject.Forward, false, false); + } + } + bool triggerOnce = this._data.Result.LongAttackData.TriggerOnce; + if (triggerOnce) + { + this.OnOnceTriggered(); + } + } + + private void OnOnceTriggered() + { + bool triggerOnce = this._data.Result.LongAttackData.TriggerOnce; + if (triggerOnce) + { + bool isPingPong = this._data.Result.LongAttackData.IsPingPong; + if (isPingPong) + { + this.OnPingPong(); + } + else + { + this._active = false; + } + } + } + + private void Result(XEntity target, bool cycle = true) + { + bool demonstration = this._data.Demonstration; + if (!demonstration) + { + bool flag = target == null; + if (flag) + { + XSkill.SkillResult(this, this._bullet.Forward, this._bullet.Position, cycle); + } + else + { + bool flag2 = !this._data.Result.Attack_Only_Target || target == this._data.Target; + if (flag2) + { + bool syncMode = XSingleton.singleton.SyncMode; + if (syncMode) + { + bool triggerOnce = this._data.Result.LongAttackData.TriggerOnce; + if (triggerOnce) + { + this.OnOnceTriggered(); + } + } + else + { + Vector3 hitdir = target.EngineObject.Position - this._origin; + hitdir.y = 0f; + hitdir.Normalize(); + XSkill.SkillResult(this._data.Token, this._data.Firer, this._data.SkillCore, this, this._data.Sequnce, this._data.ResultID, this._data.ResultTime, hitdir, target); + } + bool triggerOnce2 = this._data.Result.LongAttackData.TriggerOnce; + if (triggerOnce2) + { + this._hit_triggered = true; + } + } + } + } + } + + public void Update(float fDeltaT) + { + bool flag = !this._active; + if (!flag) + { + this._elapsed += fDeltaT; + float num = 0f; + Vector3 vector = Vector3.forward; + switch (this._data.Result.LongAttackData.Type) + { + case XResultBulletType.Sphere: + case XResultBulletType.Plane: + num = ((this._elapsed > this._data.Running && this._elapsed < this._data.Life) ? 0f : this._data.Velocity) * fDeltaT; + vector = this._bullet.Forward; + break; + case XResultBulletType.Satellite: + { + bool flag2 = this._elapsed - fDeltaT <= XCommon.XEps; + if (flag2) + { + Vector3 position = this._data.Firer.EngineObject.Position + this._data.BulletRay.direction * this._data.Result.LongAttackData.RingRadius; + position.y = this._bullet.Position.y; + this._bullet.Position = position; + num = 0f; + vector = XSingleton.singleton.HorizontalRotateVetor3(this._data.Firer.MoveObj.Forward, (float)((this._data.Result.LongAttackData.Palstance < 0f) ? -90 : 90), true); + } + else + { + Vector3 vector2 = XSingleton.singleton.HorizontalRotateVetor3(this._data.BulletRay.direction, this._data.Result.LongAttackData.Palstance * (this._elapsed - fDeltaT), true) * this._data.Result.LongAttackData.RingRadius; + Vector3 vector3 = XSingleton.singleton.HorizontalRotateVetor3(this._data.BulletRay.direction, this._data.Result.LongAttackData.Palstance * this._elapsed, true) * this._data.Result.LongAttackData.RingRadius; + this._bullet.Forward = XSingleton.singleton.Horizontal(vector3 - vector2); + vector3 += this._data.Firer.EngineObject.Position; + Vector3 vector4 = vector3 - this._bullet.Position; + vector4.y = 0f; + num = vector4.magnitude; + vector = vector4.normalized; + } + break; + } + case XResultBulletType.Ring: + { + Vector3 position2 = this._data.Firer.EngineObject.Position; + position2.y = this._bullet.Position.y; + this._bullet.Position = position2; + break; + } + } + bool flag3 = this._data.Result.LongAttackData.IsPingPong && this._pingpong; + if (flag3) + { + bool flag4 = !this._data.Demonstration && !XEntity.ValideEntity(this._data.Firer); + if (flag4) + { + this._active = false; + return; + } + Vector3 vector5 = this._data.Firer.EngineObject.Position - this._bullet.Position; + vector5.y = 0f; + bool flag5 = num * num >= vector5.sqrMagnitude; + if (flag5) + { + this._active = false; + return; + } + vector = vector5.normalized; + } + else + { + bool flag6 = this._data.Result.LongAttackData.Follow && XEntity.ValideEntity(this._data.Target); + if (flag6) + { + vector = XSingleton.singleton.Horizontal(this._data.Target.EngineObject.Position - this._bullet.Position); + } + } + bool flag7 = this._data.Result.LongAttackData.Type != XResultBulletType.Satellite; + if (flag7) + { + this._bullet.Forward = vector; + } + Vector3 vector6 = vector * num; + this._origin = this._bullet.Position; + this._bullet.Position += vector6; + bool demonstration = this._data.Demonstration; + if (!demonstration) + { + float num2 = 0f; + bool flag8 = !XSingleton.singleton.TryGetTerrainY(this._bullet.Position, out num2); + if (flag8) + { + bool isPingPong = this._data.Result.LongAttackData.IsPingPong; + if (isPingPong) + { + this.OnPingPong(); + } + else + { + this._active = false; + } + } + else + { + bool staticCollider = this._data.Result.LongAttackData.StaticCollider; + if (staticCollider) + { + bool flag9 = num2 < 0f; + if (flag9) + { + bool isPingPong2 = this._data.Result.LongAttackData.IsPingPong; + if (isPingPong2) + { + this.OnPingPong(); + } + else + { + this._active = false; + } + return; + } + } + bool dynamicCollider = this._data.Result.LongAttackData.DynamicCollider; + if (dynamicCollider) + { + bool flag10 = !XSingleton.singleton.CheckDynamicBlock(this._origin, this._bullet.Position); + if (flag10) + { + bool isPingPong3 = this._data.Result.LongAttackData.IsPingPong; + if (isPingPong3) + { + this.OnPingPong(); + } + else + { + this._active = false; + } + return; + } + } + bool flag11 = !this._data.HasTarget; + if (flag11) + { + bool flyWithTerrain = this._data.FlyWithTerrain; + if (flyWithTerrain) + { + Vector3 position3 = this._bullet.Position; + position3.y = num2 + this._data.InitHeight; + this._bullet.Position = position3; + } + else + { + bool flag12 = Mathf.Abs(this._bullet.Position.y - num2) < 0.2f || num2 < 0f; + if (flag12) + { + this._active = false; + bool flag13 = !string.IsNullOrEmpty(this._data.Result.LongAttackData.HitGround_Fx); + if (flag13) + { + XFx xfx = XSingleton.singleton.CreateFx(this._data.Result.LongAttackData.HitGround_Fx, null, true); + xfx.DelayDestroy = this._data.Result.LongAttackData.HitGroundFx_LifeTime; + Quaternion rotation = this._bullet.Rotation; + rotation = XSingleton.singleton.RotateToGround(this._bullet.Position, this._bullet.Forward); + xfx.Play(this._bullet.Position, rotation, Vector3.one, 1f); + XSingleton.singleton.DestroyFx(xfx, false); + } + return; + } + } + vector6 = this._bullet.Position - this._origin; + } + bool syncMode = XSingleton.singleton.SyncMode; + if (!syncMode) + { + bool manipulation = this._data.Result.LongAttackData.Manipulation; + if (manipulation) + { + List opponent = XSingleton.singleton.GetOpponent(this._data.Firer); + Vector3 position4 = this._bullet.Position; + for (int i = 0; i < opponent.Count; i++) + { + XEntity xentity = opponent[i]; + bool flag14 = !XEntity.ValideEntity(xentity); + if (!flag14) + { + Vector3 vector7 = position4 - xentity.EngineObject.Position; + vector7.y = 0f; + bool flag15 = vector7.magnitude < this._data.Result.LongAttackData.ManipulationRadius; + if (flag15) + { + float num3 = this._data.Result.LongAttackData.ManipulationForce * fDeltaT; + xentity.ApplyMove(vector7.normalized * Mathf.Min(vector7.magnitude, num3)); + } + } + } + } + bool hit_triggered = this._hit_triggered; + if (!hit_triggered) + { + bool withCollision = this._data.Result.LongAttackData.WithCollision; + if (withCollision) + { + switch (this._data.Result.LongAttackData.Type) + { + case XResultBulletType.Sphere: + case XResultBulletType.Satellite: + { + Vector3 vector8; + vector8= new Vector3(vector6.x, 0f, vector6.z); + float num4 = vector8.magnitude * 0.5f; + vector.y = 0f; + float num5 = (vector.sqrMagnitude == 0f) ? 0f : Vector3.Angle(Vector3.right, vector); + bool flag16 = num5 > 0f && XSingleton.singleton.Clockwise(Vector3.right, vector); + if (flag16) + { + num5 = -num5; + } + XBullet.BulletCollideUnit(this._data.Firer, new Vector3(this._origin.x + vector.x * num4, 0f, this._origin.z + vector.z * num4), num4, num5, this._data.Radius, this); + break; + } + case XResultBulletType.Plane: + XBullet.PlaneBulletCollideUnit(this._data.Firer, this._origin, vector6, this._data.Radius, this); + break; + case XResultBulletType.Ring: + { + float num6 = XSingleton.singleton.IsGreater(this._elapsed, this._data.Life) ? 0f : (this._data.Result.LongAttackData.RingFull ? (XSingleton.singleton.IsGreater(this._elapsed, this._data.Life * 0.5f) ? (this._data.Life - this._elapsed) : this._elapsed) : this._elapsed); + float num7 = num6 * this._data.Result.LongAttackData.RingVelocity; + float or = num7 + this._data.Result.LongAttackData.RingRadius; + XBullet.RingBulletCollideUnit(this._data.Firer, num7, or, this); + break; + } + } + } + } + } + } + } + } + } + + private static void RingBulletCollideUnit(XEntity firer, float ir, float or, XBullet bullet) + { + Vector3 position = firer.EngineObject.Position; + List opponent = XSingleton.singleton.GetOpponent(firer); + for (int i = 0; i < opponent.Count; i++) + { + bool flag = !XEntity.ValideEntity(opponent[i]); + if (!flag) + { + bool flag2 = false; + bool flag3 = opponent[i].Present != null && opponent[i].Present.PresentLib.Huge; + if (flag3) + { + SeqListRef hugeMonsterColliders = opponent[i].Present.PresentLib.HugeMonsterColliders; + for (int j = 0; j < hugeMonsterColliders.Count; j++) + { + float num = hugeMonsterColliders[j, 2] * opponent[i].Scale; + Vector3 vector = opponent[i].HugeMonsterColliderCenter(j) - position; + vector.y = 0f; + float sqrMagnitude = vector.sqrMagnitude; + flag2 = (sqrMagnitude > ir * ir && sqrMagnitude < or * or); + bool flag4 = flag2; + if (flag4) + { + break; + } + } + } + else + { + Vector3 vector2 = opponent[i].RadiusCenter - position; + vector2.y = 0f; + float sqrMagnitude2 = vector2.sqrMagnitude; + flag2 = (sqrMagnitude2 > ir * ir && sqrMagnitude2 < or * or); + } + bool flag5 = flag2; + if (flag5) + { + bullet.Result(opponent[i], true); + } + bool flag6 = bullet.IsExpired(); + if (flag6) + { + break; + } + } + } + } + + private static void PlaneBulletCollideUnit(XEntity firer, Vector3 origin, Vector3 move, float r, XBullet bullet) + { + Vector3 vector = XSingleton.singleton.HorizontalRotateVetor3(move, 90f, true); + Vector3 q = origin + vector * r; + Vector3 q2 = origin - vector * r; + List opponent = XSingleton.singleton.GetOpponent(firer); + for (int i = 0; i < opponent.Count; i++) + { + bool flag = !XEntity.ValideEntity(opponent[i]); + if (!flag) + { + bool flag2 = false; + bool flag3 = opponent[i].Present != null && opponent[i].Present.PresentLib.Huge; + if (flag3) + { + SeqListRef hugeMonsterColliders = opponent[i].Present.PresentLib.HugeMonsterColliders; + for (int j = 0; j < hugeMonsterColliders.Count; j++) + { + float num = hugeMonsterColliders[j, 2] * opponent[i].Scale; + Vector3 vector2 = opponent[i].HugeMonsterColliderCenter(j); + flag2 = XSingleton.singleton.IsLineSegmentCross(vector2, vector2 - move, q, q2); + bool flag4 = flag2; + if (flag4) + { + break; + } + } + } + else + { + Vector3 radiusCenter = opponent[i].RadiusCenter; + flag2 = XSingleton.singleton.IsLineSegmentCross(radiusCenter, radiusCenter - move, q, q2); + } + bool flag5 = flag2; + if (flag5) + { + bullet.Result(opponent[i], true); + } + bool flag6 = bullet.IsExpired(); + if (flag6) + { + break; + } + } + } + } + + private static void BulletCollideUnit(XEntity firer, Vector3 rectcenter, float hlen, float rotation, float r, XBullet bullet) + { + List opponent = XSingleton.singleton.GetOpponent(firer); + for (int i = 0; i < opponent.Count; i++) + { + bool flag = !XEntity.ValideEntity(opponent[i]); + if (!flag) + { + bool flag2 = false; + bool flag3 = opponent[i].Present != null && opponent[i].Present.PresentLib.Huge; + if (flag3) + { + SeqListRef hugeMonsterColliders = opponent[i].Present.PresentLib.HugeMonsterColliders; + for (int j = 0; j < hugeMonsterColliders.Count; j++) + { + float num = hugeMonsterColliders[j, 2] * opponent[i].Scale; + Vector3 vector = opponent[i].HugeMonsterColliderCenter(j); + vector -= rectcenter; + vector.y = 0f; + flag2 = XSingleton.singleton.IsRectCycleCross(hlen, r, vector, num); + bool flag4 = !flag2; + if (flag4) + { + float num2 = num; + float magnitude = vector.magnitude; + flag2 = (magnitude - num2 < r); + } + bool flag5 = flag2; + if (flag5) + { + break; + } + } + } + else + { + Vector3 vector2 = opponent[i].RadiusCenter; + vector2 -= rectcenter; + vector2.y = 0f; + vector2 = XSingleton.singleton.HorizontalRotateVetor3(vector2, rotation, false); + flag2 = XSingleton.singleton.IsRectCycleCross(hlen, r, vector2, opponent[i].Radius); + bool flag6 = !flag2; + if (flag6) + { + float radius = opponent[i].Radius; + float magnitude2 = vector2.magnitude; + flag2 = (magnitude2 - radius < r); + } + } + bool flag7 = flag2; + if (flag7) + { + bullet.Result(opponent[i], true); + } + bool flag8 = bullet.IsExpired(); + if (flag8) + { + break; + } + } + } + } + } +} -- cgit v1.1-26-g67d0