public BaseContext(IAIAgent agent) { this.AIAgent = agent; this.Entity = agent.Entity; this.sampledPositions = new List <Vector3>(); this.Memory = new Memory(); }
public static bool Evaluate(IAIAgent self, Vector3 optionPosition, out Vector3 dir, out float dot) { dir = optionPosition - self.Entity.ServerPosition; NPCPlayerApex nPCPlayerApex = self as NPCPlayerApex; if (nPCPlayerApex == null) { dir.Normalize(); dot = Vector3.Dot(dir, self.Entity.transform.forward); if (dot < self.GetStats.VisionCone) { dot = -1f; return(false); } } else { if (nPCPlayerApex.ToEnemyRangeEnum(dir.sqrMagnitude) == NPCPlayerApex.EnemyRangeEnum.CloseAttackRange) { dot = 1f; dir.Normalize(); return(true); } dir.Normalize(); dot = Vector3.Dot(dir, nPCPlayerApex.eyes.BodyForward()); if (dot < self.GetStats.VisionCone) { dot = -1f; return(false); } } return(true); }
private void OnEnable() { this.isRegistered = false; if (Object.op_Equality((Object)SingletonComponent <AiManager> .Instance, (Object)null) || !((Behaviour)SingletonComponent <AiManager> .Instance).get_enabled() || AiManager.nav_disable) { ((Behaviour)this).set_enabled(false); } else { this.agent = (IAIAgent)((Component)this).GetComponent <IAIAgent>(); if (this.agent == null) { return; } if (this.agent.Entity.isClient) { ((Behaviour)this).set_enabled(false); } else { this.agent.AgentTypeIndex = this.AgentTypeIndex; this.Invoke(new Action(this.DelayedRegistration), SeedRandom.Value((uint)Mathf.Abs(((Object)this).GetInstanceID())) * 3f); } } }
public static void Evaluate(IAIAgent self, Vector3 optionPosition, out float distanceSqr, out float aggroRangeSqr) { Vector3 vector3 = optionPosition - self.Entity.ServerPosition; aggroRangeSqr = self.GetActiveAggressionRangeSqr(); distanceSqr = Mathf.Min(vector3.sqrMagnitude, aggroRangeSqr); }
public virtual float EvaluateScore(Intelligence intelligence, IAIAgent[] possibleTargets) { Consideration[] considerations = decisionData.considerationHandler.considerations; float finalScore = decisionData.weight; for (int i = 0; i < considerations.Length; i++) { Consideration currentConsideration = considerations[i]; float considerationScore = currentConsideration.Score(intelligence, ref possibleTargets); float evaluatedScore = currentConsideration.Evaluate(considerationScore); if (evaluatedScore == 0.0f) { return(0.0f); } finalScore *= Mathf.Clamp01(evaluatedScore); } if (possibleTargets.Length <= 0) { return(0.0f); } targetAgent = possibleTargets[0]; return(finalScore); }
internal void AddActiveAgency(IAIAgent agent) { if (this.pendingAddToActive.Contains(agent)) { return; } this.pendingAddToActive.Add(agent); }
internal void AddDormantAgency(IAIAgent agent) { if (this.pendingAddToDormant.Contains(agent)) { return; } this.pendingAddToDormant.Add(agent); }
public void Init(IAIAgent <L, V> agent) { Agent = agent; state = States.Enabled; SetPreconditions(); SetEffects(); OnInit(); }
internal void RemoveActiveAgency(IAIAgent agent) { if (this.pendingRemoveFromActive.Contains(agent)) { return; } this.pendingRemoveFromActive.Add(agent); }
public static float RangeFromHome(Vector3 point, IAIAgent agent) { if ((point - agent.SpawnPosition).sqrMagnitude > agent.GetStats.MaxRoamRange * ConVar.AI.npc_max_roam_multiplier) { return(0f); } return(1f); }
internal void RemoveDormantAgency(IAIAgent agent) { if (this.pendingRemoveFromDormant.Contains(agent)) { return; } this.pendingRemoveFromDormant.Add(agent); }
public void Remove(IAIAgent agent) { this.RemoveActiveAgency(agent); if (AiManager.ai_dormant) { this.RemoveDormantAgency(agent); } }
public static float FlankPointValue(Vector3 point, IAIAgent agent) { if (Object.op_Equality((Object)agent.AttackTarget, (Object)null)) { return(0.0f); } float num = 0.0f; return(!NavPointSampler.PointDirectnessToTarget(point, agent.Entity.ServerPosition, agent.AttackTarget.ServerPosition, out num) || (double)num < -0.100000001490116 || (double)num > 0.100000001490116 ? 0.0f : 1f); }
public void Refresh(IAIAgent self, BaseEntity[] entities, int entityCount) { this.Self = self; this.Entities = entities; this.EntityCount = entityCount; this.AnimalTarget = null; this.AnimalScore = 0f; this.ExplosiveTarget = null; this.ExplosiveScore = 0f; }
public void Refresh(IAIAgent self, BasePlayer[] players, int playerCount) { this.Self = self; this.Players = players; this.PlayerCount = playerCount; this.Target = (BasePlayer)null; this.Score = 0.0f; this.Index = -1; this.LastKnownPosition = Vector3.get_zero(); }
private static bool _SampleNavMesh(ref Vector3 pos, IAIAgent agent) { NavMeshHit navMeshHit; if (!NavMesh.SamplePosition(pos, out navMeshHit, agent.GetNavAgent.height * 2f, agent.GetNavAgent.areaMask)) { return(false); } pos = navMeshHit.position; return(true); }
public static void Evaluate( IAIAgent self, Vector3 optionPosition, out float distanceSqr, out float aggroRangeSqr) { Vector3 vector3 = Vector3.op_Subtraction(optionPosition, self.Entity.ServerPosition); aggroRangeSqr = self.GetActiveAggressionRangeSqr(); distanceSqr = Mathf.Min(((Vector3) ref vector3).get_sqrMagnitude(), aggroRangeSqr); }
public static float RetreatFromDirection(Vector3 point, IAIAgent agent) { if (Vector3.op_Equality(agent.Entity.LastAttackedDir, Vector3.get_zero())) { return(0.0f); } Vector3 vector3 = Vector3.op_Subtraction(point, agent.Entity.ServerPosition); Vector3 normalized = ((Vector3) ref vector3).get_normalized(); return((double)Vector3.Dot(agent.Entity.LastAttackedDir, normalized) > -0.5 ? 0.0f : 1f); }
private static bool _SampleNavMesh(ref Vector3 pos, IAIAgent agent) { NavMeshHit navMeshHit; if (!NavMesh.SamplePosition(pos, ref navMeshHit, agent.GetNavAgent.get_height() * 2f, agent.GetNavAgent.get_areaMask())) { return(false); } pos = ((NavMeshHit) ref navMeshHit).get_position(); return(true); }
public static float TopologyPreference(Vector3 point, IAIAgent agent) { if (Object.op_Inequality((Object)TerrainMeta.TopologyMap, (Object)null)) { int topology = TerrainMeta.TopologyMap.GetTopology(point); if ((agent.TopologyPreference() & topology) > 0) { return(1f); } } return(0.0f); }
public static float TopologyPreference(Vector3 point, IAIAgent agent) { if (TerrainMeta.TopologyMap != null) { int topology = TerrainMeta.TopologyMap.GetTopology(point); if ((agent.TopologyPreference() & topology) > 0) { return(1f); } } return(0f); }
public virtual float Score(Intelligence intelligence, ref IAIAgent[] agents) { filteredAgents.Clear(); for (int i = 0; i < agents.Length; i++) { IAIAgent currentAgent = agents[i]; FilterAgents(intelligence, currentAgent); } agents = filteredAgents.ToArray(); return(filteredAgents.Count > 0 ? 1f : 0f); }
public static float RetreatFromDirection(Vector3 point, IAIAgent agent) { if (agent.Entity.LastAttackedDir == Vector3.zero) { return(0f); } Vector3 vector3 = (point - agent.Entity.ServerPosition).normalized; if (Vector3.Dot(agent.Entity.LastAttackedDir, vector3) > -0.5f) { return(0f); } return(1f); }
public static float ApproachPointValue(Vector3 point, IAIAgent agent) { if (Object.op_Equality((Object)agent.AttackTarget, (Object)null)) { return(0.0f); } float num = 0.0f; if (!NavPointSampler.PointDirectnessToTarget(point, agent.Entity.ServerPosition, agent.AttackTarget.ServerPosition, out num) || (double)num < 0.5) { return(0.0f); } return(num); }
private void InitialiseNodeLists(IAIAgent <L, V> agent, IAIGoal <L, V> goal) { nullNodes.Clear(); openNodes.Clear(); closedNodes.Clear(); currentNode = new AINode <L, V>(agent, goal); closedNodes.Add(currentNode); foreach (var action in agent.Actions.GetActions()) { nullNodes.Add(new AINode <L, V>(agent, goal, action)); } }
public void Refresh(IAIAgent self, Vector3 dangerPoint, List <CoverPoint> sampledCoverPoints) { this.Self = self; this.DangerPoint = dangerPoint; this.SampledCoverPoints = sampledCoverPoints; this.BestRetreatValue = 0f; this.BestFlankValue = 0f; this.BestAdvanceValue = 0f; this.BestRetreatCP = null; this.BestFlankCP = null; this.BestAdvanceCP = null; this.HideoutValue = 0f; this.HideoutCP = null; }
public void Add(IAIAgent agent) { if (!AiManager.ai_dormant) { this.AddActiveAgency(agent); return; } if (this.IsAgentCloseToPlayers(agent)) { this.AddActiveAgency(agent); return; } this.AddDormantAgency(agent); }
private static float _DiscourageSharpTurns(Vector3 pos, IAIAgent agent) { Vector3 vector3 = (pos - agent.Entity.ServerPosition).normalized; float single = Vector3.Dot(agent.Entity.transform.forward, vector3); if (single > 0.45f) { return(1f); } if (single > 0f) { return(single); } return(0f); }
private static float _DiscourageSharpTurns(Vector3 pos, IAIAgent agent) { Vector3 vector3 = Vector3.op_Subtraction(pos, agent.Entity.ServerPosition); Vector3 normalized = ((Vector3) ref vector3).get_normalized(); float num = Vector3.Dot(((Component)agent.Entity).get_transform().get_forward(), normalized); if ((double)num > 0.449999988079071) { return(1f); } if ((double)num > 0.0) { return(num); } return(0.0f); }
public static float RetreatPointValueExplosive(Vector3 point, IAIAgent agent) { BaseContext context = agent.GetContext(Guid.Empty) as BaseContext; if (context == null || context.DeployedExplosives.Count == 0 || (Object.op_Equality((Object)context.DeployedExplosives[0], (Object)null) || context.DeployedExplosives[0].IsDestroyed)) { return(0.0f); } float num = 0.0f; if (!NavPointSampler.PointDirectnessToTarget(point, agent.Entity.ServerPosition, context.DeployedExplosives[0].ServerPosition, out num) || (double)num > -0.5) { return(0.0f); } return(num * -1f); }