특정 엔티티 입력
특정 엔티티 입력(예: AI HFSM이 상태를 기반으로 한 특정 EntityRef
대상을 제공하는 경우)을 지원하기 위해서는 폭발적으로 필요한 메모리가 증가할 수 있으므로 InputDesires
내부에 모든 입력을 저장하는 것은 효율적인 솔루션이 아닙니다. 이 작업은 다음을 통해 수행할 수 있습니다.
- AI 또는 기타 입력 소스가 원하는 입력을 특정 엔티티 컴포넌트에 직접 생성합니다.
- 구현된 경우 생성된 입력은 나중에 다음 메소드로 처리할 수 있습니다:
ProcessInputDesires()
PreProcessComponentDesires()
PostProcessComponentDesires()
Update()
아래 다이어그램은 이 프로세스가 InputDesires
를 바이패스하는 데 사용되는 방법을 보여줍니다.
(우선순위 좌 => 우, 상단 => 하단).
HFSM 동작 내에서 스파이더 엔티티에 대한 공격 대상 입력을 생성하는 예:
C#
[Serializable]
public unsafe sealed class SetSpiderAttackTargetAIAction : AIAction
{
public AIBlackboardValueKey ReferenceKey;
public override void Update(Frame frame, EntityRef entity)
{
if (ReferenceKey.Key.HasValue() == false)
{
Log.Warn($"Missing ReferenceKey {frame.EntityContext.CurrentHFSMState.Label} {nameof(SetSpiderAttackTargetAIAction)}");
return;
}
frame.GetComponent<Spider>(entity)->AttackTarget = frame.EntityContext.AIBlackboard->GetEntityRef(frame, ReferenceKey.Key);
}
}
그리고 가능한 처리 방법 중의 하나가 SpiderController
에 있습니다:
C#
public unsafe class SpiderController : UpdatableActorController, IEntityInitializer, IInputController, IPreProcessComponentDesiresController, IDeathController
{
...
internal override void Update(Frame frame, EntityRef entity)
{
Spider* spider = frame.GetComponent<Spider>(entity);
if (spider->AttackTarget != EntityRef.None)
{
TryAttack(frame, spider->AttackTarget);
}
}
...
}
Back to top