HMDPEJRZK3PO6M5Z655Y4HWCUKC5I35GRMVVQOZYXWWCIH5ZWNPQC
VUAVVMQEUYSXHBIUJHGRX237EZFT5MCB73ZKVWMGJDRHYZH4XZKAC
R475KN7MR3OG7EBLVNOO7QRIKXDGY2PIDXXV3HW4KBD5QM7B5OJQC
DTKCWM4J7PFNWAAES3RZHQGDA6PTDNX4TZVOXAKF5V7LCZBI3XUAC
TKLR43RQKXB47J2YVVSJ7CAZAJZYOKXSDUXAUOVQMFUN73KZVUVQC
L4TF5YRRHYUPEAF72DU2GO3PBK5CXXHPYZB5SX3NRCUN6AQELH2QC
UBKE7KXKA35CBKZLD366TUQXK72GYT7RLPEMMLCR4XC3TLMXD7EQC
2RUZ7TTRT7SMZT2V7YWUCCTJJXNRT2LNJ2QBBVN4RMREMOGMGMHQC
HDXZWK64UDKEV5JBETQK6KMT5RXW5XPDU3YY4HLBCGP5XA6727BQC
FQZF2IY4T2F7KEVSHMFID35WNAU55CRRDF6XEXZB7PYZH26UGYPQC
ROTMK5LNNK7T5YXVOMUODVMCQWIHPZYOME4WDIAMZJ4VXD7SOEBAC
JLT7KOJ5QGXMRLXQXOHDTF62W3EGPX7XTHNEYAKGMJKK3V4QUPGQC
CD5FF75KTOBTMVMTMCKMR6F5DFKOF26I5K43ITNHGBI3ZAZHA4RAC
UZML3EYZI5YSVYMADFBG3HBQUQAAYVLAS4R2BIR7BOVWQKIHE4IAC
HXTSBPAP75A7EC4RKWYQMVPPHPNZFPHUORBZWDHGEB6MPAGI7G7AC
S256EPZUSOF4TV2KGOFZDJXUFDD57GZFYTCARFJ3SD24RPC56PHAC
public int Get(EffectContext context, IEnumerable<Transform> affected, IResourceAccessor accessor);
public void Set(EffectContext context, IEnumerable<Transform> affected, IResourceAccessor accessor, int value);
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 int Get(EffectContext context, IEnumerable<Transform> affected, IResourceAccessor accessor) =>
(int)accessor.Get<TResource, TUnit>(context, affected);
public void Set(EffectContext context, IEnumerable<Transform> affected, IResourceAccessor accessor, int value) =>
accessor.Set<TResource, TUnit>(context, affected, (Unit<TUnit>)value);
public IEnumerable<float> Get(EffectContext context, IEnumerable<Transform> affected, IResourceAccessor accessor) {
return accessor.Get<TResource, TUnit>(context, affected).Select(resource => (float)resource);
}
public void Set(EffectContext context, IEnumerable<Transform> affected, IResourceAccessor accessor, IEnumerable<int> values) {
accessor.Set<TResource, TUnit>(context, affected, values.Select(value => (Unit<TUnit>)value));
}
fileFormatVersion: 2
guid: 9a18dd7931ae8384aa1c111c381cd97c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace TagFighter.Effects
{
public interface IResourceOperator
{
public float Operate(float a, float b);
}
[Serializable]
public class AddOperator : IResourceOperator
{
public float Operate(float a, float b) => a + b;
public override string ToString() => "+";
}
[Serializable]
public class MultiplyOperator : IResourceOperator
{
public float Operate(float a, float b) => a * b;
public override string ToString() => "*";
}
}
var sum = affected
.Select(transform => transform.GetComponent<TResource>())
.Where(resource => resource != null)
.Select(resource => resource.Current)
.Aggregate((Unit<TUnit>)0, (sum, next) => sum += next);
return sum;
return affected.Select(transform => transform.GetComponent<TResource>()).Select(resource => resource? resource.Current : (Unit<TUnit>)0);
}
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;
}
public IResourceAccessor By;
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]
public class UnaryResourceEffect : IEffect
{
public ResourceInfo From;
public ResourceInfo To;
[SerializeReference, ShowSerializeReference]
public IResourceTypeAccessor DestResource;
[SerializeReference, ShowSerializeReference]
public IResourceAccessor Dest;
public void Apply(EffectContext context, IEnumerable<Transform> affected) {
string _effectName = $"UnaryResourceFrom({From.Type}.{From.Location})To({To.Type}.{To.Location})Effect";
Debug.Log($"{_effectName} : Apply");
[SerializeField] float Multiplier = 1f;
[SerializeField] float Addend = 0f;
var resourceFrom = From.Get(context, affected);
To.Set(context, affected, resourceFrom);
}
}
[Serializable]
public class BinaryResourceEffect : IEffect
{
[SerializeReference, ShowSerializeReference]
public IResourceOperator Operator;
public ResourceInfo FromA;
public ResourceInfo FromB;
public ResourceInfo To;
string _effectName = $"Accumulate({DestResource})By({ByResource})Effect";
string _effectName = $"BinaryResourceFrom({FromA.Type}.{FromA.Location} {Operator} {FromB.Type}.{FromB.Location})To({To.Type}.{To.Location})Effect";
if (Operator == null) {
Debug.Log($"{_effectName}: Apply missing operator, skipping");
return;
}
ByResource:
rid: 7043444504695668776
By:
rid: 7043444504695668777
DestResource:
rid: 7043444504695668778
Dest:
rid: 7043444504695668779
Multiplier: 5
Addend: 0
- rid: 7043444504695668776
Operator:
rid: 7043444546427682859
FromA:
Type:
rid: 7043444546427682860
Location:
rid: 7043444546427682861
Multiplier: 1
Addend: 0
FromB:
Type:
rid: 7043444546427682862
Location:
rid: 7043444546427682863
Multiplier: 1
Addend: 0
To:
Type:
rid: 7043444546427682871
Location:
rid: 7043444546427682872
Multiplier: 1
Addend: 0
- rid: 7043444546427682859
type: {class: AddOperator, ns: TagFighter.Effects, asm: Assembly-CSharp}
- rid: 7043444546427682860
type: {class: BlueTagType, ns: TagFighter.Effects.ResourceTypeAccessors, asm: Assembly-CSharp}
- rid: 7043444546427682861
type: {class: PawnCurrent, ns: TagFighter.Effects, asm: Assembly-CSharp}
- rid: 7043444546427682862
- rid: 7043444504695668778
- rid: 7043444546427682866
type: {class: UnaryResourceEffect, ns: TagFighter.Effects, asm: Assembly-CSharp}
data:
From:
Type:
rid: 7043444546427682873
Location:
rid: 7043444546427682874
Multiplier: 1
Addend: 0
To:
Type:
rid: 7043444546427682869
Location:
rid: 7043444546427682870
Multiplier: 5
Addend: 0
- rid: 7043444546427682869
type: {class: FatigueType, ns: TagFighter.Effects.ResourceTypeAccessors, asm: Assembly-CSharp}
- rid: 7043444546427682870
type: {class: PawnCurrent, ns: TagFighter.Effects, asm: Assembly-CSharp}
- rid: 7043444546427682871
- rid: 7043444504695668780
type: {class: AccumulateResourceEffect, ns: TagFighter.Effects, asm: Assembly-CSharp}
data:
ByResource:
rid: 7043444504695668781
By:
rid: 7043444504695668782
DestResource:
rid: 7043444504695668784
Dest:
rid: 7043444504695668785
Multiplier: 2
Addend: 0
- rid: 7043444504695668781
- rid: 7043444546427682873
RefIds: []
RefIds:
- rid: 7043444546427682816
type: {class: ReleaseEffect, ns: TagFighter.Effects, asm: Assembly-CSharp}
- rid: 7043444546427682817
type: {class: AoeEffect, ns: TagFighter.Effects, asm: Assembly-CSharp}
data:
_areaOfEffect:
rid: 7043444546427682818
- rid: 7043444546427682818
type: {class: CircleArea, ns: , asm: Assembly-CSharp}
data:
Radius: 15
- rid: 7043444546427682876
type: {class: ImmediateEffect, ns: TagFighter.Effects, asm: Assembly-CSharp}
data:
_areaOfEffect:
rid: 7043444546427682882
- rid: 7043444546427682877
type: {class: UnaryResourceEffect, ns: TagFighter.Effects, asm: Assembly-CSharp}
data:
From:
Type:
rid: 7043444546427682878
Location:
rid: 7043444546427682879
Multiplier: 1
Addend: 0
To:
Type:
rid: 7043444546427682880
Location:
rid: 7043444546427682881
Multiplier: 1
Addend: 0
- 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
type: {class: GreenTagType, ns: TagFighter.Effects.ResourceTypeAccessors, asm: Assembly-CSharp}
- rid: 7043444546427682881
type: {class: PawnCurrent, ns: TagFighter.Effects, asm: Assembly-CSharp}
- rid: 7043444546427682882
type: {class: CircleArea, ns: , asm: Assembly-CSharp}
data:
Radius: 15
--- !u!114 &1460840154
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1460840143}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f3afa09e4365bf74aa8ea874ddc7e2de, type: 3}
m_Name:
m_EditorClassIdentifier:
_current:
_value: 0
_capacity:
_value: 100
regenerationAmount:
_value: -1
RegenerationRate: 2
--- !u!114 &1460840155
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1460840143}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b24f5f4c556b5c2439398a7d59da24b1, type: 3}
m_Name:
m_EditorClassIdentifier:
_current:
_value: 0
_capacity:
_value: 100
regenerationAmount:
_value: -1
RegenerationRate: 2
--- !u!114 &1460840156
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1460840143}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 75c933b4f95911047ad31a06d80bbfd4, type: 3}
m_Name:
m_EditorClassIdentifier:
_current:
_value: 0
_capacity:
_value: 9
regenerationAmount:
_value: 0
RegenerationRate: 10
--- !u!114 &1460840157
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1460840143}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 748244e87f3d420469b7e5bd23f876cc, type: 3}
m_Name:
m_EditorClassIdentifier:
_current:
_value: 0
_capacity:
_value: 9
regenerationAmount:
_value: 0
RegenerationRate: 10
--- !u!114 &1460840158
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1460840143}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a805c007a08e37b4d86153c5426ae728, type: 3}
m_Name:
m_EditorClassIdentifier:
_current:
_value: 5
_capacity:
_value: 9
regenerationAmount:
_value: 0
RegenerationRate: 10