Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions Attacks/DownAttack.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Needleforge.Components;
using Needleforge.Data;
using System;
using System.Collections;
using UnityEngine;
using DownSlashTypes = HeroControllerConfig.DownSlashTypes;
using UObject = UnityEngine.Object;
Expand Down Expand Up @@ -76,6 +77,7 @@ public HeroSlashBounceConfig BounceConfig
private HeroDownAttack? heroDownAttack;
private DownspikeWithBounceConfig? downspike;
private NailSlash? nailSlash;
private PlayMakerFSM? reactionFsm;

protected override NailAttackBase? NailAttack =>
heroDownAttack ? heroDownAttack.attack : null;
Expand All @@ -98,8 +100,12 @@ protected override void AddComponents(HeroController hc)
downspike = GameObject.AddComponent<DownspikeWithBounceConfig>();
heroDownAttack.attack = downspike;
break;
case DownSlashTypes.Slash:

case DownSlashTypes.Custom:
reactionFsm = GameObject.AddComponent<PlayMakerFSM>();
goto case DownSlashTypes.Slash;

case DownSlashTypes.Slash:
nailSlash = GameObject.AddComponent<NailSlash>();
heroDownAttack.attack = nailSlash;
break;
Expand Down Expand Up @@ -129,8 +135,11 @@ protected override void LateInitializeComponents(HeroController hc)
Damager!.forceSpikeUpdate = true;
break;

case DownSlashTypes.Slash:
case DownSlashTypes.Custom:
GameManager.instance.StartCoroutine(InitReactionFsm());
goto case DownSlashTypes.Slash;

case DownSlashTypes.Slash:
nailSlash!.animName = AnimName;
nailSlash!.bounceConfig = BounceConfig;
Damager!.corpseDirection =
Expand All @@ -140,6 +149,23 @@ protected override void LateInitializeComponents(HeroController hc)
};
break;
}

IEnumerator InitReactionFsm() {
yield return null; // wait one frame for components to Awake
reactionFsm!.SetFsmTemplate(ReactionFsmTemplate);
}
}

private static FsmTemplate ReactionFsmTemplate {
get {
if (!_reactionFsmTemplate) {
var reaper = HeroController.instance.transform.Find("Attacks/Scythe/DownSlash New");
var reaperFsm = reaper.GetComponent<PlayMakerFSM>();
_reactionFsmTemplate = reaperFsm.fsmTemplate;
}
return _reactionFsmTemplate;
}
}
private static FsmTemplate? _reactionFsmTemplate;

}