Exemple #1
0
            public static void Postfix(AlgaeDistilleryConfig __instance, ref GameObject go)
            {
                float ratio;

                ratio = DynamicBuildingsState.StateManager.State.SlimeConsumeKGsPerSecond / 0.6f;
                ManualDeliveryKG manualDeliveryKG = go.AddOrGet <ManualDeliveryKG>();

                manualDeliveryKG.refillMass = 120f * ratio;
                manualDeliveryKG.capacity   = 480f * ratio;
                AlgaeDistillery algaeDistillery = go.AddOrGet <AlgaeDistillery>();

                algaeDistillery.emitMass = 30f * ratio;

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

                var newConsumedElements = new[] { new ElementConverter.ConsumedElement(SimHashes.SlimeMold.CreateTag(), 0.6f * ratio) };

                var newOutputElements = new[]    {
                    new ElementConverter.OutputElement(0.2f * ratio, SimHashes.Algae, 303.15f, true, 0f, 1f, false, 0f, 0),
                    new ElementConverter.OutputElement(0.400000036f * ratio, SimHashes.DirtyWater, 303.15f, true, 0f, 0.5f, false, 0f, 0)
                };

                elementConverter.outputElements   = newOutputElements;
                elementConverter.consumedElements = newConsumedElements;
            }
