Exemplo n.º 1
0
        private void DoService(ref BehaviorTreeContext context)
        {
            if (!(context.Agent.Target is ISpatial))
            {
                throw new InvalidOperationException($"The behavior condition {nameof(GetNearestPedToAgent)} can't be used with {context.Agent.Target.GetType().Name}, it can only be used with {nameof(ISpatial)}s");
            }

            Vector3 position = ((ISpatial)context.Agent.Target).Position;

            Entity[] nearbyPeds = World.GetEntities(position, range, GetEntitiesFlags.ConsiderAllPeds);

            foreach (Entity e in nearbyPeds.OrderBy(e => Vector3.DistanceSquared(e.Position, position)))
            {
                Ped p = (Ped)e;
                if (pedPredicate == null || pedPredicate.Invoke(p))
                {
                    Ped contextPed = context.Agent.Target as Ped;
                    if (contextPed == null || contextPed != p)
                    {
                        pedSetter.Set(context, this, p);
                        return;
                    }
                }
            }
            pedSetter.Set(context, this, null);
        }
Exemplo n.º 2
0
        private void DoService(ref BehaviorTreeContext context)
        {
            Entity[] nearbyPeds = World.GetEntities(position, range, GetEntitiesFlags.ConsiderAllPeds);

            foreach (Entity e in nearbyPeds.OrderBy(e => Vector3.DistanceSquared(e.Position, position)))
            {
                Ped p = (Ped)e;
                if (pedPredicate == null || pedPredicate.Invoke(p))
                {
                    pedSetter.Set(context, this, p);
                    return;
                }
            }

            pedSetter.Set(context, this, null);
        }
Exemplo n.º 3
0
        private void DoService(ref BehaviorTreeContext context)
        {
            ISpatial p = spatial.Get(context, this);

            if (p != null)
            {
                positionSetter.Set(context, this, p.Position);
            }
        }
Exemplo n.º 4
0
        private void DoService(ref BehaviorTreeContext context)
        {
            Ped p = ped.Get(context, this);

            if (!p)
            {
                return;
            }

            Vehicle v = p.CurrentVehicle;

            vehicleSetter.Set(context, this, v);
        }
Exemplo n.º 5
0
        private void DoService(ref BehaviorTreeContext context)
        {
            Entity e = entity.Get(context, this);

            speedSetter.Set(context, this, e.Speed);
        }
Exemplo n.º 6
0
        private void DoService(ref BehaviorTreeContext context)
        {
            Ped p = Game.LocalPlayer.Character;

            pedSetter.Set(context, this, p);
        }