Example #1
0
        public static void OnReplanted(object data = null)
        {
            GameObject go = (data as Storage)?.gameObject;

            if (go == null)
            {
                return;
            }

            ReceptacleMonitor replant = go.GetComponent <ReceptacleMonitor>();

            if (replant != null)
            {
                ElementConsumer  consumer  = go.GetComponent <ElementConsumer>();
                ElementConverter converter = go.GetComponent <ElementConverter>();
                if (replant == null || !replant.Replanted)
                {
                    if (consumer != null)
                    {
                        consumer.consumptionRate *= 0.25f;                          // NOTE: this doesn't seem to be applied...
                    }
                    if (converter != null)
                    {
                        converter.SetWorkSpeedMultiplier(0.25f);
                    }
                }
            }
        }
Example #2
0
    public override void DoPostConfigureComplete(GameObject go)
    {
        GeneratedBuildings.RegisterLogicPorts(go, LogicOperationalController.INPUT_PORTS_0_1);
        go.AddOrGet <LogicOperationalController>();
        go.GetComponent <KPrefabID>().AddTag(RoomConstraints.ConstraintTags.IndustrialMachinery, false);
        go.AddOrGet <LoopingSounds>();
        go.AddOrGet <EnergyConsumer>();
        go.AddOrGet <Pump>();
        Storage storage = go.AddOrGet <Storage>();

        storage.capacityKg = 1f;
        ElementConsumer elementConsumer = go.AddOrGet <ElementConsumer>();

        elementConsumer.configuration     = ElementConsumer.Configuration.AllGas;
        elementConsumer.consumptionRate   = 0.5f;
        elementConsumer.storeOnConsume    = true;
        elementConsumer.showInStatusPanel = false;
        elementConsumer.consumptionRadius = 2;
        ConduitDispenser conduitDispenser = go.AddOrGet <ConduitDispenser>();

        conduitDispenser.conduitType    = ConduitType.Gas;
        conduitDispenser.alwaysDispense = true;
        conduitDispenser.elementFilter  = null;
        go.AddOrGetDef <OperationalController.Def>();
    }
            private static void Postfix(Oxyfern __instance, ElementConsumer ___elementConsumer, ElementConverter ___elementConverter)
            {
                float multiplier = __instance.GetAttributes().Get(OxyfernThroughput).GetTotalValue();

                ___elementConsumer.consumptionRate *= multiplier;
                ___elementConsumer.RefreshConsumptionRate();
                ___elementConverter.SetWorkSpeedMultiplier(multiplier);
            }
 private static void Prefix(ElementConsumer __instance, ref System.Guid ___statusHandle, KSelectable ___selectable)
 {
     if (__instance.showInStatusPanel && ___statusHandle != System.Guid.Empty)
     {
         ___selectable.RemoveStatusItem(___statusHandle);
         ___statusHandle = System.Guid.Empty;
     }
 }
Example #5
0
        public override void DoPostConfigureComplete(GameObject go)
        {
            base.DoPostConfigureComplete(go);

            ElementConsumer elementConsumer = go.GetComponent <ElementConsumer>();

            elementConsumer.consumptionRate   = 1;
            elementConsumer.consumptionRadius = 3;
        }
    public void OnSpawn(GameObject inst)
    {
        ElementConsumer component = inst.GetComponent <ElementConsumer>();

        if ((Object)component != (Object)null)
        {
            component.EnableConsumption(true);
        }
    }
Example #7
0
            private static void Postfix(ref GameObject inst)
            {
                ElementConsumer component = inst.GetComponent <ElementConsumer>();

                if (component != null)
                {
                    component.EnableConsumption(true);
                }
            }
Example #8
0
        public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
        {
            go.AddOrGet <LoopingSounds>();
            go.AddOrGet <DropAllWorkable>();
            Prioritizable.AddRef(go);

            Storage storage = BuildingTemplates.CreateDefaultStorage(go);

            storage.showInUI   = true;
            storage.capacityKg = 20000f;
            storage.SetDefaultStoredItemModifiers(Storage.StandardSealedStorage);

            ElementConsumer elementConsumer = go.AddOrGet <ElementConsumer>();

            elementConsumer.elementToConsume  = SimHashes.CarbonDioxide;
            elementConsumer.consumptionRate   = 1000f;
            elementConsumer.consumptionRadius = 10;
            elementConsumer.showInStatusPanel = true;
            elementConsumer.sampleCellOffset  = new Vector3(0f, 0f, 0f);
            elementConsumer.isRequired        = false;
            elementConsumer.storeOnConsume    = true;
            elementConsumer.showDescriptor    = false;

            ElementDropper elementDropper = go.AddComponent <ElementDropper>();

            elementDropper.emitMass   = 100f;
            elementDropper.emitTag    = new Tag("Carbon");
            elementDropper.emitOffset = new Vector3(0f, 0f, 0f);

            ElementConverter elementConverter = go.AddOrGet <ElementConverter>();

            elementConverter.consumedElements = new ElementConverter.ConsumedElement[]
            {
                new ElementConverter.ConsumedElement(new Tag("Filter"), 0.1f),
                new ElementConverter.ConsumedElement(new Tag("CarbonDioxide"), 1.0f)
            };
            elementConverter.outputElements = new ElementConverter.OutputElement[]
            {
                new ElementConverter.OutputElement(0.27f, SimHashes.Carbon, 0f, true, 0f, 0.5f, false, 0f, byte.MinValue),
                new ElementConverter.OutputElement(0.73f, SimHashes.Oxygen, 0f, false, 0f, 0f, false, 0f, byte.MinValue)
            };

            ManualDeliveryKG manualDeliveryKG = go.AddOrGet <ManualDeliveryKG>();

            manualDeliveryKG.SetStorage(storage);
            manualDeliveryKG.requestedItemTag = new Tag("Filter");
            manualDeliveryKG.capacity         = 100f;
            manualDeliveryKG.refillMass       = 1f;
            manualDeliveryKG.choreTypeIDHash  = Db.Get().ChoreTypes.FetchCritical.IdHash;

            CoalScrubber coalScrubber = go.AddOrGet <CoalScrubber>();

            coalScrubber.filterTag = new Tag("Filter");

            go.AddOrGet <KBatchedAnimController>().randomiseLoopedOffset = true;
        }
