754VCJRLAZAVIQP7STLUIHP3U7PUHBTYAHLNQK4A2H6IKYVNTDKAC
NPTXIY5PL7XQUOFJ2WRAZUBHMC4OFZVF4EA74GBI63TJ4QXDKMAAC
7K6FVQLVXHRANKJ3C4Q7PTMJIBGGOGWN2D6VH33NA25267VFXZCAC
VZRSH4U473FCZOP5EXURPXXN5J6F3ZLT435YY7A2JHLG2ZZB5KLQC
G4ODCLUUQ6V23B2DSMLQTRVLSBVBVO5CFZBXVZ6C3S63N7TECDHAC
ZZLU6UG75ALN7BYLP4SLGT4SIHDKJPFZPMNSYST25RQT3KLTFHPAC
6BA5NHNF3UWSL65KCWSXLRTPGYVS4N4NORDJ4FZTZ5SRRDPI4YZAC
RZAMG2H2NY73KZJIV4VXLJHJVSRGJDRWWZJERAI6O7AVDW64JEQQC
A6K2SVTQ3JQ3TC3F44H3ERSX47TRQ6R5EJGIRJKFGKZG6I4HOATQC
HXTSBPAP75A7EC4RKWYQMVPPHPNZFPHUORBZWDHGEB6MPAGI7G7AC
VU32ZIRYU6LCQJFGN4ZA3IQ5HNY5J4PNI5OCPW24L7YBOI3BOTYAC
QOAVQCDV2MRAPUX62ZLDTUB6AXYSAGEEWIEZIG4TGIQKCLP5T5GAC
M2C63XUU3TKYAUPPSPEFVF4CMBQMCVLZATANFWQW35MMYNRB2SEAC
QZXURLSF73UL67TIXDHMVS7DCFZLQJAPJ6BAGRGXOHH46VMNKGPQC
N6YTMLNYZLR4BEDGYC7RJQ43KJ3XZFILZ6ODN26Z7RF3LZ6LVUOQC
IA2O33JCJVSJ3IVBBHX2XQU4BCPL3X6JDDZ2R2KNGUFPWXAUKO7QC
2ICHN37Z2OZ455ALKTMXTV5JOULQBN5UN46OM6JCHMF3CPNHFF3AC
AZN3UTBQLTKMGIHW5UCAMLC4GGHG6MAORBQ7OIR2U7NTZ53GWGNQC
NQXDEYOPZBO7AZJHBEBNMBR3QFE4OAQFK4FHOIGKD7TXE256X23AC
S6LIARO3HIMP67ZDRIPPU3NC4GM6JQQODDIFGZH5HBN75JHFFSQAC
S5OSCH7CRN2YEKVTCTJXNLYR2B3PEGCCBUGTN2M6QOCKBNJR62NAC
DGC7DHJWSP6BZMDKZ6FG6YS7P2RXZWKFROBYHEX4KZCG7HFBLSUQC
MHN2B5YZ2Y4G3O7UOZJKFQ3SSP5HTNJCXFKCO3KYY46I2GHM3TIQC
GRTHEQW3VTYOB4CSVAB4VBEAW6MRVAJRV4CBXOIRSUFMO7SK3GCAC
O236B5LO6PHJ4TPZGYXDVSLB5EGXXRRLYYVWI46DPL5LEGXEIHZQC
DIEGZM3YMQCKTQW3NLESFZBOGMWW6FT6TZOUL7IUAJD2X5IISUYAC
34XRSILIYXGOXE3ZAO5HA22CCXHKKOZ52ZN4CI7TA4FH3XF2XKQAC
M3YG7SBTVP5RPIHG2OU4KL55YLWTAITUAU7JB5DZ525O7CBSPH3QC
ZHJFVCAJGFFEQCY6IZW2VFXBDTTWLBKDIABIGMF4CZOMTGYJKCYQC
J75RIWLT42QXABT6GQMAVIOP5XDUF7UAGFQUSSKDIULB3LEB22EQC
FIMVA3BI72IWMBRN5T3PKDCKSJW667BH25INKDWSPWGHLRKCNAPAC
5YUI4V7A6ONEYREG5CXWHMBYCOP6Q3GMMQD2OTHXZAGKCGM4FWBAC
KAROCU3SAOGWWSFXGCLE5OW76VTDJR4HDIVTK62BIAESN5SOHVDAC
62YQ7EMUYX7GS3AB6FAJDKNX53LVG6T2EH6NMVS6JV36J5VCOKIAC
BJF3R3X6UV7VZ4FUKHMPMYFN3RDEKLNXHLHA2H7QLQVRADSPZD4QC
2ZZM2HIS7HNIMK3Q6ALHIMQYLKNIHUOL6FJ57O6SR77VAMEINLWAC
4JF2MUNF23IFAVVECZNP3JJLFPEB36V7FDRQOKIZNF6Q2FAGOFRQC
2SLVO3SYIJQOEV2YNSD73BSUSWQNZVROQCGHJCPCDSMCCNKZTQFQC
HUULCHM5GFGZ7GKLCULFHC333LQ3LBI62VKII3YL5O4C5CDGCT4AC
I33Z5QD6JHPO7W7G3EHGBIXQABW6ZOC2W4NJP6L5ENDPFRORUFNAC
KM44OG3YNGF45JHSB4HOGBIDHNWS4N6LEODIRYNN6YAPPMEU5I6QC
XF52N4U7HWXOF4PDSCR7LCUENLTSXLWEZGS2IJ6562KYI567Z2GAC
7QKPEDFDFQJFTXM4BFJ4CFHOOZKOI6NKRRSBDLMP7SELPJMFOQRAC
CD5FF75KTOBTMVMTMCKMR6F5DFKOF26I5K43ITNHGBI3ZAZHA4RAC
MDJQTAONL4M7SFFORMXLJHA7WBDTDTRZAZ544JR23SODSCWSVZ3AC
NZIEX6J6Q6DSJKNSCTHNIA6EJDQEGMK3ZSP3LKX2UAEDHURQPRVQC
4PLSNSVW4VOQW5ZXXZGUWB56WI33SXTGWOCD7PNE36OWDGD7NRJAC
XIPU27GAVXMAKDP42DDSYNA6DSN5WBHH6AG4EK6YIIM43AQQHQAAC
WKHLLZ3K732M7VJ5KWDSLRWZUARDNDP6ODAXD6SW43CHCT5DX5SAC
LTG4LQJEMFY22QOI6E5HM3U4OE3JCYRFJ6VGW3KI3AFTMHZCTWRAC
5I5QA3YK5G5QQCXMSDOEAX3A74LVXV7PYWAIHMLFANR2GUFWMKGQC
3JTZIZGE6WPLZCIWXXLG3SQA2LVSVP26P7U52YBMBTY2VCC6LBLAC
JMMGK6VQWZOLY6C6YWUPAIHLQXUZ2ZZTVJQAL7ODPZAWUSZQIJJAC
6PTVYMJH7JKB54XWYGZG2TWYKC5Y2LP4FUN7GJKSW4LO33DE5OTQC
5VVJCVERFU6ZMLSEW5TWRUHOLYL2ATFLNMWAEEJBXCG2RM3MJGSAC
EF6FXKYIVJCURLSC2CLS27FCTECIIIU2EEPI352ZTCIKYKW5VOBQC
ROTMK5LNNK7T5YXVOMUODVMCQWIHPZYOME4WDIAMZJ4VXD7SOEBAC
P5O6MKCMZL3DK7ZO5SBWTCHOQB6O2MZA5VPSCQX6X4LJQVOWYV7AC
CPSTCZQDYQXOBGGW57QYLVGQLCMLXAIIBEZP3IQF3VFNHQC3CUPQC
VPXUP5WZTVC3OVD73TNKPK43IAGFXGUGCEJT56JM4IT4APYQXUHAC
fileFormatVersion: 2
guid: 0d8877ca28e2c1840a438a7203d82491
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
namespace TagFighter.UnitControl
{
[CreateAssetMenu(fileName = "NewUnitControllerType", menuName = "Game/Control/UnitControllerType")]
public class UnitControllerType : ScriptableObject { }
}
fileFormatVersion: 2
guid: 7091ffc98d65ebf4a8279f8c34e4369b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences:
- ControlledBy: {instanceID: 0}
- _eventAggregator: {fileID: 11400000, guid: 7674cb78dbff8d447b6c39984750a2da, type: 2}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using System.Collections;
using System.Collections.Generic;
using TagFighter.Events;
using TagFighter.UnitControl;
using UnityEngine;
namespace TagFighter.Events
{
public class UnitControllerTargetStartedEventArgs : EventArgs
{
public Transform UnitTransform { get; }
public UnitControllerType ControlledBy { get; }
public UnitControllerTargetStartedEventArgs(Transform unitTransform, UnitControllerType controlledBy) {
UnitTransform = unitTransform;
ControlledBy = controlledBy;
}
}
}
namespace TagFighter.UnitControl
{
public class UnitControllerTarget : MonoBehaviour
{
public UnitControllerType ControlledBy;
[SerializeField] EventAggregator _eventAggregator;
protected void Start() {
_eventAggregator.OnUnitControllerStarted(this, new(transform, ControlledBy));
}
}
}
using System;
using TagFighter.Effects;
using TagFighter.Resources;
using UnityEngine;
namespace TagFighter
{
public class WeaveAction : IAction
{
FollowAction _followAction;
Transform _target;
Weaver _weaver;
RuneWeavingContainer _runeWeaving;
Resources.Range _range;
bool _startedWeaving = false;
static State s_resetState = new(true, 1f, false, default);
bool _disposed = false;
int _lastRange;
EffectContext _context;
ITimeContextContainer _timeContextContainer;
public WeaveAction(Weaver unit, RuneWeavingContainer runeWeaving, Transform target, Resources.Range range) {
if (range is null) {
throw new ArgumentNullException("range");
}
_target = target;
_range = range;
_weaver = unit;
_runeWeaving = runeWeaving;
var currentRange = _range.GetCurrent();
_lastRange = currentRange.AsPrimitive();
_followAction = new(_weaver, _target, currentRange.ToMeter());
_range.ResourceChanged += OnResourceChanged;
_context = new EffectContext() {
EffectLocation = target,
Caster = unit.transform
};
}
void OnResourceChanged(object sender, ResourceChangeArgs e) {
if (_lastRange != e.Current) {
_followAction.Dispose();
_followAction = new(_weaver, _target, _range.GetCurrent().ToMeter());
_lastRange = e.Current;
}
}
public IActionState Advance() {
var stateToReturn = _followAction.Advance();
if (IsInAttackRange()) {
if (_startedWeaving == false) {
Debug.Log("Target got in range, weaving");
_timeContextContainer = _runeWeaving.RuneWeaving.CreateTimeContexts();
}
_startedWeaving = true;
var isAdvanced = _runeWeaving.RuneWeaving.Advance(_timeContextContainer, _context, Time.deltaTime);
stateToReturn = new State(isAdvanced, CompletionStatus(), false, _runeWeaving.RuneWeaving.GetCurrentMove(_timeContextContainer));
}
else {
if (_startedWeaving) {
Debug.Log("Target escaped");
stateToReturn = new State(false, CompletionStatus(), stateToReturn.IsMoving, _runeWeaving.RuneWeaving.GetCurrentMove(_timeContextContainer));
}
}
return stateToReturn;
}
IActionState Cancel() {
_timeContextContainer = null;
return s_resetState;
}
public float CompletionStatus() => _runeWeaving.RuneWeaving.CompletionStatus(_timeContextContainer);
public override string ToString() {
return $"{_runeWeaving.WeaveName} -> {_target.name}";
}
bool IsInAttackRange() {
// Incorrect in case there are hills. should calc range from feet.
Vector3 source = new(_weaver.transform.position.x, 0, _weaver.transform.position.z);
Vector3 target = new(_target.position.x, 0, _target.position.z);
return Vector3.Distance(source, target) <= _range.GetCurrent().ToMeter();
}
public void Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing) {
if (!_disposed) {
if (disposing) {
Cancel();
_followAction.Dispose();
_followAction = null;
_range.ResourceChanged -= OnResourceChanged;
_range = null;
_runeWeaving = null;
_target = null;
_weaver = null;
}
_disposed = true;
}
}
public readonly struct State : IActionState
{
public bool IsAdvanced { get; }
public float CompletionStatus { get; }
public bool IsMoving { get; }
public CombatMove Move { get; }
public State(bool isAdvanced, float completionStatus, bool isMoving, CombatMove move) {
IsAdvanced = isAdvanced;
CompletionStatus = completionStatus;
IsMoving = isMoving;
Move = move;
}
}
}
}
using System;
using TagFighter.Effects;
using TagFighter.Resources;
using UnityEngine;
namespace TagFighter
{
public class WeaveAction : IAction
{
FollowAction _followAction;
Transform _target;
Weaver _weaver;
RuneWeavingContainer _runeWeaving;
Resources.Range _range;
bool _startedWeaving = false;
static State s_resetState = new(true, 1f, false, default);
bool _disposed = false;
int _lastRange;
EffectContext _context;
ITimeContextContainer _timeContextContainer;
public WeaveAction(Weaver unit, RuneWeavingContainer runeWeaving, Transform target, Resources.Range range) {
if (range is null) {
throw new ArgumentNullException("range");
}
_target = target;
_range = range;
_weaver = unit;
_runeWeaving = runeWeaving;
var currentRange = _range.GetCurrent();
_lastRange = currentRange.AsPrimitive();
_followAction = new(_weaver, _target, currentRange.ToMeter());
_range.ResourceChanged += OnResourceChanged;
_context = new EffectContext() {
EffectLocation = target,
Caster = unit.transform
};
}
void OnResourceChanged(object sender, ResourceChangeArgs e) {
if (_lastRange != e.Current) {
_followAction.Dispose();
_followAction = new(_weaver, _target, _range.GetCurrent().ToMeter());
_lastRange = e.Current;
}
}
public IActionState Advance() {
var stateToReturn = _followAction.Advance();
if (IsInAttackRange()) {
if (_startedWeaving == false) {
Debug.Log("Target got in range, weaving");
_timeContextContainer = _runeWeaving.RuneWeaving.CreateTimeContexts();
}
_startedWeaving = true;
var isAdvanced = _runeWeaving.RuneWeaving.Advance(_timeContextContainer, _context, Time.deltaTime);
stateToReturn = new State(isAdvanced, CompletionStatus(), false, _runeWeaving.RuneWeaving.GetCurrentMove(_timeContextContainer));
}
else {
if (_startedWeaving) {
Debug.Log("Target escaped");
stateToReturn = new State(false, CompletionStatus(), stateToReturn.IsMoving, _runeWeaving.RuneWeaving.GetCurrentMove(_timeContextContainer));
}
}
return stateToReturn;
}
IActionState Cancel() {
_timeContextContainer = null;
return s_resetState;
}
public float CompletionStatus() => _runeWeaving.RuneWeaving.CompletionStatus(_timeContextContainer);
public bool IsSimilarAction(IActionRead action) {
if (action is not WeaveAction other) {
return false;
}
return other != null && _target == other._target && _weaver == other._weaver && _runeWeaving.WeaveName == other._runeWeaving.WeaveName;
}
public override string ToString() {
return $"{_runeWeaving.WeaveName} -> {_target.name}";
}
bool IsInAttackRange() {
// Incorrect in case there are hills. should calc range from feet.
Vector3 source = new(_weaver.transform.position.x, 0, _weaver.transform.position.z);
Vector3 target = new(_target.position.x, 0, _target.position.z);
return Vector3.Distance(source, target) <= _range.GetCurrent().ToMeter();
}
public void Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing) {
if (!_disposed) {
if (disposing) {
Cancel();
_followAction.Dispose();
_followAction = null;
_range.ResourceChanged -= OnResourceChanged;
_range = null;
_runeWeaving = null;
_target = null;
_weaver = null;
}
_disposed = true;
}
}
public readonly struct State : IActionState
{
public bool IsAdvanced { get; }
public float CompletionStatus { get; }
public bool IsMoving { get; }
public CombatMove Move { get; }
public State(bool isAdvanced, float completionStatus, bool isMoving, CombatMove move) {
IsAdvanced = isAdvanced;
CompletionStatus = completionStatus;
IsMoving = isMoving;
Move = move;
}
}
}
}
using System;
using UnityEngine;
using UnityEngine.AI;
namespace TagFighter
{
public class MoveToAction : IAction
{
Vector3 _lastTargetPosition;
NavMeshAgent _agent;
float _originalStoppingDistance;
float _desiredStoppingDistance;
bool _isFirstAdvance = true;
static State s_resetState = new(false, 0f, false);
bool _disposed = false;
public MoveToAction(Weaver unit, Vector3 target) {
if (unit == null) {
throw new ArgumentNullException("unit");
}
if (unit.TryGetComponent(out _agent) == false) {
throw new ArgumentException("Missing NavMeshAgent", "unit");
}
_lastTargetPosition = target;
_desiredStoppingDistance = _agent.stoppingDistance;
}
public MoveToAction(Weaver unit, Vector3 target, float stoppingDistance) {
if (unit == null) {
throw new ArgumentNullException("unit");
}
if (stoppingDistance < 0) {
throw new ArgumentException("Cannot be < 0", "stoppingDistance");
}
if (unit.TryGetComponent(out _agent) == false) {
throw new ArgumentException("Missing NavMeshAgent", "unit");
}
_lastTargetPosition = target;
_desiredStoppingDistance = stoppingDistance;
}
public bool SetDestination(Vector3 target) {
_lastTargetPosition = target;
return _agent.SetDestination(target);
}
public void SetStoppingDistance(float stoppingDistance) {
if (stoppingDistance < 0) {
throw new ArgumentException("Cannot be < 0", "stoppingDistance");
}
_desiredStoppingDistance = stoppingDistance;
_agent.stoppingDistance = _desiredStoppingDistance;
}
public IActionState Advance() {
if (_isFirstAdvance) {
_originalStoppingDistance = _agent.stoppingDistance;
_agent.stoppingDistance = _desiredStoppingDistance;
_agent.isStopped = false;
_agent.SetDestination(_lastTargetPosition);
_isFirstAdvance = false;
}
var isAdvanced = !_agent.hasPath || _agent.pathPending || _agent.remainingDistance > _agent.stoppingDistance;
return new State(isAdvanced, CompletionStatus(), isAdvanced);
}
IActionState Cancel() {
_agent.isStopped = true;
_agent.stoppingDistance = _originalStoppingDistance;
_agent.ResetPath();
_isFirstAdvance = true;
return s_resetState;
}
public float CompletionStatus() {
return 0;
}
public override string ToString() {
return $"Move -> {_lastTargetPosition}";
}
public void Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing) {
if (!_disposed) {
if (disposing) {
Cancel();
_agent = null;
}
_disposed = true;
}
}
public readonly struct State : IActionState
{
public bool IsAdvanced { get; }
public float CompletionStatus { get; }
public bool IsMoving { get; }
public State(bool isAdvanced, float completionStatus, bool isMoving) {
IsAdvanced = isAdvanced;
CompletionStatus = completionStatus;
IsMoving = isMoving;
}
}
}
}
using System;
using UnityEngine;
using UnityEngine.AI;
namespace TagFighter
{
public class MoveToAction : IAction
{
Vector3 _lastTargetPosition;
NavMeshAgent _agent;
float _originalStoppingDistance;
float _desiredStoppingDistance;
bool _isFirstAdvance = true;
static State s_resetState = new(false, 0f, false);
bool _disposed = false;
public MoveToAction(Weaver unit, Vector3 target) {
if (unit == null) {
throw new ArgumentNullException("unit");
}
if (unit.TryGetComponent(out _agent) == false) {
throw new ArgumentException("Missing NavMeshAgent", "unit");
}
_lastTargetPosition = target;
_desiredStoppingDistance = _agent.stoppingDistance;
}
public MoveToAction(Weaver unit, Vector3 target, float stoppingDistance) {
if (unit == null) {
throw new ArgumentNullException("unit");
}
if (stoppingDistance < 0) {
throw new ArgumentException("Cannot be < 0", "stoppingDistance");
}
if (unit.TryGetComponent(out _agent) == false) {
throw new ArgumentException("Missing NavMeshAgent", "unit");
}
_lastTargetPosition = target;
_desiredStoppingDistance = stoppingDistance;
}
public bool SetDestination(Vector3 target) {
_lastTargetPosition = target;
return _agent.SetDestination(target);
}
public void SetStoppingDistance(float stoppingDistance) {
if (stoppingDistance < 0) {
throw new ArgumentException("Cannot be < 0", "stoppingDistance");
}
_desiredStoppingDistance = stoppingDistance;
_agent.stoppingDistance = _desiredStoppingDistance;
}
public IActionState Advance() {
if (_isFirstAdvance) {
_originalStoppingDistance = _agent.stoppingDistance;
_agent.stoppingDistance = _desiredStoppingDistance;
_agent.isStopped = false;
_agent.SetDestination(_lastTargetPosition);
_isFirstAdvance = false;
}
var isAdvanced = _agent.hasPath || _agent.pathPending || _agent.remainingDistance > _agent.stoppingDistance;
return new State(isAdvanced, CompletionStatus(), isAdvanced);
}
IActionState Cancel() {
_agent.isStopped = true;
_agent.stoppingDistance = _originalStoppingDistance;
_agent.ResetPath();
_isFirstAdvance = true;
return s_resetState;
}
public float CompletionStatus() {
return 0;
}
public bool IsSimilarAction(IActionRead action) {
if (action is not MoveToAction other) {
return false;
}
return other != null && _agent == other._agent && _lastTargetPosition == other._lastTargetPosition;
}
public override string ToString() {
return $"Move -> {_lastTargetPosition}";
}
public void Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing) {
if (!_disposed) {
if (disposing) {
Cancel();
_agent = null;
}
_disposed = true;
}
}
public readonly struct State : IActionState
{
public bool IsAdvanced { get; }
public float CompletionStatus { get; }
public bool IsMoving { get; }
public State(bool isAdvanced, float completionStatus, bool isMoving) {
IsAdvanced = isAdvanced;
CompletionStatus = completionStatus;
IsMoving = isMoving;
}
}
}
}
using System;
namespace TagFighter
{
public interface IAction : IDisposable
{
public IActionState Advance();
public float CompletionStatus();
}
public interface IActionState
{
public bool IsAdvanced { get; }
public float CompletionStatus { get; }
public bool IsMoving { get; }
}
}
using System;
namespace TagFighter
{
public interface IActionRead
{
public float CompletionStatus();
public bool IsSimilarAction(IActionRead action);
}
public interface IAction : IActionRead, IDisposable
{
public IActionState Advance();
}
public interface IActionState
{
public bool IsAdvanced { get; }
public float CompletionStatus { get; }
public bool IsMoving { get; }
}
}
using System;
using UnityEngine;
namespace TagFighter
{
public class FollowAction : IAction
{
MoveToAction _moveAction;
Transform _target;
Vector3 _lastTargetPosition;
bool _disposed = false;
public FollowAction(Weaver unit, Transform target) {
_target = target ?? throw new ArgumentNullException("targetToFollow");
_lastTargetPosition = target.position;
_moveAction = new(unit, _lastTargetPosition);
}
public FollowAction(Weaver unit, Transform target, float stoppingDistance) {
_target = target ?? throw new ArgumentNullException("targetToFollow");
_lastTargetPosition = target.position;
_moveAction = new(unit, _lastTargetPosition, stoppingDistance);
}
public void SetStoppingDistance(float stoppingDistance) {
_moveAction.SetStoppingDistance(stoppingDistance);
}
public IActionState Advance() {
if (_lastTargetPosition != _target.position) {
_lastTargetPosition = _target.position;
_moveAction.SetDestination(_lastTargetPosition);
}
return _moveAction.Advance();
}
public float CompletionStatus() {
return 0;
}
public void Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing) {
if (!_disposed) {
if (disposing) {
_moveAction.Dispose();
_moveAction = null;
_target = null;
}
_disposed = true;
}
}
public override string ToString() {
return $"Follow {_target.name}";
}
}
}
using System;
using UnityEngine;
namespace TagFighter
{
public class FollowAction : IAction
{
MoveToAction _moveAction;
Transform _target;
Vector3 _lastTargetPosition;
bool _disposed = false;
public FollowAction(Weaver unit, Transform target) {
_target = target != null ? target : throw new ArgumentNullException("targetToFollow");
_lastTargetPosition = target.position;
_moveAction = new(unit, _lastTargetPosition);
}
public FollowAction(Weaver unit, Transform target, float stoppingDistance) {
_target = target != null ? target : throw new ArgumentNullException("targetToFollow");
_lastTargetPosition = target.position;
_moveAction = new(unit, _lastTargetPosition, stoppingDistance);
}
public void SetStoppingDistance(float stoppingDistance) {
_moveAction.SetStoppingDistance(stoppingDistance);
}
public IActionState Advance() {
if (_lastTargetPosition != _target.position) {
_lastTargetPosition = _target.position;
_moveAction.SetDestination(_lastTargetPosition);
}
return _moveAction.Advance();
}
public float CompletionStatus() {
return 0;
}
public bool IsSimilarAction(IActionRead action) {
if (action is not FollowAction other) {
return false;
}
return other != null && _target == other._target;
}
public void Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing) {
if (!_disposed) {
if (disposing) {
_moveAction.Dispose();
_moveAction = null;
_target = null;
}
_disposed = true;
}
}
public override string ToString() {
return $"Follow {_target.name}";
}
}
}
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace TagFighter.Actions
{
public class TakeActionEventArgs : EventArgs
{
public IActionState ActionState { get; }
public TakeActionEventArgs(IActionState actionState) {
ActionState = actionState;
}
}
public class ActionPlan : MonoBehaviour, IEnumerable<IAction>
{
public event EventHandler<TakeActionEventArgs> ActionTaken;
public event EventHandler<UnitActionEventArgs> PlanChanged;
Line<IAction> _plannedActions = new(capacity: 6);
protected void OnActionTaken(TakeActionEventArgs e) {
ActionTaken?.Invoke(this, e);
}
protected void OnPlannedActionsChanged(UnitActionEventArgs e) {
PlanChanged?.Invoke(this, e);
}
protected void Update() {
if (_plannedActions.TryPeek(out var action)) {
var actionState = action.Advance();
OnActionTaken(new(actionState));
if (!actionState.IsAdvanced) {
action.Dispose();
_plannedActions.TryGetFirstOutOfLine(out var _);
OnPlannedActionsChanged(new(transform));
}
}
}
public bool TryAddActionToPlan(IAction action) {
var success = false;
if (_plannedActions.TryWaitInLine(action)) {
OnPlannedActionsChanged(new(transform));
success = true;
}
return success;
}
public void Clear() {
foreach (var action in _plannedActions) {
action.Dispose();
}
_plannedActions.Clear();
OnPlannedActionsChanged(new(transform));
}
public bool TryRemoveActionFromPlan(int index) {
var success = false;
if (_plannedActions.TryRemoveAt(index, out var _)) {
success = true;
OnPlannedActionsChanged(new(transform));
}
return success;
}
public IEnumerator<IAction> GetEnumerator() {
return _plannedActions.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator() {
return _plannedActions.GetEnumerator();
}
}
}
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace TagFighter.Actions
{
public class TakeActionEventArgs : EventArgs
{
public IActionState ActionState { get; }
public TakeActionEventArgs(IActionState actionState) {
ActionState = actionState;
}
}
public class ActionPlan : MonoBehaviour, IEnumerable<IActionRead>
{
public event EventHandler<TakeActionEventArgs> ActionTaken;
public event EventHandler<UnitActionEventArgs> PlanChanged;
Line<IAction> _plannedActions = new(capacity: 6);
protected void OnActionTaken(TakeActionEventArgs e) {
ActionTaken?.Invoke(this, e);
}
protected void OnPlannedActionsChanged(UnitActionEventArgs e) {
PlanChanged?.Invoke(this, e);
}
protected void Update() {
if (_plannedActions.TryPeek(out var action)) {
var actionState = action.Advance();
OnActionTaken(new(actionState));
if (!actionState.IsAdvanced) {
action.Dispose();
_plannedActions.TryGetFirstOutOfLine(out var _);
OnPlannedActionsChanged(new(transform));
}
}
}
public bool TryAddActionToPlan(IAction action) {
var success = false;
if (_plannedActions.TryWaitInLine(action)) {
OnPlannedActionsChanged(new(transform));
success = true;
}
return success;
}
public void Clear() {
foreach (var action in _plannedActions) {
action.Dispose();
}
_plannedActions.Clear();
OnPlannedActionsChanged(new(transform));
}
public bool TryRemoveActionFromPlan(int index) {
var success = false;
if (_plannedActions.TryRemoveAt(index, out var _)) {
success = true;
OnPlannedActionsChanged(new(transform));
}
return success;
}
public IEnumerator<IActionRead> GetEnumerator() {
return _plannedActions.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator() {
return _plannedActions.GetEnumerator();
}
}
}
using System.Linq;
using TMPro;
using UnityEngine;
namespace TagFighter.UI
{
public class WeavePicker : MonoBehaviour
{
[UnityEngine.Serialization.FormerlySerializedAs("watchedRuneWeavingBank")]
[SerializeField] RuneWeavingBank _watchedRuneWeavingBank;
[UnityEngine.Serialization.FormerlySerializedAs("eventAggregator")]
[SerializeField] EventAggregator _eventAggregator;
TMP_Dropdown _weaveDropDown;
protected void Awake() {
_weaveDropDown = GetComponent<TMP_Dropdown>();
}
protected void Start() {
FillWeaveDropDown();
_eventAggregator.RuneWeavingBankChanged += OnRuneWeavingBankChanged;
}
void OnRuneWeavingBankChanged(object sender, EventAggregator.RuneWeavingBankChangedEventArgs e) {
FillWeaveDropDown();
}
void FillWeaveDropDown() {
_weaveDropDown.ClearOptions();
_weaveDropDown.AddOptions(_watchedRuneWeavingBank.GetWeaves().Select(weave => new TMP_Dropdown.OptionData(weave.WeaveName)).ToList());
}
protected void OnDestroy() {
_eventAggregator.RuneWeavingBankChanged -= OnRuneWeavingBankChanged;
}
}
}
using System.Linq;
using TagFighter.Events;
using TMPro;
using UnityEngine;
namespace TagFighter.UI
{
public class WeavePicker : MonoBehaviour
{
[UnityEngine.Serialization.FormerlySerializedAs("watchedRuneWeavingBank")]
[SerializeField] RuneWeavingBank _watchedRuneWeavingBank;
[UnityEngine.Serialization.FormerlySerializedAs("eventAggregator")]
[SerializeField] EventAggregator _eventAggregator;
TMP_Dropdown _weaveDropDown;
protected void Awake() {
_weaveDropDown = GetComponent<TMP_Dropdown>();
}
protected void Start() {
FillWeaveDropDown();
_eventAggregator.RuneWeavingBankChanged += OnRuneWeavingBankChanged;
}
void OnRuneWeavingBankChanged(object sender, EventAggregator.RuneWeavingBankChangedEventArgs e) {
FillWeaveDropDown();
}
void FillWeaveDropDown() {
_weaveDropDown.ClearOptions();
_weaveDropDown.AddOptions(_watchedRuneWeavingBank.GetWeaves().Select(weave => new TMP_Dropdown.OptionData(weave.WeaveName)).ToList());
}
protected void OnDestroy() {
_eventAggregator.RuneWeavingBankChanged -= OnRuneWeavingBankChanged;
}
}
}
using System;
using UnityEngine;
namespace TagFighter.UI
{
public class WeaveBuilderScreenToggle : MonoBehaviour
{
[UnityEngine.Serialization.FormerlySerializedAs("eventAggregator")]
[SerializeField] EventAggregator _eventAggregator;
bool _show = false;
Canvas _weaveBuilderScreen;
protected void Awake() {
_weaveBuilderScreen = transform.GetComponentInChildren<Canvas>(true);
}
protected void Start() {
SetVisibility(_show);
_eventAggregator.WeaveBuilderScreenToggleSelected += OnWeaveBuilderScreenToggleSelected;
}
protected void OnDestroy() {
_eventAggregator.WeaveBuilderScreenToggleSelected -= OnWeaveBuilderScreenToggleSelected;
}
void OnWeaveBuilderScreenToggleSelected(object sender, EventArgs e) {
_show = !_show;
SetVisibility(_show);
}
void SetVisibility(bool visible) {
_weaveBuilderScreen.gameObject.SetActive(visible);
}
}
}
using System;
using TagFighter.Events;
using UnityEngine;
namespace TagFighter.UI
{
public class WeaveBuilderScreenToggle : MonoBehaviour
{
[UnityEngine.Serialization.FormerlySerializedAs("eventAggregator")]
[SerializeField] EventAggregator _eventAggregator;
bool _show = false;
Canvas _weaveBuilderScreen;
protected void Awake() {
_weaveBuilderScreen = transform.GetComponentInChildren<Canvas>(true);
}
protected void Start() {
SetVisibility(_show);
_eventAggregator.WeaveBuilderScreenToggleSelected += OnWeaveBuilderScreenToggleSelected;
}
protected void OnDestroy() {
_eventAggregator.WeaveBuilderScreenToggleSelected -= OnWeaveBuilderScreenToggleSelected;
}
void OnWeaveBuilderScreenToggleSelected(object sender, EventArgs e) {
_show = !_show;
SetVisibility(_show);
}
void SetVisibility(bool visible) {
_weaveBuilderScreen.gameObject.SetActive(visible);
}
}
}
using UnityEngine;
namespace TagFighter.UI
{
public class PawnSheetToggle : MonoBehaviour
{
[SerializeField] EventAggregator _eventAggregator;
bool _show = false;
Canvas _pawnSheetScreen;
protected void Awake() {
_pawnSheetScreen = transform.GetComponentInChildren<Canvas>(true);
_eventAggregator.PawnSheetToggleSelected += OnPawnSheetToggleSelected;
}
protected void Start() {
SetVisibility(_show);
}
protected void OnDestroy() {
_eventAggregator.PawnSheetToggleSelected -= OnPawnSheetToggleSelected;
}
void OnPawnSheetToggleSelected(object sender, EventAggregator.PawnSheetToggleSelectedEventArgs e) {
_show = !_show;
SetVisibility(_show);
}
void SetVisibility(bool visible) {
_pawnSheetScreen?.gameObject.SetActive(visible);
if (visible) {
_eventAggregator.OnPawnSheetShowed(this, new());
}
else {
_eventAggregator.OnPawnSheetHid(this, new());
}
}
}
enum PawnSheetState
{
Uninit,
Hidden,
Shown
}
}
using TagFighter.Events;
using UnityEngine;
namespace TagFighter.UI
{
public class PawnSheetToggle : MonoBehaviour
{
[SerializeField] EventAggregator _eventAggregator;
bool _show = false;
Canvas _pawnSheetScreen;
protected void Awake() {
_pawnSheetScreen = transform.GetComponentInChildren<Canvas>(true);
_eventAggregator.PawnSheetToggleSelected += OnPawnSheetToggleSelected;
}
protected void Start() {
SetVisibility(_show);
}
protected void OnDestroy() {
_eventAggregator.PawnSheetToggleSelected -= OnPawnSheetToggleSelected;
}
void OnPawnSheetToggleSelected(object sender, EventAggregator.PawnSheetToggleSelectedEventArgs e) {
_show = !_show;
SetVisibility(_show);
}
void SetVisibility(bool visible) {
_pawnSheetScreen?.gameObject.SetActive(visible);
if (visible) {
_eventAggregator.OnPawnSheetShowed(this, new());
}
else {
_eventAggregator.OnPawnSheetHid(this, new());
}
}
}
enum PawnSheetState
{
Uninit,
Hidden,
Shown
}
}
using System.Collections.Generic;
using System.Linq;
using TagFighter.Equipment;
using UnityEngine;
namespace TagFighter.UI
{
public class EquipmentNavigator : MonoBehaviour
{
[SerializeField] EventAggregator _eventAggregator;
[SerializeField] ItemUI _itemUIPrefab;
PartyMember _selectedPartyMember;
Outfit _watchedOutfit;
PawnSheetState _pawnSheetState = PawnSheetState.Uninit;
[SerializeField] ItemSlotBank _itemSlotTypeIcons;
IDictionary<ItemSlotType, Sprite> _spriteForItemSlotType;
protected void Awake() {
_eventAggregator.UnitSelected += OnUnitSelected;
_eventAggregator.PawnSheetShowed += OnPawnSheetShowed;
_eventAggregator.PawnSheetHid += OnPawnSheetHid;
if (_itemSlotTypeIcons) {
_spriteForItemSlotType = new Dictionary<ItemSlotType, Sprite>();
foreach (var p in _itemSlotTypeIcons) {
_spriteForItemSlotType.TryAdd(p.ItemSlotType, p.Icon);
}
}
}
protected void OnDestroy() {
_eventAggregator.UnitSelected -= OnUnitSelected;
_eventAggregator.PawnSheetShowed -= OnPawnSheetShowed;
_eventAggregator.PawnSheetHid -= OnPawnSheetHid;
if (_watchedOutfit != null) {
_watchedOutfit.OutfitChanged -= OnOutfitChanged;
}
}
void OnPawnSheetHid(object sender, EventAggregator.PawnSheetHidEventArgs e) {
_pawnSheetState = PawnSheetState.Hidden;
}
void OnPawnSheetShowed(object sender, EventAggregator.PawnSheetShowedEventArgs e) {
_pawnSheetState = PawnSheetState.Shown;
if (_selectedPartyMember != null) {
CreateEquipmentList(_selectedPartyMember);
}
}
void OnUnitSelected(object sender, UnitActionEventArgs e) {
if (e.UnitTransform.TryGetComponent<PartyMember>(out var partyMember) && _selectedPartyMember != partyMember) {
_selectedPartyMember = partyMember;
ChangeOutfit(partyMember.GetComponent<Outfit>());
if (_pawnSheetState == PawnSheetState.Shown) {
CreateEquipmentList(_selectedPartyMember);
}
}
}
void ChangeOutfit(Outfit outfit) {
if (_watchedOutfit != null) {
_watchedOutfit.OutfitChanged -= OnOutfitChanged;
}
if (outfit != null) {
outfit.OutfitChanged += OnOutfitChanged;
}
_watchedOutfit = outfit;
}
void OnOutfitChanged(object sender, OutfitChangedEventArgs e) {
if (_pawnSheetState == PawnSheetState.Shown) {
CreateEquipmentList(_selectedPartyMember);
}
}
void CreateEquipmentList(PartyMember partyMember) {
var currentItemIndex = 0;
HashSet<Item> equippedItems = new();
foreach (var item in _watchedOutfit.Select(itemSlot => itemSlot.EquippedItem).Where(item => item != null)) {
var itemUI = currentItemIndex < transform.childCount ?
transform.GetChild(currentItemIndex).GetComponent<ItemUI>() :
Instantiate(_itemUIPrefab, transform).GetComponent<ItemUI>();
equippedItems.Add(item);
itemUI.SetData(_watchedOutfit, item, _spriteForItemSlotType);
itemUI.gameObject.SetActive(true);
currentItemIndex++;
}
foreach (var item in partyMember.GetComponent<Backpack>().Where(item => !equippedItems.Contains(item))) {
var itemUI = currentItemIndex < transform.childCount ?
transform.GetChild(currentItemIndex).GetComponent<ItemUI>() :
Instantiate(_itemUIPrefab, transform).GetComponent<ItemUI>();
itemUI.SetData(_watchedOutfit, item, _spriteForItemSlotType);
itemUI.gameObject.SetActive(true);
currentItemIndex++;
}
for (; currentItemIndex < transform.childCount; currentItemIndex++) {
transform.GetChild(currentItemIndex).gameObject.SetActive(false);
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using TagFighter.Equipment;
using TagFighter.Events;
using UnityEngine;
namespace TagFighter.UI
{
public class EquipmentNavigator : MonoBehaviour
{
[SerializeField] EventAggregator _eventAggregator;
[SerializeField] ItemUI _itemUIPrefab;
PartyMember _selectedPartyMember;
Outfit _watchedOutfit;
PawnSheetState _pawnSheetState = PawnSheetState.Uninit;
[SerializeField] ItemSlotBank _itemSlotTypeIcons;
IDictionary<ItemSlotType, Sprite> _spriteForItemSlotType;
protected void Awake() {
_eventAggregator.UnitSelected += OnUnitSelected;
_eventAggregator.PawnSheetShowed += OnPawnSheetShowed;
_eventAggregator.PawnSheetHid += OnPawnSheetHid;
if (_itemSlotTypeIcons) {
_spriteForItemSlotType = new Dictionary<ItemSlotType, Sprite>();
foreach (var p in _itemSlotTypeIcons) {
_spriteForItemSlotType.TryAdd(p.ItemSlotType, p.Icon);
}
}
}
protected void OnDestroy() {
_eventAggregator.UnitSelected -= OnUnitSelected;
_eventAggregator.PawnSheetShowed -= OnPawnSheetShowed;
_eventAggregator.PawnSheetHid -= OnPawnSheetHid;
if (_watchedOutfit != null) {
_watchedOutfit.OutfitChanged -= OnOutfitChanged;
}
}
void OnPawnSheetHid(object sender, EventAggregator.PawnSheetHidEventArgs e) {
_pawnSheetState = PawnSheetState.Hidden;
}
void OnPawnSheetShowed(object sender, EventAggregator.PawnSheetShowedEventArgs e) {
_pawnSheetState = PawnSheetState.Shown;
if (_selectedPartyMember != null) {
CreateEquipmentList(_selectedPartyMember);
}
}
void OnUnitSelected(object sender, UnitActionEventArgs e) {
if (e.UnitTransform.TryGetComponent<PartyMember>(out var partyMember) && _selectedPartyMember != partyMember) {
_selectedPartyMember = partyMember;
ChangeOutfit(partyMember.GetComponent<Outfit>());
if (_pawnSheetState == PawnSheetState.Shown) {
CreateEquipmentList(_selectedPartyMember);
}
}
}
void ChangeOutfit(Outfit outfit) {
if (_watchedOutfit != null) {
_watchedOutfit.OutfitChanged -= OnOutfitChanged;
}
if (outfit != null) {
outfit.OutfitChanged += OnOutfitChanged;
}
_watchedOutfit = outfit;
}
void OnOutfitChanged(object sender, OutfitChangedEventArgs e) {
if (_pawnSheetState == PawnSheetState.Shown) {
CreateEquipmentList(_selectedPartyMember);
}
}
void CreateEquipmentList(PartyMember partyMember) {
var currentItemIndex = 0;
HashSet<Item> equippedItems = new();
foreach (var item in _watchedOutfit.Select(itemSlot => itemSlot.EquippedItem).Where(item => item != null)) {
var itemUI = currentItemIndex < transform.childCount ?
transform.GetChild(currentItemIndex).GetComponent<ItemUI>() :
Instantiate(_itemUIPrefab, transform).GetComponent<ItemUI>();
equippedItems.Add(item);
itemUI.SetData(_watchedOutfit, item, _spriteForItemSlotType);
itemUI.gameObject.SetActive(true);
currentItemIndex++;
}
foreach (var item in partyMember.GetComponent<Backpack>().Where(item => !equippedItems.Contains(item))) {
var itemUI = currentItemIndex < transform.childCount ?
transform.GetChild(currentItemIndex).GetComponent<ItemUI>() :
Instantiate(_itemUIPrefab, transform).GetComponent<ItemUI>();
itemUI.SetData(_watchedOutfit, item, _spriteForItemSlotType);
itemUI.gameObject.SetActive(true);
currentItemIndex++;
}
for (; currentItemIndex < transform.childCount; currentItemIndex++) {
transform.GetChild(currentItemIndex).gameObject.SetActive(false);
}
}
}
}
using System.Threading;
using TagFighter.Resources;
using UnityEngine;
namespace TagFighter.UI
{
public class AttributeNavigator : MonoBehaviour
{
[SerializeField] EventAggregator _eventAggregator;
[SerializeField] AttributeUI _attributeUIPrefab;
PartyMember _selectedPartyMember;
CancellationTokenSource _cancellationSource;
PawnSheetState _pawnSheetState = PawnSheetState.Uninit;
protected void Awake() {
_eventAggregator.UnitSelected += OnUnitSelected;
_eventAggregator.PawnSheetShowed += OnPawnSheetShowed;
_eventAggregator.PawnSheetHid += OnPawnSheetHid;
}
protected void OnDestroy() {
_eventAggregator.UnitSelected -= OnUnitSelected;
_eventAggregator.PawnSheetShowed -= OnPawnSheetShowed;
_eventAggregator.PawnSheetHid -= OnPawnSheetHid;
if (_cancellationSource != null) {
_cancellationSource.Cancel();
_cancellationSource.Dispose();
}
}
void RegisterToResource(IWatchableResource resource, IResourceViewer resourceViewer, CancellationToken cancellationToken) {
void Handler(object sender, ResourceChangeArgs e) {
resourceViewer.UpdateView(e);
}
void UnregisterHandler() {
resource.ResourceChanged -= Handler;
}
resource.ResourceChanged += Handler;
cancellationToken.Register(UnregisterHandler);
resourceViewer.UpdateView(resource.Status);
}
void OnPawnSheetHid(object sender, EventAggregator.PawnSheetHidEventArgs e) {
_pawnSheetState = PawnSheetState.Hidden;
_cancellationSource?.Cancel();
}
void OnPawnSheetShowed(object sender, EventAggregator.PawnSheetShowedEventArgs e) {
_pawnSheetState = PawnSheetState.Shown;
if (_selectedPartyMember != null) {
_cancellationSource?.Cancel();
CreateAttributeList(_selectedPartyMember);
}
}
void OnUnitSelected(object sender, UnitActionEventArgs e) {
if (e.UnitTransform.TryGetComponent<PartyMember>(out var partyMember) && _selectedPartyMember != partyMember) {
_selectedPartyMember = partyMember;
if (_pawnSheetState == PawnSheetState.Shown) {
_cancellationSource?.Cancel();
CreateAttributeList(_selectedPartyMember);
}
}
}
void CreateAttributeList(PartyMember partyMember) {
var currentAttributeIndex = 0;
_cancellationSource = new();
foreach (var resource in partyMember.GetComponents<IWatchableResource>()) {
var attributeUI = currentAttributeIndex < transform.childCount ?
transform.GetChild(currentAttributeIndex).GetComponent<AttributeUI>() :
Instantiate(_attributeUIPrefab, transform).GetComponent<AttributeUI>();
attributeUI.SetName(resource.GetType().Name);
RegisterToResource(resource, attributeUI, _cancellationSource.Token);
attributeUI.gameObject.SetActive(true);
currentAttributeIndex++;
}
for (; currentAttributeIndex < transform.childCount; currentAttributeIndex++) {
transform.GetChild(currentAttributeIndex).gameObject.SetActive(false);
}
}
}
}
using System.Threading;
using TagFighter.Events;
using TagFighter.Resources;
using UnityEngine;
namespace TagFighter.UI
{
public class AttributeNavigator : MonoBehaviour
{
[SerializeField] EventAggregator _eventAggregator;
[SerializeField] AttributeUI _attributeUIPrefab;
PartyMember _selectedPartyMember;
CancellationTokenSource _cancellationSource;
PawnSheetState _pawnSheetState = PawnSheetState.Uninit;
protected void Awake() {
_eventAggregator.UnitSelected += OnUnitSelected;
_eventAggregator.PawnSheetShowed += OnPawnSheetShowed;
_eventAggregator.PawnSheetHid += OnPawnSheetHid;
}
protected void OnDestroy() {
_eventAggregator.UnitSelected -= OnUnitSelected;
_eventAggregator.PawnSheetShowed -= OnPawnSheetShowed;
_eventAggregator.PawnSheetHid -= OnPawnSheetHid;
if (_cancellationSource != null) {
_cancellationSource.Cancel();
_cancellationSource.Dispose();
}
}
void RegisterToResource(IWatchableResource resource, IResourceViewer resourceViewer, CancellationToken cancellationToken) {
void Handler(object sender, ResourceChangeArgs e) {
resourceViewer.UpdateView(e);
}
void UnregisterHandler() {
resource.ResourceChanged -= Handler;
}
resource.ResourceChanged += Handler;
cancellationToken.Register(UnregisterHandler);
resourceViewer.UpdateView(resource.Status);
}
void OnPawnSheetHid(object sender, EventAggregator.PawnSheetHidEventArgs e) {
_pawnSheetState = PawnSheetState.Hidden;
_cancellationSource?.Cancel();
}
void OnPawnSheetShowed(object sender, EventAggregator.PawnSheetShowedEventArgs e) {
_pawnSheetState = PawnSheetState.Shown;
if (_selectedPartyMember != null) {
_cancellationSource?.Cancel();
CreateAttributeList(_selectedPartyMember);
}
}
void OnUnitSelected(object sender, UnitActionEventArgs e) {
if (e.UnitTransform.TryGetComponent<PartyMember>(out var partyMember) && _selectedPartyMember != partyMember) {
_selectedPartyMember = partyMember;
if (_pawnSheetState == PawnSheetState.Shown) {
_cancellationSource?.Cancel();
CreateAttributeList(_selectedPartyMember);
}
}
}
void CreateAttributeList(PartyMember partyMember) {
var currentAttributeIndex = 0;
_cancellationSource = new();
foreach (var resource in partyMember.GetComponents<IWatchableResource>()) {
var attributeUI = currentAttributeIndex < transform.childCount ?
transform.GetChild(currentAttributeIndex).GetComponent<AttributeUI>() :
Instantiate(_attributeUIPrefab, transform).GetComponent<AttributeUI>();
attributeUI.SetName(resource.GetType().Name);
RegisterToResource(resource, attributeUI, _cancellationSource.Token);
attributeUI.gameObject.SetActive(true);
currentAttributeIndex++;
}
for (; currentAttributeIndex < transform.childCount; currentAttributeIndex++) {
transform.GetChild(currentAttributeIndex).gameObject.SetActive(false);
}
}
}
}
using UnityEngine;
using UnityEngine.EventSystems;
namespace TagFighter
{
public class TechBuilderClicker : MonoBehaviour, IPointerClickHandler
{
[SerializeField] EventAggregator _eventAggregator;
public void OnPointerClick(PointerEventData eventData) {
switch (eventData.button) {
case PointerEventData.InputButton.Left:
HandleTechBuilderToggle();
break;
case PointerEventData.InputButton.Right:
break;
}
}
void HandleTechBuilderToggle() {
_eventAggregator.OnWeaveBuilderScreenToggleSelected(this, new());
}
}
}
using TagFighter.Events;
using UnityEngine;
using UnityEngine.EventSystems;
namespace TagFighter
{
public class TechBuilderClicker : MonoBehaviour, IPointerClickHandler
{
[SerializeField] EventAggregator _eventAggregator;
public void OnPointerClick(PointerEventData eventData) {
switch (eventData.button) {
case PointerEventData.InputButton.Left:
HandleTechBuilderToggle();
break;
case PointerEventData.InputButton.Right:
break;
}
}
void HandleTechBuilderToggle() {
_eventAggregator.OnWeaveBuilderScreenToggleSelected(this, new());
}
}
}
using System.Linq;
using TagFighter.Equipment;
using UnityEngine;
namespace TagFighter.UI
{
public class RuneWeaveView : MonoBehaviour
{
[UnityEngine.Serialization.FormerlySerializedAs("weaveSelectButtonTemplate")]
public Transform WeaveSelectButtonTemplate;
[UnityEngine.Serialization.FormerlySerializedAs("watchedRuneWeavingBank")]
public RuneWeavingBank WatchedRuneWeavingBank;
[UnityEngine.Serialization.FormerlySerializedAs("eventAggregator")]
[SerializeField] EventAggregator _eventAggregator;
Outfit _watchedOutfit;
Weaver _selectedWeaver;
Weaver SelectedWeaver {
get {
return _selectedWeaver;
}
set {
if (_selectedWeaver != null) {
_eventAggregator.RuneWeavingBankChanged -= OnRuneWeavingBankChanged;
if (_watchedOutfit != null) {
_watchedOutfit.OutfitChanged -= OnOutfitChanged;
}
}
_selectedWeaver = value;
if (_selectedWeaver != null) {
_eventAggregator.RuneWeavingBankChanged += OnRuneWeavingBankChanged;
if (SelectedWeaver.TryGetComponent(out _watchedOutfit)) {
_watchedOutfit.OutfitChanged += OnOutfitChanged;
}
}
}
}
protected void Start() {
Clear();
_eventAggregator.UnitSelected += OnUnitSelected;
}
protected void OnDestroy() {
SelectedWeaver = null;
_eventAggregator.UnitSelected -= OnUnitSelected;
Clear();
}
void OnRuneWeavingBankChanged(object sender, EventAggregator.RuneWeavingBankChangedEventArgs e) {
if (WatchedRuneWeavingBank == e.Bank) {
CreateWeaveSelectionButtons(WatchedRuneWeavingBank, SelectedWeaver);
}
}
void OnUnitSelected(object sender, UnitActionEventArgs e) {
if ((e.UnitTransform.GetComponent<PartyMember>() != null) && e.UnitTransform.TryGetComponent<Weaver>(out var weaver)) {
SelectedWeaver = weaver;
CreateWeaveSelectionButtons(WatchedRuneWeavingBank, SelectedWeaver);
}
}
void OnOutfitChanged(object sender, OutfitChangedEventArgs e) {
CreateWeaveSelectionButtons(WatchedRuneWeavingBank, SelectedWeaver);
}
void CreateWeaveSelectionButtons(RuneWeavingBank bank, Weaver weaver) {
var currentWeaveIndex = 0;
var originalChildCount = transform.childCount - 1; // excluding template
foreach (var weave in bank.GetWeaves().Where(weave => weaver.CanUseWeave(weave.RuneWeaving))) {
RuneWeaveSelectUI runeWeaveSelectUI;
if (currentWeaveIndex < originalChildCount) {
runeWeaveSelectUI = transform.GetChild(currentWeaveIndex + 1).GetComponent<RuneWeaveSelectUI>();
}
else {
runeWeaveSelectUI = Instantiate(WeaveSelectButtonTemplate, transform).GetComponent<RuneWeaveSelectUI>();
}
runeWeaveSelectUI.SetRuneWeave(weave);
runeWeaveSelectUI.gameObject.SetActive(true);
currentWeaveIndex++;
}
for (; currentWeaveIndex < transform.childCount - 1; currentWeaveIndex++) {
transform.GetChild(currentWeaveIndex + 1).gameObject.SetActive(false);
}
}
void Clear() {
// Making sure to skip the template
foreach (Transform item in transform) {
if (item.GetComponent<RuneWeaveSelectUI>() != null) {
Destroy(item.gameObject);
}
}
}
}
}
using System.Linq;
using TagFighter.Equipment;
using TagFighter.Events;
using UnityEngine;
namespace TagFighter.UI
{
public class RuneWeaveView : MonoBehaviour
{
[UnityEngine.Serialization.FormerlySerializedAs("weaveSelectButtonTemplate")]
public Transform WeaveSelectButtonTemplate;
[UnityEngine.Serialization.FormerlySerializedAs("watchedRuneWeavingBank")]
public RuneWeavingBank WatchedRuneWeavingBank;
[UnityEngine.Serialization.FormerlySerializedAs("eventAggregator")]
[SerializeField] EventAggregator _eventAggregator;
Outfit _watchedOutfit;
Weaver _selectedWeaver;
Weaver SelectedWeaver {
get {
return _selectedWeaver;
}
set {
if (_selectedWeaver != null) {
_eventAggregator.RuneWeavingBankChanged -= OnRuneWeavingBankChanged;
if (_watchedOutfit != null) {
_watchedOutfit.OutfitChanged -= OnOutfitChanged;
}
}
_selectedWeaver = value;
if (_selectedWeaver != null) {
_eventAggregator.RuneWeavingBankChanged += OnRuneWeavingBankChanged;
if (SelectedWeaver.TryGetComponent(out _watchedOutfit)) {
_watchedOutfit.OutfitChanged += OnOutfitChanged;
}
}
}
}
protected void Start() {
Clear();
_eventAggregator.UnitSelected += OnUnitSelected;
}
protected void OnDestroy() {
SelectedWeaver = null;
_eventAggregator.UnitSelected -= OnUnitSelected;
Clear();
}
void OnRuneWeavingBankChanged(object sender, EventAggregator.RuneWeavingBankChangedEventArgs e) {
if (WatchedRuneWeavingBank == e.Bank) {
CreateWeaveSelectionButtons(WatchedRuneWeavingBank, SelectedWeaver);
}
}
void OnUnitSelected(object sender, UnitActionEventArgs e) {
if ((e.UnitTransform.GetComponent<PartyMember>() != null) && e.UnitTransform.TryGetComponent<Weaver>(out var weaver)) {
SelectedWeaver = weaver;
CreateWeaveSelectionButtons(WatchedRuneWeavingBank, SelectedWeaver);
}
}
void OnOutfitChanged(object sender, OutfitChangedEventArgs e) {
CreateWeaveSelectionButtons(WatchedRuneWeavingBank, SelectedWeaver);
}
void CreateWeaveSelectionButtons(RuneWeavingBank bank, Weaver weaver) {
var currentWeaveIndex = 0;
var originalChildCount = transform.childCount - 1; // excluding template
foreach (var weave in bank.GetWeaves().Where(weave => weaver.CanUseWeave(weave.RuneWeaving))) {
RuneWeaveSelectUI runeWeaveSelectUI;
if (currentWeaveIndex < originalChildCount) {
runeWeaveSelectUI = transform.GetChild(currentWeaveIndex + 1).GetComponent<RuneWeaveSelectUI>();
}
else {
runeWeaveSelectUI = Instantiate(WeaveSelectButtonTemplate, transform).GetComponent<RuneWeaveSelectUI>();
}
runeWeaveSelectUI.SetRuneWeave(weave);
runeWeaveSelectUI.gameObject.SetActive(true);
currentWeaveIndex++;
}
for (; currentWeaveIndex < transform.childCount - 1; currentWeaveIndex++) {
transform.GetChild(currentWeaveIndex + 1).gameObject.SetActive(false);
}
}
void Clear() {
// Making sure to skip the template
foreach (Transform item in transform) {
if (item.GetComponent<RuneWeaveSelectUI>() != null) {
Destroy(item.gameObject);
}
}
}
}
}
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
namespace TagFighter.UI
{
public class RuneWeaveSelectUI : MonoBehaviour, IPointerClickHandler
{
[UnityEngine.Serialization.FormerlySerializedAs("weaveName")]
[SerializeField] TextMeshProUGUI _weaveName;
RuneWeavingContainer _runeWeave;
[UnityEngine.Serialization.FormerlySerializedAs("eventAggregator")]
[SerializeField] EventAggregator _eventAggregator;
public void OnPointerClick(PointerEventData eventData) {
switch (eventData.button) {
case PointerEventData.InputButton.Left:
HandleSelectWeave();
break;
case PointerEventData.InputButton.Right:
break;
}
}
void HandleSelectWeave() {
_eventAggregator.OnRuneWeavingCastSelected(this, new(_runeWeave));
}
public void SetRuneWeave(RuneWeavingContainer runeWeave) {
_runeWeave = runeWeave;
SetWeaveName(_runeWeave.WeaveName);
}
void SetWeaveName(string weaveName) {
this._weaveName.text = weaveName;
}
}
}
using TagFighter.Events;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
namespace TagFighter.UI
{
public class RuneWeaveSelectUI : MonoBehaviour, IPointerClickHandler
{
[UnityEngine.Serialization.FormerlySerializedAs("weaveName")]
[SerializeField] TextMeshProUGUI _weaveName;
RuneWeavingContainer _runeWeave;
[UnityEngine.Serialization.FormerlySerializedAs("eventAggregator")]
[SerializeField] EventAggregator _eventAggregator;
public void OnPointerClick(PointerEventData eventData) {
switch (eventData.button) {
case PointerEventData.InputButton.Left:
HandleSelectWeave();
break;
case PointerEventData.InputButton.Right:
break;
}
}
void HandleSelectWeave() {
_eventAggregator.OnRuneWeavingCastSelected(this, new(_runeWeave));
}
public void SetRuneWeave(RuneWeavingContainer runeWeave) {
_runeWeave = runeWeave;
SetWeaveName(_runeWeave.WeaveName);
}
void SetWeaveName(string weaveName) {
this._weaveName.text = weaveName;
}
}
}
using System.Collections.Generic;
using System.Linq;
using TagFighter.Actions;
using UnityEngine;
namespace TagFighter.UI
{
public class PlannedActionsView : MonoBehaviour
{
[UnityEngine.Serialization.FormerlySerializedAs("eventAggregator")]
[SerializeField] EventAggregator _eventAggregator;
public List<PlannedActionClicker> PlannedActionsUI;
ActionPlan _watchedActionPlan;
ActionPlan WatcedActionPlan {
get {
return _watchedActionPlan;
}
set {
if (_watchedActionPlan != null) {
_watchedActionPlan.PlanChanged -= OnPlannedActionsChanged;
}
_watchedActionPlan = value;
if (_watchedActionPlan != null) {
_watchedActionPlan.PlanChanged += OnPlannedActionsChanged;
}
}
}
protected void OnDestroy() {
_eventAggregator.UnitSelected -= OnUnitSelected;
WatcedActionPlan = null;
}
protected void Start() {
_eventAggregator.UnitSelected += OnUnitSelected;
for (var i = 0; i < PlannedActionsUI.Count(); ++i) {
var uiClicker = PlannedActionsUI[i];
uiClicker.SetActionName("");
uiClicker.Index = i;
}
}
void OnPlannedActionsChanged(object sender, UnitActionEventArgs e) {
UpdatePlannedActions(e.UnitTransform.GetComponent<ActionPlan>());
}
void OnUnitSelected(object sender, UnitActionEventArgs e) {
if ((e.UnitTransform.GetComponent<PartyMember>() != null) && e.UnitTransform.TryGetComponent<ActionPlan>(out var actionPlan)) {
WatcedActionPlan = actionPlan;
UpdatePlannedActions(WatcedActionPlan);
}
}
void UpdatePlannedActions(ActionPlan actionPlan) {
var count = 0;
foreach (var item in actionPlan.Zip(PlannedActionsUI, (action, uiClicker) => (action, uiClicker))) {
item.uiClicker.SetActionName(item.action.ToString());
if (item.uiClicker.TryGetComponent(out PlannedActionStatus statusWatcher)) {
statusWatcher.SetWatched(item.action);
}
count++;
}
foreach (var uiClicker in PlannedActionsUI.Skip(count)) {
uiClicker.SetActionName("");
if (uiClicker.TryGetComponent(out PlannedActionStatus statusWatcher)) {
statusWatcher.SetWatched(null);
}
}
}
}
}
using System.Collections.Generic;
using System.Linq;
using TagFighter.Actions;
using TagFighter.Events;
using UnityEngine;
namespace TagFighter.UI
{
public class PlannedActionsView : MonoBehaviour
{
[UnityEngine.Serialization.FormerlySerializedAs("eventAggregator")]
[SerializeField] EventAggregator _eventAggregator;
public List<PlannedActionClicker> PlannedActionsUI;
ActionPlan _watchedActionPlan;
ActionPlan WatcedActionPlan {
get {
return _watchedActionPlan;
}
set {
if (_watchedActionPlan != null) {
_watchedActionPlan.PlanChanged -= OnPlannedActionsChanged;
}
_watchedActionPlan = value;
if (_watchedActionPlan != null) {
_watchedActionPlan.PlanChanged += OnPlannedActionsChanged;
}
}
}
protected void OnDestroy() {
_eventAggregator.UnitSelected -= OnUnitSelected;
WatcedActionPlan = null;
}
protected void Start() {
_eventAggregator.UnitSelected += OnUnitSelected;
for (var i = 0; i < PlannedActionsUI.Count(); ++i) {
var uiClicker = PlannedActionsUI[i];
uiClicker.SetActionName("");
uiClicker.Index = i;
}
}
void OnPlannedActionsChanged(object sender, UnitActionEventArgs e) {
UpdatePlannedActions(e.UnitTransform.GetComponent<ActionPlan>());
}
void OnUnitSelected(object sender, UnitActionEventArgs e) {
if ((e.UnitTransform.GetComponent<PartyMember>() != null) && e.UnitTransform.TryGetComponent<ActionPlan>(out var actionPlan)) {
WatcedActionPlan = actionPlan;
UpdatePlannedActions(WatcedActionPlan);
}
}
void UpdatePlannedActions(ActionPlan actionPlan) {
var count = 0;
foreach (var item in actionPlan.Zip(PlannedActionsUI, (action, uiClicker) => (action, uiClicker))) {
item.uiClicker.SetActionName(item.action.ToString());
if (item.uiClicker.TryGetComponent(out PlannedActionStatus statusWatcher)) {
statusWatcher.SetWatched(item.action);
}
count++;
}
foreach (var uiClicker in PlannedActionsUI.Skip(count)) {
uiClicker.SetActionName("");
if (uiClicker.TryGetComponent(out PlannedActionStatus statusWatcher)) {
statusWatcher.SetWatched(null);
}
}
}
}
}
using UnityEngine;
using UnityEngine.UI;
namespace TagFighter.UI
{
[RequireComponent(typeof(Image))]
public class PlannedActionStatus : MonoBehaviour
{
Image _status;
IAction _watched;
protected void Start() {
_status = GetComponent<Image>();
}
protected void Update() {
if (_watched != null) {
_status.fillAmount = _watched.CompletionStatus();
}
}
public void SetWatched(IAction action) {
_watched = action;
if (_watched == null) {
_status.fillAmount = 0;
}
else {
_status.fillAmount = _watched.CompletionStatus();
}
}
}
}
using UnityEngine;
using UnityEngine.UI;
namespace TagFighter.UI
{
[RequireComponent(typeof(Image))]
public class PlannedActionStatus : MonoBehaviour
{
Image _status;
IActionRead _watched;
protected void Start() {
_status = GetComponent<Image>();
}
protected void Update() {
if (_watched != null) {
_status.fillAmount = _watched.CompletionStatus();
}
}
public void SetWatched(IActionRead action) {
_watched = action;
if (_watched == null) {
_status.fillAmount = 0;
}
else {
_status.fillAmount = _watched.CompletionStatus();
}
}
}
}
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
namespace TagFighter.UI
{
public class PlannedActionClicker : MonoBehaviour, IPointerClickHandler
{
public int Index { get; set; }
TMP_Text _actionName;
[SerializeField] EventAggregator _eventAggregator;
protected void Awake() {
_actionName = GetComponentInChildren<TMP_Text>();
}
public void OnPointerClick(PointerEventData eventData) {
switch (eventData.button) {
case PointerEventData.InputButton.Left:
break;
case PointerEventData.InputButton.Right:
HandleRemoveFromPlannedActions();
break;
}
}
public void SetActionName(string actionName) {
_actionName.text = actionName;
}
void HandleRemoveFromPlannedActions() {
_eventAggregator.OnRemovePlannedActionSelected(this, new(Index));
}
}
}
using TagFighter.Events;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
namespace TagFighter.UI
{
public class PlannedActionClicker : MonoBehaviour, IPointerClickHandler
{
public int Index { get; set; }
TMP_Text _actionName;
[SerializeField] EventAggregator _eventAggregator;
protected void Awake() {
_actionName = GetComponentInChildren<TMP_Text>();
}
public void OnPointerClick(PointerEventData eventData) {
switch (eventData.button) {
case PointerEventData.InputButton.Left:
break;
case PointerEventData.InputButton.Right:
HandleRemoveFromPlannedActions();
break;
}
}
public void SetActionName(string actionName) {
_actionName.text = actionName;
}
void HandleRemoveFromPlannedActions() {
_eventAggregator.OnRemovePlannedActionSelected(this, new(Index));
}
}
}
using TagFighter.Resources;
using UnityEngine;
namespace TagFighter.UI
{
public class PartyView : MonoBehaviour
{
[UnityEngine.Serialization.FormerlySerializedAs("partyMemberUnitFrame")]
[SerializeField] Transform _partyMemberUnitFrame;
[UnityEngine.Serialization.FormerlySerializedAs("partyToDisplay")]
[SerializeField] Party _partyToDisplay;
[SerializeField] EventAggregator _eventAggregator;
protected void OnDestroy() {
_partyToDisplay.OnCompositionChanged -= Party_OnCompositionChanged;
_eventAggregator.UnitSelected -= OnUnitSelected;
}
protected void Start() {
_partyToDisplay.OnCompositionChanged += Party_OnCompositionChanged;
_eventAggregator.UnitSelected += OnUnitSelected;
}
void Party_OnCompositionChanged(object sender, PartyCompositionArgs e) {
foreach (Transform partyMemberPortrait in transform) {
Destroy(partyMemberPortrait.gameObject);
}
foreach (var partyMember in e.PartyMembers) {
var partyMemberPortraitTransform = Instantiate(_partyMemberUnitFrame, transform);
var partyMemberPortrait = partyMemberPortraitTransform.GetComponentInChildren<PartyMemberPortrait>();
partyMemberPortrait.SetPartyMember(partyMember);
var partyMemberResources = partyMemberPortraitTransform.GetComponentsInChildren<ResourceWatcher>();
partyMemberResources[0].WatchedResource = partyMember.GetComponent<Pain>();
partyMemberResources[1].WatchedResource = partyMember.GetComponent<Fatigue>();
}
}
void OnUnitSelected(object sender, UnitActionEventArgs e) {
if (e.UnitTransform.TryGetComponent(out PartyMember partyMember)) {
SetSelectedPortrait(partyMember);
}
}
void SetSelectedPortrait(PartyMember partyMember) {
foreach (Transform partyMemberPortraitTransform in transform) {
var partyMemberPortrait = partyMemberPortraitTransform.GetComponentInChildren<PartyMemberPortrait>();
partyMemberPortrait.SetSelected(partyMemberPortrait.GetPartyMember() == partyMember);
}
}
}
}
using TagFighter.Events;
using TagFighter.Resources;
using UnityEngine;
namespace TagFighter.UI
{
public class PartyView : MonoBehaviour
{
[UnityEngine.Serialization.FormerlySerializedAs("partyMemberUnitFrame")]
[SerializeField] Transform _partyMemberUnitFrame;
[UnityEngine.Serialization.FormerlySerializedAs("partyToDisplay")]
[SerializeField] Party _partyToDisplay;
[SerializeField] EventAggregator _eventAggregator;
protected void OnDestroy() {
_partyToDisplay.OnCompositionChanged -= Party_OnCompositionChanged;
_eventAggregator.UnitSelected -= OnUnitSelected;
}
protected void Start() {
_partyToDisplay.OnCompositionChanged += Party_OnCompositionChanged;
_eventAggregator.UnitSelected += OnUnitSelected;
}
void Party_OnCompositionChanged(object sender, PartyCompositionArgs e) {
foreach (Transform partyMemberPortrait in transform) {
Destroy(partyMemberPortrait.gameObject);
}
foreach (var partyMember in e.PartyMembers) {
var partyMemberPortraitTransform = Instantiate(_partyMemberUnitFrame, transform);
var partyMemberPortrait = partyMemberPortraitTransform.GetComponentInChildren<PartyMemberPortrait>();
partyMemberPortrait.SetPartyMember(partyMember);
var partyMemberResources = partyMemberPortraitTransform.GetComponentsInChildren<ResourceWatcher>();
partyMemberResources[0].WatchedResource = partyMember.GetComponent<Pain>();
partyMemberResources[1].WatchedResource = partyMember.GetComponent<Fatigue>();
}
}
void OnUnitSelected(object sender, UnitActionEventArgs e) {
if (e.UnitTransform.TryGetComponent(out PartyMember partyMember)) {
SetSelectedPortrait(partyMember);
}
}
void SetSelectedPortrait(PartyMember partyMember) {
foreach (Transform partyMemberPortraitTransform in transform) {
var partyMemberPortrait = partyMemberPortraitTransform.GetComponentInChildren<PartyMemberPortrait>();
partyMemberPortrait.SetSelected(partyMemberPortrait.GetPartyMember() == partyMember);
}
}
}
}
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace TagFighter.UI
{
[RequireComponent(typeof(Button))]
public class PartyMemberPortrait : MonoBehaviour, IPointerClickHandler
{
[SerializeField] EventAggregator _eventAggregator;
Button _portrait;
TextMeshProUGUI _characterName;
PartyMember _partyMember;
protected void Awake() {
_portrait = GetComponent<Button>();
_characterName = GetComponentInChildren<TextMeshProUGUI>();
}
public void OnPointerClick(PointerEventData eventData) {
switch (eventData.button) {
case PointerEventData.InputButton.Left:
HandleSelectPartyMember();
break;
case PointerEventData.InputButton.Right:
break;
}
}
public void SetSelected(bool isSelected) {
_portrait.GetComponent<Outline>().enabled = isSelected;
}
public void SetPartyMember(PartyMember partyMember) {
_partyMember = partyMember;
SetPartyMemberName(partyMember.name);
}
public PartyMember GetPartyMember() => _partyMember;
void HandleSelectPartyMember() {
_eventAggregator.OnUnitSelected(this, new(_partyMember.transform));
}
void SetPartyMemberName(string partyMemberName) {
_characterName.text = partyMemberName;
}
}
}
using TagFighter.Events;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace TagFighter.UI
{
[RequireComponent(typeof(Button))]
public class PartyMemberPortrait : MonoBehaviour, IPointerClickHandler
{
[SerializeField] EventAggregator _eventAggregator;
Button _portrait;
TextMeshProUGUI _characterName;
PartyMember _partyMember;
protected void Awake() {
_portrait = GetComponent<Button>();
_characterName = GetComponentInChildren<TextMeshProUGUI>();
}
public void OnPointerClick(PointerEventData eventData) {
switch (eventData.button) {
case PointerEventData.InputButton.Left:
HandleSelectPartyMember();
break;
case PointerEventData.InputButton.Right:
break;
}
}
public void SetSelected(bool isSelected) {
_portrait.GetComponent<Outline>().enabled = isSelected;
}
public void SetPartyMember(PartyMember partyMember) {
_partyMember = partyMember;
SetPartyMemberName(partyMember.name);
}
public PartyMember GetPartyMember() => _partyMember;
void HandleSelectPartyMember() {
_eventAggregator.OnUnitSelected(this, new(_partyMember.transform));
}
void SetPartyMemberName(string partyMemberName) {
_characterName.text = partyMemberName;
}
}
}
using UnityEngine;
using UnityEngine.EventSystems;
namespace TagFighter
{
public class CharacterSheetClicker : MonoBehaviour, IPointerClickHandler
{
[SerializeField] EventAggregator _eventAggregator;
public void OnPointerClick(PointerEventData eventData) {
switch (eventData.button) {
case PointerEventData.InputButton.Left:
HandleCharacterSheetToggle();
break;
case PointerEventData.InputButton.Right:
break;
}
}
void HandleCharacterSheetToggle() {
_eventAggregator.OnPawnSheetToggleSelected(this, new());
}
}
}
using TagFighter.Events;
using UnityEngine;
using UnityEngine.EventSystems;
namespace TagFighter
{
public class CharacterSheetClicker : MonoBehaviour, IPointerClickHandler
{
[SerializeField] EventAggregator _eventAggregator;
public void OnPointerClick(PointerEventData eventData) {
switch (eventData.button) {
case PointerEventData.InputButton.Left:
HandleCharacterSheetToggle();
break;
case PointerEventData.InputButton.Right:
break;
}
}
void HandleCharacterSheetToggle() {
_eventAggregator.OnPawnSheetToggleSelected(this, new());
}
}
}
using System.Collections;
using TagFighter;
using TagFighter.Resources;
using Testing.Line;
using Testing.TimeDialation;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.EventSystems;
public class Tester : MonoBehaviour
{
[SerializeField] Vector3 _forceToApply;
[SerializeField] Transform _affected;
[SerializeField] LayerMask _unitMovementLayerMask;
[SerializeField] ForceMode _forceMode;
[SerializeField] EventAggregator _eventAggregator;
[SerializeField] bool _shouldTestTags = false;
[SerializeField] bool _shouldTestPhysics = false;
[SerializeField] bool _shouldTestPawnConditions = false;
Renderer _r;
Rigidbody _rb;
NavMeshAgent _nma;
bool _pushed;
Vector3 _resetPosition;
protected void Start() {
if (_affected) {
_r = _affected.GetComponent<Renderer>();
_rb = _affected.GetComponent<Rigidbody>();
_nma = _affected.GetComponent<NavMeshAgent>();
_resetPosition = _affected.transform.position;
}
Reset();
}
protected void Update() {
if (_shouldTestTags) {
TestTags();
}
if (_shouldTestPhysics) {
TestPhysics();
}
if (_shouldTestPawnConditions) {
TestAddPawnCondition();
}
}
void TestAddPawnCondition() {
if (Input.GetKeyDown(KeyCode.T)) {
var condition = _affected.gameObject.AddComponent<TagFighter.Effects.PawnCondition>();
condition.Apply();
}
}
void TestTags() {
if (Input.GetKeyDown(KeyCode.L)) {
var color = UnityEngine.Random.Range(0, 3);
switch (color) {
case 0: {
var modifier = new StatModifier<BlueTagUnit> {
Amount = (Unit<BlueTagUnit>)1
};
_affected.GetComponent<BlueTag>().AddCurrentModifier(modifier, System.Threading.CancellationToken.None);
break;
}
case 1: {
var modifier = new StatModifier<RedTagUnit> {
Amount = (Unit<RedTagUnit>)1
};
_affected.GetComponent<RedTag>().AddCurrentModifier(modifier, System.Threading.CancellationToken.None);
break;
}
case 2: {
var modifier = new StatModifier<GreenTagUnit> {
Amount = (Unit<GreenTagUnit>)1
};
_affected.GetComponent<GreenTag>().AddCurrentModifier(modifier, System.Threading.CancellationToken.None);
break;
}
}
}
}
void TestPhysics() {
if (Input.GetKeyDown(KeyCode.T)) {
if (Input.GetKey(KeyCode.LeftShift)) {
Test();
}
else {
_pushed = true;
}
}
if (Input.GetKeyDown(KeyCode.B) && !EventSystem.current.IsPointerOverGameObject()) {
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out var hit)) {
var objectHit = hit.transform;
if (_unitMovementLayerMask.IsLayerInMask(objectHit.gameObject.layer)) {
_nma.Warp(hit.point);
}
}
}
if (Input.GetKeyDown(KeyCode.R)) {
Reset();
}
if (Input.GetKeyDown(KeyCode.P)) {
print($"Velocity ({_rb.velocity}), Magnitude {_rb.velocity.magnitude}");
print($"world bounds {_r.bounds} local bounds {_r.localBounds}");
}
}
protected void FixedUpdate() {
if (_rb != null && !_rb.isKinematic && _nma.isOnNavMesh && _rb.velocity.sqrMagnitude < 0.25f) {
if (Physics.Raycast(_affected.transform.position, Vector3.down, _r.bounds.extents.y + 0.1f, _unitMovementLayerMask)) {
_rb.isKinematic = true;
_nma.updatePosition = true;
_nma.updateRotation = true;
_nma.Warp(_affected.transform.position);
}
//nma.enabled = true;
}
if (_pushed) {
// nma.enabled = false;
_nma.updatePosition = false;
_nma.updateRotation = false;
_rb.isKinematic = false;
_rb.AddForce(_forceToApply, _forceMode);
_pushed = false;
}
}
void Reset() {
if (_rb != null) {
_rb.isKinematic = true;
}
if (_nma) {
_nma.updatePosition = true;
_nma.updateRotation = true;
_nma.enabled = true;
_pushed = false;
}
if (_affected) {
_affected.transform.position = _resetPosition;
}
}
void Test() {
TimeDialationTester timeDialationTester = new(_eventAggregator);
timeDialationTester.TestAll();
LineTester lineTester = new();
lineTester.TestAll();
}
}
namespace Testing.TimeDialation
{
public class TimeDialationTester
{
EventAggregator _eventAggregator;
public TimeDialationTester(EventAggregator eventAggregator) {
_eventAggregator = eventAggregator;
}
public void TestAll() {
TestTimeDialationSpeedUp();
TestTimeDialationSpeedDown();
TestTimeDialationSpeedPause();
TestTimeDialationSpeedReset();
}
public void TestTimeDialationSpeedUp() {
var currentTimeScale = Time.timeScale;
var testName = System.Reflection.MethodBase.GetCurrentMethod().Name;
_eventAggregator.OnTimeDilationSpeedUp(this, System.EventArgs.Empty);
if (Time.timeScale > currentTimeScale) {
Debug.Log($"<color=green>PASSED: {testName}</color>");
}
else {
Debug.Log($"<color=red>FAILED: {testName}</color>");
}
}
public void TestTimeDialationSpeedDown() {
var currentTimeScale = Time.timeScale;
var testName = System.Reflection.MethodBase.GetCurrentMethod().Name;
_eventAggregator.OnTimeDilationSpeedDown(this, System.EventArgs.Empty);
if (Time.timeScale < currentTimeScale) {
Debug.Log($"<color=green>PASSED: {testName}</color>");
}
else {
Debug.Log($"<color=red>FAILED: {testName}</color>");
}
}
public void TestTimeDialationSpeedPause() {
var testName = System.Reflection.MethodBase.GetCurrentMethod().Name;
_eventAggregator.OnTimeDilationSpeedPause(this, System.EventArgs.Empty);
if (Time.timeScale == 0) {
Debug.Log($"<color=green>PASSED: {testName}</color>");
}
else {
Debug.Log($"<color=red>FAILED: {testName}</color>");
}
}
public void TestTimeDialationSpeedReset() {
var testName = System.Reflection.MethodBase.GetCurrentMethod().Name;
Time.timeScale = 4;
_eventAggregator.OnTimeDilationSpeedReset(this, System.EventArgs.Empty);
if (Time.timeScale == 1) {
Debug.Log($"<color=green>PASSED: {testName}</color>");
}
else {
Debug.Log($"<color=red>FAILED: {testName}</color>");
}
}
}
}
namespace Testing.Line
{
public class LineTester
{
public void TestAll() {
TestWaitInLine();
TestCutInLine();
TestTryRemoveAt();
TestCircularInsert();
}
public void TestWaitInLine() {
var testName = System.Reflection.MethodBase.GetCurrentMethod().Name;
using System.Collections;
using TagFighter;
using TagFighter.Events;
using TagFighter.Resources;
using Testing.Actions;
using Testing.Line;
using Testing.TimeDialation;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.EventSystems;
public class Tester : MonoBehaviour
{
[SerializeField] Vector3 _forceToApply;
[SerializeField] Transform _affected;
[SerializeField] LayerMask _unitMovementLayerMask;
[SerializeField] ForceMode _forceMode;
[SerializeField] EventAggregator _eventAggregator;
[SerializeField] bool _shouldTestTags = false;
[SerializeField] bool _shouldTestPhysics = false;
[SerializeField] bool _shouldTestPawnConditions = false;
[SerializeField] bool _shouldRunAutoTests = false;
Renderer _r;
Rigidbody _rb;
NavMeshAgent _nma;
bool _pushed;
Vector3 _resetPosition;
protected void Start() {
if (_affected) {
_r = _affected.GetComponent<Renderer>();
_rb = _affected.GetComponent<Rigidbody>();
_nma = _affected.GetComponent<NavMeshAgent>();
_resetPosition = _affected.transform.position;
}
Reset();
}
protected void Update() {
if (_shouldTestTags) {
TestTags();
}
if (_shouldTestPhysics) {
TestPhysics();
}
if (_shouldTestPawnConditions) {
TestAddPawnCondition();
}
if (_shouldRunAutoTests) {
AutoTests();
}
}
void TestAddPawnCondition() {
if (Input.GetKeyDown(KeyCode.T)) {
var condition = _affected.gameObject.AddComponent<TagFighter.Effects.PawnCondition>();
condition.Apply();
}
}
void TestTags() {
if (Input.GetKeyDown(KeyCode.L)) {
var color = UnityEngine.Random.Range(0, 3);
switch (color) {
case 0: {
var modifier = new StatModifier<BlueTagUnit> {
Amount = (Unit<BlueTagUnit>)1
};
_affected.GetComponent<BlueTag>().AddCurrentModifier(modifier, System.Threading.CancellationToken.None);
break;
}
case 1: {
var modifier = new StatModifier<RedTagUnit> {
Amount = (Unit<RedTagUnit>)1
};
_affected.GetComponent<RedTag>().AddCurrentModifier(modifier, System.Threading.CancellationToken.None);
break;
}
case 2: {
var modifier = new StatModifier<GreenTagUnit> {
Amount = (Unit<GreenTagUnit>)1
};
_affected.GetComponent<GreenTag>().AddCurrentModifier(modifier, System.Threading.CancellationToken.None);
break;
}
}
}
}
void AutoTests() {
if (Input.GetKeyDown(KeyCode.T)) {
if (Input.GetKey(KeyCode.LeftShift)) {
Test();
}
}
}
void TestPhysics() {
if (Input.GetKeyDown(KeyCode.T)) {
if (!Input.GetKey(KeyCode.LeftShift)) {
_pushed = true;
}
}
if (Input.GetKeyDown(KeyCode.B) && !EventSystem.current.IsPointerOverGameObject()) {
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out var hit)) {
var objectHit = hit.transform;
if (_unitMovementLayerMask.IsLayerInMask(objectHit.gameObject.layer)) {
_nma.Warp(hit.point);
}
}
}
if (Input.GetKeyDown(KeyCode.R)) {
Reset();
}
if (Input.GetKeyDown(KeyCode.P)) {
print($"Velocity ({_rb.velocity}), Magnitude {_rb.velocity.magnitude}");
print($"world bounds {_r.bounds} local bounds {_r.localBounds}");
}
}
protected void FixedUpdate() {
if (_rb != null && !_rb.isKinematic && _nma.isOnNavMesh && _rb.velocity.sqrMagnitude < 0.25f) {
if (Physics.Raycast(_affected.transform.position, Vector3.down, _r.bounds.extents.y + 0.1f, _unitMovementLayerMask)) {
_rb.isKinematic = true;
_nma.updatePosition = true;
_nma.updateRotation = true;
_nma.Warp(_affected.transform.position);
}
//nma.enabled = true;
}
if (_pushed) {
// nma.enabled = false;
_nma.updatePosition = false;
_nma.updateRotation = false;
_rb.isKinematic = false;
_rb.AddForce(_forceToApply, _forceMode);
_pushed = false;
}
}
void Reset() {
if (_rb != null) {
_rb.isKinematic = true;
}
if (_nma) {
_nma.updatePosition = true;
_nma.updateRotation = true;
_nma.enabled = true;
_pushed = false;
}
if (_affected) {
_affected.transform.position = _resetPosition;
}
}
[SerializeField] Weaver _actionTesterWeaver;
[SerializeField] Transform _actionTesterTransform1;
[SerializeField] Transform _actionTesterTransform2;
void Test() {
TimeDialationTester timeDialationTester = new(_eventAggregator);
timeDialationTester.TestAll();
LineTester lineTester = new();
lineTester.TestAll();
ActionsTester actionsTester = new(_actionTesterWeaver, _actionTesterTransform1, _actionTesterTransform2);
actionsTester.TestAll();
}
}
namespace Testing.Actions
{
public class ActionsTester
{
Weaver _weaver;
Transform _transform1;
Transform _transform2;
public ActionsTester(Weaver weaver, Transform transform1, Transform transform2) {
_weaver = weaver;
_transform1 = transform1;
_transform2 = transform2;
}
public void TestAll() {
TestFollowActionConcreteEqual();
TestFollowActionInterfaceEqual();
TestActionInterfaceNotEqual();
TestMoveToActionConcreteEqual();
TestMoveToActionInterfaceEqual();
}
public void TestFollowActionConcreteEqual() {
var testName = System.Reflection.MethodBase.GetCurrentMethod().Name;
var action1 = new FollowAction(_weaver, _transform1);
var action2 = new FollowAction(_weaver, _transform1);
if (action1.IsSimilarAction(action2)) {
Debug.Log($"<color=green>PASSED: {testName}</color>");
}
else {
Debug.Log($"<color=red>FAILED: {testName}</color>");
}
}
public void TestFollowActionInterfaceEqual() {
var testName = System.Reflection.MethodBase.GetCurrentMethod().Name;
IAction action1 = new FollowAction(_weaver, _transform1);
IAction action2 = new FollowAction(_weaver, _transform1);
if (action1.IsSimilarAction(action2)) {
Debug.Log($"<color=green>PASSED: {testName}</color>");
}
else {
Debug.Log($"<color=red>FAILED: {testName}</color>");
}
}
public void TestActionInterfaceNotEqual() {
var testName = System.Reflection.MethodBase.GetCurrentMethod().Name;
IAction action1 = new FollowAction(_weaver, _transform1);
IAction action2 = new MoveToAction(_weaver, _transform1.position);
if (!action1.IsSimilarAction(action2)) {
Debug.Log($"<color=green>PASSED: {testName}</color>");
}
else {
Debug.Log($"<color=red>FAILED: {testName}</color>");
}
}
public void TestMoveToActionConcreteEqual() {
var testName = System.Reflection.MethodBase.GetCurrentMethod().Name;
var action1 = new MoveToAction(_weaver, _transform1.position);
var action2 = new MoveToAction(_weaver, _transform1.position);
if (action1.IsSimilarAction(action2)) {
Debug.Log($"<color=green>PASSED: {testName}</color>");
}
else {
Debug.Log($"<color=red>FAILED: {testName}</color>");
}
}
public void TestMoveToActionInterfaceEqual() {
var testName = System.Reflection.MethodBase.GetCurrentMethod().Name;
IAction action1 = new MoveToAction(_weaver, _transform1.position);
IAction action2 = new MoveToAction(_weaver, _transform1.position);
if (action1.IsSimilarAction(action2)) {
Debug.Log($"<color=green>PASSED: {testName}</color>");
}
else {
Debug.Log($"<color=red>FAILED: {testName}</color>");
}
}
}
}
namespace Testing.TimeDialation
{
public class TimeDialationTester
{
EventAggregator _eventAggregator;
public TimeDialationTester(EventAggregator eventAggregator) {
_eventAggregator = eventAggregator;
}
public void TestAll() {
TestTimeDialationSpeedUp();
TestTimeDialationSpeedDown();
TestTimeDialationSpeedPause();
TestTimeDialationSpeedReset();
}
public void TestTimeDialationSpeedUp() {
var currentTimeScale = Time.timeScale;
var testName = System.Reflection.MethodBase.GetCurrentMethod().Name;
_eventAggregator.OnTimeDilationSpeedUp(this, System.EventArgs.Empty);
if (Time.timeScale > currentTimeScale) {
Debug.Log($"<color=green>PASSED: {testName}</color>");
}
else {
Debug.Log($"<color=red>FAILED: {testName}</color>");
}
}
public void TestTimeDialationSpeedDown() {
var currentTimeScale = Time.timeScale;
var testName = System.Reflection.MethodBase.GetCurrentMethod().Name;
_eventAggregator.OnTimeDilationSpeedDown(this, System.EventArgs.Empty);
if (Time.timeScale < currentTimeScale) {
Debug.Log($"<color=green>PASSED: {testName}</color>");
}
else {
Debug.Log($"<color=red>FAILED: {testName}</color>");
}
}
public void TestTimeDialationSpeedPause() {
var testName = System.Reflection.MethodBase.GetCurrentMethod().Name;
_eventAggregator.OnTimeDilationSpeedPause(this, System.EventArgs.Empty);
if (Time.timeScale == 0) {
Debug.Log($"<color=green>PASSED: {testName}</color>");
}
else {
Debug.Log($"<color=red>FAILED: {testName}</color>");
}
}
public void TestTimeDialationSpeedReset() {
var testName = System.Reflection.MethodBase.GetCurrentMethod().Name;
Time.timeScale = 4;
_eventAggregator.OnTimeDilationSpeedReset(this, System.EventArgs.Empty);
if (Time.timeScale == 1) {
Debug.Log($"<color=green>PASSED: {testName}</color>");
}
else {
Debug.Log($"<color=red>FAILED: {testName}</color>");
}
}
}
}
namespace Testing.Line
{
public class LineTester
{
public void TestAll() {
TestWaitInLine();
TestCutInLine();
TestTryRemoveAt();
TestCircularInsert();
}
public void TestWaitInLine() {
var testName = System.Reflection.MethodBase.GetCurrentMethod().Name;
using System;
using UnityEngine;
using UnityEngine.EventSystems;
namespace TagFighter
{
public class UnitActionEventArgs : EventArgs
{
public Transform UnitTransform { get; }
public UnitActionEventArgs(Transform unitTransform) {
UnitTransform = unitTransform;
}
}
public class UnitMoveEventArgs : EventArgs
{
public Vector3 Point { get; }
public UnitMoveEventArgs(Vector3 point) {
Point = point;
}
}
public class PlayerKeyActions : MonoBehaviour
{
[SerializeField] CameraController _cameraController;
[SerializeField] LayerMask _unitSelectionLayerMask;
[SerializeField] LayerMask _unitMovementLayerMask;
[SerializeField] EventAggregator _eventAggregator;
bool _anyGameWorldHidden = false;
protected void Update() {
if (_anyGameWorldHidden == false) {
HandleTimeDilation();
HandleCameraMovement();
HandleCameraRotation();
HandleUnitActions();
}
HandleAdditionalKeyboadClicks();
HandleMouseClick();
}
void HandleAdditionalKeyboadClicks() {
if (Input.GetKeyDown(KeyCode.R)) {
if (Input.GetKey(KeyCode.LeftControl)) {
_eventAggregator.OnWeaveBuilderScreenToggleSelected(this, EventArgs.Empty);
_anyGameWorldHidden = !_anyGameWorldHidden;
}
}
if (Input.GetKeyDown(KeyCode.C)) {
_eventAggregator.OnPawnSheetToggleSelected(this, new());
}
}
void HandleUnitActions() {
}
void HandleMouseClick() {
if (!EventSystem.current.IsPointerOverGameObject()) {
if (Input.GetKeyDown(KeyCode.Mouse0)) {
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out var hit)) {
var objectHit = hit.transform;
if (_unitSelectionLayerMask.IsLayerInMask(objectHit.gameObject.layer)) {
_eventAggregator.OnUnitSelected(this, new(objectHit));
}
}
}
else if (Input.GetKeyDown(KeyCode.Mouse1)) {
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out var hit)) {
var objectHit = hit.transform;
if (_unitSelectionLayerMask.IsLayerInMask(objectHit.gameObject.layer)) {
_eventAggregator.OnTargetSelected(this, new(objectHit));
}
else if (_unitMovementLayerMask.IsLayerInMask(objectHit.gameObject.layer)) {
if (Input.GetKey(KeyCode.LeftControl)) {
_eventAggregator.OnUnitMove(this, new(hit.point));
}
else {
_eventAggregator.OnPlannedActionsClearSelected(this, EventArgs.Empty);
_eventAggregator.OnUnitMove(this, new(hit.point));
}
}
}
}
}
}
void HandleTimeDilation() {
if (Input.GetKeyDown(KeyCode.Period)) {
_eventAggregator.OnTimeDilationSpeedUp(this, EventArgs.Empty);
}
if (Input.GetKeyDown(KeyCode.Comma)) {
_eventAggregator.OnTimeDilationSpeedDown(this, EventArgs.Empty);
}
if (Input.GetKeyDown(KeyCode.Slash)) {
_eventAggregator.OnTimeDilationSpeedReset(this, EventArgs.Empty);
}
}
void HandleCameraMovement() {
if (Input.GetKey(KeyCode.W)) {
_cameraController.MoveForward();
}
if (Input.GetKey(KeyCode.A)) {
_cameraController.MoveLeft();
}
if (Input.GetKey(KeyCode.S)) {
_cameraController.MoveBack();
}
if (Input.GetKey(KeyCode.D)) {
_cameraController.MoveRight();
}
}
void HandleCameraRotation() {
if (Input.GetKey(KeyCode.Q)) {
_cameraController.RotateLeft();
}
if (Input.GetKey(KeyCode.E)) {
_cameraController.RotateRight();
}
}
}
public static class LayerMaskExtensions
{
public static bool IsLayerInMask(this LayerMask layerMask, int layer) {
return layerMask == (layerMask | (1 << layer));
}
}
}
using System;
using TagFighter.Events;
using UnityEngine;
using UnityEngine.EventSystems;
namespace TagFighter
{
public class UnitActionEventArgs : EventArgs
{
public Transform UnitTransform { get; }
public UnitActionEventArgs(Transform unitTransform) {
UnitTransform = unitTransform;
}
}
public class UnitMoveEventArgs : EventArgs
{
public Vector3 Point { get; }
public UnitMoveEventArgs(Vector3 point) {
Point = point;
}
}
public class PlayerKeyActions : MonoBehaviour
{
[SerializeField] CameraController _cameraController;
[SerializeField] LayerMask _unitSelectionLayerMask;
[SerializeField] LayerMask _unitMovementLayerMask;
[SerializeField] EventAggregator _eventAggregator;
bool _anyGameWorldHidden = false;
protected void Update() {
if (_anyGameWorldHidden == false) {
HandleTimeDilation();
HandleCameraMovement();
HandleCameraRotation();
HandleUnitActions();
}
HandleAdditionalKeyboadClicks();
HandleMouseClick();
}
void HandleAdditionalKeyboadClicks() {
if (Input.GetKeyDown(KeyCode.R)) {
if (Input.GetKey(KeyCode.LeftControl)) {
_eventAggregator.OnWeaveBuilderScreenToggleSelected(this, EventArgs.Empty);
_anyGameWorldHidden = !_anyGameWorldHidden;
}
}
if (Input.GetKeyDown(KeyCode.C)) {
_eventAggregator.OnPawnSheetToggleSelected(this, new());
}
}
void HandleUnitActions() {
}
void HandleMouseClick() {
if (!EventSystem.current.IsPointerOverGameObject()) {
if (Input.GetKeyDown(KeyCode.Mouse0)) {
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out var hit)) {
var objectHit = hit.transform;
if (_unitSelectionLayerMask.IsLayerInMask(objectHit.gameObject.layer)) {
_eventAggregator.OnUnitSelected(this, new(objectHit));
}
}
}
else if (Input.GetKeyDown(KeyCode.Mouse1)) {
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out var hit)) {
var objectHit = hit.transform;
if (_unitSelectionLayerMask.IsLayerInMask(objectHit.gameObject.layer)) {
_eventAggregator.OnTargetSelected(this, new(objectHit));
}
else if (_unitMovementLayerMask.IsLayerInMask(objectHit.gameObject.layer)) {
if (Input.GetKey(KeyCode.LeftControl)) {
_eventAggregator.OnUnitMove(this, new(hit.point));
}
else {
_eventAggregator.OnPlannedActionsClearSelected(this, EventArgs.Empty);
_eventAggregator.OnUnitMove(this, new(hit.point));
}
}
}
}
}
}
void HandleTimeDilation() {
if (Input.GetKeyDown(KeyCode.Period)) {
_eventAggregator.OnTimeDilationSpeedUp(this, EventArgs.Empty);
}
if (Input.GetKeyDown(KeyCode.Comma)) {
_eventAggregator.OnTimeDilationSpeedDown(this, EventArgs.Empty);
}
if (Input.GetKeyDown(KeyCode.Slash)) {
_eventAggregator.OnTimeDilationSpeedReset(this, EventArgs.Empty);
}
}
void HandleCameraMovement() {
if (Input.GetKey(KeyCode.W)) {
_cameraController.MoveForward();
}
if (Input.GetKey(KeyCode.A)) {
_cameraController.MoveLeft();
}
if (Input.GetKey(KeyCode.S)) {
_cameraController.MoveBack();
}
if (Input.GetKey(KeyCode.D)) {
_cameraController.MoveRight();
}
}
void HandleCameraRotation() {
if (Input.GetKey(KeyCode.Q)) {
_cameraController.RotateLeft();
}
if (Input.GetKey(KeyCode.E)) {
_cameraController.RotateRight();
}
}
}
public static class LayerMaskExtensions
{
public static bool IsLayerInMask(this LayerMask layerMask, int layer) {
return layerMask == (layerMask | (1 << layer));
}
}
}
using System;
using UnityEngine;
namespace TagFighter
{
[CreateAssetMenu(fileName = "NewEventAggregator", menuName = "Game/Misc/EventAggregator")]
public class EventAggregator : ScriptableObject
{
public event EventHandler<UnitActionEventArgs> UnitSelected;
public event EventHandler<UnitMoveEventArgs> UnitMove;
public event EventHandler<TryRemovePlannedActionEventArgs> RemovePlannedActionSelected;
public event EventHandler<UnitActionEventArgs> TargetSelected;
public event EventHandler TimeDilationSpeedUp;
public event EventHandler TimeDilationSpeedDown;
public event EventHandler TimeDilationSpeedReset;
public event EventHandler TimeDilationSpeedPause;
public event EventHandler WeaveBuilderScreenToggleSelected;
public event EventHandler<RuneWeavingBankChangedEventArgs> RuneWeavingBankChanged;
public event EventHandler<WeaveCastEventArgs> RuneWeavingCastSelected;
public event EventHandler PlannedActionsClearSelected;
public event EventHandler<PawnSheetToggleSelectedEventArgs> PawnSheetToggleSelected;
public event EventHandler<PawnSheetShowedEventArgs> PawnSheetShowed;
public event EventHandler<PawnSheetHidEventArgs> PawnSheetHid;
public void OnUnitSelected(object sender, UnitActionEventArgs e) {
UnitSelected?.Invoke(sender, e);
}
public void OnUnitMove(object sender, UnitMoveEventArgs e) {
UnitMove?.Invoke(sender, e);
}
public void OnRemovePlannedActionSelected(object sender, TryRemovePlannedActionEventArgs e) {
RemovePlannedActionSelected?.Invoke(sender, e);
}
public void OnTargetSelected(object sender, UnitActionEventArgs e) {
TargetSelected?.Invoke(sender, e);
}
public void OnTimeDilationSpeedUp(object sender, EventArgs e) {
TimeDilationSpeedUp?.Invoke(sender, e);
}
public void OnTimeDilationSpeedDown(object sender, EventArgs e) {
TimeDilationSpeedDown?.Invoke(sender, e);
}
public void OnTimeDilationSpeedReset(object sender, EventArgs e) {
TimeDilationSpeedReset?.Invoke(sender, e);
}
public void OnTimeDilationSpeedPause(object sender, EventArgs e) {
TimeDilationSpeedPause?.Invoke(sender, e);
}
public void OnWeaveBuilderScreenToggleSelected(object sender, EventArgs e) {
WeaveBuilderScreenToggleSelected?.Invoke(sender, e);
}
public void OnRuneWeavingBankChanged(object sender, RuneWeavingBankChangedEventArgs e) {
RuneWeavingBankChanged?.Invoke(sender, e);
}
public void OnRuneWeavingCastSelected(object sender, WeaveCastEventArgs e) {
RuneWeavingCastSelected?.Invoke(sender, e);
}
public void OnPlannedActionsClearSelected(object sender, EventArgs e) {
PlannedActionsClearSelected?.Invoke(sender, e);
}
public void OnPawnSheetToggleSelected(object sender, PawnSheetToggleSelectedEventArgs e) {
PawnSheetToggleSelected?.Invoke(sender, e);
}
public void OnPawnSheetShowed(object sender, PawnSheetShowedEventArgs e) {
PawnSheetShowed?.Invoke(sender, e);
}
public void OnPawnSheetHid(object sender, PawnSheetHidEventArgs e) {
PawnSheetHid?.Invoke(sender, e);
}
#region events
public class TryRemovePlannedActionEventArgs : EventArgs
{
public int Index { get; }
public TryRemovePlannedActionEventArgs(int index) {
if (index < 0) {
throw new IndexOutOfRangeException("index");
}
Index = index;
}
}
public class WeaveCastEventArgs : EventArgs
{
public RuneWeavingContainer Weave { get; }
public WeaveCastEventArgs(RuneWeavingContainer weave) {
Weave = weave;
}
}
public class RuneWeavingBankChangedEventArgs : EventArgs
{
public RuneWeavingBank Bank { get; }
public RuneWeavingBankChangedEventArgs(RuneWeavingBank bank) {
Bank = bank;
}
}
public class PawnSheetToggleSelectedEventArgs : EventArgs
{
public PawnSheetToggleSelectedEventArgs() {
}
}
public class PawnSheetShowedEventArgs : EventArgs
{
public PawnSheetShowedEventArgs() {
}
}
public class PawnSheetHidEventArgs : EventArgs
{
public PawnSheetHidEventArgs() {
}
}
#endregion
}
}
using System;
using UnityEngine;
namespace TagFighter.Events
{
[CreateAssetMenu(fileName = "NewEventAggregator", menuName = "Game/Misc/EventAggregator")]
public class EventAggregator : ScriptableObject
{
public event EventHandler<UnitActionEventArgs> UnitSelected;
public event EventHandler<UnitMoveEventArgs> UnitMove;
public event EventHandler<TryRemovePlannedActionEventArgs> RemovePlannedActionSelected;
public event EventHandler<UnitActionEventArgs> TargetSelected;
public event EventHandler TimeDilationSpeedUp;
public event EventHandler TimeDilationSpeedDown;
public event EventHandler TimeDilationSpeedReset;
public event EventHandler TimeDilationSpeedPause;
public event EventHandler WeaveBuilderScreenToggleSelected;
public event EventHandler<RuneWeavingBankChangedEventArgs> RuneWeavingBankChanged;
public event EventHandler<WeaveCastEventArgs> RuneWeavingCastSelected;
public event EventHandler PlannedActionsClearSelected;
public event EventHandler<PawnSheetToggleSelectedEventArgs> PawnSheetToggleSelected;
public event EventHandler<PawnSheetShowedEventArgs> PawnSheetShowed;
public event EventHandler<PawnSheetHidEventArgs> PawnSheetHid;
public event EventHandler<UnitControllerTargetStartedEventArgs> UnitControllerStarted;
public void OnUnitSelected(object sender, UnitActionEventArgs e) {
UnitSelected?.Invoke(sender, e);
}
public void OnUnitMove(object sender, UnitMoveEventArgs e) {
UnitMove?.Invoke(sender, e);
}
public void OnRemovePlannedActionSelected(object sender, TryRemovePlannedActionEventArgs e) {
RemovePlannedActionSelected?.Invoke(sender, e);
}
public void OnTargetSelected(object sender, UnitActionEventArgs e) {
TargetSelected?.Invoke(sender, e);
}
public void OnTimeDilationSpeedUp(object sender, EventArgs e) {
TimeDilationSpeedUp?.Invoke(sender, e);
}
public void OnTimeDilationSpeedDown(object sender, EventArgs e) {
TimeDilationSpeedDown?.Invoke(sender, e);
}
public void OnTimeDilationSpeedReset(object sender, EventArgs e) {
TimeDilationSpeedReset?.Invoke(sender, e);
}
public void OnTimeDilationSpeedPause(object sender, EventArgs e) {
TimeDilationSpeedPause?.Invoke(sender, e);
}
public void OnWeaveBuilderScreenToggleSelected(object sender, EventArgs e) {
WeaveBuilderScreenToggleSelected?.Invoke(sender, e);
}
public void OnRuneWeavingBankChanged(object sender, RuneWeavingBankChangedEventArgs e) {
RuneWeavingBankChanged?.Invoke(sender, e);
}
public void OnRuneWeavingCastSelected(object sender, WeaveCastEventArgs e) {
RuneWeavingCastSelected?.Invoke(sender, e);
}
public void OnPlannedActionsClearSelected(object sender, EventArgs e) {
PlannedActionsClearSelected?.Invoke(sender, e);
}
public void OnPawnSheetToggleSelected(object sender, PawnSheetToggleSelectedEventArgs e) {
PawnSheetToggleSelected?.Invoke(sender, e);
}
public void OnPawnSheetShowed(object sender, PawnSheetShowedEventArgs e) {
PawnSheetShowed?.Invoke(sender, e);
}
public void OnPawnSheetHid(object sender, PawnSheetHidEventArgs e) {
PawnSheetHid?.Invoke(sender, e);
}
public void OnUnitControllerStarted(object sender, UnitControllerTargetStartedEventArgs e) {
UnitControllerStarted?.Invoke(sender, e);
}
#region events
public class TryRemovePlannedActionEventArgs : EventArgs
{
public int Index { get; }
public TryRemovePlannedActionEventArgs(int index) {
if (index < 0) {
throw new IndexOutOfRangeException("index");
}
Index = index;
}
}
public class WeaveCastEventArgs : EventArgs
{
public RuneWeavingContainer Weave { get; }
public WeaveCastEventArgs(RuneWeavingContainer weave) {
Weave = weave;
}
}
public class RuneWeavingBankChangedEventArgs : EventArgs
{
public RuneWeavingBank Bank { get; }
public RuneWeavingBankChangedEventArgs(RuneWeavingBank bank) {
Bank = bank;
}
}
public class PawnSheetToggleSelectedEventArgs : EventArgs
{
public PawnSheetToggleSelectedEventArgs() {
}
}
public class PawnSheetShowedEventArgs : EventArgs
{
public PawnSheetShowedEventArgs() {
}
}
public class PawnSheetHidEventArgs : EventArgs
{
public PawnSheetHidEventArgs() {
}
}
#endregion
}
}
fileFormatVersion: 2
guid: b3c93317b2686664bb3e7d977b996d7d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using TagFighter.Actions;
using UnityEngine;
namespace TagFighter
{
public class UnitController : MonoBehaviour
{
[SerializeField] EventAggregator _eventAggregator;
Transform _targetUnit;
Transform TargetUnit {
get {
return _targetUnit;
}
set {
if (_targetUnit != null) {
TryUnregisterRuneWeavingCast();
}
_targetUnit = value;
if (_targetUnit != null) {
TryRegisterRuneWeavingCast();
}
}
}
Weaver _selectedWeaver;
Weaver SelectedWeaver {
get {
return _selectedWeaver;
}
set {
if (_selectedWeaver != null) {
_eventAggregator.PlannedActionsClearSelected -= OnPlannedActionsClearSelected;
_eventAggregator.RemovePlannedActionSelected -= OnRemovePlannedActionSelected;
_eventAggregator.UnitMove -= OnUnitMove;
TryUnregisterRuneWeavingCast();
}
_selectedWeaver = value;
if (_selectedWeaver != null) {
_eventAggregator.PlannedActionsClearSelected += OnPlannedActionsClearSelected;
_eventAggregator.RemovePlannedActionSelected += OnRemovePlannedActionSelected;
_eventAggregator.UnitMove += OnUnitMove;
TryRegisterRuneWeavingCast();
}
}
}
ActionPlan _actionPlan;
protected void Start() {
_eventAggregator.UnitSelected += OnUnitSelected;
_eventAggregator.TargetSelected += OnTargetSelected;
}
protected void OnDestroy() {
_eventAggregator.UnitSelected -= OnUnitSelected;
_eventAggregator.TargetSelected -= OnTargetSelected;
SelectedWeaver = null;
TargetUnit = null;
}
bool TryUnregisterRuneWeavingCast() {
var unregistered = false;
if (SelectedWeaver && TargetUnit) {
_eventAggregator.RuneWeavingCastSelected -= OnRuneWeavingCastSelected;
unregistered = true;
}
return unregistered;
}
bool TryRegisterRuneWeavingCast() {
var registered = false;
if (SelectedWeaver && TargetUnit) {
_eventAggregator.RuneWeavingCastSelected += OnRuneWeavingCastSelected;
registered = true;
}
return registered;
}
void OnPlannedActionsClearSelected(object sender, EventArgs e) {
_actionPlan.Clear();
}
void OnRemovePlannedActionSelected(object sender, EventAggregator.TryRemovePlannedActionEventArgs e) {
_actionPlan.TryRemoveActionFromPlan(e.Index);
}
void OnRuneWeavingCastSelected(object sender, EventAggregator.WeaveCastEventArgs e) {
RuneWeavingContainer weaving = new(e.Weave.WeaveName, e.Weave.RuneWeaving);
WeaveAction weaveAction = new(SelectedWeaver, weaving, TargetUnit, SelectedWeaver.GetComponent<Resources.Range>());
_actionPlan.TryAddActionToPlan(weaveAction);
}
void OnUnitMove(object sender, UnitMoveEventArgs e) {
_actionPlan.TryAddActionToPlan(new MoveToAction(SelectedWeaver, e.Point));
}
void OnTargetSelected(object sender, UnitActionEventArgs e) {
TargetUnit = e.UnitTransform;
}
void OnUnitSelected(object sender, UnitActionEventArgs e) {
if (e.UnitTransform.TryGetComponent<Weaver>(out var weaver)) {
SelectedWeaver = weaver;
}
if (e.UnitTransform.TryGetComponent<ActionPlan>(out var actionPlan)) {
_actionPlan = actionPlan;
}
}
}
}
using System;
using UnityEngine;
namespace TagFighter
{
public class TimeDilationController : MonoBehaviour
{
[SerializeField] float _dilationStep = 0.25f;
public const float MaxTimeDilation = 4f;
const float MinTimeDilation = 0f;
const int TimeDilationPercision = 2;
float _baseTimeScale;
[SerializeField] EventAggregator _eventAggregator;
protected void Start() {
_eventAggregator.TimeDilationSpeedUp += OnTimeDilationSpeedUp;
_eventAggregator.TimeDilationSpeedDown += OnTimeDilationSpeedDown;
_eventAggregator.TimeDilationSpeedReset += OnTimeDilationSpeedReset;
_eventAggregator.TimeDilationSpeedPause += OnTimeDilationSpeedPause;
_baseTimeScale = Time.timeScale;
}
protected void OnDestroy() {
_eventAggregator.TimeDilationSpeedUp -= OnTimeDilationSpeedUp;
_eventAggregator.TimeDilationSpeedDown -= OnTimeDilationSpeedDown;
_eventAggregator.TimeDilationSpeedReset -= OnTimeDilationSpeedReset;
_eventAggregator.TimeDilationSpeedPause -= OnTimeDilationSpeedPause;
}
void OnTimeDilationSpeedPause(object sender, EventArgs e) {
Time.timeScale = 0;
}
void OnTimeDilationSpeedReset(object sender, EventArgs e) {
Time.timeScale = _baseTimeScale;
}
void OnTimeDilationSpeedDown(object sender, EventArgs e) {
Time.timeScale = MathF.Max(MinTimeDilation, MathF.Round(Time.timeScale - _dilationStep, TimeDilationPercision));
}
void OnTimeDilationSpeedUp(object sender, EventArgs e) {
Time.timeScale = MathF.Min(MaxTimeDilation, MathF.Round(Time.timeScale + _dilationStep, TimeDilationPercision));
}
}
}
using System;
using TagFighter.Events;
using UnityEngine;
namespace TagFighter
{
public class TimeDilationController : MonoBehaviour
{
[SerializeField] float _dilationStep = 0.25f;
public const float MaxTimeDilation = 4f;
const float MinTimeDilation = 0f;
const int TimeDilationPercision = 2;
float _baseTimeScale;
[SerializeField] EventAggregator _eventAggregator;
protected void Start() {
_eventAggregator.TimeDilationSpeedUp += OnTimeDilationSpeedUp;
_eventAggregator.TimeDilationSpeedDown += OnTimeDilationSpeedDown;
_eventAggregator.TimeDilationSpeedReset += OnTimeDilationSpeedReset;
_eventAggregator.TimeDilationSpeedPause += OnTimeDilationSpeedPause;
_baseTimeScale = Time.timeScale;
}
protected void OnDestroy() {
_eventAggregator.TimeDilationSpeedUp -= OnTimeDilationSpeedUp;
_eventAggregator.TimeDilationSpeedDown -= OnTimeDilationSpeedDown;
_eventAggregator.TimeDilationSpeedReset -= OnTimeDilationSpeedReset;
_eventAggregator.TimeDilationSpeedPause -= OnTimeDilationSpeedPause;
}
void OnTimeDilationSpeedPause(object sender, EventArgs e) {
Time.timeScale = 0;
}
void OnTimeDilationSpeedReset(object sender, EventArgs e) {
Time.timeScale = _baseTimeScale;
}
void OnTimeDilationSpeedDown(object sender, EventArgs e) {
Time.timeScale = MathF.Max(MinTimeDilation, MathF.Round(Time.timeScale - _dilationStep, TimeDilationPercision));
}
void OnTimeDilationSpeedUp(object sender, EventArgs e) {
Time.timeScale = MathF.Min(MaxTimeDilation, MathF.Round(Time.timeScale + _dilationStep, TimeDilationPercision));
}
}
}
fileFormatVersion: 2
guid: 182eb69d9537e494f93493564babb7f6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences:
- _eventAggregator: {fileID: 11400000, guid: 7674cb78dbff8d447b6c39984750a2da, type: 2}
- _controllingUnitsOfType: {instanceID: 0}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System;
using TagFighter.Actions;
using TagFighter.Events;
using UnityEngine;
namespace TagFighter.UnitControl
{
public class PlayerActionController : MonoBehaviour
{
[SerializeField] EventAggregator _eventAggregator;
[SerializeField] UnitControllerType _controllingUnitsOfType;
Transform _targetUnit;
Transform TargetUnit {
get {
return _targetUnit;
}
set {
if (_targetUnit != null) {
TryUnregisterRuneWeavingCast();
}
_targetUnit = value;
if (_targetUnit != null) {
TryRegisterRuneWeavingCast();
}
}
}
Weaver _selectedWeaver;
Weaver SelectedWeaver {
get {
return _selectedWeaver;
}
set {
if (_selectedWeaver != null) {
_eventAggregator.PlannedActionsClearSelected -= OnPlannedActionsClearSelected;
_eventAggregator.RemovePlannedActionSelected -= OnRemovePlannedActionSelected;
_eventAggregator.UnitMove -= OnUnitMove;
TryUnregisterRuneWeavingCast();
}
_selectedWeaver = value;
if (_selectedWeaver != null) {
_eventAggregator.PlannedActionsClearSelected += OnPlannedActionsClearSelected;
_eventAggregator.RemovePlannedActionSelected += OnRemovePlannedActionSelected;
_eventAggregator.UnitMove += OnUnitMove;
TryRegisterRuneWeavingCast();
}
}
}
ActionPlan _actionPlan;
protected void Start() {
_eventAggregator.UnitSelected += OnUnitSelected;
_eventAggregator.TargetSelected += OnTargetSelected;
}
protected void OnDestroy() {
_eventAggregator.UnitSelected -= OnUnitSelected;
_eventAggregator.TargetSelected -= OnTargetSelected;
SelectedWeaver = null;
TargetUnit = null;
}
bool TryUnregisterRuneWeavingCast() {
var unregistered = false;
if (SelectedWeaver && TargetUnit) {
_eventAggregator.RuneWeavingCastSelected -= OnRuneWeavingCastSelected;
unregistered = true;
}
return unregistered;
}
bool TryRegisterRuneWeavingCast() {
var registered = false;
if (SelectedWeaver && TargetUnit) {
_eventAggregator.RuneWeavingCastSelected += OnRuneWeavingCastSelected;
registered = true;
}
return registered;
}
void OnPlannedActionsClearSelected(object sender, EventArgs e) {
_actionPlan.Clear();
}
void OnRemovePlannedActionSelected(object sender, EventAggregator.TryRemovePlannedActionEventArgs e) {
_actionPlan.TryRemoveActionFromPlan(e.Index);
}
void OnRuneWeavingCastSelected(object sender, EventAggregator.WeaveCastEventArgs e) {
RuneWeavingContainer weaving = new(e.Weave.WeaveName, e.Weave.RuneWeaving);
WeaveAction weaveAction = new(SelectedWeaver, weaving, TargetUnit, SelectedWeaver.GetComponent<Resources.Range>());
_actionPlan.TryAddActionToPlan(weaveAction);
}
void OnUnitMove(object sender, UnitMoveEventArgs e) {
_actionPlan.TryAddActionToPlan(new MoveToAction(SelectedWeaver, e.Point));
}
void OnTargetSelected(object sender, UnitActionEventArgs e) {
TargetUnit = e.UnitTransform;
}
void OnUnitSelected(object sender, UnitActionEventArgs e) {
if (e.UnitTransform.TryGetComponent<Weaver>(out var weaver)) {
SelectedWeaver = weaver;
}
if (e.UnitTransform.TryGetComponent<ActionPlan>(out var actionPlan)) {
_actionPlan = actionPlan;
}
}
}
}
using System;
using System.Collections.Generic;
using UnityEngine;
namespace TagFighter
{
[CreateAssetMenu(fileName = "RuneWeavingBank", menuName = "Game/Combat/RuneWeavingBank")]
public class RuneWeavingBank : ScriptableObject
{
[SerializeField] EventAggregator _eventAggregator;
[SerializeField] List<RuneWeavingContainer> _runeWeavings = new();
public void AddWeave(RuneWeaving runeWeaving, ValidWeaveName weaveName) {
_runeWeavings.Add(new RuneWeavingContainer(weaveName, runeWeaving));
_eventAggregator.OnRuneWeavingBankChanged(this, new EventAggregator.RuneWeavingBankChangedEventArgs(this));
}
public bool TryDeleteWeaveByName(ValidWeaveName weaveName) {
var found = false;
var weaveIndex = _runeWeavings.FindIndex(weave => weave.WeaveName == weaveName);
found = weaveIndex != -1;
if (found == true) {
_runeWeavings.RemoveAt(weaveIndex);
_eventAggregator.OnRuneWeavingBankChanged(this, new(this));
}
return found;
}
public bool TryGetWeaveByName(ValidWeaveName weaveName, out RuneWeavingContainer runeWeavingContainer) {
var found = false;
var weaveIndex = _runeWeavings.FindIndex(weave => weave.WeaveName == weaveName);
found = weaveIndex != -1;
if (found == true) {
runeWeavingContainer = _runeWeavings[weaveIndex];
}
else {
runeWeavingContainer = null;
}
return found;
}
public IEnumerable<RuneWeavingContainer> GetWeaves() => _runeWeavings;
}
[Serializable]
public class RuneWeavingContainer
{
public RuneWeaving RuneWeaving;
public ValidWeaveName WeaveName;
public RuneWeavingContainer(ValidWeaveName weaveName, RuneWeaving runeWeaving) {
WeaveName = weaveName;
RuneWeaving = runeWeaving;
}
public RuneWeavingContainer(RuneWeavingContainer toCopy) {
RuneWeaving = new RuneWeaving(toCopy.RuneWeaving.MartialSequence.GetSequence(), toCopy.RuneWeaving.RuneBindingSequence.GetSequence());
WeaveName = toCopy.WeaveName;
}
}
[Serializable]
public record ValidWeaveName
{
[SerializeField] string _weaveName;
ValidWeaveName(string weaveName) {
_weaveName = weaveName;
}
public bool TrySetName(string weaveName) {
var validName = IsWeaveNameValid(weaveName);
if (validName) {
_weaveName = weaveName;
}
return validName;
}
public override string ToString() {
return _weaveName;
}
public static bool TryParse(string weaveName, out ValidWeaveName validWeaveName) {
var validName = IsWeaveNameValid(weaveName);
if (validName) {
validWeaveName = new ValidWeaveName(weaveName);
}
else {
validWeaveName = null;
}
return validName;
}
public static bool IsWeaveNameValid(string weaveName) {
return weaveName.Length > 0;
}
public static implicit operator string(ValidWeaveName validWeaveName) => validWeaveName._weaveName;
}
}
using System;
using System.Collections.Generic;
using TagFighter.Events;
using UnityEngine;
namespace TagFighter
{
[CreateAssetMenu(fileName = "RuneWeavingBank", menuName = "Game/Combat/RuneWeavingBank")]
public class RuneWeavingBank : ScriptableObject
{
[SerializeField] EventAggregator _eventAggregator;
[SerializeField] List<RuneWeavingContainer> _runeWeavings = new();
public void AddWeave(RuneWeaving runeWeaving, ValidWeaveName weaveName) {
_runeWeavings.Add(new RuneWeavingContainer(weaveName, runeWeaving));
_eventAggregator.OnRuneWeavingBankChanged(this, new EventAggregator.RuneWeavingBankChangedEventArgs(this));
}
public bool TryDeleteWeaveByName(ValidWeaveName weaveName) {
var found = false;
var weaveIndex = _runeWeavings.FindIndex(weave => weave.WeaveName == weaveName);
found = weaveIndex != -1;
if (found == true) {
_runeWeavings.RemoveAt(weaveIndex);
_eventAggregator.OnRuneWeavingBankChanged(this, new(this));
}
return found;
}
public bool TryGetWeaveByName(ValidWeaveName weaveName, out RuneWeavingContainer runeWeavingContainer) {
var found = false;
var weaveIndex = _runeWeavings.FindIndex(weave => weave.WeaveName == weaveName);
found = weaveIndex != -1;
if (found == true) {
runeWeavingContainer = _runeWeavings[weaveIndex];
}
else {
runeWeavingContainer = null;
}
return found;
}
public IEnumerable<RuneWeavingContainer> GetWeaves() => _runeWeavings;
}
[Serializable]
public class RuneWeavingContainer
{
public RuneWeaving RuneWeaving;
public ValidWeaveName WeaveName;
public RuneWeavingContainer(ValidWeaveName weaveName, RuneWeaving runeWeaving) {
WeaveName = weaveName;
RuneWeaving = runeWeaving;
}
public RuneWeavingContainer(RuneWeavingContainer toCopy) {
RuneWeaving = new RuneWeaving(toCopy.RuneWeaving.MartialSequence.GetSequence(), toCopy.RuneWeaving.RuneBindingSequence.GetSequence());
WeaveName = toCopy.WeaveName;
}
}
[Serializable]
public record ValidWeaveName
{
[SerializeField] string _weaveName;
ValidWeaveName(string weaveName) {
_weaveName = weaveName;
}
public bool TrySetName(string weaveName) {
var validName = IsWeaveNameValid(weaveName);
if (validName) {
_weaveName = weaveName;
}
return validName;
}
public override string ToString() {
return _weaveName;
}
public static bool TryParse(string weaveName, out ValidWeaveName validWeaveName) {
var validName = IsWeaveNameValid(weaveName);
if (validName) {
validWeaveName = new ValidWeaveName(weaveName);
}
else {
validWeaveName = null;
}
return validName;
}
public static bool IsWeaveNameValid(string weaveName) {
return weaveName.Length > 0;
}
public static implicit operator string(ValidWeaveName validWeaveName) => validWeaveName._weaveName;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using CareBoo.Serially;
using UnityEngine;
/// <summary>
///
/// When Getting or Setting a resource, three attributes must by chosen
/// 1. Which resource should be manipulated
/// 2. What is the location of the resource (Pawn / Context) to be manipulated
/// 3. Which property of the location should be manipulated
///
/// <example>
/// 1. Get (1)Pain resource from (2)Context (3)Current Register
/// 2. Get (1)RedTag (3)Capacity from all (2)Pawns
/// </example>
///
/// In Order to allow Serialization in the editor, all three attributes have a corresponding accessor classes.
/// These are all consolidated and expected under
/// <see cref="TagFighter.Effects.ResourceInfoGet{TTypeAccessor, TLocationAccessor}"/>
/// <see cref="TagFighter.Effects.ResourceInfoSet{TTypeAccessor, TLocationAccessor}"/>
///
/// Resources are accessed through <see cref="TagFighter.Effects.ResourceTypeAccessor{TResource, TUnit}"/> with specific types encoded per resource.
/// For example: <see cref="TagFighter.Resources.Pain"/> is accessed through <see cref="TagFighter.Effects.ResourceTypeAccessors.Pain"/>
///
/// Locations are accessed through <see cref=TagFighter.Effects.IResourceLocationGet"/> and <see cref="TagFighter.Effects.IResourceLocationSet"/>
/// <example>
/// <see cref="TagFighter.Effects.EffectContext"/> is accessed through <see cref="TagFighter.Effects.ResourceLocationAccessors.Get.Context"/> and <see cref="TagFighter.Effects.ResourceLocationAccessors.Set.Context"/>
/// Pawn (Any Gameobject) is accessed through <see cref="TagFighter.Effects.ResourceLocationAccessors.Get.Pawn"/> and <see cref="TagFighter.Effects.ResourceLocationAccessors.Set.Pawn"/>
/// </example>
///
/// As each Location has different properties - Location properties have specialized accessors:
/// 1. Context - <see cref="TagFighter.Effects.ResourceLocationAccessors.ContextRegisters.IContextRegister"/>
/// 2. Pawn - <see cref="TagFighter.Effects.ResourceLocationAccessors.PawnProperties.IPawnResourceProperty"/>
/// <example>
/// Context <see cref="TagFighter.Effects.EffectContext.GetResource{TResource, TUnit, TContextRegister}"/> is accessed through <see cref="TagFighter.Effects.ResourceLocationAccessors.ContextRegisters.ContextRegister{TRegisterType}"/>
/// with specialized registers such as <see cref="TagFighter.Effects.ResourceLocationAccessors.ContextRegisters.Current"/>, <see cref="TagFighter.Effects.ResourceLocationAccessors.ContextRegisters.Removed"/>
/// or <see cref="TagFighter.Effects.ResourceLocationAccessors.ContextRegisters.Added"/>
/// Pawn <see cref="TagFighter.Resources.Resource{TUnitType}.GetCapacity"/> is accessed through <see cref="TagFighter.Effects.ResourceLocationAccessors.PawnProperties.Capacity"/>
/// and Pawn <see cref="TagFighter.Resources.Resource{TUnitType}.GetCurrent"/> is accessed through <see cref="TagFighter.Effects.ResourceLocationAccessors.PawnProperties.Current"/>
/// </example>
///
/// In addition, Context and Pawn are different in regards to amount of instances. There is always a single weave Context while there can be 0 or more pawns affected.
/// As a result, when Setting to Context, an aggregation operation method must be chosen from <see cref="TagFighter.Effects.IResourceOperator"/>
/// <example>
/// <see cref="TagFighter.Effects.Operators.Sum"/>, <see cref="TagFighter.Effects.Operators.Multiply"/>
/// </example>
///
/// </summary>
namespace TagFighter.Effects
{
[Serializable]
public class ResourceInfoGet<TTypeAccessor, TLocationAccessor> where TTypeAccessor : IResourceTypeAccessor where TLocationAccessor : IResourceLocationGet
{
[SerializeReference, ShowSerializeReference]
public TTypeAccessor Resource;
[SerializeReference, ShowSerializeReference]
public TLocationAccessor Location;
public double Multiplier = 1;
public double Addend = 0;
public bool IsInit {
get {
return (Resource != null) && (Location != null);
}
}
public IEnumerable<double> Get(EffectInput data) {
return IsInit ? Resource.Get(data, Location).Select(resource => (Multiplier * resource) + Addend) :
Enumerable.Repeat(Addend, 1);
}
public override string ToString() => $"{Resource}.{Location}";
}
[Serializable]
public class ResourceInfoSet<TTypeAccessor, TLocationAccessor> where TTypeAccessor : IResourceTypeAccessor where TLocationAccessor : IResourceLocationSet
{
[SerializeReference, ShowSerializeReference]
public TTypeAccessor Resource;
[SerializeReference, ShowSerializeReference]
public TLocationAccessor Location;
public double Multiplier = 1;
public double Addend = 0;
public bool IsInit {
get {
return (Resource != null) && (Location != null);
}
}
public void Set(EffectInput data, IEnumerable<double> value) {
if (!IsInit) {
Debug.Log("Set Resource missing Type or Location, skipping");
return;
}
var manipulatedValue = value.Select(resource => (int)((Multiplier * resource) + Addend));
Resource.Set(data, Location, manipulatedValue);
}
public override string ToString() => $"{Resource}.{Location}";
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using CareBoo.Serially;
using UnityEngine;
/// <summary>
///
/// When Getting or Setting a resource, three attributes must by chosen
/// 1. Which resource should be manipulated
/// 2. What is the location of the resource (Pawn / Context) to be manipulated
/// 3. Which property of the location should be manipulated
///
/// <example>
/// 1. Get (1)Pain resource from (2)Context (3)Current Register
/// 2. Get (1)RedTag (3)Capacity from all (2)Pawns
/// </example>
///
/// In Order to allow Serialization in the editor, all three attributes have a corresponding accessor classes.
/// These are all consolidated and expected under
/// <see cref="TagFighter.Effects.ResourceInfoGet{TTypeAccessor, TLocationAccessor}"/>
/// <see cref="TagFighter.Effects.ResourceInfoSet{TTypeAccessor, TLocationAccessor}"/>
///
/// Resources are accessed through <see cref="TagFighter.Effects.ResourceTypeAccessor{TResource, TUnit}"/> with specific types encoded per resource.
/// For example: <see cref="TagFighter.Resources.Pain"/> is accessed through <see cref="TagFighter.Effects.ResourceTypeAccessors.Pain"/>
///
/// Locations are accessed through <see cref=TagFighter.Effects.IResourceLocationGet"/> and <see cref="TagFighter.Effects.IResourceLocationSet"/>
/// <example>
/// <see cref="TagFighter.Effects.EffectContext"/> is accessed through <see cref="TagFighter.Effects.ResourceLocationAccessors.Get.Context"/> and <see cref="TagFighter.Effects.ResourceLocationAccessors.Set.Context"/>
/// Pawn (Any Gameobject) is accessed through <see cref="TagFighter.Effects.ResourceLocationAccessors.Get.Pawn"/> and <see cref="TagFighter.Effects.ResourceLocationAccessors.Set.Pawn"/>
/// </example>
///
/// As each Location has different properties - Location properties have specialized accessors:
/// 1. Context - <see cref="TagFighter.Effects.ResourceLocationAccessors.ContextRegisters.IContextRegister"/>
/// 2. Pawn - <see cref="TagFighter.Effects.ResourceLocationAccessors.PawnProperties.IPawnResourceProperty"/>
/// <example>
/// Context <see cref="TagFighter.Effects.EffectContext.GetResource{TResource, TUnit, TContextRegister}"/> is accessed through <see cref="TagFighter.Effects.ResourceLocationAccessors.ContextRegisters.ContextRegister{TRegisterType}"/>
/// with specialized registers such as <see cref="TagFighter.Effects.ResourceLocationAccessors.ContextRegisters.Current"/>, <see cref="TagFighter.Effects.ResourceLocationAccessors.ContextRegisters.Removed"/>
/// or <see cref="TagFighter.Effects.ResourceLocationAccessors.ContextRegisters.Added"/>
/// Pawn <see cref="TagFighter.Resources.Resource{TUnitType}.GetCapacity"/> is accessed through <see cref="TagFighter.Effects.ResourceLocationAccessors.PawnProperties.Capacity"/>
/// and Pawn <see cref="TagFighter.Resources.Resource{TUnitType}.GetCurrent"/> is accessed through <see cref="TagFighter.Effects.ResourceLocationAccessors.PawnProperties.Current"/>
/// </example>
///
/// In addition, Context and Pawn are different in regards to amount of instances. There is always a single weave Context while there can be 0 or more pawns affected.
/// As a result, when Setting to Context, an aggregation operation method must be chosen from <see cref="TagFighter.Effects.IResourceOperator"/>
/// <example>
/// <see cref="TagFighter.Effects.Operators.Sum"/>, <see cref="TagFighter.Effects.Operators.Multiply"/>
/// </example>
///
/// Serializing Pawn Resource Accessor in a MonoBehavior without a Context:
/// [SerializeReference, ShowSerializeReference]
/// public <see cref="TagFighter.Effects.IResourceGetter"/> Resource;
/// [SerializeReference, ShowSerializeReference]
/// public <see cref="TagFighter.Effects.ResourceLocationAccessors.PawnProperties.IPawnResourceProperty"/> Stat;
/// Resource.GetStat(transform, Stat);
///
/// </summary>
namespace TagFighter.Effects
{
[Serializable]
public class ResourceInfoGet<TTypeAccessor, TLocationAccessor> where TTypeAccessor : IResourceTypeAccessor where TLocationAccessor : IResourceLocationGet
{
[SerializeReference, ShowSerializeReference]
public TTypeAccessor Resource;
[SerializeReference, ShowSerializeReference]
public TLocationAccessor Location;
public double Multiplier = 1;
public double Addend = 0;
public bool IsInit {
get {
return (Resource != null) && (Location != null);
}
}
public IEnumerable<double> Get(EffectInput data) {
return IsInit ? Resource.Get(data, Location).Select(resource => (Multiplier * resource) + Addend) :
Enumerable.Repeat(Addend, 1);
}
public override string ToString() => $"{Resource}.{Location}";
}
[Serializable]
public class ResourceInfoSet<TTypeAccessor, TLocationAccessor> where TTypeAccessor : IResourceTypeAccessor where TLocationAccessor : IResourceLocationSet
{
[SerializeReference, ShowSerializeReference]
public TTypeAccessor Resource;
[SerializeReference, ShowSerializeReference]
public TLocationAccessor Location;
public double Multiplier = 1;
public double Addend = 0;
public bool IsInit {
get {
return (Resource != null) && (Location != null);
}
}
public void Set(EffectInput data, IEnumerable<double> value) {
if (!IsInit) {
Debug.Log("Set Resource missing Type or Location, skipping");
return;
}
var manipulatedValue = value.Select(resource => (int)((Multiplier * resource) + Addend));
Resource.Set(data, Location, manipulatedValue);
}
public override string ToString() => $"{Resource}.{Location}";
}
}
fileFormatVersion: 2
guid: 14ae6ebc5f656244eafd9305f6e04f6e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 43c5566aa78288b4d9dee65aace89f14
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences:
- _controllingUnitsOfType: {instanceID: 0}
- _eventAggregator: {fileID: 11400000, guid: 7674cb78dbff8d447b6c39984750a2da, type: 2}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using CareBoo.Serially;
using UnityEngine;
using TagFighter.Events;
using TagFighter.Actions;
namespace TagFighter.UnitControl
{
public class TestAIController : MonoBehaviour
{
[SerializeField] UnitControllerType _controllingUnitsOfType;
[SerializeField] EventAggregator _eventAggregator;
[SerializeField] float _decisionFrequency = 0.2f;
List<Transform> _alertedPawns = new();
List<Transform> _allControlledPawns = new();
LayerMask _unitsLayerMask;
protected void Awake() {
_eventAggregator.UnitControllerStarted += OnUnitControllerStarted;
_unitsLayerMask = LayerMask.NameToLayer("units");
if (_controllingUnitsOfType == null) {
Debug.LogWarning($"{transform.name} missing controllingUnitsOfType. Did you forget to set?");
}
if (_eventAggregator == null) {
Debug.LogWarning($"{transform.name} missing eventAggregator. Did you forget to set?");
}
}
protected void Start() {
StartCoroutine(DecideActionForAllAlertedUnits());
}
protected void OnDestroy() {
_eventAggregator.UnitControllerStarted -= OnUnitControllerStarted;
StopCoroutine(DecideActionForAllAlertedUnits());
}
void OnUnitControllerStarted(object sender, UnitControllerTargetStartedEventArgs e) {
if (_controllingUnitsOfType != e.ControlledBy) {
return;
}
_alertedPawns.Add(e.UnitTransform);
_allControlledPawns.Add(e.UnitTransform);
Debug.Log($"<color=green>{e.UnitTransform.name} : Added</color>");
}
IEnumerator DecideActionForAllAlertedUnits() {
// Waiting for a couple of frames before starting so all Start() events are called
yield return new WaitForEndOfFrame();
yield return new WaitForEndOfFrame();
//var a = ProduceMoveLocations().GetEnumerator();
while (true) {
foreach (var unit in _alertedPawns) {
if (unit.TryGetComponent(out ActionPlan actionPlan)) {
var currentAction = actionPlan.FirstOrDefault();
if (currentAction == default) {
//a.MoveNext();
//actionPlan.TryAddActionToPlan(new MoveToAction(unit.GetComponent<Weaver>(), a.Current
var sightedEnemy = GetEnemiesInRange(unit).FirstOrDefault();
//Debug.Log($"Sighted: {sightedEnemy}");
if (sightedEnemy != default) {
actionPlan.TryAddActionToPlan(new FollowAction(unit.GetComponent<Weaver>(), sightedEnemy, 1f));
}
}
}
}
yield return new WaitForSeconds(_decisionFrequency);
//Debug.Log("DecideActionForAllAlertedUnits");
}
}
IEnumerable<Vector3> ProduceMoveLocations() {
while (true) {
yield return new(55, 0, 60);
yield return new(55, 0, 65);
yield return new(50, 0, 65);
yield return new(50, 0, 60);
}
}
IEnumerable<Transform> GetEnemiesInRange(Transform actingUnit) {
var hits = Physics.SphereCastAll(actingUnit.position, 5f, actingUnit.forward, 0, _unitsLayerMask);
return hits.Select(hit => hit.transform).
Where(unit => unit.TryGetComponent(out UnitControllerTarget unitControllerTarget) && unitControllerTarget.ControlledBy != _controllingUnitsOfType);
}
//protected void OnDrawGizmos() {
// LayerMask _unitsLayerMask = LayerMask.NameToLayer("units");
// Gizmos.color = Color.yellow;
// Gizmos.DrawWireSphere(transform.position, 5f);
// var hits = Physics.SphereCastAll(transform.position, 5f, transform.forward, 0, _unitsLayerMask);
// foreach (var hit in hits.Where(hit => hit.transform != transform)) {
// Gizmos.DrawLine(transform.position, hit.transform.position);
// }
//}
}
}
fileFormatVersion: 2
guid: 1edb11a9085aed946b6cdba6ea1ff991
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 342f3feb89a875d49b6abcc5d52b6697
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
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: 0d8877ca28e2c1840a438a7203d82491, type: 3}
m_Name: PlayerController
m_EditorClassIdentifier:
fileFormatVersion: 2
guid: 910975dffac3a2e458f09859fb3e9ef3
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
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: 0d8877ca28e2c1840a438a7203d82491, type: 3}
m_Name: AIController
m_EditorClassIdentifier:
--- !u!114 &706576358 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 276120629325466988, guid: b9c72661de88c9946a2148d82d2ec6c2,
type: 3}
m_PrefabInstance: {fileID: 4462905262637287083}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
serializedVersion: 6
m_Component:
- component: {fileID: 1391213939}
- component: {fileID: 1391213940}
m_Layer: 0
m_Name: AIController
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1391213939
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1391213938}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 707385623}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1391213940
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1391213938}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 43c5566aa78288b4d9dee65aace89f14, type: 3}
m_Name:
m_EditorClassIdentifier:
_controllingUnitsOfType: {fileID: 11400000, guid: 910975dffac3a2e458f09859fb3e9ef3,
type: 2}
_eventAggregator: {fileID: 11400000, guid: 7674cb78dbff8d447b6c39984750a2da, type: 2}
_decisionFrequency: 0.2
--- !u!114 &-6927450962014213662
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2775200704764093955}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7091ffc98d65ebf4a8279f8c34e4369b, type: 3}
m_Name:
m_EditorClassIdentifier:
ControlledBy: {fileID: 0}
_eventAggregator: {fileID: 11400000, guid: 7674cb78dbff8d447b6c39984750a2da, type: 2}