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); }
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); }
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); } }
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."); } }
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); }
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); }