Exemplo n.º 1
0
 public void InitialiseSoilModule()
 {
     if (SoilModule != null)
     {
         SoilModule.Initialise();
     }
 }
 public void SetStartOfDayParameters()
 {
     try
     {
         if (SoilModule != null)
         {
             SoilModule.SetStartOfDayParameters();
         }
         if (IrrigationModule != null)
         {
             IrrigationModule.SetStartOfDayParameters();
         }
         if (VegetationModules != null)
         {
             SortCurrentVegList();    //resort crop list to put the current crop first.
             //VegetationModules.SetStartOfDayParameters();
         }
         if (TillageModules != null)
         {
             // TillageModules.SetStartOfDayParameters();
         }
     }
     catch (Exception ex)
     {
         throw ErrorLogger.CreateException(ex);
     }
 }
 public static void GetInteractions_Postfix(SoilModule __instance, ref IEnumerable <InteractionRestricted> __result, HumanAI actor, bool issuedByAI, bool objectInteraction)
 {
     if (__result.Any(x => x.interaction != Interaction.RemovePlant && x.interaction != Interaction.RemoveInfestedPlants))
     {
         __result = __result.Concat(new[] { new InteractionRestricted(Specialization.TendToFieldsInteraction) });
     }
 }
 public void TryModelLateralFlow()
 {
     try
     {
         SoilModule.TryModelLateralFlow();
     }
     catch (Exception ex)
     {
         throw ErrorLogger.CreateException(ex);
     }
 }
 public void CalculateErosion()
 {
     try
     {
         SoilModule.CalculateErosion();
     }
     catch (Exception ex)
     {
         throw ErrorLogger.CreateException(ex);
     }
 }
        public IEnumerable <YieldResult> New_TendToFields()
        {
            Furniture  furniture  = InteractionTarget.GetPrimaryHolder <Furniture>();
            SoilModule soilModule = furniture.GetModule <SoilModule>();

            foreach (var interaction in soilModule.GetInteractions(human, InteractionInfo.issuedByAI, false))
            {
                if (interaction.interaction == Interaction.RemoveInfestedPlants ||
                    interaction.interaction == Interaction.RemovePlant ||
                    interaction.interaction == Specialization.TendToFieldsInteraction)
                {
                    continue;
                }

                if (interaction.interaction == Interaction.WaterPlant)
                {
                    if (!soilModule.GetSeasons().Contains(SeasonManager.GetCurrentSeason()))
                    {
                        continue;
                    }

                    //InteractionRestrictionCanTakeResourceNearby cheat.  we don't check the distance
                    if (!WorldScripts.Instance.furnitureFactory.GetModules <InventoryReplenishmentModule>().Any(x => x.GetResource() == Resource.Water))
                    {
                        continue;
                    }

                    //InteractionRestrictionEquipmentEffect cheat.  we don't check the distance
                    if (!human.equipmentSet.GetEffects().Any(x => x.first == EquipmentEffect.WateringPlants))
                    {
                        continue;
                    }
                }
                else if (!WorkInteractionControllerPatch.CheckInteraction(InteractionTarget, interaction, human))
                {
                    continue;
                }

                subTask = new YieldMicroInteraction(new InteractionInfo(
                                                        interaction.interaction, InteractionTarget, interaction.restrictions, InteractionInfo.issuedByAI, InteractionInfo.priority, isContinuationOrSubtask: true),
                                                    human);

                while (subTask != null)   // WHILEPROTECTED
                {
                    subTask = subTask.Handle();
                    yield return(YieldResult.WaitFrame);
                }
                StopCurrentSubtask();
            }

            yield return(YieldResult.Completed);
        }
 public void UpdateWaterBalance()
 {
     try
     {
         if (SoilModule != null)
         {
             SoilModule.UpdateWaterBalance();
         }
     }
     catch (Exception ex)
     {
         throw ErrorLogger.CreateException(ex);
     }
 }
 public void CalculatSoilEvaporation()
 {
     try
     {
         if (SoilModule != null)
         {
             SoilModule.CalculatSoilEvaporation();
         }
     }
     catch (Exception ex)
     {
         throw ErrorLogger.CreateException(ex);
     }
 }
 public void TryModelSoilCracking()
 {
     try
     {
         if (SoilModule != null)
         {
             SoilModule.TryModelSoilCracking();
         }
     }
     catch (Exception ex)
     {
         throw ErrorLogger.CreateException(ex);
     }
 }
 public void CalculateResidue()
 {
     try
     {
         foreach (var crop in VegetationModules)
         {
             crop.CalculateResidue();
         }
         CalculateTotalResidue();
         SoilModule.CalculateResidue();
     }
     catch (Exception ex)
     {
         throw ErrorLogger.CreateException(ex);
     }
 }
 public void CalculateVolumeBalanceError()
 {
     SoilModule.CalculateVolumeBalanceError();
 }
 public static void GetEverPossibleNotRegisteredInteractions_Postfix(SoilModule __instance, ref List <Interaction> __result)
 {
     __result.Add(Specialization.TendToFieldsInteraction);
 }