Jump to content

How to increase the reservoir capacity???


Recommended Posts

Hello people! How are you? :)

Please, I am making a mod for me which is to increase some capacity of some itens such Locker, Battery Smart, etc. I got to increase almost all which I wanted, but not the reservoir of liquid and gas! How do I make this?

Below it is my code that work for Locker: 

public static class Armazenamento
    {
        [HarmonyPatch(typeof(StorageLockerConfig))]
        [HarmonyPatch(nameof(StorageLockerConfig.DoPostConfigureComplete))]
        [HarmonyPatch(new[] { typeof(GameObject) })]

        public static class ArmazenamentoAplicar
        {
            public static void Postfix(ref GameObject go)
            {
                //Aumenta a capacidade
                go.GetComponent<Storage>().capacityKg = Constantes.CAPACIDADE_TOP;
            }
        }
    }

Where my constant CAPACIDADE_TOP is 500 ton.

But for liquid and gas... no :(

See below:

 public static class ArmazenamentoGasoso
    {
        [HarmonyPatch(typeof(GasReservoirConfig))]
        [HarmonyPatch(nameof(GasReservoirConfig.DoPostConfigureComplete))]
        [HarmonyPatch(new[] { typeof(GameObject) })]

        public static class ArmazenamentoGasosoAplicar
        {
            public static void Postfix(ref GameObject go)
            {
                //Aumenta a capacidade
                go.GetComponent<Storage>().capacityKg = Constantes.CAPACIDADE_MAX_GAS_LIQUIDO;
            }
        }
    }

Where the constant CAPACIDADE_MAX_GAS_LIQUIDO is 100 ton.

I tried to find some classes with some storage and/or reservoir relations, etc., and I couldn't :(

Some idea?

Thanks!
CarLNX.

Link to comment
Share on other sites

// GasReservoirConfig
public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
	{
		go.AddOrGet<Reservoir>();
		Storage storage = BuildingTemplates.CreateDefaultStorage(go, false);
		storage.showDescriptor = true;
		storage.storageFilters = STORAGEFILTERS.GASES;
		storage.capacityKg = 150f;
		storage.SetDefaultStoredItemModifiers(GasReservoirConfig.ReservoirStoredItemModifiers);
		ConduitConsumer conduitConsumer = go.AddOrGet<ConduitConsumer>();
		conduitConsumer.conduitType = ConduitType.Gas;
		conduitConsumer.ignoreMinMassCheck = true;
		conduitConsumer.forceAlwaysSatisfied = true;
		conduitConsumer.alwaysConsume = true;
		conduitConsumer.capacityKG = storage.capacityKg;
		ConduitDispenser conduitDispenser = go.AddOrGet<ConduitDispenser>();
		conduitDispenser.conduitType = ConduitType.Gas;
		conduitDispenser.elementFilter = null;
	}
// StorageLockerConfig
public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
	{
		SoundEventVolumeCache.instance.AddVolume("storagelocker_kanim", "StorageLocker_Hit_metallic_low", NOISE_POLLUTION.NOISY.TIER1);
		Prioritizable.AddRef(go);
		Storage storage = go.AddOrGet<Storage>();
		storage.showInUI = true;
		storage.allowItemRemoval = true;
		storage.showDescriptor = true;
		storage.storageFilters = STORAGEFILTERS.NOT_EDIBLE_SOLIDS;
		storage.storageFullMargin = STORAGE.STORAGE_LOCKER_FILLED_MARGIN;
		storage.fetchCategory = Storage.FetchCategory.GeneralStorage;
		CopyBuildingSettings copyBuildingSettings = go.AddOrGet<CopyBuildingSettings>();
		copyBuildingSettings.copyGroupTag = GameTags.StorageLocker;
		go.AddOrGet<StorageLocker>();
	}

So based on the differences of these objects. It looks like you are trying to grab the wrong thing for the Gas Reservoir. It looks like you'll want to change the `conduitConsumer`'s capacity. Considering it looks like the Storage object doesn't get put into the GameObject `go` but ConduitConsumer does.

So based on your working example:

go.GetComponent<ConduitConsumer>().capacityKG = Constantes.CAPACIDADE_MAX_GAS_LIQUIDO;

Let me know if that helps :)
 

Link to comment
Share on other sites

6 hours ago, CoolAzura said:

go.GetComponent<ConduitConsumer>().capacityKG = Constantes.CAPACIDADE_MAX_GAS_LIQUIDO;

Let me know if that helps :)

This is it. A ConduitConsumer will fill up the storage until it reach capacityKG. The trick here is that it only counts what is set with ConduitConsumer.capacityTag. It isn't set here, meaning it counts everything, but it's possible to have two consumers, each with a different tag. This means the consumers shouldn't count how much is stored from the other consumer.

While this isn't used for the reservoirs, the capacityKG should still be set because the game doesn't know you don't plan on using this feature.

Link to comment
Share on other sites

On 06/08/2019 at 1:11 AM, CoolAzura said:

So based on your working example:


go.GetComponent<ConduitConsumer>().capacityKG = Constantes.CAPACIDADE_MAX_GAS_LIQUIDO;

Let me know if that helps :)
 

Yes, it worked! Thank very much. 

I am waiting new modding from you (plural!)... so many great ideas :)

Thank,

CarLNX.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...