Ejemplo n.º 1
0
 private InteractionInfo GetInteractionInfo(InteractionRestricted intRes, Interactable interactable, HumanAI human)
 {
     if (WorkInteractionControllerPatch.CheckInteraction(interactable, intRes, human))
     {
         return new InteractionInfo(intRes.interaction, interactable, intRes.restrictions, true, 50, false, true)
                {
                    data = new InteractionMaxDistanceData(this.MaxDistance)
                }
     }
     ;
     return(null);
 }
        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);
        }
Ejemplo n.º 3
0
 public IEnumerable <InteractionInfo> GetNextInteraction(HumanAI human)
 {
     foreach (var intRes in GetInteractionRestricted(human))
     {
         foreach (var interactable in human.SearchForInteractablesWithInteraction(intRes.interaction, this.MaxDistance, intRes.restrictions, true))
         {
             if (WorkInteractionControllerPatch.CheckInteraction(interactable, intRes, human))
             {
                 yield return(GetInteractionInfo(intRes, interactable, human));
             }
         }
     }
 }