Example #9
0
        public void OnSpawn(GameObject inst)
        {
            ElementConsumer component = inst.GetComponent <ElementConsumer>();

            if (component == null)
            {
                return;
            }
            component.EnableConsumption(true);
        }
Example #10
0
            public static void Postfix(ref GameObject __result, bool is_baby)
            {
                var algaeKgPerDay = 50f;
                var kgPerDay      = 150f;
                var calPerDay     = PacuTuning.STANDARD_CALORIES_PER_CYCLE;

                var dietList = new List <Diet.Info>();

                DietUtils.AddToDiet(dietList, SimHashes.Algae.CreateTag(), SimHashes.ToxicSand.CreateTag(), calPerDay, algaeKgPerDay, 0.75f);
                DietUtils.AddToDiet(dietList, SimHashes.SlimeMold.CreateTag(), SimHashes.Algae.CreateTag(), calPerDay, kgPerDay, 0.33f);
                DietUtils.AddToDiet(dietList, FOOD.FOOD_TYPES.MEAT, SimHashes.ToxicSand.CreateTag(), calPerDay, kgPerDay);
                DietUtils.AddToDiet(dietList, FOOD.FOOD_TYPES.COOKED_MEAT, SimHashes.ToxicSand.CreateTag(), calPerDay, kgPerDay);

                __result = DietUtils.SetupDiet(__result, dietList, calPerDay / kgPerDay, 25f);

                if (is_baby)
                {
                    return;
                }

                __result.AddComponent <Storage>().capacityKg = 10f;

                ElementConsumer elementConsumer = __result.AddOrGet <PassiveElementConsumer>();

                elementConsumer.elementToConsume  = SimHashes.Water;
                elementConsumer.consumptionRate   = 0.2f;
                elementConsumer.capacityKG        = 10f;
                elementConsumer.consumptionRadius = 3;
                elementConsumer.showInStatusPanel = true;
                elementConsumer.sampleCellOffset  = new Vector3(0.0f, 0.0f, 0.0f);
                elementConsumer.isRequired        = false;
                elementConsumer.storeOnConsume    = true;
                elementConsumer.showDescriptor    = false;

                __result.AddOrGet <UpdateElementConsumerPosition>();

                var bubbleSpawner = __result.AddComponent <BubbleSpawner>();

                bubbleSpawner.element         = SimHashes.DirtyWater;
                bubbleSpawner.emitMass        = 2f;
                bubbleSpawner.emitVariance    = 0.5f;
                bubbleSpawner.initialVelocity = new Vector2f(0, 1);

                var elementConverter = __result.AddOrGet <ElementConverter>();

                elementConverter.consumedElements = new ElementConverter.ConsumedElement[1]
                {
                    new ElementConverter.ConsumedElement(SimHashes.Water.CreateTag(), 0.2f)
                };
                elementConverter.outputElements = new ElementConverter.OutputElement[1]
                {
                    new ElementConverter.OutputElement(0.2f, SimHashes.DirtyWater, 0.0f, false, true)
                };
            }
Example #11
0
            public static void Postfix(GasPumpConfig __instance, ref GameObject go)
            {
                float   ratio   = DynamicBuildingsState.StateManager.State.liquidandgas;
                byte    radius  = DynamicBuildingsState.StateManager.State.SuckInRadius;
                Storage storage = go.AddOrGet <Storage>();

                storage.capacityKg = 5 * ratio;
                ElementConsumer elementConsumer = go.AddOrGet <ElementConsumer>();

                elementConsumer.consumptionRate   = ratio;
                elementConsumer.consumptionRadius = radius;
            }
Example #12
0
 [HarmonyPriority(-10000)] // Extremely low priority. We want this to happen last, since this will only overwrite FanRotatablePassiveElementConsumer variable
 public static void Prefix(ElementConsumer __instance)
 {
     if (__instance is FanRotatablePassiveElementConsumer)
     {
         Vector3   rotatableCellOffset = ((FanRotatablePassiveElementConsumer)__instance).rotatableCellOffset;
         Rotatable rotatable           = __instance.GetComponent <Rotatable>();
         if (rotatable != null)
         {
             __instance.sampleCellOffset = Rotatable.GetRotatedOffset(rotatableCellOffset, rotatable.GetOrientation());
         }
     }
 }
