W42U55HSXS45MZUEXGCSKLO5UV4CWBQN2IZPCKZPWPDSB56FVZDAC
5RAC3VW5PWOW2WPB2G2EF6PBFYMBSRKQ4HM2PQZWEIQMOKCQSK2AC
X6CHZAXRC53ABZQSK5QK5PP3QTNJOSGRFGJHNEQBLRSD2UB32AFQC
7BZ73FLUK5ANK44V7EMAROTHHVE2IGJ65GTA26DRWY65566HMNPAC
7QKPEDFDFQJFTXM4BFJ4CFHOOZKOI6NKRRSBDLMP7SELPJMFOQRAC
3UN6NREN32ZBQW4EWI7ED4WVQILCU2EIE7DQGFWZR3OUDCO3ZSPQC
DTKCWM4J7PFNWAAES3RZHQGDA6PTDNX4TZVOXAKF5V7LCZBI3XUAC
JAZ27QX53QXAN4JVMMX2KYKN4GCULWFMXYSPFZ5HWW4T7FUB5EHAC
3AONCSBYJ6T2HXAZFLCJGGV6SRNYJW3PEJ5GMGN3FYB2NGPVIQIQC
EISA46SXVFL3UEYJBHVU4RFWKRU5ZJNN7Q7ATAYKCTSAMSPLL7RAC
D4K77RTIZUI46DIDLVOR42DW3EP6IOMEAASAPZQ5XA2J7GEYFQIAC
IXGU2SOXBCQYBV3S5EHZFEFJKSCVUQPVZ3NY7KPG2UHWTEVGRZCAC
CD5FF75KTOBTMVMTMCKMR6F5DFKOF26I5K43ITNHGBI3ZAZHA4RAC
HXTSBPAP75A7EC4RKWYQMVPPHPNZFPHUORBZWDHGEB6MPAGI7G7AC
AZN3UTBQLTKMGIHW5UCAMLC4GGHG6MAORBQ7OIR2U7NTZ53GWGNQC
T335DLFOLSLEXGXPND75IPX5Z2VCMFUJQZXZCHCK3CN7Q5WZGWKAC
I23YVJJUZW4V7NLEDVTZBH7XMCBEQ6XILNHST62XRM5G5BWUXKFQC
using System.Collections.Generic;
using TagFighter.Resources;
using UnityEngine;
using System;
public interface IEffectSystem
{
void ApplyTagsEffect(IEnumerable<(Type, IUnit)> tags, Transform origin, Quaternion direction, IAreaOfEffect areaOfEffect);
Color GetEffectColor(IEnumerable<(Type, IUnit)> tags);
Mesh CreateArcMesh(Vector3 direction, float arc, float length, int numberOfVerticesInArc, Vector3 rotationAxis);
Mesh CreateQuadMesh(Vector3 direction, float width, float length, Vector3 rotationAxis);
}
using System.Collections.Generic;
using TagFighter.Resources;
using UnityEngine;
using System;
public interface IEffectSystem
{
void ApplyTagsEffect(IEnumerable<(Type, IUnit)> tags, Transform origin, Quaternion direction, IAreaOfEffect areaOfEffect);
void ApplyTagsEffect(IEnumerable<(Type, IUnit)> tags, Transform origin, Transform effectLocation, IAreaOfEffect areaOfEffect);
Color GetEffectColor(IEnumerable<(Type, IUnit)> tags);
Mesh CreateArcMesh(Vector3 direction, float arc, float length, int numberOfVerticesInArc, Vector3 rotationAxis);
Mesh CreateQuadMesh(Vector3 direction, float width, float length, Vector3 rotationAxis);
}
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using CareBoo.Serially;
using TagFighter.Resources;
using UnityEngine;
[ProvideSourceInfo]
[Serializable]
public class EffectSystem : IEffectSystem
{
ParticleSystem _rippleOutVfx;
[SerializeField] TagFighter.Effects.EffectColors _colorMapping;
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(IEnumerable<(Type, IUnit)> 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(IEnumerable<(Type, IUnit)> 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 resource
Material material = new(Resources.Load<Material>(PulseMaterial));
material.SetColor("_Color", color);
DisplayEffect(origin, direction, mesh, material);
}
void ApplyTagsEffectRadius(IEnumerable<(Type, IUnit)> 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 resource
Material material = new(Resources.Load<Material>(PulseMaterial));
material.SetColor("_Color", color);
DisplayEffect(origin, direction, mesh, material);
}
void ApplyTagsEffectCone(IEnumerable<(Type, IUnit)> 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 resource
Material material = new(Resources.Load<Material>(PulseMaterial));
material.SetColor("_Color", color);
DisplayEffect(origin, direction, mesh, material);
}
public Color GetEffectColor(IEnumerable<(Type, IUnit)> tags) {
Debug.Log("GetEffectColor");
var color = new Color();
Debug.Log($"GetEffectColor length {tags.Count()}");
if (_colorMapping != null) {
foreach (var tag in tags) {
Debug.Log("GetEffectColor tag");
if (_colorMapping.ContainsKey(tag.Item1)) {
Debug.Log("GetEffectColor mapping found");
var mappedColor = _colorMapping[tag.Item1];
// TODO: scale color by amount
color += mappedColor;
}
}
}
Debug.Log("GetEffectColor Finished");
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? direction
var 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 triangle
0, 2, 1,
// upper right triangle
2, 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;
}
}
#nullable enable
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using CareBoo.Serially;
using TagFighter.Resources;
using UnityEngine;
[ProvideSourceInfo]
[Serializable]
public class EffectSystem : IEffectSystem
{
// ParticleSystem _rippleOutVfx;
[SerializeField] TagFighter.Effects.EffectColors? _colorMapping;
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(material, PlayTime));
}
public IEnumerator PlayEffect(Material material, float playTime) {
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(IEnumerable<(Type, IUnit)> 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;
}
}
public void ApplyTagsEffect(IEnumerable<(Type, IUnit)> tags, Transform origin, Transform effectLocation, IAreaOfEffect areaOfEffect) {
var directionVector = (effectLocation.position - origin.position).normalized;
directionVector.y = 0;
var direction = Quaternion.LookRotation(directionVector, Vector3.up);
ApplyTagsEffect(tags, origin, direction, areaOfEffect);
}
void ApplyTagsEffectSingle() {
Debug.Log("ApplyTagsEffectSingle");
}
void ApplyTagsEffectPath(IEnumerable<(Type, IUnit)> 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 resource
Material material = new(Resources.Load<Material>(PulseMaterial));
material.SetColor("_Color", color);
DisplayEffect(origin, direction, mesh, material);
}
void ApplyTagsEffectRadius(IEnumerable<(Type, IUnit)> 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 resource
Material material = new(Resources.Load<Material>(PulseMaterial));
material.SetColor("_Color", color);
DisplayEffect(origin, direction, mesh, material);
}
void ApplyTagsEffectCone(IEnumerable<(Type, IUnit)> 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 resource
Material material = new(Resources.Load<Material>(PulseMaterial));
material.SetColor("_Color", color);
DisplayEffect(origin, direction, mesh, material);
}
public Color GetEffectColor(IEnumerable<(Type, IUnit)> tags) {
Debug.Log("GetEffectColor");
var color = new Color();
Debug.Log($"GetEffectColor length {tags.Count()}");
if (_colorMapping != null) {
foreach (var tag in tags) {
Debug.Log("GetEffectColor tag");
if (_colorMapping.ContainsKey(tag.Item1)) {
Debug.Log("GetEffectColor mapping found");
var mappedColor = _colorMapping[tag.Item1];
// TODO: scale color by amount
color += mappedColor;
}
}
}
Debug.Log("GetEffectColor Finished");
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? direction
var 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 triangle
0, 2, 1,
// upper right triangle
2, 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;
}
}
using System.Collections.Generic;
using TagFighter.Resources;
using UnityEngine;
using System;
class DummyEffectSystem : IEffectSystem
{
public void ApplyTagsEffect(IEnumerable<(Type, IUnit)> tags, Transform origin, Quaternion direction, IAreaOfEffect areaOfEffect) {
Debug.Log("Dummy:ApplyTagsEffect");
}
public Color GetEffectColor(IEnumerable<(Type, IUnit)> 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;
}
}
using System.Collections.Generic;
using TagFighter.Resources;
using UnityEngine;
using System;
class DummyEffectSystem : IEffectSystem
{
public void ApplyTagsEffect(IEnumerable<(Type, IUnit)> tags, Transform origin, Quaternion direction, IAreaOfEffect areaOfEffect) {
Debug.Log("Dummy:ApplyTagsEffect");
}
public void ApplyTagsEffect(IEnumerable<(Type, IUnit)> tags, Transform origin, Transform effectLocation, IAreaOfEffect areaOfEffect) {
Debug.Log("Dummy:ApplyTagsEffect");
}
public Color GetEffectColor(IEnumerable<(Type, IUnit)> 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;
}
}
var blackBoard = new EffectInput(context, new Transform[] { context.EffectLocation }, TagFighter.Resources.StatModifierAccessor.Permanent);
var blackBoard = new EffectInput(context, Enumerable.Empty<Transform>(), TagFighter.Resources.StatModifierAccessor.Permanent);
#nullable enable
namespace TagFighter.Effects.Steps
{
using System.Collections.Generic;
using System.Linq;
using CareBoo.Serially;
[StepType(StepTypeAttribute.OperatorStep)]
public class Zip : OutputStep<IEnumerable<double>>
{
[UnityEngine.SerializeField]
MultiPort<IEnumerable<double>> _in = new();
[UnityEngine.SerializeReference, ShowSerializeReference]
[UnityEngine.SerializeField]
List<double> _const = new();
public override IEnumerable<IPort> Inputs {
get {
yield return _in;
}
}
double defaultVal = 0;
}
}
.Aggregate((current, next) =>
current.Zip(next, (first, second) =>
Operator.Operate(first, second)));
}
public override string ToString() {
var operatorName = Operator == null ? "*" : Operator.GetType().Name;
var constName = _const.Count == 0 ? "" : $"({string.Join(",", _const.Select(val => $"{val}[]"))})";
return $"Zip.{operatorName}{constName}";
}
public override EffectStepNodeData ToData() {
var effectStepNodeData = base.ToData();
effectStepNodeData.Const = _const;
effectStepNodeData.Operator = Operator;
return effectStepNodeData;
}
public override bool FromData(EffectStepNodeData effectStepNodeData, Dictionary<string, EffectStepNode> guidToNode) {
base.FromData(effectStepNodeData, guidToNode);
_const = effectStepNodeData.Const ?? new();
Operator = effectStepNodeData.Operator;
return true;
}
}
}
public override bool IsValid => Operator != null;
return _in.Nodes.Select(getter => getter.Run(blackBoard)).Concat(_const.Select(value => blackBoard.Affected.Select(transform => value)))
.DefaultIfEmpty(GetDefault(blackBoard))
public override IEnumerable<double> Run(EffectInput blackBoard) {
if (!IsValid || Operator == null) {
UnityEngine.Debug.LogError($"{Guid} Inner types are null");
return GetDefault(blackBoard);
return blackBoard.Affected.Select(transform => defaultVal);
public static IEnumerable<double> GetDefault(EffectInput blackBoard) {
public IResourceOperator? Operator;
fileFormatVersion: 2
guid: bb9a9a2cce40a384084a18925a111186
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
#nullable enable
namespace TagFighter.Effects.Steps
{
using System.Collections.Generic;
using System.Linq;
[StepType(StepTypeAttribute.OperatorStep)]
public class Repeat : OutputStep<IEnumerable<double>>
{
[UnityEngine.SerializeField]
SinglePort<double> _in = new();
}
public override IEnumerable<IPort> Inputs {
get {
yield return _in;
}
}
public override string ToString() => "Repeat";
public override bool IsValid => true;
}
}
public override IEnumerable<double> Run(EffectInput blackBoard) {
var value = _in.Node != null ? _in.Node.Run(blackBoard) : default;
return blackBoard.Affected.Select(transform => value);
fileFormatVersion: 2
guid: 844f2211c024f444f876e89a2321a495
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
namespace TagFighter.Effects.Steps
{
using System.Linq;
using System.Reflection;
using System.Collections.Generic;
[StepType(StepTypeAttribute.SetterStep)]
public class PawnResourceSet : OutputStep<bool>
{
[UnityEngine.SerializeField]
SinglePort<IEnumerable<double>> _in = new();
[CareBoo.Serially.TypeFilter(derivedFrom: typeof(Resources.Resource<>))]
public override IEnumerable<IPort> Inputs {
get {
yield return _in;
}
}
public override string ToString() {
var resourceName = Resource == null || Resource.Type == null ? "*" : Resource.Type.Name;
var statName = "Current";
return $"Pawn.Set.{resourceName}.{statName}";
}
public override bool IsValid {
get {
return Resource != null && Resource.Type != null;
}
}
return false;
}
var getSpecificMethod = typeof(PawnResourceSet).GetMethod(nameof(SetSpecific), BindingFlags.NonPublic | BindingFlags.Instance).
MakeGenericMethod(Resource.Type, Resource.Type.BaseType.GetGenericArguments()[0]);
return (bool)value;
}
where TResource : Resources.Resource<TUnitType>
where TUnitType : Resources.IUnitType {
}
return true;
}
}
}
public override bool FromData(EffectStepNodeData effectStepNodeData, Dictionary<string, EffectStepNode> guidToNode) {
base.FromData(effectStepNodeData, guidToNode);
Resource = effectStepNodeData.Resource;
// Register = effectStepNodeData.Register;
}
public override EffectStepNodeData ToData() {
var effectStepNodeData = base.ToData();
effectStepNodeData.Resource = Resource;
// effectStepNodeData.Register = Register;
return effectStepNodeData;
}
return success;
var success = false;
if (_in.Node != null) {
var result = _in.Node.Run(Data);
UnityEngine.Debug.Log($"{nameof(PawnResourceSet)} result {string.Join(",", result)}");
var set = result.Zip(Data.Affected.Select(transform => transform.GetComponent<TResource>()), (value, resource) => (value, resource));
foreach (var (value, resource) in set) {
Data.StatAccessor.AddCurrentModifier(resource, (Resources.Unit<TUnitType>)value);
}
success = true;
bool SetSpecific<TResource, TUnitType>(EffectInput Data)
var value = getSpecificMethod.Invoke(this, new object[] { blackBoard });
public override bool Run(EffectInput blackBoard) {
if (!IsValid || Resource == null) {
UnityEngine.Debug.LogError($"{Guid} Inner types are null");
public CareBoo.Serially.SerializableType? Resource;
#nullable enable
fileFormatVersion: 2
guid: 9aba2983d5b304644a37facc1967f5de
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
#nullable enable
namespace TagFighter.Effects.Steps
{
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
[StepType(StepTypeAttribute.GetterStep)]
public class PawnResourceGet : OutputStep<IEnumerable<double>>
{
[CareBoo.Serially.TypeFilter(derivedFrom: typeof(Resources.Resource<>))]
UnityEngine.Debug.Log($"{Guid} Inner types are null");
}
var getSpecificMethod = typeof(PawnResourceGet).GetMethod(nameof(GetSpecific), BindingFlags.NonPublic | BindingFlags.Instance).
MakeGenericMethod(Resource.Type, Resource.Type.BaseType.GetGenericArguments()[0]);
}
where TResource : Resources.Resource<TUnitType>
where TUnitType : Resources.IUnitType {
}
public override IEnumerable<IPort> Inputs => Enumerable.Empty<IPort>();
public override string ToString() {
var resourceName = Resource == null || Resource.Type == null ? "*" : Resource.Type.Name;
var statName = "Current";
return $"Pawn.Get.{resourceName}.{statName}";
}
public override bool IsValid {
get {
return Resource != null && Resource.Type != null;
}
}
}
}
}
public override EffectStepNodeData ToData() {
var effectStepNodeData = base.ToData();
effectStepNodeData.Resource = Resource;
// effectStepNodeData.Register = Register;
return effectStepNodeData;
}
public override bool FromData(EffectStepNodeData effectStepNodeData, Dictionary<string, EffectStepNode> guidToNode) {
base.FromData(effectStepNodeData, guidToNode);
Resource = effectStepNodeData.Resource;
// Register = effectStepNodeData.Register;
return true;
return blackBoard.Affected.Select(transform => (double)transform.GetComponent<TResource>().GetCurrent().AsPrimitive());
IEnumerable<double> GetSpecific<TResource, TUnitType>(EffectInput blackBoard)
return (IEnumerable<double>)value;
var value = getSpecificMethod.Invoke(this, new object[] { blackBoard });
return blackBoard.Affected.Select(transform => 0d);
public override IEnumerable<double> Run(EffectInput blackBoard) {
if (!IsValid || Resource == null) {
public CareBoo.Serially.SerializableType? Resource;
fileFormatVersion: 2
guid: 93ba90a75f8f1fe4189ea1ed3890ae3e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
#nullable enable
namespace TagFighter.Effects.Steps
{
using System.Collections.Generic;
using System.Linq;
[StepType(StepTypeAttribute.OperatorStep)]
public class Operate : OutputStep<double>
{
[UnityEngine.SerializeField]
MultiPort<double> _in = new();
[UnityEngine.SerializeReference, CareBoo.Serially.ShowSerializeReference]
[UnityEngine.SerializeField]
List<double> _const = new();
public override IEnumerable<IPort> Inputs {
get {
yield return _in;
}
}
public override string ToString() {
var operatorName = Operator == null ? "*" : Operator.GetType().Name;
var constName = _const.Count == 0 ? "" : $"({string.Join(",", _const)})";
return $"{operatorName}{constName}";
}
}
return result;
}
}
}
}
public override EffectStepNodeData ToData() {
var effectStepNodeData = base.ToData();
effectStepNodeData.Const = _const;
effectStepNodeData.Operator = Operator;
return effectStepNodeData;
}
public override bool FromData(EffectStepNodeData effectStepNodeData, Dictionary<string, EffectStepNode> guidToNode) {
base.FromData(effectStepNodeData, guidToNode);
_const = effectStepNodeData.Const ?? new();
Operator = effectStepNodeData.Operator;
return true;
var result = Operator.OperateEnum(_in.Nodes.Select(getter => getter.Run(blackBoard)).Concat(_const));
return default;
public override double Run(EffectInput blackBoard) {
if (!IsValid || Operator == null) {
UnityEngine.Debug.LogError($"{Guid} Inner types are null");
public override bool IsValid => Operator != null;
public IResourceOperator? Operator;
fileFormatVersion: 2
guid: ba8070acc07ec7f448050fe3c5cd4278
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
#nullable enable
namespace TagFighter.Effects.Steps
{
using System.Collections.Generic;
using System.Linq;
[StepType(StepTypeAttribute.OperatorStep)]
public class Fold : OutputStep<double>
{
[UnityEngine.SerializeField]
SinglePort<IEnumerable<double>> _in = new();
[UnityEngine.SerializeReference, CareBoo.Serially.ShowSerializeReference]
}
public override IEnumerable<IPort> Inputs {
get {
yield return _in;
}
}
public override string ToString() {
var operatorName = Operator == null ? "*" : Operator.GetType().Name;
return $"Fold.{operatorName}";
}
public override EffectStepNodeData ToData() {
var effectStepNodeData = base.ToData();
effectStepNodeData.Operator = Operator;
return effectStepNodeData;
}
}
}
public override bool FromData(EffectStepNodeData effectStepNodeData, Dictionary<string, EffectStepNode> guidToNode) {
base.FromData(effectStepNodeData, guidToNode);
Operator = effectStepNodeData.Operator;
return true;
}
public override bool IsValid => Operator != null;
return _in.Node.Run(blackBoard).DefaultIfEmpty(GetDefault()).Aggregate((current, next) => Operator.Operate(current, next));
public IResourceOperator? Operator;
public double GetDefault() {
const double DefaultVal = 0;
return DefaultVal;
}
public override double Run(EffectInput blackBoard) {
if (!IsValid || Operator == null) {
UnityEngine.Debug.LogError($"{Guid} Inner types are null");
return GetDefault();
}
if (_in.Node == null) {
return GetDefault();
}
fileFormatVersion: 2
guid: 95498ab7ed723494fb6b3c000a0f1c35
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
namespace TagFighter.Effects.Steps
{
using System.Collections.Generic;
using System.Reflection;
using TagFighter.Effects.ResourceLocationAccessors.ContextRegisters;
[StepType(StepTypeAttribute.SetterStep)]
public class ContextResourceSet : OutputStep<bool>
{
[UnityEngine.SerializeField]
SinglePort<double> _in = new();
[CareBoo.Serially.TypeFilter(derivedFrom: typeof(Resources.Resource<>))]
[CareBoo.Serially.TypeFilter(derivedFrom: typeof(ContextRegister<>))]
public override IEnumerable<IPort> Inputs {
get {
yield return _in;
}
}
public override string ToString() {
var resourceName = Resource == null || Resource.Type == null ? "*" : Resource.Type.Name;
var registerName = Register == null || Register.Type == null ? "*" : Register.Type.Name;
return $"Context.Set.{resourceName}.{registerName}";
}
public override bool IsValid {
get {
return Register != null && Register.Type != null && Resource != null && Resource.Type != null;
}
}
return false;
}
var getSpecificMethod = typeof(ContextResourceSet).GetMethod(nameof(SetSpecific), BindingFlags.NonPublic | BindingFlags.Instance).
MakeGenericMethod(Resource.Type, Resource.Type.BaseType.GetGenericArguments()[0], Register.Type);
return (bool)value;
}
where TResource : Resources.Resource<TUnitType>
where TUnitType : Resources.IUnitType
where TContextRegister : IContextRegister {
}
}
}
public override EffectStepNodeData ToData() {
var effectStepNodeData = base.ToData();
effectStepNodeData.Resource = Resource;
effectStepNodeData.Register = Register;
return effectStepNodeData;
}
public override bool FromData(EffectStepNodeData effectStepNodeData, Dictionary<string, EffectStepNode> guidToNode) {
base.FromData(effectStepNodeData, guidToNode);
Resource = effectStepNodeData.Resource;
Register = effectStepNodeData.Register;
return true;
}
return success;
var success = false;
if (blackBoard != null) {
blackBoard.Context.SetResource<TResource, TUnitType, TContextRegister>((Resources.Unit<TUnitType>)result);
success = true;
}
var result = (_in.Node != null) ? _in.Node.Run(blackBoard) : default;
bool SetSpecific<TResource, TUnitType, TContextRegister>(EffectInput blackBoard)
var value = getSpecificMethod.Invoke(this, new object[] { Data });
public override bool Run(EffectInput Data) {
if (!IsValid || Resource == null || Register == null) {
UnityEngine.Debug.LogError($"{Guid} Inner types are null");
public CareBoo.Serially.SerializableType? Register;
public CareBoo.Serially.SerializableType? Resource;
#nullable enable
fileFormatVersion: 2
guid: c5c37fc06b3d0ad45b6305eb93d68542
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
#nullable enable
namespace TagFighter.Effects.Steps
{
using System.Reflection;
using System.Collections.Generic;
using System.Linq;
using TagFighter.Effects.ResourceLocationAccessors.ContextRegisters;
[StepType(StepTypeAttribute.GetterStep)]
public class ContextResourceGet : OutputStep<double>
{
[CareBoo.Serially.TypeFilter(derivedFrom: typeof(Resources.Resource<>))]
[CareBoo.Serially.TypeFilter(derivedFrom: typeof(ContextRegister<>))]
return 0;
}
var getSpecificMethod = typeof(ContextResourceGet).GetMethod(nameof(GetSpecific), BindingFlags.NonPublic | BindingFlags.Instance).
MakeGenericMethod(Resource.Type, Resource.Type.BaseType.GetGenericArguments()[0], Register.Type);
return (int)value;
}
public double Test(EffectInput[] Data) {
return 0;
}
where TResource : Resources.Resource<TUnitType>
where TUnitType : Resources.IUnitType
where TContextRegister : IContextRegister {
}
public override IEnumerable<IPort> Inputs => Enumerable.Empty<IPort>();
public override string ToString() {
var resourceName = Resource == null || Resource.Type == null ? "*" : Resource.Type.Name;
var registerName = Register == null || Register.Type == null ? "*" : Register.Type.Name;
return $"Context.Get.{resourceName}.{registerName}";
}
public override bool IsValid {
get {
return Register != null && Register.Type != null && Resource != null && Resource.Type != null;
}
}
}
}
}
public override EffectStepNodeData ToData() {
var effectStepNodeData = base.ToData();
effectStepNodeData.Resource = Resource;
effectStepNodeData.Register = Register;
return effectStepNodeData;
}
public override bool FromData(EffectStepNodeData effectStepNodeData, Dictionary<string, EffectStepNode> guidToNode) {
base.FromData(effectStepNodeData, guidToNode);
Resource = effectStepNodeData.Resource;
Register = effectStepNodeData.Register;
return true;
return blackBoard != null ? blackBoard.Context.GetResource<TResource, TUnitType, TContextRegister>().AsPrimitive() : 0;
int GetSpecific<TResource, TUnitType, TContextRegister>(EffectInput blackBoard)
var value = getSpecificMethod.Invoke(this, new object[] { blackBoard });
public override double Run(EffectInput blackBoard) {
if (!IsValid || Register == null || Resource == null) {
UnityEngine.Debug.LogError($"{Guid} Inner types are null");
public CareBoo.Serially.SerializableType? Register;
public CareBoo.Serially.SerializableType? Resource;
fileFormatVersion: 2
guid: 81d788b04f027ce4080f0b8736d97a71
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
#nullable enable
namespace TagFighter.Effects.Steps
{
using System.Collections.Generic;
[StepType(StepTypeAttribute.SetterStep)]
public class ContextAreaSet : OutputStep<bool>
{
[UnityEngine.SerializeField]
SinglePort<IAreaOfEffect> _in = new();
public override IEnumerable<IPort> Inputs {
get {
yield return _in;
}
}
public override string ToString() => "Context.AOE.Set";
public override bool IsValid => true;
var success = false;
if (_in.Node != null) {
success = true;
}
return success;
}
}
}
blackBoard.Context.AreaOfEffect = _in.Node.Run(blackBoard);
public override bool Run(EffectInput blackBoard) {
fileFormatVersion: 2
guid: c419ef0e55c3e694cb24080375e68c2e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
#nullable enable
namespace TagFighter.Effects.Steps
{
using System.Collections.Generic;
using System.Linq;
[StepType(StepTypeAttribute.GetterStep)]
public class ConstValue : OutputStep<double>
{
[UnityEngine.SerializeField]
double _value;
return _value;
}
public override IEnumerable<IPort> Inputs => Enumerable.Empty<IPort>();
public override string ToString() {
return $"Const {_value}";
}
public override bool IsValid => true;
}
}
public override bool FromData(EffectStepNodeData effectStepNodeData, Dictionary<string, EffectStepNode> guidToNode) {
base.FromData(effectStepNodeData, guidToNode);
_value = effectStepNodeData.Const != null ? effectStepNodeData.Const.FirstOrDefault() : default;
return true;
}
}
public override EffectStepNodeData ToData() {
var effectStepNodeData = base.ToData();
effectStepNodeData.Const = new() { _value };
return effectStepNodeData;
public override double Run(EffectInput blackBoard) {
fileFormatVersion: 2
guid: e3d165e54b32e6d4cbcc75c5b0cf7a68
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
#nullable enable
namespace TagFighter.Effects.Steps
{
using System.Collections.Generic;
[StepType(StepTypeAttribute.GetterStep)]
public class ConeAreaGet : OutputStep<IAreaOfEffect>
{
[UnityEngine.SerializeField]
SinglePort<double> _radius = new() {
DisplayName = "Radius"
};
[UnityEngine.SerializeField]
SinglePort<double> _angle = new() {
DisplayName = "Angle"
};
public override IEnumerable<IPort> Inputs {
get {
yield return _radius;
yield return _angle;
}
}
public override string ToString() => "Cone AOE";
public override bool IsValid => true;
return new ConeArea() {
};
}
}
}
Radius = (float)(_radius.Node != null ? _radius.Node.Run(blackBoard) : default),
Angle = (float)(_angle.Node != null ? _angle.Node.Run(blackBoard) : default),
public override IAreaOfEffect Run(EffectInput blackBoard) {
fileFormatVersion: 2
guid: 05c74f9724c88004184e3074359893c6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
namespace TagFighter.Effects.Steps
{
using System.Collections.Generic;
[StepType(StepTypeAttribute.GetterStep)]
public class CircleAreaGet : OutputStep<IAreaOfEffect>
{
[UnityEngine.SerializeField]
SinglePort<double> _radius = new() {
DisplayName = "Radius"
};
public override IEnumerable<IPort> Inputs {
get {
yield return _radius;
}
}
public override string ToString() => "Circle AOE";
public override bool IsValid => true;
}
}
public override IAreaOfEffect Run(EffectInput blackBoard) => new CircleArea() {
Radius = (float)(_radius.Node != null ? _radius.Node.Run(blackBoard) : default),
};
#nullable enable
blackBoard.Affected = blackBoard.Context.GetAffectedUnits();
var appliedResource = blackBoard.Context.GetAllResourcesInRegister<ResourceLocationAccessors.ContextRegisters.Current>();
blackBoard.Context.EffectSystem.ApplyTagsEffect(appliedResource, blackBoard.Context.Caster, blackBoard.Context.EffectLocation, blackBoard.Context.AreaOfEffect);
blackBoard.Affected = blackBoard.Context.GetAffectedUnits().ToList();
--- !u!114 &-3588640908992573351
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c419ef0e55c3e694cb24080375e68c2e, type: 3}
m_Name: ConstValue
m_EditorClassIdentifier:
Position: {x: 69, y: 463}
Guid: eb75d72e-dc15-4b20-b3b5-4c3e472ce5ef
_value: 30
--- !u!114 &6326256876420960218
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e3d165e54b32e6d4cbcc75c5b0cf7a68, type: 3}
m_Name: ConeAreaGet
m_EditorClassIdentifier:
Position: {x: 236, y: 362}
Guid: 855586fc-1169-4349-8cfd-7ec04d63f9f1
_radius:
Node: {fileID: -5229030080647256284}
_angle:
Node: {fileID: -3588640908992573351}