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Unit { }
public sealed class GreenTagUnit : IUnit { }
public sealed class RedTagUnit : IUnitType { }
public sealed class BlueTagUnit : IUnitType { }
public sealed class GreenTagUnit : IUnitType { }
public IEnumerable<float> Get(EffectContext context, IEnumerable<Transform> affected, IResourceAccessor accessor);
public void Set(EffectContext context, IEnumerable<Transform> affected, IResourceAccessor accessor, IEnumerable<int> value);
public IEnumerable<float> Get(EffectContext context, IEnumerable<Transform> affected, IResourceGet accessor);
public void Set(EffectContext context, IEnumerable<Transform> affected, IResourceSet accessor, IEnumerable<int> value);
public float Operate(float a, float b);
public double Operate(params double[] values) => OperateEnum(values);
public Unit<TUnit> Operate<TUnit>(params Unit<TUnit>[] values) where TUnit : IUnitType => OperateEnum(values);
public Unit<TUnit> OperateEnum<TUnit>(IEnumerable<Unit<TUnit>> values) where TUnit : IUnitType => (Unit<TUnit>)OperateEnum(values.Select(value => value.AsPrimitive()));
public double OperateEnum(IEnumerable<double> values);
public int OperateEnum(IEnumerable<int> values);
public float Operate(float a, float b) => a + b;
public override string ToString() => "+";
}
[Serializable]
public class Sum : IResourceOperator
{
public double OperateEnum(IEnumerable<double> a) => a.Sum();
public int OperateEnum(IEnumerable<int> a) => a.Sum();
public override string ToString() => nameof(Sum);
}
[Serializable]
public class Multiply : IResourceOperator
{
public double OperateEnum(IEnumerable<double> values) => values.Aggregate(1d, (acc, val) => acc * val);
public int OperateEnum(IEnumerable<int> values) => values.Aggregate(1, (acc, val) => acc * val);
public override string ToString() => nameof(Multiply);
}
[Serializable]
public class Min : IResourceOperator
{
public double OperateEnum(IEnumerable<double> values) => values.Min();
public int OperateEnum(IEnumerable<int> values) => values.Min();
public override string ToString() => nameof(Min);
}
[Serializable]
public class Max : IResourceOperator
{
public double OperateEnum(IEnumerable<double> values) => values.Max();
public int OperateEnum(IEnumerable<int> values) => values.Max();
public override string ToString() => nameof(Max);
}
[Serializable]
public class MultiplyOperator : IResourceOperator
{
public float Operate(float a, float b) => a * b;
public override string ToString() => "*";
[Serializable]
public class Average : IResourceOperator
{
public double OperateEnum(IEnumerable<double> values) => values.Average();
public int OperateEnum(IEnumerable<int> values) => (int)values.Average();
public override string ToString() => nameof(Average);
}
fileFormatVersion: 2
guid: 72b2e70c03f22794ebeeb7a3b7d89018
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections.Generic;
using System.Linq;
using CareBoo.Serially;
using UnityEngine;
namespace TagFighter.Effects
{
[Serializable]
public class ResourceInfoGet
{
[SerializeReference, ShowSerializeReference]
public IResourceTypeAccessor Type;
[SerializeReference, ShowSerializeReference]
public IResourceGet Location;
public double Multiplier = 1;
public double Addend = 0;
public bool IsInit {
get {
return (Type != null) && (Location != null);
}
}
public IEnumerable<double> Get(EffectContext context, IEnumerable<Transform> affected) {
return IsInit ? Type.Get(context, affected, Location).Select(resource => (Multiplier * resource) + Addend) :
Resource(Addend);
}
private IEnumerable<T> Resource<T>(T r) {
yield return r;
}
public override string ToString() => $"{Type}.{Location}";
}
[Serializable]
public class ResourceInfoSet
{
[SerializeReference, ShowSerializeReference]
public IResourceTypeAccessor Type;
[SerializeReference, ShowSerializeReference]
public IResourceSet Location;
public double Multiplier = 1;
public double Addend = 0;
public bool IsInit {
get {
return (Type != null) && (Location != null);
}
}
public void Set(EffectContext context, IEnumerable<Transform> affected, IEnumerable<double> value) {
if (!IsInit) {
Debug.Log("Set Resource missing Type or Location, skipping");
return;
}
var manipulatedValue = value.Select(resource => (int)((Multiplier * resource) + Addend));
Type.Set(context, affected, Location, manipulatedValue);
}
public override string ToString() => $"{Type}.{Location}";
}
}
public IEnumerable<Unit<TUnit>> Get<TResource, TUnit>(EffectContext context, IEnumerable<Transform> affected)
where TResource : Resource<TUnit>
where TUnit : IUnit {
return affected.Select(transform => transform.GetComponent<TResource>()).Select(resource => resource? resource.Current : (Unit<TUnit>)0);
public interface IPawnResourceProperty
{
public Unit<TUnit> Get<TResource, TUnit>(TResource resource)
where TResource : Resource<TUnit> where TUnit : IUnitType;
public void Set<TResource, TUnit>(TResource resource, Unit<TUnit> value)
where TResource : Resource<TUnit> where TUnit : IUnitType;
public void Set<TResource, TUnit>(EffectContext context, IEnumerable<Transform> affected, IEnumerable<Unit<TUnit>> values)
where TResource : Resource<TUnit>
where TUnit : IUnit {
foreach (var tuple in affected.Select(target => target.GetComponent<TResource>())
.Zip(Repeat<TResource, TUnit>(values), (resource, value) => (resource, value))
.Where(tuple => tuple.resource)) {
tuple.resource.Current = tuple.value;
}
[Serializable]
public class Current : IPawnResourceProperty
{
public Unit<TUnit> Get<TResource, TUnit>(TResource resource)
where TResource : Resource<TUnit> where TUnit : IUnitType => resource.Current;
public void Set<TResource, TUnit>(TResource resource, Unit<TUnit> value)
where TResource : Resource<TUnit> where TUnit : IUnitType => resource.Current = value;
public override string ToString() => nameof(Current);
}
[Serializable]
public class Capacity : IPawnResourceProperty
{
public Unit<TUnit> Get<TResource, TUnit>(TResource resource)
where TResource : Resource<TUnit> where TUnit : IUnitType => resource.Capacity;
public void Set<TResource, TUnit>(TResource resource, Unit<TUnit> value)
where TResource : Resource<TUnit> where TUnit : IUnitType => resource.Capacity = value;
public override string ToString() => nameof(Capacity);
private IEnumerable<Unit<TUnit>> Repeat<TResource, TUnit>(IEnumerable<Unit<TUnit>> values)
where TResource : Resource<TUnit>
where TUnit : IUnit {
while (true) {
foreach (var val in values) {
yield return val;
[Serializable]
public class RegenerationAmount : IPawnResourceProperty
{
public Unit<TUnit> Get<TResource, TUnit>(TResource resource)
where TResource : Resource<TUnit> where TUnit : IUnitType => resource.RegenerationAmount;
public void Set<TResource, TUnit>(TResource resource, Unit<TUnit> value)
where TResource : Resource<TUnit> where TUnit : IUnitType => resource.RegenerationAmount = value;
public override string ToString() => nameof(RegenerationAmount);
}
namespace Get
{
[Serializable]
public class Pawn : IResourceGet
{
[SerializeReference, ShowSerializeReference]
IPawnResourceProperty Property;
public IEnumerable<Unit<TUnit>> Get<TResource, TUnit>(EffectContext context, IEnumerable<Transform> affected)
where TResource : Resource<TUnit>
where TUnit : IUnitType {
return affected.Select(transform => transform.GetComponent<TResource>())
.Select(resource => resource ? Property.Get<TResource, TUnit>(resource) : (Unit<TUnit>)0);
public override string ToString() => "Pawn.Current";
namespace Set
{
[Serializable]
public class Pawn : IResourceSet
{
[SerializeReference, ShowSerializeReference]
IPawnResourceProperty Property;
public void Set<TResource, TUnit>(EffectContext context, IEnumerable<Transform> affected, IEnumerable<Unit<TUnit>> values)
where TResource : Resource<TUnit>
where TUnit : IUnitType {
foreach (var tuple in affected.Zip(Repeat<TResource, TUnit>(values), (transform, value) => (resource: transform.GetComponent<TResource>(), value))
.Where(tuple => tuple.resource)) {
Property.Set(tuple.resource, tuple.value);
}
}
private IEnumerable<Unit<TUnit>> Repeat<TResource, TUnit>(IEnumerable<Unit<TUnit>> values)
where TResource : Resource<TUnit>
where TUnit : IUnitType {
while (true) {
foreach (var val in values) {
yield return val;
}
}
}
public override string ToString() => $"{nameof(Pawn)}.{Property}";
}
}
public IEnumerable<Unit<TUnit>> Get<TResource, TUnit>(EffectContext context, IEnumerable<Transform> affected)
where TResource : Resource<TUnit>
where TUnit : IUnit {
yield return context.Resource<TResource, TUnit>().Current;
[Serializable] public sealed class Current : ContextRegister<Current> { }
[Serializable] public sealed class Added : ContextRegister<Added> { }
[Serializable] public sealed class Removed : ContextRegister<Removed> { }
public interface IContextRegister
{
public IEnumerable<Unit<TUnit>> Get<TResource, TUnit>(EffectContext context)
where TResource : Resource<TUnit>
where TUnit : IUnitType;
public void Set<TResource, TUnit>(EffectContext context, Unit<TUnit> value)
where TResource : Resource<TUnit>
where TUnit : IUnitType;
public void Set<TResource, TUnit>(EffectContext context, IEnumerable<Transform> affected, IEnumerable<Unit<TUnit>> values)
where TResource : Resource<TUnit>
where TUnit : IUnit {
context.Resource<TResource, TUnit>().Current = values.Aggregate((Unit<TUnit>)0,(sum, next) => sum += next);
public class ContextRegister<TRegister> : IContextRegister
{
public IEnumerable<Unit<TUnit>> Get<TResource, TUnit>(EffectContext context)
where TResource : Resource<TUnit>
where TUnit : IUnitType {
yield return context.GetResource<TResource, TUnit, TRegister>();
}
public void Set<TResource, TUnit>(EffectContext context, Unit<TUnit> value)
where TResource : Resource<TUnit>
where TUnit : IUnitType {
context.SetResource<TResource, TUnit, TRegister>(value);
}
public override string ToString() => typeof(TRegister).Name;
public override string ToString() => "Context.Current";
}
namespace Get
{
[Serializable]
public class Context : IResourceGet
{
[SerializeReference, ShowSerializeReference]
IContextRegister Register;
public IEnumerable<Unit<TUnit>> Get<TResource, TUnit>(EffectContext context, IEnumerable<Transform> affected)
where TResource : Resource<TUnit>
where TUnit : IUnitType {
return Register.Get<TResource, TUnit>(context);
}
[Serializable]
public class ContextAdded : IResourceAccessor
{
public IEnumerable<Unit<TUnit>> Get<TResource, TUnit>(EffectContext context, IEnumerable<Transform> affected)
where TResource : Resource<TUnit>
where TUnit : IUnit {
yield return context.Resource<TResource, TUnit>().Added;
public override string ToString() => $"{nameof(Context)}.{Register}";
}
public void Set<TResource, TUnit>(EffectContext context, IEnumerable<Transform> affected, IEnumerable<Unit<TUnit>> values)
where TResource : Resource<TUnit>
where TUnit : IUnit {
context.Resource<TResource, TUnit>().Added = values.Aggregate((Unit<TUnit>)0,(sum, next) => sum += next);
}
namespace Set
{
[Serializable]
public class Context : IResourceSet
{
[SerializeReference, ShowSerializeReference]
IContextRegister Register;
[Serializable]
public class ContextRemoved : IResourceAccessor
{
public IEnumerable<Unit<TUnit>> Get<TResource, TUnit>(EffectContext context, IEnumerable<Transform> affected)
where TResource : Resource<TUnit>
where TUnit : IUnit {
yield return context.Resource<TResource, TUnit>().Removed;
}
public void Set<TResource, TUnit>(EffectContext context, IEnumerable<Transform> affected, IEnumerable<Unit<TUnit>> values)
where TResource : Resource<TUnit>
where TUnit : IUnitType {
Register.Set<TResource, TUnit>(context, SetAs.OperateEnum(values));
}
public void Set<TResource, TUnit>(EffectContext context, IEnumerable<Transform> affected, IEnumerable<Unit<TUnit>> values)
where TResource : Resource<TUnit>
where TUnit : IUnit {
context.Resource<TResource, TUnit>().Removed = values.Aggregate((Unit<TUnit>)0,(sum, next) => sum += next);
public override string ToString() => $"{nameof(Context)}.{Register}";
}
where TUnit : IUnit {
if (!ResourceCounter.TryGetValue(typeof(TResource), out var resourceContext)) {
resourceContext = new ResourceContext<TUnit>();
ResourceCounter.Add(typeof(TResource), resourceContext);
where TUnit : IUnitType {
System.Type resourceLocation = typeof((TResource, TLocation));
if (!ResourceCounter.TryGetValue(resourceLocation, out var value)) {
value = (Unit<TUnit>)0;
ResourceCounter.Add(resourceLocation, value);
public EffectContext(EffectSystem effectSystem) {
EffectSystem = effectSystem;
public void SetResource<TResource, TUnit, TLocation>(Unit<TUnit> value)
where TResource : Resource<TUnit>
where TUnit : IUnitType {
System.Type resourceLocation = typeof((TResource, TLocation));
ResourceCounter[resourceLocation] = value;
Debug.Log($"{nameof(SetResource)} ({typeof(TResource).Name},{typeof(TLocation).Name}) = {ResourceCounter[resourceLocation]}");
}
public interface IResourceContext { };
public class ResourceContext<TUnitType> : IResourceContext
where TUnitType : IUnit
{
public Unit<TUnitType> Current { get; set; }
public Unit<TUnitType> Added { get; set; }
public Unit<TUnitType> Removed { get; set; }
public class ResourceInfo
{
[SerializeReference, ShowSerializeReference]
public IResourceTypeAccessor Type;
[SerializeReference, ShowSerializeReference]
public IResourceAccessor Location;
[SerializeField] float Multiplier = 1;
[SerializeField] float Addend = 0;
public bool IsInit {
get {
return (Type != null) && (Location != null);
}
}
public IEnumerable<float> Get(EffectContext context, IEnumerable<Transform> affected) {
return IsInit ? Type.Get(context, affected, Location).Select(resource => (Multiplier * resource) + Addend) :
Resource(Addend);
}
public void Set(EffectContext context, IEnumerable<Transform> affected, IEnumerable<float> value) {
if (!IsInit) {
Debug.Log("Set Resource missing Type or Location, skipping");
return;
}
var manipulatedValue = value.Select(resource => (int)((Multiplier * resource) + Addend));
Type.Set(context, affected, Location, manipulatedValue);
}
private IEnumerable<T> Resource<T>(T r) {
yield return r;
}
}
[Serializable]
var resourceFromA = FromA.Get(context, affected);
var resourceFromB = FromB.Get(context, affected);
var resourceFromA = FromA.Get(context, affected).ToList();
var resourceFromB = FromB.Get(context, affected).ToList();
var manipulated = Combine(resourceFromA, resourceFromB);
To.Set(context, affected, manipulated);
}
var sum = resourceFromA.Zip(resourceFromB, (a, b) => Operator.Operate(a, b));
To.Set(context, affected, sum);
private IEnumerable<double> Combine(List<double> a, List<double> b) {
return (a.Count == 1) ? b.Zip(Repeat(a),(valB, valA) => Operator.Operate(valA, valB)) :
a.Zip(Repeat(b),(valA, valB) => Operator.Operate(valA, valB));
}
- rid: 7043444546427682872
type: {class: ContextCurrent, ns: TagFighter.Effects, asm: Assembly-CSharp}
- rid: 7043444546427682873
- rid: 7043444579999678465
type: {class: GreenTagType, ns: TagFighter.Effects.ResourceTypeAccessors, asm: Assembly-CSharp}
- rid: 7043444579999678510
- rid: 7043444546427682874
type: {class: ContextCurrent, ns: TagFighter.Effects, asm: Assembly-CSharp}
- rid: 7043444593006739478
type: {class: Context, ns: TagFighter.Effects.Context.Set, asm: Assembly-CSharp}
data:
Register:
rid: 7043444593006739479
SetAs:
rid: 7043444593006739498
- rid: 7043444593006739479
type: {class: Current, ns: TagFighter.Effects.Context, asm: Assembly-CSharp}
- rid: 7043444593006739481
type: {class: Context, ns: TagFighter.Effects.Context.Get, asm: Assembly-CSharp}
data:
Register:
rid: 7043444593006739482
- rid: 7043444593006739482
type: {class: Current, ns: TagFighter.Effects.Context, asm: Assembly-CSharp}
- rid: 7043444593006739483
type: {class: Pawn, ns: TagFighter.Effects.Pawn.Get, asm: Assembly-CSharp}
data:
Property:
rid: 7043444593006739484
- rid: 7043444593006739484
type: {class: Current, ns: TagFighter.Effects.Pawn, asm: Assembly-CSharp}
- rid: 7043444593006739494
type: {class: Pawn, ns: TagFighter.Effects.Pawn.Get, asm: Assembly-CSharp}
data:
Property:
rid: 7043444593006739495
- rid: 7043444593006739495
type: {class: Current, ns: TagFighter.Effects.Pawn, asm: Assembly-CSharp}
- rid: 7043444593006739496
type: {class: Pawn, ns: TagFighter.Effects.Pawn.Set, asm: Assembly-CSharp}
data:
Property:
rid: 7043444593006739497
- rid: 7043444593006739497
type: {class: Current, ns: TagFighter.Effects.Pawn, asm: Assembly-CSharp}
- rid: 7043444593006739498
type: {class: Sum, ns: TagFighter.Effects.Operators, asm: Assembly-CSharp}
- rid: 7043444593006739501
type: {class: Max, ns: TagFighter.Effects.Operators, asm: Assembly-CSharp}
- rid: 7043444546427682876
type: {class: ImmediateEffect, ns: TagFighter.Effects, asm: Assembly-CSharp}
data:
_areaOfEffect:
rid: 7043444546427682882
- rid: 7043444546427682877
- rid: 7043444579999678513
type: {class: DelayedEffect, ns: TagFighter.Effects, asm: Assembly-CSharp}
- rid: 7043444583699054625
- rid: 7043444546427682878
type: {class: BlueTagType, ns: TagFighter.Effects.ResourceTypeAccessors, asm: Assembly-CSharp}
- rid: 7043444546427682879
type: {class: PawnCurrent, ns: TagFighter.Effects, asm: Assembly-CSharp}
- rid: 7043444546427682880
- rid: 7043444583699054626
- rid: 7043444546427682881
type: {class: PawnCurrent, ns: TagFighter.Effects, asm: Assembly-CSharp}
- rid: 7043444546427682882
type: {class: CircleArea, ns: , asm: Assembly-CSharp}
- rid: 7043444583699054628
type: {class: PainType, ns: TagFighter.Effects.ResourceTypeAccessors, asm: Assembly-CSharp}
- rid: 7043444583699054631
type: {class: DelayedEffect, ns: TagFighter.Effects, asm: Assembly-CSharp}
- rid: 7043444583699054637
type: {class: BinaryResourceEffect, ns: TagFighter.Effects, asm: Assembly-CSharp}
Radius: 15
Operator:
rid: 7043444593006739500
FromA:
Type:
rid: 7043444583699054638
Location:
rid: 7043444593006739476
Multiplier: 2
Addend: 0
FromB:
Type:
rid: 7043444583699054640
Location:
rid: 7043444593006739487
Multiplier: 1
Addend: 0
To:
Type:
rid: 7043444583699054642
Location:
rid: 7043444593006739492
Multiplier: 1
Addend: 0
- rid: 7043444583699054638
type: {class: PainType, ns: TagFighter.Effects.ResourceTypeAccessors, asm: Assembly-CSharp}
- rid: 7043444583699054640
type: {class: PainType, ns: TagFighter.Effects.ResourceTypeAccessors, asm: Assembly-CSharp}
- rid: 7043444583699054642
type: {class: PainType, ns: TagFighter.Effects.ResourceTypeAccessors, asm: Assembly-CSharp}
- rid: 7043444593006739473
type: {class: Context, ns: TagFighter.Effects.Context.Set, asm: Assembly-CSharp}
data:
Register:
rid: 7043444593006739474
SetAs:
rid: 7043444593006739499
- rid: 7043444593006739474
type: {class: Current, ns: TagFighter.Effects.Context, asm: Assembly-CSharp}
- rid: 7043444593006739476
type: {class: Context, ns: TagFighter.Effects.Context.Get, asm: Assembly-CSharp}
data:
Register:
rid: 7043444593006739477
- rid: 7043444593006739477
type: {class: Current, ns: TagFighter.Effects.Context, asm: Assembly-CSharp}
- rid: 7043444593006739485
type: {class: Pawn, ns: TagFighter.Effects.Pawn.Get, asm: Assembly-CSharp}
data:
Property:
rid: 7043444593006739486
- rid: 7043444593006739486
type: {class: Current, ns: TagFighter.Effects.Pawn, asm: Assembly-CSharp}
- rid: 7043444593006739487
type: {class: Pawn, ns: TagFighter.Effects.Pawn.Get, asm: Assembly-CSharp}
data:
Property:
rid: 7043444593006739488
- rid: 7043444593006739488
type: {class: Current, ns: TagFighter.Effects.Pawn, asm: Assembly-CSharp}
- rid: 7043444593006739492
type: {class: Pawn, ns: TagFighter.Effects.Pawn.Set, asm: Assembly-CSharp}
data:
Property:
rid: 7043444593006739493
- rid: 7043444593006739493
type: {class: Current, ns: TagFighter.Effects.Pawn, asm: Assembly-CSharp}
- rid: 7043444593006739499
type: {class: Sum, ns: TagFighter.Effects.Operators, asm: Assembly-CSharp}
- rid: 7043444593006739500
type: {class: Sum, ns: TagFighter.Effects.Operators, asm: Assembly-CSharp}