Example #13
0
        public static GameObject CreateHatch(
            string id,
            string name,
            string desc,
            string anim_file,
            bool is_baby)
        {
            GameObject wildCreature = EntityTemplates.ExtendEntityToWildCreature(
                BaseHatchConfig.BaseHatch(
                    id,
                    name,
                    desc,
                    anim_file,
                    BaseTraitId,
                    is_baby,
                    SymbolOverride
                    ),
                HatchTuning.PEN_SIZE_PER_CREATURE);

            CreateTrait(name);

            List <Diet.Info> diet_infos = WoodenDiet(
                poopTag: WoodLogConfig.TAG,
                caloriesPerKg: CaloriesPerKgOfFood,
                producedConversionRate: TUNING.CREATURES.CONVERSION_EFFICIENCY.GOOD_2);//nerfed effiendy from 3 to normal

            wildCreature.AddOrGet <DecorProvider>()?.SetValues(tier);
            if (!is_baby)
            {
                wildCreature.AddComponent <Storage>().capacityKg = 10f;
                ElementConsumer elementConsumer = (ElementConsumer)wildCreature.AddOrGet <PassiveElementConsumer>();
                elementConsumer.elementToConsume  = element_input;
                elementConsumer.consumptionRate   = 0.2f;
                elementConsumer.capacityKG        = 10f;
                elementConsumer.consumptionRadius = (byte)3;
                elementConsumer.showInStatusPanel = true;
                elementConsumer.sampleCellOffset  = new Vector3(0.0f, 0.0f, 0.0f);
                elementConsumer.isRequired        = false;
                elementConsumer.storeOnConsume    = true;
                elementConsumer.showDescriptor    = false;
                ElementConverter elementConverter = wildCreature.AddOrGet <ElementConverter>();
                elementConverter.consumedElements = new ElementConverter.ConsumedElement[1]
                {
                    new ElementConverter.ConsumedElement(element_input.CreateTag(), 0.2f)
                };
                elementConverter.outputElements = new ElementConverter.OutputElement[1]
                {
                    new ElementConverter.OutputElement(0.2f, element_output, 0.0f, false, false, 0.0f, 0.5f, 1f, byte.MaxValue, 0)
                };
            }

            return(BaseHatchConfig.SetupDiet(wildCreature, diet_infos, CaloriesPerKgOfFood, MinPoopSizeKg));
        }
    public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
    {
        go.AddOrGet <LoopingSounds>();
        go.GetComponent <KPrefabID>().AddTag(RoomConstraints.ConstraintTags.IndustrialMachinery, false);
        Storage storage = BuildingTemplates.CreateDefaultStorage(go, false);

        storage.showInUI   = true;
        storage.capacityKg = 30000f;
        storage.SetDefaultStoredItemModifiers(Storage.StandardSealedStorage);
        AirFilter airFilter = go.AddOrGet <AirFilter>();

        airFilter.filterTag = GameTagExtensions.Create(SimHashes.Water);
        ElementConsumer elementConsumer = go.AddOrGet <PassiveElementConsumer>();

        elementConsumer.elementToConsume  = SimHashes.CarbonDioxide;
        elementConsumer.consumptionRate   = 0.6f;
        elementConsumer.capacityKG        = 0.6f;
        elementConsumer.consumptionRadius = 3;
        elementConsumer.showInStatusPanel = true;
        elementConsumer.sampleCellOffset  = new Vector3(0f, 0f, 0f);
        elementConsumer.isRequired        = false;
        elementConsumer.storeOnConsume    = true;
        elementConsumer.showDescriptor    = false;
        ElementConverter elementConverter = go.AddOrGet <ElementConverter>();

        elementConverter.consumedElements = new ElementConverter.ConsumedElement[2]
        {
            new ElementConverter.ConsumedElement(GameTagExtensions.Create(SimHashes.Water), 1f),
            new ElementConverter.ConsumedElement(GameTagExtensions.Create(SimHashes.CarbonDioxide), 0.3f)
        };
        elementConverter.outputElements = new ElementConverter.OutputElement[1]
        {
            new ElementConverter.OutputElement(1f, SimHashes.DirtyWater, 0f, false, true, 0f, 0.5f, 1f, byte.MaxValue, 0)
        };
        ConduitConsumer conduitConsumer = go.AddOrGet <ConduitConsumer>();

        conduitConsumer.conduitType          = ConduitType.Liquid;
        conduitConsumer.consumptionRate      = 2f;
        conduitConsumer.capacityKG           = 2f;
        conduitConsumer.capacityTag          = ElementLoader.FindElementByHash(SimHashes.Water).tag;
        conduitConsumer.wrongElementResult   = ConduitConsumer.WrongElementResult.Store;
        conduitConsumer.forceAlwaysSatisfied = true;
        ConduitDispenser conduitDispenser = go.AddOrGet <ConduitDispenser>();

        conduitDispenser.conduitType         = ConduitType.Liquid;
        conduitDispenser.invertElementFilter = true;
        conduitDispenser.elementFilter       = new SimHashes[1]
        {
            SimHashes.Water
        };
        go.AddOrGet <KBatchedAnimController>().randomiseLoopedOffset = true;
    }
Example #15
0
 [HarmonyPriority(-10000)] // Extremely low priority. We want this to happen last, since this will only overwrite RotatableElementConsumer variable
 public static void Prefix(ElementConsumer __instance)
 {
     if (__instance is RotatableElementConsumer)
     {
         Vector3   rotatableCellOffset = ((RotatableElementConsumer)__instance).rotatableCellOffset;
         Rotatable rotatable           = __instance.GetComponent <Rotatable>();
         if (rotatable != null)
         {
             __instance.sampleCellOffset = Rotatable.GetRotatedOffset(rotatableCellOffset, rotatable.GetOrientation());
         }
         //Debug.Log("GetSampleCell call " + rotatableCellOffset + ", " + __instance.sampleCellOffset);
     }
 }
Example #16
0
    public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
    {
        go.AddOrGet <LoopingSounds>();
        Prioritizable.AddRef(go);
        Storage storage = BuildingTemplates.CreateDefaultStorage(go, false);

        storage.showInUI   = true;
        storage.capacityKg = 200f;
        storage.SetDefaultStoredItemModifiers(Storage.StandardSealedStorage);
        ElementConsumer elementConsumer = go.AddOrGet <ElementConsumer>();

        elementConsumer.elementToConsume  = SimHashes.ContaminatedOxygen;
        elementConsumer.consumptionRate   = 0.1f;
        elementConsumer.consumptionRadius = 3;
        elementConsumer.showInStatusPanel = true;
        elementConsumer.sampleCellOffset  = new Vector3(0f, 0f, 0f);
        elementConsumer.isRequired        = false;
        elementConsumer.storeOnConsume    = true;
        elementConsumer.showDescriptor    = false;
        ElementDropper elementDropper = go.AddComponent <ElementDropper>();

        elementDropper.emitMass   = 10f;
        elementDropper.emitTag    = new Tag("Clay");
        elementDropper.emitOffset = new Vector3(0f, 0f, 0f);
        ElementConverter elementConverter = go.AddOrGet <ElementConverter>();

        elementConverter.consumedElements = new ElementConverter.ConsumedElement[2]
        {
            new ElementConverter.ConsumedElement(new Tag("Filter"), 0.13333334f),
            new ElementConverter.ConsumedElement(new Tag("ContaminatedOxygen"), 0.1f)
        };
        elementConverter.outputElements = new ElementConverter.OutputElement[2]
        {
            new ElementConverter.OutputElement(0.143333346f, SimHashes.Clay, 0f, false, true, 0f, 0.5f, 0.25f, byte.MaxValue, 0),
            new ElementConverter.OutputElement(0.0899999961f, SimHashes.Oxygen, 0f, false, false, 0f, 0f, 0.75f, byte.MaxValue, 0)
        };
        ManualDeliveryKG manualDeliveryKG = go.AddOrGet <ManualDeliveryKG>();

        manualDeliveryKG.SetStorage(storage);
        manualDeliveryKG.requestedItemTag = new Tag("Filter");
        manualDeliveryKG.capacity         = 320.000031f;
        manualDeliveryKG.refillMass       = 32.0000038f;
        manualDeliveryKG.choreTypeIDHash  = Db.Get().ChoreTypes.FetchCritical.IdHash;
        AirFilter airFilter = go.AddOrGet <AirFilter>();

        airFilter.filterTag = new Tag("Filter");
        go.AddOrGet <KBatchedAnimController>().randomiseLoopedOffset = true;
    }
