Ejemplo n.º 1
0
        /// <summary>
        /// Attempt to change to a different Mount on the same object.
        /// </summary>
        /// <param name="newMountId"></param>
        public virtual bool ChangeMount(int newMountId)
        {
            if (ReferenceEquals(currentMount, null))
            {
                Debug.LogWarning("'" + name + "' is not currently mounted, so we cannot change to a different mount.");
                return(false);
            }

            if ((mountableTo & (1 << newMountId)) == 0)
            {
                Debug.LogWarning("'" + name + "' is trying to switch to a mount '" + MountSettings.GetName(newMountId) + "' , but mount is not set as valid in SyncState.");
                return(false);
            }

            var lookup = currentMount.mountsLookup.mountIdLookup;

            if (!lookup.ContainsKey(newMountId))
            {
                Debug.LogWarning("'" + name + "' doesn't contain a mount for '" + MountSettings.GetName(newMountId) + "'.");
                return(false);
            }
            var attachTo = lookup[newMountId];

            //Debug.Log("New Mount:" + attachTo + ":" + newMountId);

            ChangeState(new StateChangeInfo(currentState.state, attachTo, false));

            return(true);
        }
Ejemplo n.º 2
0
        public override void OnGUI(Rect r, SerializedProperty property, GUIContent label)
        {
            var index = property.FindPropertyRelative("id");

            int newindex = EditorGUI.Popup(r, label.text, index.intValue, MountSettings.ToArray());

            if (newindex != index.intValue)
            {
                Undo.RecordObject(property.serializedObject.targetObject, "Change Mount Selection");
                index.intValue = newindex;
                property.serializedObject.ApplyModifiedProperties();
            }
        }
Ejemplo n.º 3
0
        public override void OnStart()
        {
            base.OnStart();

            var mountsLookup = GetComponent <MountsManager>();

            if (mountsLookup)
            {
                if (mountsLookup.mountIdLookup.ContainsKey(defaultMounting.id))
                {
                    DefaultMount = mountsLookup.mountIdLookup[defaultMounting.id];
                }
                else
                {
                    Debug.LogWarning("Sync Vitals has a Default Mount setting of "
                                     + MountSettings.GetName(defaultMounting.id) +
                                     " but no such mount is defined yet on GameObject: '" + name + "'. Root mount will be used as a failsafe.");

                    /// Invalid default mounting (doesn't exist)... warn and set to Root
                    defaultMounting.id = 0;
                    DefaultMount       = mountsLookup.mountIdLookup[0];
                }
            }
        }
Ejemplo n.º 4
0
 protected override string[] GetStringNames(SerializedProperty property)
 {
     return(MountSettings.ToArray());
 }