Exemple #2
0
    public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
    {
        go.GetComponent <KPrefabID>().AddTag(RoomConstraints.ConstraintTags.IndustrialMachinery, false);
        ConduitDispenser conduitDispenser = go.AddOrGet <ConduitDispenser>();

        conduitDispenser.conduitType   = ConduitType.Liquid;
        conduitDispenser.elementFilter = new SimHashes[1]
        {
            SimHashes.Ethanol
        };
        Storage storage = go.AddOrGet <Storage>();

        storage.capacityKg = 1000f;
        storage.SetDefaultStoredItemModifiers(Storage.StandardSealedStorage);
        storage.showInUI = true;
        ManualDeliveryKG manualDeliveryKG = go.AddOrGet <ManualDeliveryKG>();

        manualDeliveryKG.SetStorage(storage);
        manualDeliveryKG.requestedItemTag = WoodLogConfig.TAG;
        manualDeliveryKG.capacity         = 600f;
        manualDeliveryKG.refillMass       = 150f;
        manualDeliveryKG.choreTypeIDHash  = Db.Get().ChoreTypes.MachineFetch.IdHash;
        ElementConverter elementConverter = go.AddOrGet <ElementConverter>();

        elementConverter.consumedElements = new ElementConverter.ConsumedElement[1]
        {
            new ElementConverter.ConsumedElement(WoodLogConfig.TAG, 1f)
        };
        elementConverter.outputElements = new ElementConverter.OutputElement[3]
        {
            new ElementConverter.OutputElement(0.5f, SimHashes.Ethanol, 346.5f, false, true, 0f, 0.5f, 1f, byte.MaxValue, 0),
            new ElementConverter.OutputElement(0.333333343f, SimHashes.ToxicSand, 366.5f, false, true, 0f, 0.5f, 1f, byte.MaxValue, 0),
            new ElementConverter.OutputElement(0.166666672f, SimHashes.CarbonDioxide, 366.5f, false, false, 0f, 0.5f, 1f, byte.MaxValue, 0)
        };
        AlgaeDistillery algaeDistillery = go.AddOrGet <AlgaeDistillery>();

        algaeDistillery.emitMass   = 20f;
        algaeDistillery.emitTag    = new Tag("ToxicSand");
        algaeDistillery.emitOffset = new Vector3(2f, 1f);
        Prioritizable.AddRef(go);
    }
    public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
    {
        go.GetComponent <KPrefabID>().AddTag(RoomConstraints.ConstraintTags.IndustrialMachinery, false);
        AlgaeDistillery algaeDistillery = go.AddOrGet <AlgaeDistillery>();

        algaeDistillery.emitTag  = new Tag("Algae");
        algaeDistillery.emitMass = 30f;
        ConduitDispenser conduitDispenser = go.AddOrGet <ConduitDispenser>();

        conduitDispenser.conduitType   = ConduitType.Liquid;
        conduitDispenser.elementFilter = new SimHashes[1]
        {
            SimHashes.DirtyWater
        };
        Storage storage = go.AddOrGet <Storage>();

        storage.capacityKg = 1000f;
        storage.SetDefaultStoredItemModifiers(Storage.StandardSealedStorage);
        storage.showInUI = true;
        Tag tag = SimHashes.SlimeMold.CreateTag();
        ManualDeliveryKG manualDeliveryKG = go.AddOrGet <ManualDeliveryKG>();

        manualDeliveryKG.SetStorage(storage);
        manualDeliveryKG.requestedItemTag = tag;
        manualDeliveryKG.refillMass       = 120f;
        manualDeliveryKG.capacity         = 480f;
        manualDeliveryKG.choreTypeIDHash  = Db.Get().ChoreTypes.MachineFetch.IdHash;
        ElementConverter elementConverter = go.AddOrGet <ElementConverter>();

        elementConverter.consumedElements = new ElementConverter.ConsumedElement[1]
        {
            new ElementConverter.ConsumedElement(tag, 0.6f)
        };
        elementConverter.outputElements = new ElementConverter.OutputElement[2]
        {
            new ElementConverter.OutputElement(0.2f, SimHashes.Algae, 303.15f, false, true, 0f, 1f, 1f, byte.MaxValue, 0),
            new ElementConverter.OutputElement(0.400000036f, SimHashes.DirtyWater, 303.15f, false, true, 0f, 0.5f, 1f, byte.MaxValue, 0)
        };
        Prioritizable.AddRef(go);
    }
        public static void ProcessPost(BuildingDef buildingDef)
        {
            float multiplier;
            bool  flag = CustomizeBuildingsState.StateManager.State.MachineMultiplier.TryGetValue(buildingDef.PrefabID, out multiplier);

            if (!flag)
            {
                flag = CustomizeBuildingsState.StateManager.State.MachineMultiplier.TryGetValue(BuildingConfigManager_RegisterBuilding.FindBetweenLink.Match(buildingDef.Name).Groups[1].Value, out multiplier);
            }
            if (flag)
            {
                ElementConverter[] converters = buildingDef.BuildingComplete.GetComponents <ElementConverter>();
                for (int j = 0; j < converters.Count(); j++)
                {
                    ElementConverter converter = converters[j];

                    for (int i = 0; i < converter.consumedElements.Count(); i++)
                    {
                        converter.consumedElements[i].massConsumptionRate *= (float)multiplier;
                    }
                    for (int i = 0; i < converter.outputElements.Count(); i++)
                    {
                        converter.outputElements[i].massGenerationRate *= (float)multiplier;
                    }
                    //converter.SetWorkSpeedMultiplier((float)multiplier);
                    Debug.Log("Multiplier: " + buildingDef.PrefabID + " x" + multiplier);
                }
                //if(converters.Count() == 0) Debug.Log("Muliplier: converter was null for " + buildingDef.PrefabID);

                Storage[] storages = buildingDef.BuildingComplete.GetComponents <Storage>();
                for (int i = 0; i < storages.Count(); i++)
                {
                    storages[i].capacityKg *= multiplier;
                }

                ManualDeliveryKG[] manualDeliveryKGs = buildingDef.BuildingComplete.GetComponents <ManualDeliveryKG>();
                for (int i = 0; i < manualDeliveryKGs.Count(); i++)
                {
                    manualDeliveryKGs[i].capacity *= multiplier;
                }

                ConduitConsumer conduitConsumer = buildingDef.BuildingComplete.GetComponent <ConduitConsumer>();
                if (conduitConsumer != null)
                {
                    conduitConsumer.capacityKG *= multiplier;
                }

                PassiveElementConsumer elementConsumer = buildingDef.BuildingComplete.GetComponent <PassiveElementConsumer>();
                if (elementConsumer != null)
                {
                    elementConsumer.consumptionRate *= multiplier;
                    elementConsumer.capacityKG      *= multiplier;
                }

                BuildingElementEmitter buildingElementEmitter = buildingDef.BuildingComplete.GetComponent <BuildingElementEmitter>();
                if (buildingElementEmitter != null)
                {
                    buildingElementEmitter.emitRate *= multiplier;
                }

                AlgaeDistillery algaeDistillery = buildingDef.BuildingComplete.GetComponent <AlgaeDistillery>();
                if (algaeDistillery != null)
                {
                    algaeDistillery.emitMass *= multiplier;
                }

                ElementDropper elementDropper = buildingDef.BuildingComplete.GetComponent <ElementDropper>();
                if (elementDropper != null)
                {
                    elementDropper.emitMass *= multiplier;
                }
            }
        }