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 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];
                }
            }
        }