示例#1
0
        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>();
                }
            }
        }
        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;
                }
            }
        }