using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Threading; using Uber.Storage; using Uber.HabboHotel.GameClients; using Uber.HabboHotel.Users; namespace Uber.HabboHotel.Misc { class PixelManager { private const int RCV_EVERY_MINS = 10; private const int RCV_AMOUNT = 250; public Boolean KeepAlive; private Task WorkerThread; public PixelManager() { this.KeepAlive = true; this.WorkerThread = null; this.WorkerThread = new Task(Process, CancellationToken.None, TaskCreationOptions.LongRunning); } public void Start() { this.WorkerThread.Start(); } public void Stop() { this.KeepAlive = false; this.WorkerThread.Wait(); this.WorkerThread.Dispose(); this.WorkerThread = null; } private void Process() { while (KeepAlive) { if (WorkerThread != null /*|| (!WorkerThread.IsCanceled)*/) { this.WorkerThread.Wait(RCV_EVERY_MINS * 1000); } if (UberEnvironment.GetGame().GetClientManager() != null) { UberEnvironment.GetGame().GetClientManager().CheckPixelUpdates(); } } } public Boolean NeedsUpdate(GameClient Client) { Double PassedMins = (UberEnvironment.GetUnixTimestamp() - Client.GetHabbo().LastActivityPointsUpdate) / 60; if (PassedMins >= RCV_EVERY_MINS) { return true; } return false; } public void GivePixels(GameClient Client) { Double Timestamp = UberEnvironment.GetUnixTimestamp(); Client.GetHabbo().LastActivityPointsUpdate = Timestamp; Client.GetHabbo().ActivityPoints += (Client.GetHabbo().IsUltraVip) ? RCV_AMOUNT + 100 : RCV_AMOUNT; Client.GetHabbo().UpdateActivityPointsBalance(true, RCV_AMOUNT); if (Client.GetHabbo().Credits < 15000 && Client.GetHabbo().IsUltraVip) { Client.GetHabbo().Credits = Client.GetHabbo().Credits + 100; Client.GetHabbo().UpdateCreditsBalance(true); } } } }