public override void ResetState() { base.ResetState(); this.Memory.ResetState(); this.IsWorldStateDirty = false; this.PlanState = PlanStateType.NoPlan; this.PlanResult = PlanResultType.NoPlan; this.HtnPlan.Clear(); this.AppliedEffects.Clear(); this.AppliedExpectedEffects.Clear(); this.DecompositionScore = 2147483647; this.CurrentTask = null; this.HasVisitedLastKnownEnemyPlayerLocation = false; this.OrientationType = NpcOrientation.Heading; this.PlayersInRange.Clear(); this.EnemyPlayersInRange.Clear(); this.EnemyPlayersAudible.Clear(); this.EnemyPlayersInLineOfSight.Clear(); NpcPlayerInfo npcPlayerInfo = new NpcPlayerInfo(); this.PrimaryEnemyPlayerAudible = npcPlayerInfo; npcPlayerInfo = new NpcPlayerInfo(); this.PrimaryEnemyPlayerInLineOfSight = npcPlayerInfo; this.Location = null; this.CoverPoints.Clear(); for (int i = 0; i < (int)this._worldState.Length; i++) { this._worldState[i] = 0; this._previousWorldState[i] = 0; } }
public override void ResetState() { base.ResetState(); this.Memory.ResetState(); this.IsWorldStateDirty = false; this.PlanState = (PlanStateType)0; this.PlanResult = (PlanResultType)0; this.HtnPlan.Clear(); this.AppliedEffects.Clear(); this.AppliedExpectedEffects.Clear(); this.DecompositionScore = int.MaxValue; this.CurrentTask = (PrimitiveTaskSelector)null; this.HasVisitedLastKnownEnemyPlayerLocation = false; this.OrientationType = NpcOrientation.Heading; this.PlayersInRange.Clear(); this.EnemyPlayersInRange.Clear(); this.EnemyPlayersAudible.Clear(); this.EnemyPlayersInLineOfSight.Clear(); this.PrimaryEnemyPlayerAudible = new NpcPlayerInfo(); this.PrimaryEnemyPlayerInLineOfSight = new NpcPlayerInfo(); this.Location = (AiLocationManager)null; this.CoverPoints.Clear(); for (int index = 0; index < this._worldState.Length; ++index) { this._worldState[index] = (byte)0; this._previousWorldState[index] = (byte)0; } }
private bool _FindCoverPointsInVolume( IHTNAgent npc, Vector3 position, List <CoverPoint> coverPoints, ref CoverPointVolume volume, ref float nextTime, float time, AiLocationManager location, float maxDistanceToCoverSqr) { if (Object.op_Equality((Object)SingletonComponent <AiManager> .Instance, (Object)null) || !((Behaviour)SingletonComponent <AiManager> .Instance).get_enabled() || !((AiManager)SingletonComponent <AiManager> .Instance).UseCover) { return(false); } if ((double)time > (double)nextTime) { nextTime = time + this.TickFrequency * AI.npc_cover_info_tick_rate_multiplier; if (Object.op_Equality((Object)volume, (Object)null) || !volume.Contains(position)) { if (Object.op_Inequality((Object)npc.Body, (Object)null) && Object.op_Inequality((Object)npc.Body.GetParentEntity(), (Object)null) && Object.op_Inequality((Object)location.DynamicCoverPointVolume, (Object)null)) { volume = location.DynamicCoverPointVolume; } else if (Object.op_Inequality((Object)SingletonComponent <AiManager> .Instance, (Object)null) && ((Behaviour)SingletonComponent <AiManager> .Instance).get_enabled() && ((AiManager)SingletonComponent <AiManager> .Instance).UseCover) { volume = ((AiManager)SingletonComponent <AiManager> .Instance).GetCoverVolumeContaining(position); if (Object.op_Equality((Object)volume, (Object)null)) { volume = AiManager.CreateNewCoverVolume(position, Object.op_Inequality((Object)location, (Object)null) ? location.CoverPointGroup : (Transform)null); } } } } if (!Object.op_Inequality((Object)volume, (Object)null)) { return(false); } if (coverPoints.Count > 0) { coverPoints.Clear(); } foreach (CoverPoint coverPoint in volume.CoverPoints) { if (!coverPoint.IsReserved && !coverPoint.IsCompromised) { Vector3 position1 = coverPoint.Position; Vector3 vector3 = Vector3.op_Subtraction(position, position1); if ((double)((Vector3) ref vector3).get_sqrMagnitude() <= (double)maxDistanceToCoverSqr) { coverPoints.Add(coverPoint); } } } if (coverPoints.Count > 1) { coverPoints.Sort((IComparer <CoverPoint>) this.coverPointComparer); } return(true); }
public ScientistJunkpileContext(HTNPlayer body, ScientistJunkpileDomain domain) { int length = System.Enum.GetValues(typeof(Facts)).Length; if (this._worldState == null || this._worldState.Length != length) { this._worldState = new byte[length]; this._previousWorldState = new byte[length]; if (ScientistJunkpileContext._worldStateChanges == null) { ScientistJunkpileContext._worldStateChanges = new Stack <WorldStateInfo> [length]; for (int index = 0; index < length; ++index) { ScientistJunkpileContext._worldStateChanges[index] = new Stack <WorldStateInfo>(5); } } } this._decompositionScore = int.MaxValue; this.Body = body; this.Domain = domain; this.PlanState = (PlanStateType)0; if (this.Memory == null || this.Memory.ScientistJunkpileContext != this) { this.Memory = new ScientistJunkpileMemory(this); } if (!Object.op_Equality((Object)this.Location, (Object)null)) { return; } float num = float.MaxValue; foreach (AiLocationManager manager in AiLocationManager.Managers) { Vector3 vector3 = Vector3.op_Subtraction(((Component)manager).get_transform().get_position(), ((Component)this.Body).get_transform().get_position()); float sqrMagnitude = ((Vector3) ref vector3).get_sqrMagnitude(); if ((double)sqrMagnitude < (double)num) { num = sqrMagnitude; this.Location = manager; } } if (!Object.op_Inequality((Object)this.Location, (Object)null)) { return; } this.Junkpile = (JunkPile)((Component)this.Location).GetComponent <JunkPile>(); }
public ScientistJunkpileContext(HTNPlayer body, ScientistJunkpileDomain domain) { int length = Enum.GetValues(typeof(Facts)).Length; if (this._worldState == null || (int)this._worldState.Length != length) { this._worldState = new byte[length]; this._previousWorldState = new byte[length]; if (ScientistJunkpileContext._worldStateChanges == null) { ScientistJunkpileContext._worldStateChanges = new Stack <WorldStateInfo> [length]; for (int i = 0; i < length; i++) { ScientistJunkpileContext._worldStateChanges[i] = new Stack <WorldStateInfo>(5); } } } this._decompositionScore = 2147483647; this.Body = body; this.Domain = domain; this.PlanState = PlanStateType.NoPlan; if (this.Memory == null || this.Memory.ScientistJunkpileContext != this) { this.Memory = new ScientistJunkpileMemory(this); } if (this.Location == null) { float single = Single.MaxValue; foreach (AiLocationManager manager in AiLocationManager.Managers) { Vector3 vector3 = manager.transform.position - this.Body.transform.position; float single1 = vector3.sqrMagnitude; if (single1 >= single) { continue; } single = single1; this.Location = manager; } if (this.Location != null) { this.Junkpile = this.Location.GetComponent <JunkPile>(); } } }
private bool _FindCoverPointsInVolume(Vector3 position, List <CoverPoint> coverPoints, ref CoverPointVolume volume, ref float nextTime, float time, AiLocationManager location, float maxDistanceToCoverSqr) { Transform coverPointGroup; if (SingletonComponent <AiManager> .Instance == null || !SingletonComponent <AiManager> .Instance.enabled || !SingletonComponent <AiManager> .Instance.UseCover) { return(false); } if (time > nextTime) { nextTime = time + this.TickFrequency * ConVar.AI.npc_cover_info_tick_rate_multiplier; if (location.DynamicCoverPointVolume != null) { volume = location.DynamicCoverPointVolume; } else if ((volume == null || !volume.Contains(position)) && SingletonComponent <AiManager> .Instance != null && SingletonComponent <AiManager> .Instance.enabled && SingletonComponent <AiManager> .Instance.UseCover) { volume = SingletonComponent <AiManager> .Instance.GetCoverVolumeContaining(position); if (volume == null) { Vector3 vector3 = position; if (location != null) { coverPointGroup = location.CoverPointGroup; } else { coverPointGroup = null; } volume = AiManager.CreateNewCoverVolume(vector3, coverPointGroup); } } } if (volume == null) { return(false); } if (coverPoints.Count > 0) { coverPoints.Clear(); } foreach (CoverPoint coverPoint in volume.CoverPoints) { if (coverPoint.IsReserved || coverPoint.IsCompromised || (position - coverPoint.Position).sqrMagnitude > maxDistanceToCoverSqr) { continue; } coverPoints.Add(coverPoint); } if (coverPoints.Count > 1) { coverPoints.Sort(this.coverPointComparer); } return(true); }
public override void ResetState() { base.ResetState(); ScientistJunkpileMemory memory = this.Memory; if (memory != null) { memory.ResetState(); } else { } this.IsWorldStateDirty = false; this.PlanState = PlanStateType.NoPlan; this.PlanResult = PlanResultType.NoPlan; Stack <PrimitiveTaskSelector> htnPlan = this.HtnPlan; if (htnPlan != null) { htnPlan.Clear(); } else { } Dictionary <Guid, Stack <IEffect> > appliedEffects = this.AppliedEffects; if (appliedEffects != null) { appliedEffects.Clear(); } else { } Dictionary <Guid, Stack <IEffect> > appliedExpectedEffects = this.AppliedExpectedEffects; if (appliedExpectedEffects != null) { appliedExpectedEffects.Clear(); } else { } this.DecompositionScore = 2147483647; this.CurrentTask = null; this.HasVisitedLastKnownEnemyPlayerLocation = false; this.OrientationType = NpcOrientation.Heading; List <NpcPlayerInfo> playersInRange = this.PlayersInRange; if (playersInRange != null) { playersInRange.Clear(); } else { } List <NpcPlayerInfo> enemyPlayersInRange = this.EnemyPlayersInRange; if (enemyPlayersInRange != null) { enemyPlayersInRange.Clear(); } else { } List <NpcPlayerInfo> enemyPlayersAudible = this.EnemyPlayersAudible; if (enemyPlayersAudible != null) { enemyPlayersAudible.Clear(); } else { } List <NpcPlayerInfo> enemyPlayersInLineOfSight = this.EnemyPlayersInLineOfSight; if (enemyPlayersInLineOfSight != null) { enemyPlayersInLineOfSight.Clear(); } else { } NpcPlayerInfo npcPlayerInfo = new NpcPlayerInfo(); this.PrimaryEnemyPlayerAudible = npcPlayerInfo; npcPlayerInfo = new NpcPlayerInfo(); this.PrimaryEnemyPlayerInLineOfSight = npcPlayerInfo; this.Location = null; List <CoverPoint> coverPoints = this.CoverPoints; if (coverPoints != null) { coverPoints.Clear(); } else { } if (this._worldState != null) { for (int i = 0; i < (int)this._worldState.Length; i++) { this._worldState[i] = 0; this._previousWorldState[i] = 0; } } }