Ejemplo n.º 1
0
    /// <summary>
    /// adds a movment option to the state if nor already contained
    /// </summary>
    /// <param name="option">the option being added</param>
    public void AddMovementOption(EntityMovementOption option)
    {
        if (MovementOptions == null)
        {
            movementOptions = new List <EntityMovementOption>();
        }

        if (movementOptions.Contains(option))
        {
            return; //already contained don't double add
        }
        movementOptions.Add(option);

        //add it's requests to the mapping at the end
        var att = Attribute.GetCustomAttribute(option.GetType(), typeof(PossibleTransitionRequestTypesAttribute)) as PossibleTransitionRequestTypesAttribute;

        if (att != null)
        {
            for (int i = 0; i < att.Types.Length; i++)
            {
                var req = TransitionRequest.Factory.BuildRequest(att.Types[i]);

                AddPriorityRequest(req, minPriorityValue);
            }
        }
    }
Ejemplo n.º 2
0
 public void AddGeneralMovementOption(EntityMovementOption option)
 {
     generalOptionsData.Add(option.GetType().Name);
 }
Ejemplo n.º 3
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);
                }
            }
        }
    }