Ejemplo n.º 1
0
 public PickRandomLocationExecutable Init(IBlackboardComponent blackboard, HiraBlackboardKey key, string locationName)
 {
     _blackboard   = blackboard;
     _key          = key.Index;
     _locationName = locationName;
     return(this);
 }
Ejemplo n.º 2
0
 public RotateToExecutable Init(Transform target, IBlackboardComponent blackboard, HiraBlackboardKey locationKey)
 {
     _target      = target;
     _blackboard  = blackboard;
     _locationKey = locationKey;
     return(this);
 }
Ejemplo n.º 3
0
        public BottomLayerRunner(
            IParentLayerRunner parent,
            MonoBehaviour coroutineRunner,
            IBlackboardComponent blackboard,
            IPlannerDomain domain,
            byte layerIndex,
            float maxFScore,
            RawBlackboardArrayWrapper plannerDatasets,
            byte maxPlanLength)
        {
            Parent           = parent;
            _coroutineRunner = coroutineRunner;
            _blackboard      = blackboard;
            _domain          = domain;
            _layerIndex      = layerIndex;
            _maxFScore       = maxFScore;

            _plannerDatasets = plannerDatasets;
            _result.First    = new PlannerResult(maxPlanLength, Allocator.Persistent)
            {
                Count = 0
            };
            _result.Second = new PlannerResult(maxPlanLength, Allocator.Persistent)
            {
                Count = 0
            };
        }
Ejemplo n.º 4
0
 public static void ApplyTo(this IBlackboardEffector[] effectors, IBlackboardComponent blackboard)
 {
     foreach (var effector in effectors)
     {
         effector.ApplyTo(blackboard);
     }
 }
Ejemplo n.º 5
0
 public TaskRunner(HiraComponentContainer target, IBlackboardComponent blackboard, IPlannerDomain domain, Action <bool> onPlanRunnerFinished)
 {
     _domain               = domain;
     _target               = target;
     _blackboard           = blackboard;
     _executionQueue       = ExecutionQueue.Create();
     _serviceRunner        = ServiceRunner.Create();
     _onPlanRunnerFinished = onPlanRunnerFinished;
 }
        public Executable GetExecutable(HiraComponentContainer target, IBlackboardComponent blackboard)
        {
            if (target is IContainsComponent <NavMeshAgent> navigableTarget && navigableTarget.Component != null)
            {
                return(GenericPool <StaticMoveToExecutable> .Retrieve().Init(navigableTarget.Component, blackboard, targetPosition, followTarget, speed, tolerance));
            }

            return(AutoFailExecutable.INSTANCE);
        }
        public Executable GetExecutable(HiraComponentContainer target, IBlackboardComponent blackboard)
        {
            if (target is IContainsComponent <AgentAnimator> animatedTarget)
            {
                return(GenericPool <KickExecutable> .Retrieve().Init(animatedTarget.Component));
            }

            return(AutoFailExecutable.INSTANCE);
        }
Ejemplo n.º 8
0
        public override unsafe void DrawEditor(void *data, IBlackboardComponent blackboard)
        {
            var value  = *(byte *)data;
            var output = UnityEditor.EditorGUILayout.Toggle(name, (value).ToBoolean()).ToByte();

            if (output != value)
            {
                MainThreadDispatcher.Schedule(() => blackboard.SetValue(Index, output));
            }
        }
Ejemplo n.º 9
0
        public override unsafe void DrawEditor(void *data, IBlackboardComponent blackboard)
        {
            var value  = *(int *)data;
            var output = UnityEditor.EditorGUILayout.DelayedIntField(name, value);

            if (value != output)
            {
                MainThreadDispatcher.Schedule(() => blackboard.SetValue(Index, output));
            }
        }
Ejemplo n.º 10
0
 public StaticMoveToExecutable Init(NavMeshAgent navMeshAgent, IBlackboardComponent blackboard, HiraBlackboardKey targetPositionKey, bool followTarget, float speed, float tolerance)
 {
     _navMeshAgent      = navMeshAgent;
     _blackboard        = blackboard;
     _targetPositionKey = targetPositionKey.Index;
     _followTarget      = followTarget;
     _speed             = speed;
     _tolerance         = tolerance;
     return(this);
 }
        public bool IsValidOn(IBlackboardComponent blackboard)
        {
            var currentX = blackboard.GetValue <float>(key.Index);
            var currentY = blackboard.GetValue <float>((ushort)(key.Index + sizeof(float)));
            var currentZ = blackboard.GetValue <float>((ushort)(key.Index + sizeof(float) + sizeof(float)));

            return(invert != ((Mathf.Abs(currentX - value.x) <= tolerance.x) &&
                              (Mathf.Abs(currentY - value.y) <= tolerance.y) &&
                              (Mathf.Abs(currentZ - value.z) <= tolerance.z)));
        }
Ejemplo n.º 12
0
        public override unsafe void DrawEditor(void *data, IBlackboardComponent blackboard)
        {
            var value  = *(float *)data;
            var output = UnityEditor.EditorGUILayout.DelayedFloatField(name, value);

            // ReSharper disable once CompareOfFloatsByEqualityOperator
            if (output != value)
            {
                MainThreadDispatcher.Schedule(() => blackboard.SetValue(Index, output));
            }
        }
