Esempio n. 1
0
 static void validateInputRestrictions(InputRestrictions inputRestrictions)
 {
     if (!isValidRange(inputRestrictions))
     {
         throw new ArgumentOutOfRangeException("Input restrictions out of range, the value must be greater than 0");
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Sets the <see cref="InputRestrictions.AttackKeyDown"/> on the given <see cref="FirstPersonMover"/>
        /// </summary>
        /// <param name="firstPersonMover">The <see cref="FirstPersonMover"/> to set the input restrictions of</param>
        /// <param name="inputRestrictions">The <see cref="InputRestrictions"/> to set</param>
        public static void SetInputRestrictions(FirstPersonMover firstPersonMover, InputRestrictions inputRestrictions)
        {
            validateInputRestrictions(inputRestrictions);

            _characterInputRestrictions[firstPersonMover] = inputRestrictions;

            filterDictionary();
        }
Esempio n. 3
0
        /// <summary>
        /// Removes all input restrictions defined in the given bitfield from a <see cref="FirstPersonMover"/>, if no input restrictions remain, the <see cref="FirstPersonMover"/> will be removed from the input restrictions dictionary
        /// </summary>
        /// <param name="firstPersonMover">The <see cref="FirstPersonMover"/> to remove the restrictions from</param>
        /// <param name="inputRestriction">A bitfield of input restrictions to remove</param>
        public static void RemoveRestriction(FirstPersonMover firstPersonMover, InputRestrictions inputRestriction)
        {
            validateHasRestrictionsForCharacter(firstPersonMover);
            validateInputRestrictions(inputRestriction);

            _characterInputRestrictions[firstPersonMover] &= ~inputRestriction; // Remove the restriction(s) from the bitfield

            filterDictionary();
        }
Esempio n. 4
0
        /// <summary>
        /// Returns if the given <see cref="FirstPersonMover"/> has all of the input restrictions in the given <see cref="InputRestrictions"/> bitfield
        /// </summary>
        /// <param name="firstPersonMover">The <see cref="FirstPersonMover"/> to check</param>
        /// <param name="inputRestriction">A bitfield of input restrictions to check for</param>
        /// <returns></returns>
        public static bool HasRestrictions(FirstPersonMover firstPersonMover, InputRestrictions inputRestriction)
        {
            validateInputRestrictions(inputRestriction);

            if (!_characterInputRestrictions.ContainsKey(firstPersonMover))
            {
                return(false);
            }

            return((_characterInputRestrictions[firstPersonMover] & inputRestriction) == inputRestriction);
        }
Esempio n. 5
0
        /// <summary>
        /// Adds an input restriction on the given <see cref="FirstPersonMover"/>
        /// </summary>
        /// <param name="firstPersonMover">The target to add a restriction to</param>
        /// <param name="inputRestriction">A bitfield of input restrictions to apply</param>
        public static void AddRestriction(FirstPersonMover firstPersonMover, InputRestrictions inputRestriction)
        {
            validateInputRestrictions(inputRestriction);

            if (!_characterInputRestrictions.ContainsKey(firstPersonMover))
            {
                _characterInputRestrictions.Add(firstPersonMover, 0);
            }

            _characterInputRestrictions[firstPersonMover] |= inputRestriction;

            firstPersonMover.AddDeathListener(filterDictionary);
        }
Esempio n. 6
0
 static bool isValidRange(InputRestrictions inputRestrictions)
 {
     return(inputRestrictions > 0);
 }
Esempio n. 7
0
 public Action(KeyCode _KC1, KeyCode _KC2, InputRestrictions _Restrictions)
 {
     Key1         = _KC1;
     SpecialKey   = _KC2;
     Restrictions = _Restrictions;
 }