Пример #1
0
    /// <summary>
    /// removes a movment option from the state, and all it's associated transitions that it might cause
    /// </summary>
    /// <param name="option">the option being removed</param>
    public void RemoveMovementOption(EntityMovementOption option)
    {
        if (movementOptions.Remove(option))
        {
            PossibleTransitionRequestTypesAttribute att = Attribute.GetCustomAttribute(option.GetType(), typeof(PossibleTransitionRequestTypesAttribute)) as PossibleTransitionRequestTypesAttribute;
            if (att != null)
            {
                for (int i = 0; i < att.Types.Length; i++)
                {
                    var type = TransitionRequest.Factory.BuildRequest(att.Types[i]);

                    RemoveTransition(type);
                    //remove from mapping (relinearize if last one removed)
                    RemovePriorityMapping(type, i == att.Types.Length - 1);
                }
            }
        }
    }
Пример #2
0
    /// <summary>
    /// gets all possible transition request that can be generated in this state
    /// </summary>
    /// <param name="st">the state interested in</param>
    /// <returns>list of transition requests this state can create</returns>
    public List <TransitionRequest> GetPossibleTransitionRequests(MovementState st)
    {
        List <TransitionRequest> poss = new List <TransitionRequest>();

        collisionHandlerTransitionEventHandler.AddPossibleReqeusts(ref poss);

        for (int i = 0; i < st.MovementOptions.Count; i++)
        {
            var opt = st.MovementOptions[i];

            PossibleTransitionRequestTypesAttribute att = Attribute.GetCustomAttribute(opt.GetType(), typeof(PossibleTransitionRequestTypesAttribute)) as PossibleTransitionRequestTypesAttribute;
            if (att != null)
            {
                for (int j = 0; j < att.Types.Length; j++)
                {
                    var reqT = TransitionRequest.Factory.BuildRequest(att.Types[j]);
                    poss.Add(reqT);
                }
            }
        }

        return(poss);
    }