Beispiel #1
0
        public void Update(SongInfoChanged newInfo)
        {
            var data = CurrentPlayData;

            if (data is null)
            {
                return;
            }
            if (newInfo.Title != null)
            {
                data.ResourceData.ResourceTitle = newInfo.Title;
            }
            // further properties...
            OnResourceUpdated?.Invoke(this, data);
        }
Beispiel #2
0
        public void ClearResource(int id)
        {
            ResourceItem res = playerData.resources.Find(r => r.id == id);

            if (res == null || res.count == 0)
            {
                return;
            }

            int count = res.count;

            res.count = 0;
            SaveResLocal(res);
            OnResourceUpdated?.Invoke(res.id, -count);
        }
Beispiel #3
0
 public void Update(SongInfoChanged newInfo)
 {
     lock (Lock) {
         Log.Info("Song info (title) updated");
         var data = CurrentPlayData;
         if (data is null)
         {
             return;
         }
         if (newInfo.Title != null)
         {
             data.ResourceData = data.ResourceData.WithTitle(newInfo.Title);
         }
         // further properties...
         OnResourceUpdated?.Invoke(this, data);
     }
 }
Beispiel #4
0
        public async Task Update(SongInfoChanged newInfo)
        {
            var data = CurrentPlayData;

            if (data is null)
            {
                return;
            }
            if (newInfo.Title != null)
            {
                data.ResourceData.ResourceTitle = newInfo.Title;
            }
            // further properties...
            try
            {
                await OnResourceUpdated.InvokeAsync(this, data);
            }
            catch (AudioBotException ex)
            {
                Log.Warn(ex, "Error in OnResourceUpdated event.");
            }
        }
Beispiel #5
0
        public void SubResource(int id, int count)
        {
            ResourceItem res = playerData.resources.Find(r => r.id == id);

            if (res == null)
            {
                res       = new ResourceItem();
                res.id    = id;
                res.count = 0;
                playerData.resources.Add(res);
            }
            if (res.count - count <= 0)
            {
                res.count = 0;
            }
            else
            {
                res.count -= count;
            }

            SaveResLocal(res);
            OnResourceUpdated?.Invoke(res.id, -count);
        }
Beispiel #6
0
        public void AddResource(int id, int count)
        {
            ResourceItem res = playerData.resources.Find(r => r.id == id);

            if (res == null)
            {
                res       = new ResourceItem();
                res.id    = id;
                res.count = 0;
                playerData.resources.Add(res);
            }

            int max = MaxResourceValue(id);

            if (res.count + count > max)
            {
                count = max - res.count;
            }

            res.count += count;

            SaveResLocal(res);
            OnResourceUpdated?.Invoke(res.id, count);
        }