Beispiel #1
0
 private void Update()
 {
     if (!_isInitialised)
     {
         _groupComponents = FabricManager.Instance.gameObject.GetComponentsInChildren <GroupComponent>();
         _isInitialised   = true;
     }
     if (_presetList != null)
     {
         for (int i = 0; i < _presetList.Length; i++)
         {
             Preset preset = _presetList[i];
             if (preset.HasEventNameSet() && preset.IsEventActive())
             {
                 AddPreset(preset);
             }
         }
     }
     if (_groupComponents == null)
     {
         return;
     }
     for (int j = 0; j < _groupComponents.Length; j++)
     {
         GroupComponent groupComponent = _groupComponents[j];
         float          num            = 0f;
         float          num2           = 1f;
         for (int k = 0; k < _activePresets.Count; k++)
         {
             Preset preset2 = _activePresets[k];
             if (preset2.HasEventNameSet() && !preset2.IsEventActive() && !preset2.IsDeactivating)
             {
                 preset2.Deactivate();
             }
             if (preset2.IsActive())
             {
                 GroupPreset groupComponentByID = preset2.GetGroupComponentByID(groupComponent.GetInstanceID());
                 if (groupComponentByID != null)
                 {
                     num  += groupComponentByID.CalculateVolume();
                     num2 *= groupComponentByID.CalculatePitch();
                 }
             }
             else
             {
                 _activePresets.Remove(preset2);
             }
         }
         float value = AudioTools.DBToLinear(num);
         AudioTools.Limit(ref value, 0f, 1f);
         groupComponent.MixerVolume = value;
         groupComponent.MixerPitch  = num2;
     }
 }
        public async Task <IActionResult> OnGet(int?presetid)
        {
            if (presetid == null)
            {
                return(NotFound());
            }

            GroupPreset = await _context.GroupPresets.FindAsync(presetid);

            return(Page());
        }
Beispiel #3
0
 public GroupPreset GetGroupComponentByName(string Name)
 {
     for (int i = 0; i < _groupPreset.Length; i++)
     {
         GroupPreset groupPreset = _groupPreset[i];
         if (groupPreset.GroupComponent != null && Name == groupPreset.Name)
         {
             return(groupPreset);
         }
     }
     return(null);
 }
Beispiel #4
0
 public GroupPreset GetGroupComponentByNameSlow(string Name)
 {
     _groupPreset = GetComponents <GroupPreset>();
     for (int i = 0; i < _groupPreset.Length; i++)
     {
         GroupPreset groupPreset = _groupPreset[i];
         if ((bool)groupPreset.GroupComponent && groupPreset.GroupComponent.name == Name)
         {
             return(groupPreset);
         }
     }
     return(null);
 }
Beispiel #5
0
 public void SwitchFromPreset(Preset sourcePreset)
 {
     if (_groupPreset == null)
     {
         return;
     }
     for (int i = 0; i < sourcePreset._groupPreset.Length; i++)
     {
         GroupPreset groupComponentByID = GetGroupComponentByID(sourcePreset._groupPreset[i].GroupComponent.GetInstanceID());
         if (groupComponentByID != null)
         {
             groupComponentByID.SwitchFromPreset(sourcePreset._groupPreset[i]);
         }
     }
     sourcePreset.Reset();
 }
        public async Task <IActionResult> OnPostAsync()
        {
            GroupPreset groupPresetToDelete = await _context.GroupPresets
                                              .FindAsync(GroupPreset.ID);

            try
            {
                _context.GroupPresets.Remove(groupPresetToDelete);
                await _context.SaveChangesAsync();
            }
            catch
            {
                return(new JsonResult("Cannot update!"));
            }
            return(RedirectToPage("./Index"));
        }
Beispiel #7
0
        private async Task UpdateCameraGroupingAssignments(GroupPreset presetToUpdate, List <int> newCameraCollection)
        {
            var oldCameraCollection = presetToUpdate.CameraGroupingAssignments
                                      .Select(cga => cga.CameraID).ToList(); //camera ids
            var allCameras = await _context.Cameras.ToListAsync();

            foreach (var thisCamera in allCameras)
            {
                if (newCameraCollection.Contains(thisCamera.ID))     //if selected
                {
                    if (oldCameraCollection.Contains(thisCamera.ID)) //if exists in the database
                    {
                        //do nothing for now, nothing to update
                    }
                    else //if does not exist in the database
                    {
                        presetToUpdate.CameraGroupingAssignments.Add( //add
                            new CameraGroupingAssignment
                        {
                            GroupPresetID = presetToUpdate.ID,
                            CameraID      = thisCamera.ID
                        });
                    }
                }
                else //if not selected
                {
                    if (oldCameraCollection.Contains(thisCamera.ID)) //if exists in the database
                    {
                        var cameraToRemove = presetToUpdate.CameraGroupingAssignments
                                             .FirstOrDefault(cga => cga.CameraID == thisCamera.ID);
                        presetToUpdate.CameraGroupingAssignments.Remove(cameraToRemove); //remove
                    }
                }
            }
            await _context.SaveChangesAsync();
        }
Beispiel #8
0
        private async Task UpdateBoardGroupingAssignments(GroupPreset presetToUpdate, List <int> newBoardCollection)
        {
            var oldBoardCollection = presetToUpdate.BoardGroupingAssignments
                                     .Select(bga => bga.BoardID).ToList(); //board ids
            var allBoards = await _context.Boards.ToListAsync();

            foreach (var thisBoard in allBoards)
            {
                if (newBoardCollection.Contains(thisBoard.ID))     //if selected
                {
                    if (oldBoardCollection.Contains(thisBoard.ID)) //if exists in the database
                    {
                        //do nothing for now, nothing to update
                    }
                    else //if does not exist in the database
                    {
                        presetToUpdate.BoardGroupingAssignments.Add( //add
                            new BoardGroupingAssignment
                        {
                            GroupPresetID = presetToUpdate.ID,
                            BoardID       = thisBoard.ID
                        });
                    }
                }
                else //if not selected
                {
                    if (oldBoardCollection.Contains(thisBoard.ID)) //if exists in the database
                    {
                        var memberToRemove = presetToUpdate.BoardGroupingAssignments
                                             .FirstOrDefault(bga => bga.BoardID == thisBoard.ID);
                        presetToUpdate.BoardGroupingAssignments.Remove(memberToRemove); //remove
                    }
                }
            }
            await _context.SaveChangesAsync();
        }
Beispiel #9
0
    public void AddGroupComponent(GroupComponent groupComponent)
    {
        GroupPreset groupPreset = base.gameObject.AddComponent <GroupPreset>();

        groupPreset.Init(groupComponent);
    }
Beispiel #10
0
 public void SwitchFromPreset(GroupPreset sourcePreset)
 {
     _volumeParameter.Reset(sourcePreset._volume);
     _pitchParameter.Reset(sourcePreset._pitch);
     Activate();
 }