Example #17
0
    private void OnReplanted(object data = null)
    {
        ReceptacleMonitor component = GetComponent <ReceptacleMonitor>();

        if (!((UnityEngine.Object)component == (UnityEngine.Object)null))
        {
            ElementConsumer component2 = GetComponent <ElementConsumer>();
            if (component.Replanted)
            {
                component2.consumptionRate = consumptionRate;
            }
            else
            {
                component2.consumptionRate = consumptionRate * 0.25f;
            }
        }
    }
    public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
    {
        Storage storage  = go.AddComponent <Storage>();
        Storage storage2 = go.AddComponent <Storage>();

        storage2.capacityKg = 100f;
        go.AddOrGet <BuildingComplete>().isManuallyOperated = true;
        go.AddOrGet <LoopingSounds>();
        Prioritizable.AddRef(go);
        float           num             = 2426.72f;
        float           num2            = 0.01f;
        LiquidCooledFan liquidCooledFan = go.AddOrGet <LiquidCooledFan>();

        liquidCooledFan.gasStorage           = storage;
        liquidCooledFan.liquidStorage        = storage2;
        liquidCooledFan.waterKGConsumedPerKJ = 1f / (num * num2);
        liquidCooledFan.coolingKilowatts     = 80f;
        liquidCooledFan.minCooledTemperature = 290f;
        liquidCooledFan.minEnvironmentMass   = 0.25f;
        liquidCooledFan.minCoolingRange      = new Vector2I(-2, 0);
        liquidCooledFan.maxCoolingRange      = new Vector2I(2, 4);
        ManualDeliveryKG manualDeliveryKG = go.AddComponent <ManualDeliveryKG>();

        manualDeliveryKG.requestedItemTag = new Tag("Water");
        manualDeliveryKG.capacity         = 500f;
        manualDeliveryKG.refillMass       = 50f;
        manualDeliveryKG.choreTypeIDHash  = Db.Get().ChoreTypes.MachineFetch.IdHash;
        ElementConsumer elementConsumer = go.AddOrGet <ElementConsumer>();

        elementConsumer.storeOnConsume    = true;
        elementConsumer.storage           = storage;
        elementConsumer.configuration     = ElementConsumer.Configuration.AllGas;
        elementConsumer.consumptionRadius = 8;
        elementConsumer.EnableConsumption(true);
        elementConsumer.sampleCellOffset = new Vector3(0f, 0f);
        elementConsumer.showDescriptor   = false;
        LiquidCooledFanWorkable liquidCooledFanWorkable = go.AddOrGet <LiquidCooledFanWorkable>();

        liquidCooledFanWorkable.SetWorkTime(20f);
        liquidCooledFanWorkable.overrideAnims = new KAnimFile[1]
        {
            Assets.GetAnim("anim_interacts_liquidfan_kanim")
        };
    }
Example #19
0
        public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
        {
            go.AddOrGet <LoopingSounds>();
            Prioritizable.AddRef(go);
            Storage storage = BuildingTemplates.CreateDefaultStorage(go, false);

            storage.showInUI   = true;
            storage.capacityKg = 50f;
            storage.SetDefaultStoredItemModifiers(Storage.StandardSealedStorage);

            ElementConsumer elementConsumer = go.AddOrGet <ElementConsumer>();

            elementConsumer.elementToConsume  = SimHashes.CarbonDioxide;
            elementConsumer.consumptionRate   = 0.3f;
            elementConsumer.consumptionRadius = 3;
            elementConsumer.showInStatusPanel = true;
            elementConsumer.sampleCellOffset  = new Vector3(0f, 0f, 0f);
            elementConsumer.isRequired        = false;
            elementConsumer.storeOnConsume    = true;
            elementConsumer.showDescriptor    = false;

            ElementDropper elementDropper = go.AddComponent <ElementDropper>();

            elementDropper.emitMass   = 10f;
            elementDropper.emitTag    = new Tag("Carbon");
            elementDropper.emitOffset = new Vector3(0f, 0f, 0f);
            ElementConverter elementConverter = go.AddOrGet <ElementConverter>();

            elementConverter.consumedElements = new ElementConverter.ConsumedElement[]
            {
                //new ElementConverter.ConsumedElement(new Tag("Filter"), 0.13333334f),
                new ElementConverter.ConsumedElement(new Tag("CarbonDioxide"), 0.25f)
            };
            elementConverter.outputElements = new ElementConverter.OutputElement[]
            {
                new ElementConverter.OutputElement(0.0833333f, SimHashes.Carbon, 0f, false, true, 0f, 0.5f, 0.25f, 255, 0),
                new ElementConverter.OutputElement(0.1666667f, SimHashes.Oxygen, 0f, false, false, 0f, 0f, 0.75f, 255, 0)
            };
            CoalSynth airFilter = go.AddOrGet <CoalSynth>();

            airFilter.filterTag = new Tag("CarbonDioxide");
            go.AddOrGet <KBatchedAnimController>().randomiseLoopedOffset = true;
        }
        public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
        {
            go.AddOrGet <WaterScrubber>();
            go.AddOrGet <DropAllWorkable>();

            Storage storage = go.AddOrGet <Storage>();

            storage.capacityKg = 100000f;
            storage.showInUI   = true;

            ElementConsumer elementConsumer = go.AddOrGet <ElementConsumer>();

            elementConsumer.configuration     = ElementConsumer.Configuration.AllGas;
            elementConsumer.capacityKG        = 100000f;
            elementConsumer.consumptionRate   = 30f;
            elementConsumer.consumptionRadius = 10;
            elementConsumer.showInStatusPanel = true;
            elementConsumer.sampleCellOffset  = new Vector3(0f, 0f, 0f);
            elementConsumer.isRequired        = false;
            elementConsumer.storeOnConsume    = true;

            ElementDropper elementDropper = go.AddComponent <ElementDropper>();

            elementDropper.emitMass   = 30f;
            elementDropper.emitTag    = new Tag("Water");
            elementDropper.emitOffset = new Vector3(0f, 1f, 0f);

            float            x = 10f;
            ElementConverter elementConverter = go.AddOrGet <ElementConverter>();

            elementConverter.consumedElements = new ElementConverter.ConsumedElement[2]
            {
                new ElementConverter.ConsumedElement(new Tag("Oxygen"), 0.888f * x),
                new ElementConverter.ConsumedElement(new Tag("Hydrogen"), 0.112f * x)
            };
            elementConverter.outputElements = new ElementConverter.OutputElement[1]
            {
                new ElementConverter.OutputElement(1f * x, SimHashes.Water, 0f, storeOutput: false, 0f, 0f, apply_input_temperature: false, 0f, 0)
            };
        }
