2023-06-29 11:55:02 +08:00

2.9 KiB
Raw Blame History

InputBufferConponent

绑定输入。输入命令队列。 IsTransitimtCache如果有Pool里有对应命令就会切换到下一个State。

SDHInputCommandActionMap

  • Has Order解析Command是否按键顺序。
  • InputActionCommandType在LCMDates.h定义。
  • ButtonAction在LCMDates.h定义。

StateMachine

Transition每帧都会检测。

  • EnableButtonActionBufferBlockMap该状态可以启用的命令
  • ResetButtonActionBufferBlockMapState将所有命令都设置为禁止。
  • CacheCommandTransmitter将命令加到Pool中。

我的想法

因为大部分StateMachine都和GAS会有关联GASTag与GAS属性判断所以我希望

  1. 在OnStartStateMachine中先获取GAS组件。
  2. 在编辑器模式下检测StateGraph中的StateABility是否都已经想GAS组件注册。有的时候会忘记
  3. 监控Ability是否结束以及控制Ability结束。BP_SDHSkillStateIns
  4. 之后使用 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);
  1. 监听StateAbility的Ability结束。方法有21、绑定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)