| using System; |
| using System; |
| using System.Collections.Generic; |
| using System.Collections.Generic; |
| using UnityEngine; |
| using UnityEngine; |
| |
| |
| public class EffectArea : MonoBehaviour |
| public class EffectArea : MonoBehaviour |
| { |
| { |
| private void Awake() |
| private void Awake() |
| { |
| { |
| if (!string.IsNullOrEmpty(this.m_statusEffect)) |
| if (!string.IsNullOrEmpty(this.m_statusEffect)) |
| { |
| { |
| this.m_statusEffectHash = this.m_statusEffect.GetStableHashCode(); |
| this.m_statusEffectHash = this.m_statusEffect.GetStableHashCode(); |
| } |
| } |
| if (EffectArea.s_characterMask == 0) |
| if (EffectArea.s_characterMask == 0) |
| { |
| { |
| EffectArea.s_characterMask = LayerMask.GetMask(new string[] { "character_trigger" }); |
| EffectArea.s_characterMask = LayerMask.GetMask(new string[] { "character_trigger" }); |
| } |
| } |
| this.m_collider = base.GetComponent<Collider>(); |
| this.m_collider = base.GetComponent<Collider>(); |
| . | |
| this.m_collider.isTrigger = true; |
| if ((this.m_type & EffectArea.Type.NoMonsters) != EffectArea.Type.None) |
| if ((this.m_type & EffectArea.Type.NoMonsters) != EffectArea.Type.None) |
| { |
| { |
| this.noMonsterArea = new KeyValuePair<Bounds, EffectArea>(this.m_collider.bounds, this); |
| this.noMonsterArea = new KeyValuePair<Bounds, EffectArea>(this.m_collider.bounds, this); |
| EffectArea.s_noMonsterAreas.Add(this.noMonsterArea); |
| EffectArea.s_noMonsterAreas.Add(this.noMonsterArea); |
| Bounds bounds = this.m_collider.bounds; |
| Bounds bounds = this.m_collider.bounds; |
| bounds.Expand(new Vector3(15f, 15f, 15f)); |
| bounds.Expand(new Vector3(15f, 15f, 15f)); |
| this.noMonsterCloseToArea = new KeyValuePair<Bounds, EffectArea>(bounds, this); |
| this.noMonsterCloseToArea = new KeyValuePair<Bounds, EffectArea>(bounds, this); |
| EffectArea.s_noMonsterCloseToAreas.Add(this.noMonsterCloseToArea); |
| EffectArea.s_noMonsterCloseToAreas.Add(this.noMonsterCloseToArea); |
| } |
| } |
| EffectArea.s_allAreas.Add(this); |
| EffectArea.s_allAreas.Add(this); |
| } |
| } |
| |
| |
| private void OnDestroy() |
| private void OnDestroy() |
| { |
| { |
| EffectArea.s_allAreas.Remove(this); |
| EffectArea.s_allAreas.Remove(this); |
| if (EffectArea.s_noMonsterAreas.Contains(this.noMonsterArea)) |
| if (EffectArea.s_noMonsterAreas.Contains(this.noMonsterArea)) |
| { |
| { |
| EffectArea.s_noMonsterAreas.Remove(this.noMonsterArea); |
| EffectArea.s_noMonsterAreas.Remove(this.noMonsterArea); |
| } |
| } |
| if (EffectArea.s_noMonsterCloseToAreas.Contains(this.noMonsterCloseToArea)) |
| if (EffectArea.s_noMonsterCloseToAreas.Contains(this.noMonsterCloseToArea)) |
| { |
| { |
| EffectArea.s_noMonsterCloseToAreas.Remove(this.noMonsterCloseToArea); |
| EffectArea.s_noMonsterCloseToAreas.Remove(this.noMonsterCloseToArea); |
| } |
| } |
| } |
| } |
| |
| |
| private void OnTriggerStay(Collider collider) |
| private void OnTriggerStay(Collider collider) |
| { |
| { |
| if (ZNet.instance == null) |
| if (ZNet.instance == null) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| Character component = collider.GetComponent<Character>(); |
| Character component = collider.GetComponent<Character>(); |
| if (component && component.IsOwner()) |
| if (component && component.IsOwner()) |
| { |
| { |
| if (this.m_playerOnly && !component.IsPlayer()) |
| if (this.m_playerOnly && !component.IsPlayer()) |
| { |
| { |
| return; |
| return; |
| } |
| } |
| if (!string.IsNullOrEmpty(this.m_statusEffect)) |
| if (!string.IsNullOrEmpty(this.m_statusEffect)) |
| { |
| { |
| component.GetSEMan().AddStatusEffect(this.m_statusEffectHash, true, 0, 0f); |
| component.GetSEMan().AddStatusEffect(this.m_statusEffectHash, true, 0, 0f); |
| } |
| } |
| if ((this.m_type & EffectArea.Type.Heat) != EffectArea.Type.None) |
| if ((this.m_type & EffectArea.Type.Heat) != EffectArea.Type.None) |
| { |
| { |
| component.OnNearFire(base.transform.position); |
| component.OnNearFire(base.transform.position); |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| |
| public float GetRadius() |
| public float GetRadius() |
| { |
| { |
| . | SphereCollider sphereCollider = this.m_collider as SphereCollider; |
| Collider collider = this.m_collider; |
| if (sphereCollider != null) |
| SphereCollider sphereCollider = collider as SphereCollider; |
| |
| float num; |
| |
| if (sphereCollider == null) |
| { |
| { |
| . | return sphereCollider.radius; |
| CapsuleCollider capsuleCollider = collider as CapsuleCollider; |
| |
| if (capsuleCollider == null) |
| |
| { |
| |
| num = this.m_collider.bounds.size.magnitude; |
| |
| } |
| |
| else |
| |
| { |
| |
| num = capsuleCollider.radius; |
| |
| } |
| |
| } |
| |
| else |
| |
| { |
| |
| num = sphereCollider.radius; |
| } |
| } |
| . | return this.m_collider.bounds.size.magnitude; |
| return num; |
| } |
| } |
| |
| |
| public static EffectArea IsPointInsideNoMonsterArea(Vector3 p) |
| public static EffectArea IsPointInsideNoMonsterArea(Vector3 p) |
| { |
| { |
| foreach (KeyValuePair<Bounds, EffectArea> keyValuePair in EffectArea.s_noMonsterAreas) |
| foreach (KeyValuePair<Bounds, EffectArea> keyValuePair in EffectArea.s_noMonsterAreas) |
| { |
| { |
| if (keyValuePair.Key.Contains(p)) |
| if (keyValuePair.Key.Contains(p)) |
| { |
| { |
| return keyValuePair.Value; |
| return keyValuePair.Value; |
| } |
| } |
| } |
| } |
| return null; |
| return null; |
| } |
| } |
| |
| |
| public static EffectArea IsPointCloseToNoMonsterArea(Vector3 p) |
| public static EffectArea IsPointCloseToNoMonsterArea(Vector3 p) |
| { |
| { |
| foreach (KeyValuePair<Bounds, EffectArea> keyValuePair in EffectArea.s_noMonsterCloseToAreas) |
| foreach (KeyValuePair<Bounds, EffectArea> keyValuePair in EffectArea.s_noMonsterCloseToAreas) |
| { |
| { |
| if (keyValuePair.Key.Contains(p)) |
| if (keyValuePair.Key.Contains(p)) |
| { |
| { |
| return keyValuePair.Value; |
| return keyValuePair.Value; |
| } |
| } |
| } |
| } |
| return null; |
| return null; |
| } |
| } |
| |
| |
| public static EffectArea IsPointInsideArea(Vector3 p, EffectArea.Type type, float radius = 0f) |
| public static EffectArea IsPointInsideArea(Vector3 p, EffectArea.Type type, float radius = 0f) |
| { |
| { |
| int num = Physics.OverlapSphereNonAlloc(p, radius, EffectArea.m_tempColliders, EffectArea.s_characterMask); |
| int num = Physics.OverlapSphereNonAlloc(p, radius, EffectArea.m_tempColliders, EffectArea.s_characterMask); |
| for (int i = 0; i < num; i++) |
| for (int i = 0; i < num; i++) |
| { |
| { |
| EffectArea component = EffectArea.m_tempColliders[i].GetComponent<EffectArea>(); |
| EffectArea component = EffectArea.m_tempColliders[i].GetComponent<EffectArea>(); |
| if (component && (component.m_type & type) != EffectArea.Type.None) |
| if (component && (component.m_type & type) != EffectArea.Type.None) |
| { |
| { |
| return component; |
| return component; |
| } |
| } |
| } |
| } |
| return null; |
| return null; |
| } |
| } |
| |
| |
| public static int GetBaseValue(Vector3 p, float radius) |
| public static int GetBaseValue(Vector3 p, float radius) |
| { |
| { |
| int num = 0; |
| int num = 0; |
| int num2 = Physics.OverlapSphereNonAlloc(p, radius, EffectArea.m_tempColliders, EffectArea.s_characterMask); |
| int num2 = Physics.OverlapSphereNonAlloc(p, radius, EffectArea.m_tempColliders, EffectArea.s_characterMask); |
| for (int i = 0; i < num2; i++) |
| for (int i = 0; i < num2; i++) |
| { |
| { |
| EffectArea component = EffectArea.m_tempColliders[i].GetComponent<EffectArea>(); |
| EffectArea component = EffectArea.m_tempColliders[i].GetComponent<EffectArea>(); |
| if (component && (component.m_type & EffectArea.Type.PlayerBase) != EffectArea.Type.None) |
| if (component && (component.m_type & EffectArea.Type.PlayerBase) != EffectArea.Type.None) |
| { |
| { |
| num++; |
| num++; |
| } |
| } |
| } |
| } |
| return num; |
| return num; |
| } |
| } |
| |
| |
| public static List<EffectArea> GetAllAreas() |
| public static List<EffectArea> GetAllAreas() |
| { |
| { |
| return EffectArea.s_allAreas; |
| return EffectArea.s_allAreas; |
| } |
| } |
| |
| |
| private KeyValuePair<Bounds, EffectArea> noMonsterArea; |
| private KeyValuePair<Bounds, EffectArea> noMonsterArea; |
| |
| |
| private KeyValuePair<Bounds, EffectArea> noMonsterCloseToArea; |
| private KeyValuePair<Bounds, EffectArea> noMonsterCloseToArea; |
| |
| |
| [BitMask(typeof(EffectArea.Type))] |
| [BitMask(typeof(EffectArea.Type))] |
| public EffectArea.Type m_type; |
| public EffectArea.Type m_type; |
| |
| |
| public string m_statusEffect = ""; |
| public string m_statusEffect = ""; |
| |
| |
| public bool m_playerOnly; |
| public bool m_playerOnly; |
| |
| |
| private int m_statusEffectHash; |
| private int m_statusEffectHash; |
| |
| |
| private Collider m_collider; |
| private Collider m_collider; |
| |
| |
| private static int s_characterMask = 0; |
| private static int s_characterMask = 0; |
| |
| |
| private static readonly List<EffectArea> s_allAreas = new List<EffectArea>(); |
| private static readonly List<EffectArea> s_allAreas = new List<EffectArea>(); |
| |
| |
| private static readonly List<KeyValuePair<Bounds, EffectArea>> s_noMonsterAreas = new List<KeyValuePair<Bounds, EffectArea>>(); |
| private static readonly List<KeyValuePair<Bounds, EffectArea>> s_noMonsterAreas = new List<KeyValuePair<Bounds, EffectArea>>(); |
| |
| |
| private static readonly List<KeyValuePair<Bounds, EffectArea>> s_noMonsterCloseToAreas = new List<KeyValuePair<Bounds, EffectArea>>(); |
| private static readonly List<KeyValuePair<Bounds, EffectArea>> s_noMonsterCloseToAreas = new List<KeyValuePair<Bounds, EffectArea>>(); |
| |
| |
| private static Collider[] m_tempColliders = new Collider[128]; |
| private static Collider[] m_tempColliders = new Collider[128]; |
| |
| |
| [Flags] |
| [Flags] |
| public enum Type : byte |
| public enum Type : byte |
| { |
| { |
| None = 0, |
| None = 0, |
| Heat = 1, |
| Heat = 1, |
| Fire = 2, |
| Fire = 2, |
| PlayerBase = 4, |
| PlayerBase = 4, |
| Burning = 8, |
| Burning = 8, |
| Teleport = 16, |
| Teleport = 16, |
| NoMonsters = 32, |
| NoMonsters = 32, |
| WarmCozyArea = 64, |
| WarmCozyArea = 64, |
| PrivateProperty = 128 |
| PrivateProperty = 128 |
| } |
| } |
| } |
| } |
| |
| |