Example #21
0
        public static GameObject CreatePacu(
            string id,
            string name,
            string desc,
            string anim_file,
            bool is_baby)
        {
            GameObject wildCreature = EntityTemplates.ExtendEntityToWildCreature(BasePacuConfig.CreatePrefab(id, BASE_TRAIT_ID, name, desc, anim_file, is_baby, null, 303.15f, 353.15f), PacuTuning.PEN_SIZE_PER_CREATURE, 25f);

            if (!is_baby)
            {
                wildCreature.AddComponent <Storage>().capacityKg = 10f;
                ElementConsumer elementConsumer = wildCreature.AddOrGet <PassiveElementConsumer>();
                elementConsumer.elementToConsume  = INPUT_ELEMENT;
                elementConsumer.consumptionRate   = 0.2f;
                elementConsumer.capacityKG        = 10f;
                elementConsumer.consumptionRadius = 3;
                elementConsumer.showInStatusPanel = true;
                elementConsumer.sampleCellOffset  = new Vector3(0.0f, 0.0f, 0.0f);
                elementConsumer.isRequired        = false;
                elementConsumer.storeOnConsume    = true;
                elementConsumer.showDescriptor    = false;
                wildCreature.AddOrGet <UpdateElementConsumerPosition>();
                BubbleSpawner bubbleSpawner = wildCreature.AddComponent <BubbleSpawner>();
                bubbleSpawner.element         = OUTPUT_ELEMENT;
                bubbleSpawner.emitMass        = 2f;
                bubbleSpawner.emitVariance    = 0.5f;
                bubbleSpawner.initialVelocity = new Vector2f(0, 1);
                ElementConverter elementConverter = wildCreature.AddOrGet <ElementConverter>();
                elementConverter.consumedElements = new ElementConverter.ConsumedElement[1]
                {
                    new ElementConverter.ConsumedElement(INPUT_ELEMENT.CreateTag(), 0.2f)
                };
                elementConverter.outputElements = new ElementConverter.OutputElement[1]
                {
                    new ElementConverter.OutputElement(0.2f, OUTPUT_ELEMENT, 0.0f, true, true, 0.0f, 0.5f, 1f, byte.MaxValue, 0)
                };
            }
            return(wildCreature);
        }
        private static void Postfix(GameObject go)
        {
            ElementConsumer elementConsumer = go.GetComponent <ElementConsumer>();

            if (elementConsumer == null)
            {
                Debug.LogWarning("GasPumpConfig_DoPostConfigureComplete elementConsumer was null");
                return;
            }

            Storage storage = go.GetComponent <Storage>();

            if (storage == null)
            {
                Debug.LogWarning("GasPumpConfig_DoPostConfigureComplete storage was null");
                return;
            }

            storage.capacityKg = CustomizeBuildingsState.StateManager.State.PipeGasPump * 2;

            elementConsumer.consumptionRate = CustomizeBuildingsState.StateManager.State.PipeGasPump;
        }
Example #23
0
        public override void DoPostConfigureComplete(GameObject go)
        {
            GeneratedBuildings.RegisterLogicPorts(go, PressureLiquidPumpConfig.INPUT_PORTS);
            go.AddOrGet <LogicOperationalController>();
            go.GetComponent <KPrefabID>().AddTag(RoomConstraints.ConstraintTags.IndustrialMachinery);
            go.AddOrGet <LoopingSounds>();
            go.AddOrGet <EnergyConsumer>();
            go.AddOrGet <Pump>();
            go.AddOrGet <Storage>().capacityKg = 400f;
            ElementConsumer elementConsumer = go.AddOrGet <ElementConsumer>();

            elementConsumer.configuration     = ElementConsumer.Configuration.AllLiquid;
            elementConsumer.consumptionRate   = 200f;
            elementConsumer.storeOnConsume    = true;
            elementConsumer.showInStatusPanel = false;
            elementConsumer.consumptionRadius = (byte)2;
            ConduitDispenser conduitDispenser = go.AddOrGet <ConduitDispenser>();

            conduitDispenser.conduitType    = ConduitType.Liquid;
            conduitDispenser.alwaysDispense = true;
            conduitDispenser.elementFilter  = (SimHashes[])null;
            go.AddOrGetDef <OperationalController.Def>();
        }
    public static GameObject CreatePacu(string id, string name, string desc, string anim_file, bool is_baby)
    {
        GameObject prefab = BasePacuConfig.CreatePrefab(id, "PacuCleanerBaseTrait", name, desc, anim_file, is_baby, "glp_", 243.15f, 278.15f);

        prefab = EntityTemplates.ExtendEntityToWildCreature(prefab, PacuTuning.PEN_SIZE_PER_CREATURE, 25f);
        if (!is_baby)
        {
            Storage storage = prefab.AddComponent <Storage>();
            storage.capacityKg = 10f;
            ElementConsumer elementConsumer = prefab.AddOrGet <PassiveElementConsumer>();
            elementConsumer.elementToConsume  = SimHashes.DirtyWater;
            elementConsumer.consumptionRate   = 0.2f;
            elementConsumer.capacityKG        = 10f;
            elementConsumer.consumptionRadius = 3;
            elementConsumer.showInStatusPanel = true;
            elementConsumer.sampleCellOffset  = new Vector3(0f, 0f, 0f);
            elementConsumer.isRequired        = false;
            elementConsumer.storeOnConsume    = true;
            elementConsumer.showDescriptor    = false;
            prefab.AddOrGet <UpdateElementConsumerPosition>();
            BubbleSpawner bubbleSpawner = prefab.AddComponent <BubbleSpawner>();
            bubbleSpawner.element         = SimHashes.Water;
            bubbleSpawner.emitMass        = 2f;
            bubbleSpawner.emitVariance    = 0.5f;
            bubbleSpawner.initialVelocity = new Vector2f(0, 1);
            ElementConverter elementConverter = prefab.AddOrGet <ElementConverter>();
            elementConverter.consumedElements = new ElementConverter.ConsumedElement[1]
            {
                new ElementConverter.ConsumedElement(SimHashes.DirtyWater.CreateTag(), 0.2f)
            };
            elementConverter.outputElements = new ElementConverter.OutputElement[1]
            {
                new ElementConverter.OutputElement(0.2f, SimHashes.Water, 0f, true, true, 0f, 0.5f, 1f, byte.MaxValue, 0)
            };
        }
        return(prefab);
    }
