internal int FindActionIndex( GOAPAction goapAction )
        {
            var idx = this.actions.IndexOf( goapAction );
            if( idx > -1 )
                return idx;

            this.actions.Add( goapAction );

            return this.actions.Count - 1;
        }
        public void AddAction( GOAPAction goapAction )
        {
            var actionId = this.FindActionIndex( goapAction );
            if( actionId == -1 )
                throw new KeyNotFoundException( "could not find or create Action" );

            foreach( var preCondition in goapAction.PreConditions )
            {
                var conditionId = this.FindConditionNameIndex( preCondition.Item1 );
                if( conditionId == -1 )
                    throw new KeyNotFoundException( "could not find or create conditionName" );

                this.preConditions[actionId].Set( conditionId, preCondition.Item2 );
            }

            foreach( var postCondition in goapAction.PostConditions )
            {
                var conditionId = this.FindConditionNameIndex( postCondition.Item1 );
                if( conditionId == -1 )
                    throw new KeyNotFoundException( "could not find conditionName" );

                this.postConditions[actionId].Set( conditionId, postCondition.Item2 );
            }
        }
예제 #3
0
 public void Reset()
 {
     this.Action = null;
     this.Parent = null;
 }