Ejemplo n.º 13
0
        public override unsafe void DrawEditor(void *data, IBlackboardComponent blackboard)
        {
            var valuePtr = (float *)data;
            var output   = UnityEditor.EditorGUILayout.Vector3Field(name, new Vector3(valuePtr[0], valuePtr[1], valuePtr[2]));

            // ReSharper disable thrice CompareOfFloatsByEqualityOperator
            if (output.x != valuePtr[0] || output.y != valuePtr[1] || output.z != valuePtr[2])
            {
                MainThreadDispatcher.Schedule(() => blackboard.SetValue(Index, output));
            }
        }
Ejemplo n.º 14
0
        public static bool IsValidOn(this IBlackboardDecorator[] decorators, IBlackboardComponent blackboard)
        {
            foreach (var decorator in decorators)
            {
                if (!decorator.IsValidOn(blackboard))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 15
0
    public override ExecutionStatus Execute(float deltaTime)
    {
        ExecutionStatus result;

        if (RandomLocation.TryGet(_locationName, out _current))
        {
            _blackboard.SetValue <Vector3>(_key, _current.transform.position);
            result = ExecutionStatus.Succeeded;
        }
        else
        {
            result = ExecutionStatus.Failed;
        }

        _blackboard = null;

        return(result);
    }
Ejemplo n.º 16
0
        public TopLayerRunner(
            MonoBehaviour coroutineRunner,
            IBlackboardComponent blackboard,
            IPlannerDomain domain,
            RawBlackboardArrayWrapper plannerDatasets)
        {
            _coroutineRunner = coroutineRunner;
            _blackboard      = blackboard;
            _domain          = domain;

            _plannerDatasets = plannerDatasets;
            _result.First    = new PlannerResult(1, Allocator.Persistent)
            {
                Count = 1, [0] = byte.MaxValue
            };
            _result.Second = new PlannerResult(1, Allocator.Persistent)
            {
                Count = 1, [0] = byte.MaxValue
            };
        }
Ejemplo n.º 17
0
 public bool IsValidOn(IBlackboardComponent blackboard) => blackboard.GetValue <byte>(key.Index) == value.ToByte();
Ejemplo n.º 18
0
 public void OnReturn()
 {
     _target      = null;
     _blackboard  = null;
     _locationKey = null;
 }
        public unsafe void CopyFirstFrom(IBlackboardComponent blackboard)
        {
            var data = (byte *)_container.GetUnsafePtr();

            UnsafeUtility.MemCpy(data, blackboard.Data.GetUnsafeReadOnlyPtr(), _size);
        }
Ejemplo n.º 20
0
 public Executable GetExecutable(HiraComponentContainer target, IBlackboardComponent blackboard)
 {
     return(GenericPool <RotateToExecutable> .Retrieve().Init(target.transform, blackboard, location));
 }
Ejemplo n.º 21
0
 public bool IsValidOn(IBlackboardComponent blackboard) =>
 invert != (Mathf.Abs(blackboard.GetValue <float>(key.Index) - value) <= tolerance);
Ejemplo n.º 22
0
 public void ApplyTo(IBlackboardComponent blackboard) =>
 blackboard.SetValue <int>(key.Index, blackboard.GetValue <int>(key.Index) + blackboard.GetValue <int>(toAdd.Index));
Ejemplo n.º 23
0
 public void ApplyTo(IBlackboardComponent blackboard)
 {
     blackboard.SetValue <float>(key.Index, value.x);
     blackboard.SetValue <float>((ushort)(key.Index + sizeof(float)), value.y);
     blackboard.SetValue <float>((ushort)(key.Index + sizeof(float) + sizeof(float)), value.z);
 }
Ejemplo n.º 24
0
 public float CalculateScore(IBlackboardComponent blackboard) => score;
Ejemplo n.º 25
0
 public Executable GetExecutable(HiraComponentContainer target, IBlackboardComponent blackboard) =>
 GenericPool <PickRandomLocationExecutable> .Retrieve().Init(blackboard, storeIn, location);
Ejemplo n.º 26
0
 public abstract unsafe void DrawEditor(void *data, IBlackboardComponent blackboard);
 public float CalculateScore(IBlackboardComponent blackboard) => IsValidOn(blackboard) ? score : 0f;
Ejemplo n.º 28
0
        public static float CalculateScore(this IBlackboardScoreCalculator[] scoreCalculators, IBlackboardComponent blackboard)
        {
            var score = 0f;

            foreach (var calculator in scoreCalculators)
            {
                score += calculator.CalculateScore(blackboard);
            }

            return(score);
        }
Ejemplo n.º 29
0
 public void ApplyTo(IBlackboardComponent blackboard) => blackboard.SetValue <byte>(key.Index, (byte)(1 - blackboard.GetValue <byte>(key.Index)));
Ejemplo n.º 30
0
        public void Populate(ExecutionQueue executionQueue, ServiceRunner serviceRunner, HiraComponentContainer target, IBlackboardComponent blackboard)
        {
            if (Collection4.Length == 0)
            {
                executionQueue.Append(AutoSucceedExecutable.INSTANCE);
            }

            foreach (var provider in Collection4)
            {
                executionQueue.Append(provider.GetExecutable(target, blackboard));
            }

            foreach (var serviceProvider in Collection5)
            {
                serviceRunner.Append(serviceProvider.GetService(target, blackboard));
            }
        }