Example #25
0
            public static void Postfix(ColdBreatherConfig __instance, ref GameObject __result)
            {
                TemperatureVulnerable temperatureVulnerable = __result.AddOrGet <TemperatureVulnerable>();

                temperatureVulnerable.Configure(50f, 10f, 900f, 1000f);

                ColdBreather coldBreather = __result.AddOrGet <ColdBreather>();

                coldBreather.deltaEmitTemperature = -10f;
                coldBreather.emitOffsetCell       = new Vector3(0f, 2f);

                Storage storage = BuildingTemplates.CreateDefaultStorage(__result);

                storage.showInUI = true;

                ElementConsumer elementConsumer = __result.AddOrGet <ElementConsumer>();

                elementConsumer.capacityKG        = 20f;
                elementConsumer.consumptionRate   = 5f;
                elementConsumer.consumptionRadius = 5;

                ElementConverter elementConverter = __result.AddOrGet <ElementConverter>();
                var newConsumedElements           = new[] { new ElementConverter.ConsumedElement(GameTagExtensions.Create(SimHashes.CarbonDioxide), 3f) };
                var newOutputElements             = new[]
                {
                    new ElementConverter.OutputElement(1f, SimHashes.Carbon, 323.15f, true, 0f, 0.5f, false, 1f, byte.MaxValue, 0),
                    new ElementConverter.OutputElement(2f, SimHashes.Oxygen, 323.15f, true, 0f, 0.5f, false, 1f, byte.MaxValue, 0)
                };

                elementConverter.consumedElements = newConsumedElements;
                elementConverter.outputElements   = newOutputElements;
                ElementDropper elementDropper = __result.AddComponent <ElementDropper>();

                elementDropper.emitMass   = 100f;
                elementDropper.emitTag    = SimHashes.Carbon.CreateTag();
                elementDropper.emitOffset = new Vector3(0.5f, 1f, 0f);
            }
Example #26
0
        public static bool Prefix(Oxyfern __instance, ReceptacleMonitor ___receptacleMonitor)
        {
            float oxyfernOxygenPerSecond = CustomizePlantsState.StateManager.State.OxyfernOxygenPerSecond;

            ElementConsumer elementConsumer = __instance.GetComponent <ElementConsumer>();

            if (elementConsumer != null)
            {
                if (___receptacleMonitor.Replanted)
                {
                    elementConsumer.consumptionRate = oxyfernOxygenPerSecond / 50f;
                }
                else
                {
                    elementConsumer.consumptionRate = oxyfernOxygenPerSecond / 200f;
                }
                return(false);
            }
            else
            {
                Debug.LogWarning("Oxyfern_SetConsumptionRate elementConsumer was null");
            }
            return(true);
        }
        public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
        {
            Storage storage1 = go.AddOrGet <Storage>();

            storage1.showInUI = true;

            Storage storage2 = go.AddComponent <Storage>();

            storage2.capacityKg = 5f;
            storage2.showInUI   = true;
            storage2.SetDefaultStoredItemModifiers(PollutedWaterStorageModifiers);
            storage2.allowItemRemoval = false;
            storage2.storageFilters   = new List <Tag> {
                ElementLoader.FindElementByHash(SimHashes.DirtyWater).tag
            };

            ManualDeliveryKG manualDeliveryKg1 = go.AddOrGet <ManualDeliveryKG>();

            manualDeliveryKg1.SetStorage(storage1);
            manualDeliveryKg1.requestedItemTag = new Tag("Algae");
            manualDeliveryKg1.capacity         = 90f;
            manualDeliveryKg1.refillMass       = 18f;
            manualDeliveryKg1.choreTypeIDHash  = Db.Get().ChoreTypes.OperateFetch.IdHash;

            ManualDeliveryKG manualDeliveryKg2 = go.AddComponent <ManualDeliveryKG>();

            manualDeliveryKg2.SetStorage(storage1);
            manualDeliveryKg2.requestedItemTag = new Tag("Water");
            manualDeliveryKg2.capacity         = 360f;
            manualDeliveryKg2.refillMass       = 72f;
            manualDeliveryKg2.allowPause       = true;
            manualDeliveryKg2.choreTypeIDHash  = Db.Get().ChoreTypes.OperateFetch.IdHash;

            PipedAlgaeTerrarium algaeHabitat = go.AddOrGet <PipedAlgaeTerrarium>();

            algaeHabitat.lightBonusMultiplier = 1.1f;
            algaeHabitat.pressureSampleOffset = new CellOffset(0, 1);

            ElementConverter elementConverter = go.AddComponent <ElementConverter>();

            elementConverter.consumedElements = new ElementConverter.ConsumedElement[2]
            {
                new ElementConverter.ConsumedElement(new Tag("Algae"), 0.03f),
                new ElementConverter.ConsumedElement(new Tag("Water"), 0.3f)
            };
            elementConverter.outputElements = new ElementConverter.OutputElement[2]
            {
                new ElementConverter.OutputElement(0.04f, SimHashes.Oxygen, 303.15f, false, 0.0f, 1f, false, 1f, byte.MaxValue, 0),
                new ElementConverter.OutputElement(0.2903333f, SimHashes.DirtyWater, 303.15f, true, 0.0f, 1f, false, 1f, byte.MaxValue, 0)
            };

            ConduitDispenser conduitDispenser = go.AddOrGet <ConduitDispenser>();

            conduitDispenser.conduitType         = ConduitType.Liquid;
            conduitDispenser.invertElementFilter = true;
            conduitDispenser.elementFilter       = new SimHashes[1]
            {
                SimHashes.Water
            };

            ElementConsumer elementConsumer = go.AddOrGet <ElementConsumer>();

            elementConsumer.elementToConsume  = SimHashes.CarbonDioxide;
            elementConsumer.consumptionRate   = 0.0003333333f;
            elementConsumer.consumptionRadius = (byte)3;
            elementConsumer.showInStatusPanel = true;
            elementConsumer.sampleCellOffset  = new Vector3(0.0f, 1f, 0.0f);
            elementConsumer.isRequired        = false;

            PassiveElementConsumer passiveElementConsumer = go.AddComponent <PassiveElementConsumer>();

            passiveElementConsumer.elementToConsume  = SimHashes.Water;
            passiveElementConsumer.consumptionRate   = 1.2f;
            passiveElementConsumer.consumptionRadius = (byte)1;
            passiveElementConsumer.showDescriptor    = false;
            passiveElementConsumer.storeOnConsume    = true;
            passiveElementConsumer.capacityKG        = 360f;
            passiveElementConsumer.showInStatusPanel = false;

            go.AddOrGet <AnimTileable>();

            Prioritizable.AddRef(go);
        }
