Example #1
0
        public static void RemoveIrrigation(GameObject plant)
        {
            StateMachineController controller = plant.GetComponent <StateMachineController>();

            if (controller != null)
            {
                IrrigationMonitor.Def def = plant.GetDef <IrrigationMonitor.Def>();
                if (def != null)
                {
                    controller.cmpdef.defs.Remove(def);
                }

                FertilizationMonitor.Def def2 = plant.GetDef <FertilizationMonitor.Def>();
                if (def2 != null)
                {
                    controller.cmpdef.defs.Remove(def2);
                }
            }

            ManualDeliveryKG[] delivers = plant.GetComponents <ManualDeliveryKG>();
            foreach (ManualDeliveryKG deliver in delivers)
            {
                UnityEngine.Object.DestroyImmediate(deliver);
            }
        }
Example #2
0
    public static GameObject ExtendPlantToFertilizable(GameObject template, PlantElementAbsorber.ConsumeInfo[] fertilizers)
    {
        HashedString idHash = Db.Get().ChoreTypes.FarmFetch.IdHash;

        for (int i = 0; i < fertilizers.Length; i++)
        {
            PlantElementAbsorber.ConsumeInfo consumeInfo = fertilizers[i];
            ManualDeliveryKG manualDeliveryKG            = template.AddComponent <ManualDeliveryKG>();
            manualDeliveryKG.RequestedItemTag       = consumeInfo.tag;
            manualDeliveryKG.capacity               = consumeInfo.massConsumptionRate * 600f * 3f;
            manualDeliveryKG.refillMass             = consumeInfo.massConsumptionRate * 600f * 0.5f;
            manualDeliveryKG.minimumMass            = consumeInfo.massConsumptionRate * 600f * 0.5f;
            manualDeliveryKG.operationalRequirement = FetchOrder2.OperationalRequirement.Functional;
            manualDeliveryKG.choreTypeIDHash        = idHash;
        }
        KPrefabID component = template.GetComponent <KPrefabID>();

        FertilizationMonitor.Def def = template.AddOrGetDef <FertilizationMonitor.Def>();
        def.wrongFertilizerTestTag = GameTags.Solid;
        def.consumedElements       = fertilizers;
        component.prefabInitFn    += delegate(GameObject inst)
        {
            ManualDeliveryKG[] components = inst.GetComponents <ManualDeliveryKG>();
            foreach (ManualDeliveryKG manualDeliveryKG2 in components)
            {
                manualDeliveryKG2.Pause(true, "init");
            }
        };
        return(template);
    }