Exemplo n.º 1
0
 /// <summary>
 /// Get a mounted triggerable class instance that has been created for a specified triggerable module.
 /// </summary>
 /// <param name="triggerable">A reference to the triggerable module.</param>
 /// <returns>The MountedTriggerable instance.</returns>
 private MountedTriggerable GetMountedTriggerable(Triggerable triggerable)
 {
     foreach (MountedTriggerable mountedTriggerable in mountedTriggerables)
     {
         if (mountedTriggerable.triggerable == triggerable)
         {
             return(mountedTriggerable);
         }
     }
     return(null);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Called when a module is unmounted from a module mount.
        /// </summary>
        /// <param name="moduleMount">The module mount where the module was unmounted.</param>
        /// <param name="module">The module that was unmounted.</param>
        protected override void OnModuleUnmounted(Module module)
        {
            // Get the module's triggerable if it exists.
            Triggerable triggerable = module.GetComponent <Triggerable>();

            if (triggerable == null)
            {
                return;
            }

            // Remove any reference to it
            for (int i = 0; i < mountedTriggerables.Count; ++i)
            {
                if (mountedTriggerables[i].triggerable == triggerable)
                {
                    mountedTriggerables.RemoveAt(i);
                    break;
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Event called when a new module is mounted on one of the module mounts, to store it if it's a triggerable module.
        /// </summary>
        /// <param name="moduleMount">The module mount where the new module was loaded.</param>
        protected override void OnModuleMounted(Module module)
        {
            // Get a reference to a Triggerable component on the new module.
            Triggerable triggerable = module.GetComponent <Triggerable>();

            // Store the triggerable found on the new module mounted on the module mount.
            if (triggerable != null && !triggerable.ManagedLocally)
            {
                // Check if it's already referenced
                for (int i = 0; i < mountedTriggerables.Count; ++i)
                {
                    if (mountedTriggerables[i].triggerable == triggerable)
                    {
                        return;
                    }
                }

                CreateMountedTriggerable(triggerable);
            }
        }
Exemplo n.º 4
0
        protected virtual void CreateMountedTriggerable(Triggerable triggerable)
        {
            // Create a new mounted triggerable instance for the new triggerable
            MountedTriggerable newMountedTriggerable = new MountedTriggerable(triggerable);

            if (mountedTriggerables.Count == 0)
            {
                mountedTriggerables.Add(newMountedTriggerable);
            }
            else
            {
                int insertIndex = Mathf.Clamp(triggerable.OrderingIndex, -1, mountedTriggerables.Count - 1);
                mountedTriggerables.Insert(insertIndex, newMountedTriggerable);
            }

            // Add the default trigger to all the trigger groups.
            for (int i = 0; i < numGroups; ++i)
            {
                newMountedTriggerable.triggerValuesByGroup.Add(newMountedTriggerable.triggerable.DefaultTrigger);
            }
        }
Exemplo n.º 5
0
 public MountedTriggerable(Triggerable triggerable)
 {
     this.triggerable     = triggerable;
     triggerValuesByGroup = new List <int>();
 }