Ejemplo n.º 1
0
 void tryChangeStaticRecources()
 {
     GlobalRecources.RecourcesChanged -= tryChangeStaticRecources;
     if (PBParams.recourcesRequired)
     {
         if (GlobalRecources.CanChangeAmount(PBParams.StaticRecourcesRequired, true))
         {
             GlobalRecources.SubstractRecources(PBParams.StaticRecourcesRequired);
             GlobalRecources.AddRecources(PBParams.StaticRecourcesProvided);
             if (UtilityDebug.PassivebuildingLog)
             {
                 Debug.Log($"[PB_ProductionCycle] {Building.BuildingName} вычел input, дал output [{Time.deltaTime}]", Building.gameObject);
             }
             StaticRecourcesChanged.Invoke();
         }
         else
         {
             GlobalRecources.RecourcesChanged += tryChangeStaticRecources;
         }
     }
     else
     {
         GlobalRecources.AddRecources(PBParams.StaticRecourcesProvided);
         if (UtilityDebug.PassivebuildingLog)
         {
             Debug.Log($"[PB_ProductionCycle] {Building.BuildingName} input не нужен, отдаю output. [{Time.deltaTime}]", Building.gameObject);
         }
         StaticRecourcesChanged.Invoke();
     }
 }
 void checkStaticRecources()
 {
     GlobalRecources.RecourcesChanged -= checkStaticRecources;
     if (GlobalRecources.CanChangeAmount(abParams.StaticRecourceCost, true))
     {
         GlobalRecources.SubstractRecources(abParams.StaticRecourceCost);
         if (UtilityDebug.ActivebuildingLog)
         {
             Debug.Log($"[AB_State_productionCycle] {Building.BuildingName} проверка статичных ресурсов пройдена" +
                       $" [{Time.deltaTime}]", Building.gameObject);
         }
         staticRecourceProvided();
     }
     else
     {
         GlobalRecources.RecourcesChanged += checkStaticRecources;
     }
 }