예제 #1
0
        public void CacheModKeys()
        {
            // don't update the cached modkey list if nothing has changed.
            if (lastCachedModKeys == modKeys)
            {
                return;
            }

            int enumCount = BitTools.BitsNeeded((int)ModKeys.UnModded) - 1;

            modKeysList.Clear();

            for (int i = 1; i < enumCount; i++)
            {
                // create a list of the flagged mod key enums, so we only test those specified.
                if ((modKeys & (1 << i)) > 0)
                {
                    modKeysList.Add(mods[i]);
                }
            }

            //if (((ModKeys)modKeys & ModKeys.RightShift) > 0) modKeysList.Add(KeyCode.RightShift);
            //if (((ModKeys)modKeys & ModKeys.LeftShift) > 0) modKeysList.Add(KeyCode.LeftShift);
            //if (((ModKeys)modKeys & ModKeys.RightAlt) > 0) modKeysList.Add(KeyCode.RightAlt);
            //if (((ModKeys)modKeys & ModKeys.LeftAlt) > 0) modKeysList.Add(KeyCode.LeftAlt);
            //if (((ModKeys)modKeys & ModKeys.RightControl) > 0) modKeysList.Add(KeyCode.RightControl);
            //if (((ModKeys)modKeys & ModKeys.LeftControl) > 0) modKeysList.Add(KeyCode.LeftControl);
            //if (((ModKeys)modKeys & ModKeys.RightCommand) > 0) modKeysList.Add(KeyCode.RightCommand);
            //if (((ModKeys)modKeys & ModKeys.LeftCommand) > 0) modKeysList.Add(KeyCode.LeftCommand);
            //if (((ModKeys)modKeys & ModKeys.RightApple) > 0) modKeysList.Add(KeyCode.RightApple);
            //if (((ModKeys)modKeys & ModKeys.LeftApple) > 0) modKeysList.Add(KeyCode.LeftApple);
            //modKeysCached = true;
            lastCachedModKeys = modKeys;
        }
예제 #2
0
        public void InitializeRanges()
        {
            // Clean up the ranges
            for (int axisId = 0; axisId < 3; axisId++)
            {
                AxisRanges ar = axes[axisId];

                // If this axis is unused, mark as zero and move on.
                if (!this[axisId])
                {
                    ar.bits = 0;
                    continue;
                }

                if (axes[axisId].limitRange)
                {
                    if (ar.max < ar.min)
                    {
                        ar.max += 360;
                    }
                    // If the range is greater than 360, get the max down into range. Likely user selected bad min/max values.
                    if (ar.max - ar.min > 360)
                    {
                        ar.max -= 360;
                    }
                }

                // use the range as determined by the min/max - unless we are not limiting range, then use 180/360/360
                ar.range =
                    ar.limitRange ? ar.max - ar.min :
                    (axisId == 0) ? 180f : 360f;

                // Get the bits required to transmit the max possible value
                ar.bits = this[axisId] ?  Mathf.Max(0, BitTools.BitsNeeded((uint)(Mathf.CeilToInt(ar.range / ar.res)))) : 0;

                // Do the heavier division work here so only one multipy per encode/decode is needed
                ar.mult   = (maxValue[ar.bits]) / ar.range;
                ar.unmult = ar.range / (maxValue[ar.bits]);
                ar.wrap   = ar.range + (360 - ar.range) / 2;
            }
        }
예제 #3
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            _target = NSTHitGroupsSettings.EnsureExistsInScene(NSTSettings.DEFAULT_GO_NAME);

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("flow overlay box");
            EditorGUILayout.Space();

            Rect rt = EditorGUILayout.GetControlRect();

            float padding      = 5f;
            float xButtonWidth = 16f;
            float fieldLeft    = rt.xMin + EditorGUIUtility.labelWidth - padding; // rt.width - EditorGUIUtility.fieldWidth;
            float fieldWidth   = rt.width - fieldLeft - padding;                  // EditorGUIUtility.fieldWidth;

            // Default tag will always be 0 and 'Default'
            EditorGUI.LabelField(new Rect(rt.xMin + padding, rt.yMin, rt.width - padding * 2 - xButtonWidth, rt.height), "Hit Group 0", NSTHitGroupsSettings.DEF_NAME);

            for (int i = 1; i < _target.hitGroupTags.Count; i++)
            {
                rt = EditorGUILayout.GetControlRect();
                EditorGUI.LabelField(new Rect(rt.xMin + padding, rt.yMin, rt.width - padding * 2 - xButtonWidth, rt.height), "Hit Group " + i);
                _target.hitGroupTags[i] = EditorGUI.TextField(new Rect(fieldLeft, rt.yMin, fieldWidth, rt.height), GUIContent.none, _target.hitGroupTags[i]);

                bool isRepeat = IsTagAlreadyUsed(_target.hitGroupTags[i], i);

                if (isRepeat)
                {
                    EditorUtils.CreateErrorIconF(EditorGUIUtility.labelWidth - 2, rt.yMin,
                                                 "Each name can only be used once, repeats will be discarded at build time which cause some unpedictable results when looking up by name.");
                }

                if (GUI.Button(new Rect(rt.xMin + rt.width - xButtonWidth - padding, rt.yMin, xButtonWidth, rt.height), "X"))
                {
                    _target.hitGroupTags.RemoveAt(i);
                }
            }

            rt = EditorGUILayout.GetControlRect();

            if (_target.hitGroupTags.Count < 32)
            {
                if (GUI.Button(new Rect(rt.xMin + 8, rt.yMin + 3, rt.width - 14, rt.height + 4), "Add Hitbox Group"))
                {
                    string newtag = "HitGroup" + _target.hitGroupTags.Count;

                    while (IsTagAlreadyUsed(newtag, _target.hitGroupTags.Count))
                    {
                        newtag += "X";
                    }

                    _target.hitGroupTags.Add(newtag);
                }
            }

            rt = EditorGUILayout.GetControlRect();

            EditorGUILayout.EndVertical();

            EditorGUILayout.HelpBox(
                "These tags are used by NSTHitboxGroupTag to assign colliders to hitbox groups, for things like headshots and critical hits.", MessageType.None);
            EditorGUILayout.HelpBox(BitTools.BitsNeeded((uint)(_target.hitGroupTags.Count - 1)) + " bits per Rewind Cast added for hit tags.", MessageType.None);
        }