B:BD[
3.5096] → [
2.473:3565]
using System;
using System.Collections.Generic;
using CareBoo.Serially;
using TagFighter.Resources;
using UnityEngine;
namespace TagFighter.Effects.ResourceLocationAccessors
{
namespace ContextRegisters
{
public interface IRegisterType { }
[Serializable] public sealed class Current : IRegisterType { }
[Serializable] public sealed class Added : IRegisterType { }
[Serializable] public sealed class Removed : IRegisterType { }
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 class ContextRegister<TRegisterType> : IContextRegister where TRegisterType : IRegisterType
{
public IEnumerable<Unit<TUnit>> Get<TResource, TUnit>(EffectContext context)
where TResource : Resource<TUnit>
where TUnit : IUnitType {
yield return context.GetResource<TResource, TUnit, TRegisterType>();
}
public void Set<TResource, TUnit>(EffectContext context, Unit<TUnit> value)
where TResource : Resource<TUnit>
where TUnit : IUnitType {
context.SetResource<TResource, TUnit, TRegisterType>(value);
}
public override string ToString() => typeof(TRegisterType).Name;
}
}
namespace Get
{
using ContextRegisters;
[Serializable]
public class Context : IResourceLocationGet
{
[SerializeReference, ShowSerializeReference]
public IContextRegister Register;
public IEnumerable<Unit<TUnit>> Get<TResource, TUnit>(EffectInput data)
where TResource : Resource<TUnit>
where TUnit : IUnitType {
return Register.Get<TResource, TUnit>(data.Context);
}
public override string ToString() => $"{nameof(Context)}.{Register}";
}
}
namespace Set
{
using ContextRegisters;
[Serializable]
public class Context : IResourceLocationSet
{
[SerializeReference, ShowSerializeReference]
public IContextRegister Register;
[SerializeReference, ShowSerializeReference]
public IResourceOperator SetAs;
public void Set<TResource, TUnit>(EffectInput data, IEnumerable<Unit<TUnit>> values)
where TResource : Resource<TUnit>
where TUnit : IUnitType {
Register.Set<TResource, TUnit>(data.Context, SetAs.OperateEnum(values));
}
public override string ToString() => $"{nameof(Context)}.{Register}";
}
}
}
using System;
using System.Collections.Generic;
using CareBoo.Serially;
using TagFighter.Resources;
using UnityEngine;
namespace TagFighter.Effects.ResourceLocationAccessors
{
namespace ContextRegisters
{
public interface IRegisterType { }
public class CurrentRegisterType : IRegisterType { }
public class AddedRegisterType : IRegisterType { }
public class RemovedRegisterType : IRegisterType { }
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 class ContextRegister<TRegisterType> : IContextRegister where TRegisterType : IRegisterType
{
public IEnumerable<Unit<TUnit>> Get<TResource, TUnit>(EffectContext context)
where TResource : Resource<TUnit>
where TUnit : IUnitType {
yield return context.GetResource<TResource, TUnit, TRegisterType>();
}
public void Set<TResource, TUnit>(EffectContext context, Unit<TUnit> value)
where TResource : Resource<TUnit>
where TUnit : IUnitType {
context.SetResource<TResource, TUnit, TRegisterType>(value);
}
public override string ToString() => typeof(TRegisterType).Name;
}
[Serializable] public sealed class Current : ContextRegister<CurrentRegisterType> { }
[Serializable] public sealed class Added : ContextRegister<AddedRegisterType> { }
[Serializable] public sealed class Removed : ContextRegister<RemovedRegisterType> { }
}
namespace Get
{
using ContextRegisters;
[Serializable]
public class Context : IResourceLocationGet
{
[SerializeReference, ShowSerializeReference]
public IContextRegister Register;
public IEnumerable<Unit<TUnit>> Get<TResource, TUnit>(EffectInput data)
where TResource : Resource<TUnit>
where TUnit : IUnitType {
return Register.Get<TResource, TUnit>(data.Context);
}
public override string ToString() => $"{nameof(Context)}.{Register}";
}
}
namespace Set
{
using ContextRegisters;
[Serializable]
public class Context : IResourceLocationSet
{
[SerializeReference, ShowSerializeReference]
public IContextRegister Register;
[SerializeReference, ShowSerializeReference]
public IResourceOperator SetAs;
public void Set<TResource, TUnit>(EffectInput data, IEnumerable<Unit<TUnit>> values)
where TResource : Resource<TUnit>
where TUnit : IUnitType {
Register.Set<TResource, TUnit>(data.Context, SetAs.OperateEnum(values));
}
public override string ToString() => $"{nameof(Context)}.{Register}";
}
}
}