2.9 KiB
2.9 KiB
InputBufferConponent
绑定输入。输入命令队列。 IsTransitimtCache,如果有Pool里有对应命令就会切换到下一个State。
SDHInputCommandActionMap
- Has Order:解析Command是否按键顺序。
- InputActionCommandType:在LCMDates.h定义。
- ButtonAction:在LCMDates.h定义。
StateMachine
Transition每帧都会检测。
- EnableButtonActionBufferBlockMap:该状态可以启用的命令
- ResetButtonActionBufferBlockMapState:将所有命令都设置为禁止。
- CacheCommandTransmitter:将命令加到Pool中。
我的想法
因为大部分StateMachine都和GAS会有关联(GASTag与GAS属性判断),所以我希望:
- 在OnStartStateMachine中先获取GAS组件。
- 在编辑器模式下,检测StateGraph中的StateABility是否都已经想GAS组件注册。(有的时候会忘记)
- 监控Ability是否结束,以及控制Ability结束。BP_SDHSkillStateIns
- 之后使用 FGameplayAbilityEndedDelegate OnAbilityEnded;。
/** Allow events to be registered for specific gameplay tags being added or removed */
FOnGameplayEffectTagCountChanged& RegisterGameplayTagEvent(FGameplayTag Tag, EGameplayTagEventType::Type EventType=EGameplayTagEventType::NewOrRemoved);
/** Unregister previously added events */
void UnregisterGameplayTagEvent(FDelegateHandle DelegateHandle, FGameplayTag Tag, EGameplayTagEventType::Type EventType=EGameplayTagEventType::NewOrRemoved);
/** Register a tag event and immediately call it */
FDelegateHandle RegisterAndCallGameplayTagEvent(FGameplayTag Tag, FOnGameplayEffectTagCountChanged::FDelegate Delegate, EGameplayTagEventType::Type EventType=EGameplayTagEventType::NewOrRemoved);
/** Returns multicast delegate that is invoked whenever a tag is added or removed (but not if just count is increased. Only for 'new' and 'removed' events) */
FOnGameplayEffectTagCountChanged& RegisterGenericGameplayTagEvent();
/** Executes a gameplay event. Returns the number of successful ability activations triggered by the event */
virtual int32 HandleGameplayEvent(FGameplayTag EventTag, const FGameplayEventData* Payload);
- 监听StateAbility的Ability结束。方法有2:1、绑定GAS组件的OnAbilityEnded委托。2、重写EndAbility函数。
bool UAbilitySystemComponent::TryActivateAbilityByClass(TSubclassOf<UGameplayAbility> InAbilityToActivate, bool bAllowRemoteActivation)
{
bool bSuccess = false;
const UGameplayAbility* const InAbilityCDO = InAbilityToActivate.GetDefaultObject();
for (const FGameplayAbilitySpec& Spec : ActivatableAbilities.Items)
{
if (Spec.Ability == InAbilityCDO)
{
bSuccess |= TryActivateAbility(Spec.Handle, bAllowRemoteActivation);
break;
}
}
return bSuccess;
}
bool UAbilitySystemComponent::TryActivateAbility(FGameplayAbilitySpecHandle AbilityToActivate, bool bAllowRemoteActivation)
void UAbilitySystemComponent::NotifyAbilityEnded(FGameplayAbilitySpecHandle Handle, UGameplayAbility* Ability, bool bWasCancelled)