public void CollectResources() { var ci = (ConstructionItem)GetParent(); var span = ci.GetLevel().GetTime() - m_vTimeSinceLastClick; float currentResources = 0; if (!ci.IsBoosted) { currentResources = m_vResourcesPerHour[ci.UpgradeLevel] / (60f * 60f) * (float)span.TotalSeconds; } else { if (ci.GetBoostEndTime() >= ci.GetLevel().GetTime()) { currentResources = m_vResourcesPerHour[ci.UpgradeLevel] / (60f * 60f) * (float)span.TotalSeconds; currentResources *= ci.GetBoostMultipier(); } else { var boostedTime = (float)span.TotalSeconds - (float)(ci.GetLevel().GetTime() - ci.GetBoostEndTime()).TotalSeconds; var notBoostedTime = (float)span.TotalSeconds - boostedTime; currentResources = m_vResourcesPerHour[ci.UpgradeLevel] / (60f * 60f) * notBoostedTime; currentResources += m_vResourcesPerHour[ci.UpgradeLevel] / (60f * 60f) * boostedTime * ci.GetBoostMultipier(); ci.IsBoosted = false; } } currentResources = Math.Min(Math.Max(currentResources, 0), m_vMaxResources[ci.UpgradeLevel]); if (currentResources >= 1) { var ca = ci.GetLevel().GetPlayerAvatar(); if (ca.GetResourceCap(m_vProductionResourceData) >= ca.GetResourceCount(m_vProductionResourceData)) { if (ca.GetResourceCap(m_vProductionResourceData) - ca.GetResourceCount(m_vProductionResourceData) < currentResources) { var newCurrentResources = ca.GetResourceCap(m_vProductionResourceData) - ca.GetResourceCount(m_vProductionResourceData); m_vTimeSinceLastClick = ci.GetLevel() .GetTime() .AddSeconds( -((currentResources - newCurrentResources) / (m_vResourcesPerHour[ci.UpgradeLevel] / (60f * 60f)))); currentResources = newCurrentResources; } else { m_vTimeSinceLastClick = ci.GetLevel().GetTime(); } Debugger.WriteLine( string.Format("Collect {0} {1}", (int)currentResources, m_vProductionResourceData.GetName()), null, 5, ConsoleColor.Blue); ca.CommodityCountChangeHelper(0, m_vProductionResourceData, (int)currentResources); } } }