public static StorageResources StorageProportion(MaterialResource dbProportion) { return(new StorageResources { Current = dbProportion }); }
public static StorageResources DictionaryToStorageResources(Dictionary <string, Dictionary <string, double> > res) { return(new StorageResources { Current = MaterialResource.DictionaryToMaterialResource(res[CurrentKey]), Max = MaterialResource.DictionaryToMaterialResource(res[MaxKey]) }); }
public static StorageResources InitPlanetResources() { var max = MaterialResource.StoreDefaultMaxStorable(); var cur = MaterialResource.InitStartResourses(max); return(new StorageResources { Current = cur, Max = max }); }
public static StorageResources InitMotherResources() { var max = MaterialResource.MaxMotherResourses(); var cur = MaterialResource.InitStartResourses(max); return(new StorageResources { Current = cur, Max = max.Multiply(0.5) }); }
public static void CalculateProductionResources(StorageResources currentResources, MaterialResource productionProportion, ref int lastUpgradeTime, int buildExtractionLevel, bool isActivePremium, double baseIr, double baseDm, Func <int, bool, double> getPower, Action <StorageResources> fixCurrentResourcesFactory) { var curTime = UnixTime.UtcNow(); if (lastUpgradeTime == 0 || curTime == lastUpgradeTime || currentResources.AllFull()) { lastUpgradeTime = curTime; return; } var deltaTime = curTime - lastUpgradeTime; if (deltaTime < 0) { throw new Exception(Error.ServerTimeIsWrong); } //11147 var power = getPower(buildExtractionLevel, isActivePremium);//ExtractionModule.GetPower(buildExtractionLevel, isActivePremium); var pdoucedResource = ExtractionResource.CalculateExtractionBySeconds(productionProportion, power, deltaTime, baseIr, baseDm); currentResources.Current = MaterialResource.GetSummResource(currentResources.Current, pdoucedResource); if (currentResources.NeedFix()) { fixCurrentResourcesFactory(currentResources); // StorageResourcesService.FixCurrentResources(res) } lastUpgradeTime = curTime; }
public StorageResources SetStorageResource(MaterialResource current, MaterialResource max) { Current = Current.SetResource(current); Max = Max.SetResource(max); return(this); }
public void InitializeField() { Current = new MaterialResource(); Max = new MaterialResource(); }