Example #28
0
        public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
        {
            Storage storage1 = go.AddOrGet <Storage>();

            storage1.showInUI = true;

            Storage storage2 = go.AddComponent <Storage>();

            storage2.capacityKg = 5f;
            storage2.showInUI   = true;
            storage2.SetDefaultStoredItemModifiers(PollutedWaterStorageModifiers);
            storage2.allowItemRemoval = false;
            storage2.storageFilters   = new List <Tag> {
                SimHashes.Algae.CreateTag(), SimHashes.CarbonDioxide.CreateTag()
            };

            ManualDeliveryKG manualDeliveryKg1 = go.AddOrGet <ManualDeliveryKG>();

            manualDeliveryKg1.SetStorage(storage1);
            manualDeliveryKg1.requestedItemTag = SimHashes.Fertilizer.CreateTag();
            manualDeliveryKg1.capacity         = 90f;
            manualDeliveryKg1.refillMass       = 18f;
            manualDeliveryKg1.choreTypeIDHash  = Db.Get().ChoreTypes.OperateFetch.IdHash;

            ManualDeliveryKG manualDeliveryKg2 = go.AddComponent <ManualDeliveryKG>();

            manualDeliveryKg2.SetStorage(storage1);
            manualDeliveryKg2.requestedItemTag = SimHashes.Water.CreateTag();
            manualDeliveryKg2.capacity         = 360f;
            manualDeliveryKg2.refillMass       = 72f;
            manualDeliveryKg2.allowPause       = true;
            manualDeliveryKg2.choreTypeIDHash  = Db.Get().ChoreTypes.OperateFetch.IdHash;

            AlgaeGrower algaeHabitat = go.AddOrGet <AlgaeGrower>();

            algaeHabitat.pressureSampleOffset = new CellOffset(0, 1);

            ElementConverter elementConverter = go.AddComponent <ElementConverter>();

            elementConverter.consumedElements = new ElementConverter.ConsumedElement[3]
            {
                new ElementConverter.ConsumedElement(SimHashes.CarbonDioxide.CreateTag(), 0.01375f),
                new ElementConverter.ConsumedElement(SimHashes.Fertilizer.CreateTag(), 0.000625f),
                new ElementConverter.ConsumedElement(SimHashes.Water.CreateTag(), 0.005625f)
            };
            elementConverter.outputElements = new ElementConverter.OutputElement[2]
            {
                new ElementConverter.OutputElement(0.005f, SimHashes.Oxygen, 303.15f, false, 0.0f, 1f),
                new ElementConverter.OutputElement(0.015f, SimHashes.Algae, 303.15f, true, 0.0f, 1f)
            };

            ElementDropper elementDropper = go.AddComponent <ElementDropper>();

            elementDropper.emitMass = 5;
            elementDropper.emitTag  = SimHashes.Algae.CreateTag();

            ElementConsumer elementConsumer = go.AddOrGet <ElementConsumer>();

            elementConsumer.elementToConsume  = SimHashes.CarbonDioxide;
            elementConsumer.consumptionRate   = 0.01375f;
            elementConsumer.consumptionRadius = 3;
            elementConsumer.showInStatusPanel = true;
            elementConsumer.storeOnConsume    = true;
            elementConsumer.sampleCellOffset  = new Vector3(0.0f, 1f, 0.0f);
            elementConsumer.isRequired        = true;

            PassiveElementConsumer passiveElementConsumer = go.AddComponent <PassiveElementConsumer>();

            passiveElementConsumer.elementToConsume  = SimHashes.Water;
            passiveElementConsumer.consumptionRate   = 1.2f;
            passiveElementConsumer.consumptionRadius = 1;
            passiveElementConsumer.showDescriptor    = false;
            passiveElementConsumer.storeOnConsume    = true;
            passiveElementConsumer.capacityKG        = 360f;
            passiveElementConsumer.showInStatusPanel = false;

            go.AddOrGet <AnimTileable>();

            Prioritizable.AddRef(go);
        }
