블랙보드에 사용할 SO 제작, MoveToTarget 대중화
This commit is contained in:
parent
466313acb9
commit
ec4f5d58c1
BIN
Assets/_DDD/_Addressables/AI/Customer/Subtree/CustomerDefault.asset
(Stored with Git LFS)
BIN
Assets/_DDD/_Addressables/AI/Customer/Subtree/CustomerDefault.asset
(Stored with Git LFS)
Binary file not shown.
@ -38,7 +38,7 @@ public override void OnStart()
|
|||||||
|
|
||||||
var blackboard = gameObject.GetComponent<IAISharedBlackboard>();
|
var blackboard = gameObject.GetComponent<IAISharedBlackboard>();
|
||||||
|
|
||||||
_cachedTarget = blackboard.GetBlackboardValue<GameObject>(nameof(RestaurantCustomerBlackboardKey.CurrentInteractionTarget));
|
_cachedTarget = blackboard.GetBlackboardValue<GameObject>(nameof(RestaurantCustomerBlackboardKey.CurrentTargetGameObject));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override TaskStatus OnUpdate()
|
public override TaskStatus OnUpdate()
|
||||||
|
@ -8,7 +8,7 @@ namespace DDD.Restaurant
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// IAiMovement를 이용해 인터랙션 타겟으로 이동하는 액션
|
/// IAiMovement를 이용해 인터랙션 타겟으로 이동하는 액션
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MoveToInteractionTarget : Action
|
public class MoveToTargetPoint : Action
|
||||||
{
|
{
|
||||||
[Header("Target Settings")]
|
[Header("Target Settings")]
|
||||||
[Tooltip("InteractionPoints를 사용해 가장 가까운 지점으로 이동")]
|
[Tooltip("InteractionPoints를 사용해 가장 가까운 지점으로 이동")]
|
||||||
@ -41,7 +41,7 @@ public override void OnStart()
|
|||||||
_isMoving = false;
|
_isMoving = false;
|
||||||
|
|
||||||
var blackboard = gameObject.GetComponent<IAISharedBlackboard>();
|
var blackboard = gameObject.GetComponent<IAISharedBlackboard>();
|
||||||
_target = blackboard.GetBlackboardValue<GameObject>(nameof(RestaurantCustomerBlackboardKey.CurrentInteractionTarget));
|
_target = blackboard.GetBlackboardValue<GameObject>(nameof(RestaurantCustomerBlackboardKey.CurrentTargetGameObject));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override TaskStatus OnUpdate()
|
public override TaskStatus OnUpdate()
|
@ -0,0 +1,36 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Opsive.GraphDesigner.Runtime.Variables;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace DDD.Restaurant
|
||||||
|
{
|
||||||
|
public class BlackboardSo<T> : ScriptableObject where T : Enum
|
||||||
|
{
|
||||||
|
private Dictionary<T, SharedVariable> _variables = new();
|
||||||
|
|
||||||
|
public SharedVariable<T1> GetVariable<T1>(T key)
|
||||||
|
{
|
||||||
|
if (_variables.TryGetValue(key, out var variable))
|
||||||
|
{
|
||||||
|
return variable as SharedVariable<T1>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetVariable<T1>(T key, T1 value)
|
||||||
|
{
|
||||||
|
var outVariable = GetVariable<T1>(key);
|
||||||
|
if (outVariable != null)
|
||||||
|
{
|
||||||
|
outVariable.Value = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SharedVariable<T1> sharedVariable = new SharedVariable<T1>() { Value = value };
|
||||||
|
_variables.Add(key, sharedVariable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 24029c24eac8499bbb9ca02126da8148
|
||||||
|
timeCreated: 1756462002
|
@ -23,7 +23,7 @@ public override void OnStart()
|
|||||||
public override TaskStatus OnUpdate()
|
public override TaskStatus OnUpdate()
|
||||||
{
|
{
|
||||||
var blackboard = gameObject.GetComponent<IAISharedBlackboard>();
|
var blackboard = gameObject.GetComponent<IAISharedBlackboard>();
|
||||||
var target = blackboard?.GetBlackboardValue<GameObject>(nameof(RestaurantCustomerBlackboardKey.CurrentInteractionTarget));
|
var target = blackboard?.GetBlackboardValue<GameObject>(nameof(RestaurantCustomerBlackboardKey.CurrentTargetGameObject));
|
||||||
IInteractable currentInteractable = target?.GetComponent<IInteractable>();
|
IInteractable currentInteractable = target?.GetComponent<IInteractable>();
|
||||||
if (_targetOrderType == RestaurantOrderType.Wait)
|
if (_targetOrderType == RestaurantOrderType.Wait)
|
||||||
{
|
{
|
||||||
@ -34,7 +34,7 @@ public override TaskStatus OnUpdate()
|
|||||||
return TaskStatus.Failure;
|
return TaskStatus.Failure;
|
||||||
}
|
}
|
||||||
var customerBlackboard = gameObject.GetComponent<IAISharedBlackboard>();
|
var customerBlackboard = gameObject.GetComponent<IAISharedBlackboard>();
|
||||||
customerBlackboard?.SetBlackboardValue(nameof(RestaurantCustomerBlackboardKey.CurrentInteractionTarget), currentInteractable.GetInteractableGameObject());
|
customerBlackboard?.SetBlackboardValue(nameof(RestaurantCustomerBlackboardKey.CurrentTargetGameObject), currentInteractable.GetInteractableGameObject());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check order type of the current interactable
|
// Check order type of the current interactable
|
||||||
@ -71,7 +71,7 @@ public override TaskStatus OnUpdate()
|
|||||||
if (_targetOrderType == RestaurantOrderType.Busy)
|
if (_targetOrderType == RestaurantOrderType.Busy)
|
||||||
{
|
{
|
||||||
var customerBlackboard = gameObject.GetComponent<IAISharedBlackboard>();
|
var customerBlackboard = gameObject.GetComponent<IAISharedBlackboard>();
|
||||||
customerBlackboard?.SetBlackboardValue<GameObject>(nameof(RestaurantCustomerBlackboardKey.CurrentInteractionTarget), null);
|
customerBlackboard?.SetBlackboardValue<GameObject>(nameof(RestaurantCustomerBlackboardKey.CurrentTargetGameObject), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TaskStatus.Success;
|
return TaskStatus.Success;
|
||||||
|
@ -19,7 +19,7 @@ public override void OnStart()
|
|||||||
if (!gameObject.TryGetComponent<IAISharedBlackboard>(out var sharedBlackboard)) return;
|
if (!gameObject.TryGetComponent<IAISharedBlackboard>(out var sharedBlackboard)) return;
|
||||||
interactionTarget =
|
interactionTarget =
|
||||||
sharedBlackboard.GetBlackboardValue<GameObject>(
|
sharedBlackboard.GetBlackboardValue<GameObject>(
|
||||||
nameof(RestaurantCustomerBlackboardKey.CurrentInteractionTarget));
|
nameof(RestaurantCustomerBlackboardKey.CurrentTargetGameObject));
|
||||||
|
|
||||||
if (interactionTarget == null)
|
if (interactionTarget == null)
|
||||||
{
|
{
|
||||||
|
@ -6,9 +6,9 @@ public enum RestaurantCustomerBlackboardKey
|
|||||||
{
|
{
|
||||||
SelfGameObject,
|
SelfGameObject,
|
||||||
CustomerDataId,
|
CustomerDataId,
|
||||||
CurrentInteractionTarget,
|
CurrentTargetGameObject,
|
||||||
CurrentMarkerTarget,
|
SatisfactionLevel,
|
||||||
IsSatisfy
|
OrderCount,
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ICustomerBlackboard
|
public interface ICustomerBlackboard
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using DDD.Restaurant;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DDD
|
namespace DDD.Restaurant
|
||||||
{
|
{
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class RestaurantPropLocation
|
public class RestaurantPropLocation
|
||||||
|
Loading…
Reference in New Issue
Block a user