COV4RS6N6Z7PJ5S6LZGNSTP77UJNTKN42OI6K7CBQH6TKCS7ITLQC
DLEUGO4VYTO63GD26UI3AZURQLUS44AEFAGFHSRHNODMVW6OBGZAC
CD5FF75KTOBTMVMTMCKMR6F5DFKOF26I5K43ITNHGBI3ZAZHA4RAC
VZRSH4U473FCZOP5EXURPXXN5J6F3ZLT435YY7A2JHLG2ZZB5KLQC
5I5QA3YK5G5QQCXMSDOEAX3A74LVXV7PYWAIHMLFANR2GUFWMKGQC
HXTSBPAP75A7EC4RKWYQMVPPHPNZFPHUORBZWDHGEB6MPAGI7G7AC
754VCJRLAZAVIQP7STLUIHP3U7PUHBTYAHLNQK4A2H6IKYVNTDKAC
J5CTPTTJ22V4MMQ3IZ2LUJE7GP35I4NS2JIZ2HQRNIVJF3ERYELAC
VVKEQMFYXC4F72W2RS5ZAVRCROH4NDFOI4DIAWGGEID2YFPQTSSAC
33YYBTSQFQMGO5RYBAFYGX3L4N7YS4DT4CEJKB6ZVYCIIZGDQD2QC
J75RIWLT42QXABT6GQMAVIOP5XDUF7UAGFQUSSKDIULB3LEB22EQC
O236B5LO6PHJ4TPZGYXDVSLB5EGXXRRLYYVWI46DPL5LEGXEIHZQC
AZN3UTBQLTKMGIHW5UCAMLC4GGHG6MAORBQ7OIR2U7NTZ53GWGNQC
ZHJFVCAJGFFEQCY6IZW2VFXBDTTWLBKDIABIGMF4CZOMTGYJKCYQC
I23YVJJUZW4V7NLEDVTZBH7XMCBEQ6XILNHST62XRM5G5BWUXKFQC
fileFormatVersion: 2
guid: b1c25ba61093a5d4eb33806d7d3c7833
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 2acbd42d3ff21084c819e199ab54ab8f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 56381ccb9f7dcec418f3f87d7032ff04
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 830221fc3f20a6b4ba88495b546536d5
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 0
wrapV: 0
wrapW: 0
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 05e82e90cd64be042bb61f460b0ce0a5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using System;
using System.Linq;
using System.ComponentModel;
namespace System.Runtime.CompilerServices
{
[EditorBrowsable(EditorBrowsableState.Never)]
internal class IsExternalInit { }
}
namespace TagFighter.Dialogue.Editor
{
record DialogueManipulation
{
public record None() : DialogueManipulation();
public record RepositionNode(Vector2 DraggingOffset, DialogueNode DraggingNode) : DialogueManipulation();
public record ResizeNode(Vector2 DraggingOffset, DialogueNode DraggingNode) : DialogueManipulation();
public record RepositionCanvas(Vector2 DraggingOffset) : DialogueManipulation();
public record CreateNode(DialogueNode NodeParent) : DialogueManipulation();
public record DeleteNode(DialogueNode NodeToDelete) : DialogueManipulation();
DialogueManipulation() { }
}
public class DialogueEditor : EditorWindow
{
Dialogue _selectedDialogue = null;
[NonSerialized]
GUIStyle _nodeStyle = null;
[NonSerialized]
GUIStyle _playerNodeStyle = null;
[NonSerialized]
DialogueNode _linkingParentNode = null;
[NonSerialized]
Vector2 _scrollPosition;
[NonSerialized]
DialogueManipulation _manipulationState = new DialogueManipulation.None();
const int _leftMouseButton = 0;
const float _canvasSize = 4000;
const float _backgroundsize = 50;
private const int _resizeBorder = 8;
[MenuItem("Window/Dialogue Editor")]
public static void ShowEditorWindow() {
var window = GetWindow<DialogueEditor>();
window.titleContent = new GUIContent("Dialogue");
window.Show();
var dialogueCandidate = Selection.activeObject as Dialogue;
if (dialogueCandidate != null) {
window._selectedDialogue = dialogueCandidate;
}
}
[OnOpenAsset(1)]
public static bool OnOpenAsset(int instanceID, int line) {
var dialogue = EditorUtility.InstanceIDToObject(instanceID) as Dialogue;
if (dialogue != null) {
ShowEditorWindow();
return true;
}
return false;
}
private void OnEnable() {
Selection.selectionChanged += OnSelectionChanged;
_nodeStyle = new();
_nodeStyle.normal.background = EditorGUIUtility.Load("node0") as Texture2D;
_nodeStyle.padding = new RectOffset(12, 12, 12, 12);
_nodeStyle.border = new RectOffset(12, 12, 12, 12);
_nodeStyle.overflow = new RectOffset(7, 7, 7, 7);
_playerNodeStyle = new();
_playerNodeStyle.normal.background = EditorGUIUtility.Load("node1") as Texture2D;
_playerNodeStyle.padding = new RectOffset(12, 12, 12, 12);
_playerNodeStyle.border = new RectOffset(12, 12, 12, 12);
_playerNodeStyle.overflow = new RectOffset(7, 7, 7, 7);
}
private void OnDisable() {
Selection.selectionChanged -= OnSelectionChanged;
}
private void OnSelectionChanged() {
var dialogueCandidate = Selection.activeObject as Dialogue;
if (dialogueCandidate != null) {
_selectedDialogue = dialogueCandidate;
Repaint();
}
}
private void OnGUI() {
if (_selectedDialogue == null) {
EditorGUILayout.LabelField("Choose A Dialogue", EditorStyles.boldLabel);
}
else {
ProcessEvents();
_scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition);
EditorGUILayout.LabelField(_selectedDialogue.name, EditorStyles.boldLabel);
var canvas = GUILayoutUtility.GetRect(_canvasSize, _canvasSize);
var backgroundTex = UnityEngine.Resources.Load("background") as Texture2D;
Rect texCoords = new(0, 0, _canvasSize / _backgroundsize, _canvasSize / _backgroundsize);
GUI.DrawTextureWithTexCoords(canvas, backgroundTex, texCoords);
foreach (var node in _selectedDialogue.Nodes) {
DrawConnections(node);
}
foreach (var node in _selectedDialogue.Nodes) {
DrawNode(node);
}
EditorGUILayout.EndScrollView();
switch (_manipulationState) {
case DialogueManipulation.CreateNode action:
_selectedDialogue.CreateNode(action.NodeParent);
_manipulationState = new DialogueManipulation.None();
break;
case DialogueManipulation.DeleteNode action:
_selectedDialogue.DeleteNode(action.NodeToDelete);
_manipulationState = new DialogueManipulation.None();
break;
}
}
}
private void ProcessEvents() {
switch (_manipulationState, Event.current.type, Event.current.button) {
case (DialogueManipulation.None, EventType.MouseDown, _leftMouseButton):
var clickedNode = GetNodeAtPoint(Event.current.mousePosition + _scrollPosition);
if (clickedNode != null) {
Selection.activeObject = clickedNode;
var dragOffset = clickedNode.Rect.position - Event.current.mousePosition;
_manipulationState = (clickedNode.Rect.height + dragOffset.y > _resizeBorder) || (clickedNode.Rect.width + dragOffset.x > _resizeBorder) ?
new DialogueManipulation.RepositionNode(dragOffset, clickedNode) : new DialogueManipulation.ResizeNode(dragOffset, clickedNode);
}
else {
Selection.activeObject = _selectedDialogue;
_manipulationState = new DialogueManipulation.RepositionCanvas(Event.current.mousePosition + _scrollPosition);
}
break;
case (DialogueManipulation.RepositionNode state, EventType.MouseDrag, _leftMouseButton):
state.DraggingNode.Position = Event.current.mousePosition + state.DraggingOffset;
GUI.changed = true;
break;
case (DialogueManipulation.ResizeNode state, EventType.MouseDrag, _leftMouseButton):
state.DraggingNode.Size = Event.current.mousePosition - state.DraggingNode.Position;
GUI.changed = true;
break;
case (DialogueManipulation.RepositionCanvas state, EventType.MouseDrag, _leftMouseButton):
_scrollPosition = state.DraggingOffset - Event.current.mousePosition;
GUI.changed = true;
break;
case (_, EventType.MouseUp, _leftMouseButton):
_manipulationState = new DialogueManipulation.None();
break;
}
}
private DialogueNode GetNodeAtPoint(Vector2 point) {
return _selectedDialogue.Nodes.Where(node => node.Rect.Contains(point)).LastOrDefault();
}
private void DrawNode(DialogueNode node) {
GUIStyle nodeStyle = node.IsPlayerSpeaking ? _playerNodeStyle : _nodeStyle;
GUILayout.BeginArea(node.Rect, nodeStyle);
node.Text = EditorGUILayout.TextField(node.Text);
GUILayout.BeginHorizontal();
GUI.enabled = _selectedDialogue.Nodes.Count > 1;
if (GUILayout.Button("x")) {
_manipulationState = new DialogueManipulation.DeleteNode(node);
}
DrawLinkButtons(node);
GUI.enabled = true;
if (GUILayout.Button("+")) {
_manipulationState = new DialogueManipulation.CreateNode(node);
}
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
private void DrawLinkButtons(DialogueNode node) {
if (_linkingParentNode == null) {
if (GUILayout.Button("link")) {
_linkingParentNode = node;
}
}
else if (_linkingParentNode == node) {
if (GUILayout.Button("cancel")) {
_linkingParentNode = null;
}
}
else if (_linkingParentNode.GetChildren().Contains(node.name)) {
if (GUILayout.Button("unlink")) {
_linkingParentNode.RemoveChild(node.name);
_linkingParentNode = null;
}
}
else if (GUILayout.Button("child")) {
_linkingParentNode.AddChild(node.name);
_linkingParentNode = null;
}
}
private void DrawConnections(DialogueNode node) {
Vector3 startPosition = new Vector2(node.Rect.xMax, node.Rect.center.y);
foreach (var childNode in _selectedDialogue.GetAllChildren(node)) {
Vector3 endPosition = new Vector2(childNode.Rect.xMin, childNode.Rect.center.y);
Vector3 controlPointOffset = endPosition - startPosition;
controlPointOffset.y = 0;
controlPointOffset.x *= 0.8f;
Handles.DrawBezier(startPosition, endPosition, startPosition + controlPointOffset, endPosition - controlPointOffset, Color.white, null, 4f);
}
}
}
}
fileFormatVersion: 2
guid: 480303b4b1409b54d8239c1b17e97f2b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace TagFighter.Dialogue
{
public class DialogueNode : ScriptableObject
{
[SerializeField]
bool _isPlayerSpeaking = false;
[SerializeField]
private string _text = new("");
[SerializeField]
private List<string> _children = new();
[SerializeField]
private Rect _rect = new(0, 0, 200, 100);
#if UNITY_EDITOR
public bool IsPlayerSpeaking {
get { return _isPlayerSpeaking; }
set {
Undo.RecordObject(this, "Change Dialogue Speaker");
_isPlayerSpeaking = value;
EditorUtility.SetDirty(this);
}
}
#endif
public string Text {
get { return _text; }
#if UNITY_EDITOR
set {
if (_text != value) {
Undo.RecordObject(this, "Update Dialogue Text");
_text = value;
EditorUtility.SetDirty(this);
}
}
#endif
}
public Rect Rect {
get => _rect;
#if UNITY_EDITOR
set {
Undo.RecordObject(this, "Update Node Position");
_rect = value;
EditorUtility.SetDirty(this);
}
#endif
}
public Vector2 Position {
get => _rect.position;
#if UNITY_EDITOR
set {
Undo.RecordObject(this, "Update Node Position");
_rect.position = value;
EditorUtility.SetDirty(this);
}
#endif
}
public Vector2 Size {
get => _rect.size;
#if UNITY_EDITOR
set {
Undo.RecordObject(this, "Update Node Resize");
_rect.size = value;
EditorUtility.SetDirty(this);
}
#endif
}
public IEnumerable<string> GetChildren() {
return _children;
}
public DialogueNode AddChild(string childID) {
Undo.RecordObject(this, "Link Child");
_children.Add(childID);
EditorUtility.SetDirty(this);
return this;
}
public DialogueNode RemoveChild(string childID) {
Undo.RecordObject(this, "Unlink Child");
_children.Remove(childID);
EditorUtility.SetDirty(this);
return this;
}
}
}
fileFormatVersion: 2
guid: 714f334e7ffb0154996de980ccf9e1c0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace TagFighter.Dialogue
{
[CreateAssetMenu(fileName = "NewDialogue", menuName = "Game/Dialogue", order = 0)]
public class Dialogue : ScriptableObject, ISerializationCallbackReceiver
{
[SerializeField]
List<DialogueNode> nodes = new();
Dictionary<string, DialogueNode> nodeDictionary;
[SerializeField]
Vector2 _newNodeOffset = new(250, 0);
void Awake() {
RebuildNodeIndex();
}
void OnValidate() {
RebuildNodeIndex();
}
void RebuildNodeIndex() {
nodeDictionary = nodes.Where(node => node.name != null).ToDictionary(node => node.name);
}
public List<DialogueNode> Nodes {
get { return nodes; }
}
public IEnumerable<DialogueNode> GetAllChildren(DialogueNode parentNode) {
return parentNode.GetChildren().Where(childID => nodeDictionary.ContainsKey(childID)).Select(childID => nodeDictionary[childID]);
}
#if UNITY_EDITOR
public void CreateNode(DialogueNode parent) {
DialogueNode node = MakeNode(parent);
Undo.RegisterCreatedObjectUndo(node, "Created Dialogue Node");
Undo.RecordObject(this, "Added Dialogue Node");
AddNode(node);
}
void AddNode(DialogueNode node) {
nodes.Add(node);
RebuildNodeIndex();
}
DialogueNode MakeNode(DialogueNode parent) {
var node = CreateInstance<DialogueNode>();
node.name = Guid.NewGuid().ToString();
if (parent != null) {
node.Position = parent.Position + _newNodeOffset;
node.IsPlayerSpeaking = !parent.IsPlayerSpeaking;
parent.AddChild(node.name);
}
return node;
}
public void DeleteNode(DialogueNode nodeToDelete) {
Undo.RegisterCreatedObjectUndo(this, "Remove Dialogue Node");
nodes.Remove(nodeToDelete);
RebuildNodeIndex();
foreach (DialogueNode node in nodes) {
node.RemoveChild(nodeToDelete.name);
}
Undo.DestroyObjectImmediate(nodeToDelete);
}
#endif
public void OnBeforeSerialize() {
#if UNITY_EDITOR
if (nodes.Count == 0) {
var root = MakeNode(null);
AddNode(root);
}
if (AssetDatabase.GetAssetPath(this) != "") {
foreach (var node in nodes.Where(node => AssetDatabase.GetAssetPath(node) == "")) {
AssetDatabase.AddObjectToAsset(node, this);
}
}
#endif
}
public void OnAfterDeserialize() {
}
}
}
fileFormatVersion: 2
guid: 770ba402795ad304b84ff991d7fe01d4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
namespace TagFighter.Testing.Optics
{
using CareBoo.Serially;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using TagFighter.Effects;
using TagFighter.Effects.ResourceLocationAccessors.ContextRegisters;
using TagFighter.Resources;
using UnityEngine;
public interface ILens<Whole, Part>
{
Part Get(Whole whole);
Whole Set(Part part, Whole whole);
}
public readonly struct Lens<TWhole, TPart>
{
public readonly Func<TWhole, TPart> Get;
public readonly Func<TWhole, TPart, TWhole> Set;
public Lens(Func<TWhole, TPart> getter, Func<TWhole, TPart, TWhole> setter) {
Get = getter ?? throw new ArgumentNullException(nameof(getter));
Set = setter ?? throw new ArgumentNullException(nameof(setter));
}
}
public static class LensExtensions
{
public static Lens<TWhole, TPart> Lens<TWhole, TPart>(
this TWhole _,
Func<TWhole, TPart> getter, Func<TWhole, TPart, TWhole> setter) =>
new(getter, setter);
//public static TWhole Update<TWhole, TPart>(
// this Lens<TWhole, TPart> lens,
// TWhole whole, Func<TPart, TPart> update) =>
// lens.Set(whole, update(lens.Get(whole)));
public static Lens<TWhole, TSubPart> Compose<TWhole, TPart, TSubPart>(
this Lens<TWhole, TPart> parent, Lens<TPart, TSubPart> child) =>
new(
whole => child.Get(parent.Get(whole)),
(whole, part) => parent.Set(whole, child.Set(parent.Get(whole), part)));
}
public interface IResourceStatLensCreator
{
public Lens<TResource, Unit<TUnitType>> Create<TResource, TUnitType>()
where TResource : Resource<TUnitType>
where TUnitType : IUnitType;
}
[ProvideSourceInfo]
[Serializable]
public class ResourceCurrentLensCreator : IResourceStatLensCreator
{
public Lens<TResource, Unit<TUnitType>> Create<TResource, TUnitType>()
where TResource : Resource<TUnitType>
where TUnitType : IUnitType {
return new Lens<TResource, Unit<TUnitType>>(r => r.GetCurrent(), (r, u) => r);
}
}
[ProvideSourceInfo]
[Serializable]
public class ResourceCapacityLensCreator : IResourceStatLensCreator
{
public Lens<TResource, Unit<TUnitType>> Create<TResource, TUnitType>()
where TResource : Resource<TUnitType>
where TUnitType : IUnitType {
return new Lens<TResource, Unit<TUnitType>>(r => r.GetCapacity(), (r, u) => r);
}
}
public interface ILocationAccessor { };
public interface IPawnAccessor
{
public Lens<Transform, int> CreateSpecific<TResource, TUnitType>() where TResource : Resource<TUnitType> where TUnitType : IUnitType;
};
[ProvideSourceInfo]
[Serializable]
public class PawnAccessor : IPawnAccessor, ILocationAccessor
{
[SerializeReference, ShowSerializeReference]
public IResourceStatLensCreator ResourceLensCreator; // Current/Capacity
public Lens<Transform, int> CreateSpecific<TResource, TUnitType>()
where TResource : Resource<TUnitType>
where TUnitType : IUnitType {
var resource = new Lens<Transform, TResource>(t => t.GetComponent<TResource>(), (t, r) => t);
var statLens = ResourceLensCreator.Create<TResource, TUnitType>();
var valueLens = new Lens<Unit<TUnitType>, int>(u => u.AsPrimitive(), (u, v) => u = (Unit<TUnitType>)v);
var lens = resource.Compose(statLens).Compose(valueLens);
return lens;
}
}
public interface IContextAccessor
{
public Lens<EffectContext, int> CreateSpecificResource<TResource, TUnitType>()
where TResource : Resource<TUnitType> where TUnitType : IUnitType;
public Lens<EffectContext, int> CreateSpecific<TResource, TUnitType, TContextRegister>()
where TResource : Resource<TUnitType> where TUnitType : IUnitType where TContextRegister : IContextRegister;
}
[ProvideSourceInfo]
[Serializable]
public class ContextAccessor : IContextAccessor, ILocationAccessor
{
[TypeFilter(derivedFrom: typeof(ContextRegister<>))]
[SerializeField]
public SerializableType Register;
[SerializeReference, ShowSerializeReference]
public IResourceOperator Fold;
public Lens<EffectContext, int> CreateSpecificResource<TResource, TUnitType>()
where TResource : Resource<TUnitType>
where TUnitType : IUnitType {
var createSpecificLensMethod = typeof(ContextAccessor).GetMethod(nameof(CreateSpecific)).
MakeGenericMethod(typeof(TResource), typeof(TUnitType), Register.Type);
var lens = createSpecificLensMethod.Invoke(this, null);
return (Lens<EffectContext, int>)lens;
}
public Lens<EffectContext, int> CreateSpecific<TResource, TUnitType, TContextRegister>()
where TResource : Resource<TUnitType>
where TUnitType : IUnitType
where TContextRegister : IContextRegister {
var registerLens = new Lens<EffectContext, Unit<TUnitType>>(
context => context.GetResource<TResource, TUnitType, TContextRegister>(),
(context, v) => {
context.SetResource<TResource, TUnitType, TContextRegister>(v);
return context;
});
var valueLens = new Lens<Unit<TUnitType>, int>(u => u.AsPrimitive(), (u, v) => u = (Unit<TUnitType>)v);
return registerLens.Compose(valueLens);
}
}
[ProvideSourceInfo]
[Serializable]
public class EffectDataAccessor
{
[TypeFilter(derivedFrom: typeof(Resource<>))]
[SerializeField]
public SerializableType Resource;
[SerializeReference, ShowSerializeReference] ILocationAccessor _location;
public IEnumerable<int> Get(EffectInput ei) {
switch (_location) {
case PawnAccessor accessor:
var pawnLens = PawnLens(accessor);
return ei.Affected.Select(p => pawnLens.Get(p));
case ContextAccessor accessor:
var contextLens = ContextLens(accessor);
return Enumerable.Empty<int>().Append(contextLens.Get(ei.Context));
default:
return Enumerable.Empty<int>();
}
}
public EffectInput Set(EffectInput ei, IEnumerable<int> values) {
switch (_location) {
case PawnAccessor accessor:
var pawnLens = PawnLens(accessor);
var repeatedValues = Enumerable.Repeat(values.ToList(), int.MaxValue).SelectMany(value => value);
foreach (var tuple in ei.Affected.Zip(repeatedValues, (transform, value) => (transform, value))) {
pawnLens.Set(tuple.transform, tuple.value);
}
break;
case ContextAccessor accessor:
var contextLens = ContextLens(accessor);
contextLens.Set(ei.Context, accessor.Fold.OperateEnum(values));
break;
}
return ei;
}
Lens<Transform, int> PawnLens(PawnAccessor accessor) {
var createSpecificLensMethod = typeof(PawnAccessor).GetMethod(nameof(PawnAccessor.CreateSpecific)).
MakeGenericMethod(Resource.Type, Resource.Type.BaseType.GetGenericArguments()[0]);
var lens = createSpecificLensMethod.Invoke(accessor, null);
return (Lens<Transform, int>)lens;
}
Lens<EffectContext, int> ContextLens(ContextAccessor accessor) {
var createSpecificLensMethod = typeof(ContextAccessor).GetMethod(nameof(ContextAccessor.CreateSpecificResource)).
MakeGenericMethod(Resource.Type, Resource.Type.BaseType.GetGenericArguments()[0]);
var lens = createSpecificLensMethod.Invoke(accessor, null);
return (Lens<EffectContext, int>)lens;
}
}
}
fileFormatVersion: 2
guid: 580430f5af31371469f9165b636ba8c6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
opticsTester:
_transforms:
- {fileID: 1683100414}
- {fileID: 1190570253}
_from:
Resource:
typeId: 7f412c19-18fe-476f-92e4-469ffad0c5d4
_location:
rid: 8942665896105607170
_to:
Resource:
typeId: da13f1c1-4359-4eb9-b969-7db50afe6423
_location:
rid: 8942665896105607172
_rg:
Resource:
rid: 8942665896105607182
Location:
rid: 8942665896105607183
ResourceType:
typeId: 7f412c19-18fe-476f-92e4-469ffad0c5d4
Multiplier: 1
Addend: 0
_rs:
Resource:
rid: 8942665896105607178
Location:
rid: 8942665896105607179
Multiplier: 1
Addend: 0
actionsTester:
_weaver: {fileID: 1829046329}
_transform1: {fileID: 1683100414}
_transform2: {fileID: 1190570253}
references:
version: 2
RefIds:
- rid: 8942665896105607170
type: {class: PawnAccessor, ns: TagFighter.Testing.Optics, asm: Assembly-CSharp}
data:
ResourceLensCreator:
rid: 8942665896105607171
- rid: 8942665896105607171
type: {class: ResourceCurrentLensCreator, ns: TagFighter.Optics, asm: Assembly-CSharp}
- rid: 8942665896105607172
type: {class: ContextAccessor, ns: TagFighter.Testing.Optics, asm: Assembly-CSharp}
data:
Register:
typeId: 47eae1ff-9ff5-41fd-b08e-0f674b3848e6
Fold:
rid: 8942665896105607176
- rid: 8942665896105607176
type: {class: Max, ns: TagFighter.Effects.Operators, asm: Assembly-CSharp}
- rid: 8942665896105607178
type: {class: RedTag, ns: TagFighter.Effects.ResourceTypeAccessors, asm: Assembly-CSharp}
- rid: 8942665896105607179
type: {class: Context, ns: TagFighter.Effects.ResourceLocationAccessors.Set,
asm: Assembly-CSharp}
data:
Register:
rid: 8942665896105607180
SetAs:
rid: 8942665896105607181
- rid: 8942665896105607180
type: {class: Current, ns: TagFighter.Effects.ResourceLocationAccessors.ContextRegisters,
asm: Assembly-CSharp}
- rid: 8942665896105607181
type: {class: Sum, ns: TagFighter.Effects.Operators, asm: Assembly-CSharp}
- rid: 8942665896105607182
type: {class: RedTag, ns: TagFighter.Effects.ResourceTypeAccessors, asm: Assembly-CSharp}
- rid: 8942665896105607183
type: {class: Context, ns: TagFighter.Effects.ResourceLocationAccessors.Get,
asm: Assembly-CSharp}
data:
Register:
rid: 8942665896105607184
- rid: 8942665896105607184
type: {class: Current, ns: TagFighter.Effects.ResourceLocationAccessors.ContextRegisters,
asm: Assembly-CSharp}
_actionsTester:
_weaver: {fileID: 0}
_transform1: {fileID: 0}
_transform2: {fileID: 0}
--- !u!114 &1829046329 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 1763275424511731206, guid: 689a4763a3cde4b46a7c011ddb15ea97,
type: 3}
m_PrefabInstance: {fileID: 1446124018}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 07f01f81836cb3d488d4164378aa326b, type: 3}
m_Name:
m_EditorClassIdentifier: