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); }
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); }
private void DoService(ref BehaviorTreeContext context) { ISpatial p = spatial.Get(context, this); if (p != null) { positionSetter.Set(context, this, p.Position); } }
private void DoService(ref BehaviorTreeContext context) { Ped p = ped.Get(context, this); if (!p) { return; } Vehicle v = p.CurrentVehicle; vehicleSetter.Set(context, this, v); }
private void DoService(ref BehaviorTreeContext context) { Entity e = entity.Get(context, this); speedSetter.Set(context, this, e.Speed); }
private void DoService(ref BehaviorTreeContext context) { Ped p = Game.LocalPlayer.Character; pedSetter.Set(context, this, p); }