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C HUULCHM5GFGZ7GKLCULFHC333LQ3LBI62VKII3YL5O4C5CDGCT4AC WKHLLZ3K732M7VJ5KWDSLRWZUARDNDP6ODAXD6SW43CHCT5DX5SAC VZRSH4U473FCZOP5EXURPXXN5J6F3ZLT435YY7A2JHLG2ZZB5KLQC RJXFDWT7OWTX3DQ7SBJFK6M66AQ2LGGIO32QD6G7VTJJS7U2R7XQC MML56TWYWB6SUY5JEWHG2PNLAH3JY72PGCEXIGOYE54EAC2WSWBAC FNS4LRFQNFM4BCB23CYHOWA2N4MG2DEUMNK6D55BQ26TX6OJLIBQC R475KN7MR3OG7EBLVNOO7QRIKXDGY2PIDXXV3HW4KBD5QM7B5OJQC HDXZWK64UDKEV5JBETQK6KMT5RXW5XPDU3YY4HLBCGP5XA6727BQC DTKCWM4J7PFNWAAES3RZHQGDA6PTDNX4TZVOXAKF5V7LCZBI3XUAC P5O6MKCMZL3DK7ZO5SBWTCHOQB6O2MZA5VPSCQX6X4LJQVOWYV7AC MDJQTAONL4M7SFFORMXLJHA7WBDTDTRZAZ544JR23SODSCWSVZ3AC HXTSBPAP75A7EC4RKWYQMVPPHPNZFPHUORBZWDHGEB6MPAGI7G7AC G4XIS2NEM4WHRP2775YBCLFDT7JZZS52CMEHY3PA43QSXL45XNDAC using System.Collections;using UnityEngine;public class EffectSystem{ParticleSystem _rippleOutVfx;const string PulseMaterial = "Materials/PulseMaterial2";class EffectRunner : MonoBehaviour{public GameObject EffectObj;public Material Material;public float PlayTime;public void Run(GameObject effectObj, Material material, float playTime) {EffectObj = effectObj;Material = material;PlayTime = playTime;Material.SetFloat("_Phase", 0);EffectObj.SetActive(true);StartCoroutine("PlayEffect");}public IEnumerator PlayEffect() {float totalTime = 0;float phase = 0;while (phase < 0.98) {totalTime += Time.deltaTime;phase = totalTime / PlayTime;Material.SetFloat("_Phase", phase);yield return null;}Destroy(EffectObj);}}public EffectSystem(ParticleSystem rippleOutVfx) {_rippleOutVfx = rippleOutVfx;}public void ApplyTagsEffect(TagCounter tags, Transform origin, Quaternion direction, IAreaOfEffect areaOfEffect) {switch (areaOfEffect) {case SingleTarget: ApplyTagsEffectSingle(); break;case CircleArea aoe: ApplyTagsEffectRadius(tags, origin, direction, aoe); break;case ConeArea aoe: ApplyTagsEffectCone(tags, origin, direction, aoe); break;case PathArea aoe: ApplyTagsEffectPath(tags, origin, direction, aoe); break;}}void ApplyTagsEffectSingle() {Debug.Log("ApplyTagsEffectSingle");}void ApplyTagsEffectPath(TagCounter tags, Transform origin, Quaternion direction, PathArea areaOfEffect) {var color = GetEffectColor(tags);var mesh = CreateQuadMeshForUnit(origin, areaOfEffect.Width, areaOfEffect.Length);// Add a new to clone the shared resourceMaterial material = new(Resources.Load<Material>(PulseMaterial));material.SetColor("_Color", color);DisplayEffect(origin, direction, mesh, material);}void ApplyTagsEffectRadius(TagCounter tags, Transform origin, Quaternion direction, CircleArea areaOfEffect) {var color = GetEffectColor(tags);var mesh = CreateArcMeshForUnit(origin, 360, areaOfEffect.Radius);// Add a new to clone the shared resourceMaterial material = new(Resources.Load<Material>(PulseMaterial));material.SetColor("_Color", color);DisplayEffect(origin, direction, mesh, material);}void ApplyTagsEffectCone(TagCounter tags, Transform origin, Quaternion direction, ConeArea areaOfEffect) {Debug.Log("ApplyTagsEffectCone");var color = GetEffectColor(tags);var mesh = CreateArcMeshForUnit(origin, areaOfEffect.Angle, areaOfEffect.Radius);// Add a new to clone the shared resourceMaterial material = new(Resources.Load<Material>(PulseMaterial));material.SetColor("_Color", color);DisplayEffect(origin, direction, mesh, material);}public Color GetEffectColor(TagCounter tags) {var total = tags[TagColor.Red] + tags[TagColor.Green] + tags[TagColor.Blue];var red = tags[TagColor.Red] / total;var green = tags[TagColor.Green] / total;var blue = tags[TagColor.Blue] / total;Color color = new(red, green, blue);return color;}public Mesh CreateArcMeshForUnit(Transform unit, float arc, float length, int numberOfVerticesInArc = 100) {return CreateArcMesh(unit.forward, arc, length, numberOfVerticesInArc, Vector3.up);}public Mesh CreateQuadMeshForUnit(Transform unit, float width, float length) {return CreateQuadMesh(unit.forward, width, length, Vector3.up);}void DisplayEffect(Transform originUnit, Quaternion direction, Mesh mesh, Material material) {GameObject effectObj = new();effectObj.SetActive(false);effectObj.transform.position = originUnit.position;effectObj.transform.rotation = direction;var meshRenderer = effectObj.AddComponent<MeshRenderer>();meshRenderer.sharedMaterial = material;meshRenderer.shadowCastingMode = 0;meshRenderer.receiveShadows = false;var meshFilter = effectObj.AddComponent<MeshFilter>();meshFilter.mesh = mesh;effectObj.AddComponent<EffectRunner>();var effectRunner = effectObj.GetComponent<EffectRunner>();effectRunner.Run(effectObj, material, 1f);}public static Mesh CreateArcMesh(Vector3 direction, float arc, float length, int numberOfVerticesInArc, Vector3 rotationAxis) {var origin = Vector3.zero;Mesh mesh = new();var n = numberOfVerticesInArc + 1;var arcStep = arc / (n - 2);var currentDegrees = -arc / 2;var vertices = new Vector3[n];var uv = new Vector2[n];vertices[0] = origin;uv[0] = origin;for (var i = 1; i < n; i++) {vertices[i] = Quaternion.AngleAxis(currentDegrees, rotationAxis) * direction * length;uv[i] = new Vector2(0, 1);//Debug.Log($"Current Degrees: {currentDegrees} -> {vertices[i]}");currentDegrees += arcStep;}mesh.vertices = vertices;mesh.uv = uv;var tris = new int[(n - 2) * 3];for (var i = 0; i < n - 2; i++) {tris[i * 3] = 0;tris[i * 3 + 1] = i + 1;tris[i * 3 + 2] = i + 2;}mesh.triangles = tris;var normals = new Vector3[n];for (var i = 0; i < n; i++) {normals[i] = rotationAxis;}mesh.normals = normals;return mesh;}public static Mesh CreateQuadMesh(Vector3 direction, float width, float length, Vector3 rotationAxis) {Mesh mesh = new();var origin = Vector3.zero;// TODO: how to calculate local rotation? directionvar vertices = new Vector3[4]{new Vector3(-width/2, 0, 0) + origin,new Vector3(width/2, 0, 0) + origin,new Vector3(-width/2, 0, length) + origin,new Vector3(width/2, 0, length) + origin};mesh.vertices = vertices;var tris = new int[6]{// lower left triangle0, 2, 1,// upper right triangle2, 3, 1};mesh.triangles = tris;var normals = new Vector3[4]{rotationAxis,rotationAxis,rotationAxis,rotationAxis};mesh.normals = normals;var uv = new Vector2[4]{new Vector2(0, 0),new Vector2(1, 0),new Vector2(0, 1),new Vector2(1, 1)};mesh.uv = uv;return mesh;}}
fileFormatVersion: 2guid: 68ef7d8accbc2c448858818eb93bfff8MonoImporter:externalObjects: {}serializedVersion: 2defaultReferences: []executionOrder: 0icon: {instanceID: 0}userData:assetBundleName:assetBundleVariant:
_effectSystem.ApplyTagsEffect(new TagCounter() { }, _affected, _affected.transform.rotation, new CircleArea() { Radius = 15 });
SystemsHandler.EffectSystem.ApplyTagsEffect(new TagCounter() { }, _affected, _affected.transform.rotation, new CircleArea() { Radius = 15 });
fileFormatVersion: 2guid: 505d231857f821246ad1c5b1714052f2folderAsset: yesDefaultImporter:externalObjects: {}userData:assetBundleName:assetBundleVariant:
fileFormatVersion: 2guid: 49bfcc18316645b47bde84d7a4d06abfMonoImporter:externalObjects: {}serializedVersion: 2defaultReferences: []executionOrder: 0icon: {instanceID: 0}userData:assetBundleName:assetBundleVariant:
using System.Collections;using System.Collections.Generic;using CareBoo.Serially;using UnityEngine;public class SystemsHandler : MonoBehaviour{[SerializeReference, ShowSerializeReference]IEffectSystem effectSystem = new DummyEffectSystem();static SystemsHandler handler;public static IEffectSystem EffectSystem {get {return handler.effectSystem;}}void Awake() {handler = this;}// Start is called before the first frame updatevoid Start() {}// Update is called once per framevoid Update() {}}
fileFormatVersion: 2guid: 3b2111d1246c92149a6a62655a645a02folderAsset: yesDefaultImporter:externalObjects: {}userData:assetBundleName:assetBundleVariant:
fileFormatVersion: 2guid: 88607fefd2d11e643afc852559e862c2MonoImporter:externalObjects: {}serializedVersion: 2defaultReferences: []executionOrder: 0icon: {instanceID: 0}userData:assetBundleName:assetBundleVariant:
using UnityEngine;public interface IEffectSystem{void ApplyTagsEffect(TagCounter tags, Transform origin, Quaternion direction, IAreaOfEffect areaOfEffect);Color GetEffectColor(TagCounter tags);Mesh CreateArcMesh(Vector3 direction, float arc, float length, int numberOfVerticesInArc, Vector3 rotationAxis);Mesh CreateQuadMesh(Vector3 direction, float width, float length, Vector3 rotationAxis);}
fileFormatVersion: 2guid: 68ef7d8accbc2c448858818eb93bfff8MonoImporter:externalObjects: {}serializedVersion: 2defaultReferences: []executionOrder: 0icon: {instanceID: 0}userData:assetBundleName:assetBundleVariant:
using System;using System.Collections;using UnityEngine;[Serializable]public class EffectSystem : IEffectSystem{ParticleSystem _rippleOutVfx;const string PulseMaterial = "Materials/PulseMaterial2";class EffectRunner : MonoBehaviour{public GameObject EffectObj;public Material Material;public float PlayTime;public void Run(GameObject effectObj, Material material, float playTime) {EffectObj = effectObj;Material = material;PlayTime = playTime;Material.SetFloat("_Phase", 0);EffectObj.SetActive(true);StartCoroutine("PlayEffect");}public IEnumerator PlayEffect() {float totalTime = 0;float phase = 0;while (phase < 0.98) {totalTime += Time.deltaTime;phase = totalTime / PlayTime;Material.SetFloat("_Phase", phase);yield return null;}Destroy(EffectObj);}}public EffectSystem() {}public void ApplyTagsEffect(TagCounter tags, Transform origin, Quaternion direction, IAreaOfEffect areaOfEffect) {switch (areaOfEffect) {case SingleTarget: ApplyTagsEffectSingle(); break;case CircleArea aoe: ApplyTagsEffectRadius(tags, origin, direction, aoe); break;case ConeArea aoe: ApplyTagsEffectCone(tags, origin, direction, aoe); break;case PathArea aoe: ApplyTagsEffectPath(tags, origin, direction, aoe); break;}}void ApplyTagsEffectSingle() {Debug.Log("ApplyTagsEffectSingle");}void ApplyTagsEffectPath(TagCounter tags, Transform origin, Quaternion direction, PathArea areaOfEffect) {var color = GetEffectColor(tags);var mesh = CreateQuadMeshForUnit(origin, areaOfEffect.Width, areaOfEffect.Length);// Add a new to clone the shared resourceMaterial material = new(Resources.Load<Material>(PulseMaterial));material.SetColor("_Color", color);DisplayEffect(origin, direction, mesh, material);}void ApplyTagsEffectRadius(TagCounter tags, Transform origin, Quaternion direction, CircleArea areaOfEffect) {var color = GetEffectColor(tags);var mesh = CreateArcMeshForUnit(origin, 360, areaOfEffect.Radius);// Add a new to clone the shared resourceMaterial material = new(Resources.Load<Material>(PulseMaterial));material.SetColor("_Color", color);DisplayEffect(origin, direction, mesh, material);}void ApplyTagsEffectCone(TagCounter tags, Transform origin, Quaternion direction, ConeArea areaOfEffect) {Debug.Log("ApplyTagsEffectCone");var color = GetEffectColor(tags);var mesh = CreateArcMeshForUnit(origin, areaOfEffect.Angle, areaOfEffect.Radius);// Add a new to clone the shared resourceMaterial material = new(Resources.Load<Material>(PulseMaterial));material.SetColor("_Color", color);DisplayEffect(origin, direction, mesh, material);}public Color GetEffectColor(TagCounter tags) {var total = tags[TagColor.Red] + tags[TagColor.Green] + tags[TagColor.Blue];var red = tags[TagColor.Red] / total;var green = tags[TagColor.Green] / total;var blue = tags[TagColor.Blue] / total;Color color = new(red, green, blue);return color;}public Mesh CreateArcMeshForUnit(Transform unit, float arc, float length, int numberOfVerticesInArc = 100) {return CreateArcMesh(unit.forward, arc, length, numberOfVerticesInArc, Vector3.up);}public Mesh CreateQuadMeshForUnit(Transform unit, float width, float length) {return CreateQuadMesh(unit.forward, width, length, Vector3.up);}void DisplayEffect(Transform originUnit, Quaternion direction, Mesh mesh, Material material) {GameObject effectObj = new();effectObj.SetActive(false);effectObj.transform.position = originUnit.position;effectObj.transform.rotation = direction;var meshRenderer = effectObj.AddComponent<MeshRenderer>();meshRenderer.sharedMaterial = material;meshRenderer.shadowCastingMode = 0;meshRenderer.receiveShadows = false;var meshFilter = effectObj.AddComponent<MeshFilter>();meshFilter.mesh = mesh;effectObj.AddComponent<EffectRunner>();var effectRunner = effectObj.GetComponent<EffectRunner>();effectRunner.Run(effectObj, material, 1f);}public Mesh CreateArcMesh(Vector3 direction, float arc, float length, int numberOfVerticesInArc, Vector3 rotationAxis) {var origin = Vector3.zero;Mesh mesh = new();var n = numberOfVerticesInArc + 1;var arcStep = arc / (n - 2);var currentDegrees = -arc / 2;var vertices = new Vector3[n];var uv = new Vector2[n];vertices[0] = origin;uv[0] = origin;for (var i = 1; i < n; i++) {vertices[i] = Quaternion.AngleAxis(currentDegrees, rotationAxis) * direction * length;uv[i] = new Vector2(0, 1);//Debug.Log($"Current Degrees: {currentDegrees} -> {vertices[i]}");currentDegrees += arcStep;}mesh.vertices = vertices;mesh.uv = uv;var tris = new int[(n - 2) * 3];for (var i = 0; i < n - 2; i++) {tris[i * 3] = 0;tris[i * 3 + 1] = i + 1;tris[i * 3 + 2] = i + 2;}mesh.triangles = tris;var normals = new Vector3[n];for (var i = 0; i < n; i++) {normals[i] = rotationAxis;}mesh.normals = normals;return mesh;}public Mesh CreateQuadMesh(Vector3 direction, float width, float length, Vector3 rotationAxis) {Mesh mesh = new();var origin = Vector3.zero;// TODO: how to calculate local rotation? directionvar vertices = new Vector3[4]{new Vector3(-width/2, 0, 0) + origin,new Vector3(width/2, 0, 0) + origin,new Vector3(-width/2, 0, length) + origin,new Vector3(width/2, 0, length) + origin};mesh.vertices = vertices;var tris = new int[6]{// lower left triangle0, 2, 1,// upper right triangle2, 3, 1};mesh.triangles = tris;var normals = new Vector3[4]{rotationAxis,rotationAxis,rotationAxis,rotationAxis};mesh.normals = normals;var uv = new Vector2[4]{new Vector2(0, 0),new Vector2(1, 0),new Vector2(0, 1),new Vector2(1, 1)};mesh.uv = uv;return mesh;}}
fileFormatVersion: 2guid: 0200192b4aba80842a33c02b90ec0a75MonoImporter:externalObjects: {}serializedVersion: 2defaultReferences: []executionOrder: 0icon: {instanceID: 0}userData:assetBundleName:assetBundleVariant:
using UnityEngine;class DummyEffectSystem : IEffectSystem{public void ApplyTagsEffect(TagCounter tags, Transform origin, Quaternion direction, IAreaOfEffect areaOfEffect) {Debug.Log("Dummy:ApplyTagsEffect");}public Color GetEffectColor(TagCounter tags) {Debug.Log("Dummy:GetEffectColor");return Color.cyan;}public Mesh CreateArcMesh(Vector3 direction, float arc, float length, int numberOfVerticesInArc, Vector3 rotationAxis) {Debug.Log("Dummy:CreateArcMesh");return null;}public Mesh CreateQuadMesh(Vector3 direction, float width, float length, Vector3 rotationAxis) {Debug.Log("Dummy:CreateQuadMesh");return null;}}
--- !u!1 &265760079GameObject:m_ObjectHideFlags: 0m_CorrespondingSourceObject: {fileID: 0}m_PrefabInstance: {fileID: 0}m_PrefabAsset: {fileID: 0}serializedVersion: 6m_Component:- component: {fileID: 265760081}- component: {fileID: 265760080}m_Layer: 0m_Name: Systemsm_TagString: Untaggedm_Icon: {fileID: 0}m_NavMeshLayer: 0m_StaticEditorFlags: 0m_IsActive: 1--- !u!114 &265760080MonoBehaviour:m_ObjectHideFlags: 0m_CorrespondingSourceObject: {fileID: 0}m_PrefabInstance: {fileID: 0}m_PrefabAsset: {fileID: 0}m_GameObject: {fileID: 265760079}m_Enabled: 1m_EditorHideFlags: 0m_Script: {fileID: 11500000, guid: 49bfcc18316645b47bde84d7a4d06abf, type: 3}m_Name:m_EditorClassIdentifier:effectSystem:rid: 412932756796342272references:version: 2RefIds:- rid: 412932756796342272type: {class: EffectSystem, ns: , asm: Assembly-CSharp}--- !u!4 &265760081Transform:m_ObjectHideFlags: 0m_CorrespondingSourceObject: {fileID: 0}m_PrefabInstance: {fileID: 0}m_PrefabAsset: {fileID: 0}m_GameObject: {fileID: 265760079}m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}m_LocalPosition: {x: 0, y: 0, z: 0}m_LocalScale: {x: 1, y: 1, z: 1}m_ConstrainProportionsScale: 0m_Children: []m_Father: {fileID: 0}m_RootOrder: 17m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}