Example #29
0
    public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
    {
        Storage storage  = go.AddComponent <Storage>();
        Storage storage2 = go.AddComponent <Storage>();

        storage2.capacityKg = 20000f;
        go.AddOrGet <BuildingComplete>().isManuallyOperated = false;
        go.AddOrGet <LoopingSounds>();
        Prioritizable.AddRef(go);
        //float num = 2426.72f;
        //float num2 = 0.01f;

        LiquidTank liquidCooledFan = go.AddOrGet <LiquidTank>();

        //liquidCooledFan.gasStorage = storage;
        liquidCooledFan.liquidStorage = storage2;
        //liquidCooledFan.waterKGConsumedPerKJ = 1f / (num * num2);
        //liquidCooledFan.coolingKilowatts = 80f;
        //liquidCooledFan.minCooledTemperature = 290f;
        //liquidCooledFan.minEnvironmentMass = 0.25f;
        //liquidCooledFan.minCoolingRange = new Vector2I(-2, 0);
        //liquidCooledFan.maxCoolingRange = new Vector2I(2, 4);

        /*
         * ManualDeliveryKG manualDeliveryKG = go.AddComponent<ManualDeliveryKG>();
         * manualDeliveryKG.requestedItemTag = new Tag("Water");
         * manualDeliveryKG.capacity = 500f;
         * manualDeliveryKG.refillMass = 50f;
         * manualDeliveryKG.choreTypeIDHash = Db.Get().ChoreTypes.Fetch.IdHash;
         *
         * ElementConsumer elementConsumer = go.AddOrGet<ElementConsumer>();
         * elementConsumer.storeOnConsume = true;
         * elementConsumer.storage = storage;
         * elementConsumer.configuration = ElementConsumer.Configuration.AllGas;
         * elementConsumer.consumptionRadius = 8;
         * elementConsumer.EnableConsumption(true);
         * elementConsumer.sampleCellOffset = new Vector3(0f, 0f);
         * elementConsumer.showDescriptor = false;
         */
        ElementConsumer elementConsumer = go.AddOrGet <ElementConsumer>();

        ConduitConsumer conduitConsumer = go.AddOrGet <ConduitConsumer>();

        conduitConsumer.conduitType          = ConduitType.Liquid;
        conduitConsumer.consumptionRate      = 10f;
        conduitConsumer.capacityKG           = 20000f;
        conduitConsumer.capacityTag          = GameTags.Liquid;
        conduitConsumer.forceAlwaysSatisfied = true;
        conduitConsumer.alwaysConsume        = true;
        conduitConsumer.wrongElementResult   = ConduitConsumer.WrongElementResult.Dump;

        ConduitDispenser conduitDispenser = go.AddOrGet <ConduitDispenser>();

        conduitDispenser.conduitType = ConduitType.Liquid;

        /*
         * LiquidCooledFanWorkable liquidCooledFanWorkable = go.AddOrGet<LiquidCooledFanWorkable>();
         * liquidCooledFanWorkable.SetWorkTime(20f);
         * liquidCooledFanWorkable.overrideAnims = new KAnimFile[1]
         * {
         *      Assets.GetAnim("anim_interacts_liquidfan_kanim")
         * };
         */
    }
    public GameObject CreatePrefab()
    {
        GameObject gameObject = EntityTemplates.CreatePlacedEntity("ColdBreather", STRINGS.CREATURES.SPECIES.COLDBREATHER.NAME, STRINGS.CREATURES.SPECIES.COLDBREATHER.DESC, 400f, Assets.GetAnim("coldbreather_kanim"), "grow_seed", Grid.SceneLayer.BuildingFront, 1, 2, DECOR.BONUS.TIER1, NOISE_POLLUTION.NOISY.TIER2, SimHashes.Creature, null, 293f);

        gameObject.AddOrGet <ReceptacleMonitor>();
        gameObject.AddOrGet <EntombVulnerable>();
        gameObject.AddOrGet <WiltCondition>();
        gameObject.AddOrGet <Prioritizable>();
        gameObject.AddOrGet <Uprootable>();
        gameObject.AddOrGet <UprootedMonitor>();
        gameObject.AddOrGet <DrowningMonitor>();
        EntityTemplates.ExtendPlantToFertilizable(gameObject, new PlantElementAbsorber.ConsumeInfo[1]
        {
            new PlantElementAbsorber.ConsumeInfo
            {
                tag = SimHashes.Phosphorite.CreateTag(),
                massConsumptionRate = 0.006666667f
            }
        });
        TemperatureVulnerable temperatureVulnerable = gameObject.AddOrGet <TemperatureVulnerable>();

        temperatureVulnerable.Configure(213.15f, 183.15f, 368.15f, 463.15f);
        gameObject.AddOrGet <OccupyArea>().objectLayers = new ObjectLayer[1]
        {
            ObjectLayer.Building
        };
        ColdBreather coldBreather = gameObject.AddOrGet <ColdBreather>();

        coldBreather.deltaEmitTemperature = -5f;
        coldBreather.emitOffsetCell       = new Vector3(0f, 1f);
        coldBreather.consumptionRate      = 1f;
        gameObject.AddOrGet <KBatchedAnimController>().randomiseLoopedOffset = true;
        Storage storage = BuildingTemplates.CreateDefaultStorage(gameObject, false);

        storage.showInUI = false;
        ElementConsumer elementConsumer = gameObject.AddOrGet <ElementConsumer>();

        elementConsumer.storeOnConsume    = true;
        elementConsumer.configuration     = ElementConsumer.Configuration.AllGas;
        elementConsumer.capacityKG        = 2f;
        elementConsumer.consumptionRate   = 0.25f;
        elementConsumer.consumptionRadius = 1;
        elementConsumer.sampleCellOffset  = new Vector3(0f, 0f);
        SimTemperatureTransfer component = gameObject.GetComponent <SimTemperatureTransfer>();

        component.SurfaceArea = 10f;
        component.Thickness   = 0.001f;
        GameObject plant = gameObject;

        SeedProducer.ProductionType productionType = SeedProducer.ProductionType.Hidden;
        string     id   = "ColdBreatherSeed";
        string     name = STRINGS.CREATURES.SPECIES.SEEDS.COLDBREATHER.NAME;
        string     desc = STRINGS.CREATURES.SPECIES.SEEDS.COLDBREATHER.DESC;
        KAnimFile  anim = Assets.GetAnim("seed_coldbreather_kanim");
        List <Tag> list = new List <Tag>();

        list.Add(GameTags.CropSeed);
        list = list;
        GameObject seed = EntityTemplates.CreateAndRegisterSeedForPlant(plant, productionType, id, name, desc, anim, "object", 1, list, SingleEntityReceptacle.ReceptacleDirection.Top, default(Tag), 2, STRINGS.CREATURES.SPECIES.COLDBREATHER.DOMESTICATEDDESC, EntityTemplates.CollisionShape.CIRCLE, 0.3f, 0.3f, null, string.Empty, false);

        EntityTemplates.CreateAndRegisterPreviewForPlant(seed, "ColdBreather_preview", Assets.GetAnim("coldbreather_kanim"), "place", 1, 2);
        SoundEventVolumeCache.instance.AddVolume("coldbreather_kanim", "ColdBreather_grow", NOISE_POLLUTION.CREATURES.TIER3);
        SoundEventVolumeCache.instance.AddVolume("coldbreather_kanim", "ColdBreather_intake", NOISE_POLLUTION.CREATURES.TIER3);
        return(gameObject);
    }