public ScientistAStarContext(HTNPlayer body, ScientistAStarDomain 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 (ScientistAStarContext._worldStateChanges == null)
                {
                    ScientistAStarContext._worldStateChanges = new Stack <WorldStateInfo> [length];
                    for (int index = 0; index < length; ++index)
                    {
                        ScientistAStarContext._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.ScientistContext != this)
            {
                this.Memory = new ScientistAStarMemory(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;
                }
            }
        }
Exemplo n.º 2
0
        public ScientistAStarContext(HTNPlayer body, ScientistAStarDomain 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 (ScientistAStarContext._worldStateChanges == null)
                {
                    ScientistAStarContext._worldStateChanges = new Stack <WorldStateInfo> [length];
                    for (int i = 0; i < length; i++)
                    {
                        ScientistAStarContext._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.ScientistContext != this)
            {
                this.Memory = new ScientistAStarMemory(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;
                }
            }
        }