62YQ7EMUYX7GS3AB6FAJDKNX53LVG6T2EH6NMVS6JV36J5VCOKIAC
S256EPZUSOF4TV2KGOFZDJXUFDD57GZFYTCARFJ3SD24RPC56PHAC
VZRSH4U473FCZOP5EXURPXXN5J6F3ZLT435YY7A2JHLG2ZZB5KLQC
M2C63XUU3TKYAUPPSPEFVF4CMBQMCVLZATANFWQW35MMYNRB2SEAC
HXTSBPAP75A7EC4RKWYQMVPPHPNZFPHUORBZWDHGEB6MPAGI7G7AC
6BA5NHNF3UWSL65KCWSXLRTPGYVS4N4NORDJ4FZTZ5SRRDPI4YZAC
KAROCU3SAOGWWSFXGCLE5OW76VTDJR4HDIVTK62BIAESN5SOHVDAC
QZXURLSF73UL67TIXDHMVS7DCFZLQJAPJ6BAGRGXOHH46VMNKGPQC
5YUI4V7A6ONEYREG5CXWHMBYCOP6Q3GMMQD2OTHXZAGKCGM4FWBAC
A6K2SVTQ3JQ3TC3F44H3ERSX47TRQ6R5EJGIRJKFGKZG6I4HOATQC
O236B5LO6PHJ4TPZGYXDVSLB5EGXXRRLYYVWI46DPL5LEGXEIHZQC
IA2O33JCJVSJ3IVBBHX2XQU4BCPL3X6JDDZ2R2KNGUFPWXAUKO7QC
FIMVA3BI72IWMBRN5T3PKDCKSJW667BH25INKDWSPWGHLRKCNAPAC
6PTVYMJH7JKB54XWYGZG2TWYKC5Y2LP4FUN7GJKSW4LO33DE5OTQC
XF52N4U7HWXOF4PDSCR7LCUENLTSXLWEZGS2IJ6562KYI567Z2GAC
3JTZIZGE6WPLZCIWXXLG3SQA2LVSVP26P7U52YBMBTY2VCC6LBLAC
XIPU27GAVXMAKDP42DDSYNA6DSN5WBHH6AG4EK6YIIM43AQQHQAAC
CD5FF75KTOBTMVMTMCKMR6F5DFKOF26I5K43ITNHGBI3ZAZHA4RAC
[SerializeField] EventAggregator _eventAggregator;
public event EventHandler<WeaponEquippedArgs> OnWeaponEquipped;
public event EventHandler<CombatFormEquippedArgs> OnCombatFormEquipped;
public event EventHandler<TakeActionArgs> OnTakeAction;
public event EventHandler<UnitActionArgs> OnPlannedActionsChanged;
public static event EventHandler<WeaponEquippedArgs> OnWeaponEquipped;
public static event EventHandler<CombatFormEquippedArgs> OnCombatFormEquipped;
AnimationManager _animationManager;
WeaponSwap _swapper;
private void Awake() {
_animationManager = GetComponent<AnimationManager>();
_swapper = GetComponent<WeaponSwap>();
}
if (_animationManager != null) {
_animationManager.ChangeClipSet(_equippedWeapon.name);
}
if (_swapper != null) {
_swapper.ChangeActiveWeaponSet(_equippedWeapon.name);
}
public void ChangeActiveWeaponSet(string weaponName) {
if (_watchedWeaver != null) {
_watchedWeaver.OnWeaponEquipped += Weaver_OnWeaponEquipped;
}
}
void Awake() {
SetWatchedWeaver(GetComponent<Weaver>());
}
void OnDestroy() {
SetWatchedWeaver(null);
}
void Weaver_OnWeaponEquipped(object sender, WeaponEquippedArgs e) {
ChangeActiveWeaponSet(e.Weapon.name);
}
void ChangeActiveWeaponSet(string weaponName) {
Weaver _watchedWeaver;
void SetWatchedWeaver(Weaver weaver) {
if (_watchedWeaver != null) {
_watchedWeaver.OnWeaponEquipped -= Weaver_OnWeaponEquipped;
_watchedWeaver.OnTakeAction -= Weaver_OnTakeAction;
}
_watchedWeaver = weaver;
if (_watchedWeaver != null) {
_watchedWeaver.OnWeaponEquipped += Weaver_OnWeaponEquipped;
_watchedWeaver.OnTakeAction += Weaver_OnTakeAction;
}
}
public void ChangeClipSet(string weaponName) {
void Weaver_OnTakeAction(object sender, TakeActionArgs e) {
SetActionState(e.ActionState);
}
void Weaver_OnWeaponEquipped(object sender, WeaponEquippedArgs e) {
ChangeClipSet(e.Weapon.name);
}
void ChangeClipSet(string weaponName) {
Weaver _watchedWeaver;
Weaver _selectedWeaver;
Weaver SelectedWeaver {
get {
return _selectedWeaver;
}
set {
if (_selectedWeaver != null) {
_selectedWeaver.OnWeaponEquipped -= Weaver_OnWeaponEquipped;
eventAggregator.OnRuneWeavingBankChanged -= EventAggregator_OnRuneWeavingBankChanged;
}
_selectedWeaver = value;
void CreateWeaveSelectionButtons(RuneWeavingBank bank, Weaver watchedWeaver) {
_watchedWeaver = watchedWeaver;
foreach (var weave in bank.GetWeaves().Where(weave => watchedWeaver.CanUseWeave(weave.runeWeaving))) {
void CreateWeaveSelectionButtons(RuneWeavingBank bank, Weaver weaver) {
foreach (var weave in bank.GetWeaves().Where(weave => weaver.CanUseWeave(weave.runeWeaving))) {
private void EventAggregator_OnUnitPlannedActionsChanged(object sender, UnitActionArgs e) {
if ((_watchedWeaver != null) && (e.UnitTransform == _watchedWeaver.transform)) {
UpdatePlannedActions(e.UnitTransform.GetComponent<Weaver>());
}
private void Weaver_OnPlannedActionsChanged(object sender, UnitActionArgs e) {
UpdatePlannedActions(e.UnitTransform.GetComponent<Weaver>());
Weaver selectedWeaver;
Weaver _selectedWeaver;
Weaver SelectedWeaver {
get {
return _selectedWeaver;
}
set {
if (_selectedWeaver != null) {
_selectedWeaver.OnWeaponEquipped -= Weaver_OnWeaponEquipped;
_selectedWeaver.OnCombatFormEquipped -= Weaver_OnCombatFormEquipped;
}
_selectedWeaver = value;
if (_selectedWeaver != null) {
_selectedWeaver.OnWeaponEquipped += Weaver_OnWeaponEquipped;
_selectedWeaver.OnCombatFormEquipped += Weaver_OnCombatFormEquipped;
}
}
}
if ((unitSelectedArgs.UnitTransform.GetComponent<PartyMember>() != null) && (unitSelectedArgs.UnitTransform.TryGetComponent<Weaver>(out var weaver))) {
selectedWeaver = weaver;
CreateCombatFormSelectionButtons(selectedWeaver);
if ((unitSelectedArgs.UnitTransform.GetComponent<PartyMember>() != null) && unitSelectedArgs.UnitTransform.TryGetComponent<Weaver>(out var weaver)) {
SelectedWeaver = weaver;
CreateCombatFormSelectionButtons(SelectedWeaver);
[SerializeField] Transform targetUnit;
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.OnClearPlannedActions -= EventAggregator_OnClearPlannedActions;
eventAggregator.OnTryRemovePlannedAction -= EventAggregator_OnTryRemovePlannedAction;
CombatFormSelectUI.OnCombatFormSelected -= CombatFormSelectUI_OnCombatFormSelected;
PlayerKeyActions.OnUnitMove -= PlayerKeyActions_OnUnitMove;
WeaponSelectUI.OnWeaponSelected -= WeaponSelectUI_OnWeaponSelected;
TryUnregisterRuneWeavingCast();
}
_selectedWeaver = value;
private void Start() {
PlayerKeyActions.OnUnitSelected += PlayerKeyActions_OnUnitSelected;
PlayerKeyActions.OnUnitMove += PlayerKeyActions_OnUnitMove;
eventAggregator.OnUnitTargeted += EventAggregator_InvokeOnUnitTargeted;
if (_selectedWeaver != null) {
eventAggregator.OnClearPlannedActions += EventAggregator_OnClearPlannedActions;
eventAggregator.OnTryRemovePlannedAction += EventAggregator_OnTryRemovePlannedAction;
CombatFormSelectUI.OnCombatFormSelected += CombatFormSelectUI_OnCombatFormSelected;
PlayerKeyActions.OnUnitMove += PlayerKeyActions_OnUnitMove;
WeaponSelectUI.OnWeaponSelected += WeaponSelectUI_OnWeaponSelected;
TryRegisterRuneWeavingCast();
}
}
}
eventAggregator.OnSelectRuneWeavingCast += EventAggregator_OnSelectRuneWeavingCast;
eventAggregator.OnTryRemovePlannedAction += EventAggregator_OnTryRemovePlannedAction;
eventAggregator.OnUnitTargeted += EventAggregator_InvokeOnUnitTargeted;
eventAggregator.OnSelectRuneWeavingCast -= EventAggregator_OnSelectRuneWeavingCast;
eventAggregator.OnTryRemovePlannedAction -= EventAggregator_OnTryRemovePlannedAction;
eventAggregator.OnUnitTargeted -= EventAggregator_InvokeOnUnitTargeted;
private void EventAggregator_OnClearPlannedActions(object sender, EventArgs e) {
if (selectedUnit != null && selectedUnit.TryGetComponent(out Weaver trySelectWeaver)) {
trySelectWeaver.ClearActionPlan();
}
bool TryUnregisterRuneWeavingCast() {
bool unregistered = false;
if (SelectedWeaver && TargetUnit) {
eventAggregator.OnSelectRuneWeavingCast -= EventAggregator_OnSelectRuneWeavingCast;
unregistered = true;
}
return unregistered;
private void EventAggregator_OnTryRemovePlannedAction(object sender, TryRemovePlannedActionArgs e) {
if (selectedUnit != null && selectedUnit.TryGetComponent(out Weaver trySelectWeaver)) {
trySelectWeaver.TryRemoveActionFromPlan(e.Index);
bool TryRegisterRuneWeavingCast() {
bool registered = false;
if (SelectedWeaver && TargetUnit) {
eventAggregator.OnSelectRuneWeavingCast += EventAggregator_OnSelectRuneWeavingCast;
registered = true;
private void EventAggregator_OnSelectRuneWeavingCast(object sender, WeaveCastArgs e) {
if (selectedUnit != null && targetUnit != null && selectedUnit.TryGetComponent(out Weaver trySelectWeaver)) {
trySelectWeaver.TryQueueWeave(new(e.Weave), targetUnit);
}
void EventAggregator_OnClearPlannedActions(object sender, EventArgs e) {
SelectedWeaver.ClearActionPlan();
private void CombatFormSelectUI_OnCombatFormSelected(object sender, CombatFormSelectedArgs e) {
if (selectedUnit.TryGetComponent(out Weaver trySelectWeaver)) {
trySelectWeaver.TryEquipCombatForm(e.CombatForm.name);
}
void EventAggregator_OnTryRemovePlannedAction(object sender, TryRemovePlannedActionArgs e) {
SelectedWeaver.TryRemoveActionFromPlan(e.Index);
private void WeaponSelectUI_OnWeaponSelected(object sender, WeaponSelectedArgs e) {
if (selectedUnit.TryGetComponent(out Weaver trySelectWeaver)) {
trySelectWeaver.TryDrawWeapon(e.Weapon.name);
}
void EventAggregator_OnSelectRuneWeavingCast(object sender, WeaveCastArgs e) {
SelectedWeaver.TryQueueWeave(new(e.Weave), TargetUnit);
private void PartyMemberPortrait_OnPartyMemberSelected(object sender, PartyMemberSelectedArgs e) {
selectedUnit = e.PartyMember.transform;
void CombatFormSelectUI_OnCombatFormSelected(object sender, CombatFormSelectedArgs e) {
SelectedWeaver.TryEquipCombatForm(e.CombatForm.name);
private void PlayerKeyActions_OnUnitMove(object sender, UnitMoveArgs e) {
if (selectedUnit != null && selectedUnit.TryGetComponent(out Weaver trySelectWeaver)) {
trySelectWeaver.TryQueueMove(e.Point);
void PlayerKeyActions_OnUnitMove(object sender, UnitMoveArgs e) {
SelectedWeaver.TryQueueMove(e.Point);
}
void EventAggregator_InvokeOnUnitTargeted(object sender, UnitActionArgs e) {
TargetUnit = e.UnitTransform;
}
void PartyMemberPortrait_OnPartyMemberSelected(object sender, PartyMemberSelectedArgs e) {
if (e.PartyMember.TryGetComponent<Weaver>(out var weaver)) {
SelectedWeaver = weaver;
private void PlayerKeyActions_OnUnitSelected(object sender, UnitActionArgs e) {
selectedUnit = e.UnitTransform;
void PlayerKeyActions_OnUnitSelected(object sender, UnitActionArgs e) {
if (e.UnitTransform.TryGetComponent<Weaver>(out var weaver)) {
SelectedWeaver = weaver;
}