Sign in to follow this  
War_TT

[Issue] Whit mod :/ Crashing after load

Recommended Posts

War_TT    0

Hello,

 

I have create mod for all power generators, started game, test it - ok. Added more mirror changes (some Battery, some CO2 Scrubber, and Wire). 

Started game, test it - ok works.

Add some more change. Starting game Crash. Cut my main big MOD to smaller portion's works to check witch part makes problem.

CO2ScrubberConfig , GasReservoirConfig and ElectrolyzerConfig stop working :/ I didn't change a thing in theme since first creation.

Can any one point what I do Wrong ?

 

namespace BalanceEnergy
{

    //-----------******* Decress Power Usage - LiquidPump  *******-----------

    [HarmonyPatch(typeof(LiquidPumpConfig), "CreateBuildingDef")]
    public static class LiquidPumpConfiggMod
    {
        public static void Postfix(ref BuildingDef __result)
        {
            __result.EnergyConsumptionWhenActive = 60f;
        }
    }

    [HarmonyPatch(typeof(LiquidFilterConfig), "CreateBuildingDef")]
    public static class LiquidFilterConfigMod
    {
        public static void Postfix(ref BuildingDef __result)
        {
            __result.EnergyConsumptionWhenActive = 30f;
        }
    }

    [HarmonyPatch(typeof(LiquidHeaterConfig), "CreateBuildingDef")]
    public static class LiquidHeaterConfigMod
    {
        public static void Postfix(ref BuildingDef __result)
        {
            __result.EnergyConsumptionWhenActive = 1450f;
            __result.ExhaustKilowattsWhenActive = 6200f;
        }
    }

    [HarmonyPatch(typeof(SpaceHeaterConfig), "CreateBuildingDef")]
    public static class SpaceHeaterConfigMod
    {
        public static void Postfix(ref BuildingDef __result)
        {
            __result.EnergyConsumptionWhenActive = 420f;
            __result.ExhaustKilowattsWhenActive = 120f;
        }
    }

    //-----------*******      END       *******-----------


    //-----------******* POWER UP GRADE for all generateros - Hydro, Petrol, Methane, Wood and Coal (AKA Generator) *******-----------

    [HarmonyPatch(typeof(HydrogenGeneratorConfig), "CreateBuildingDef")]
    public static class HydrogenGeneratorConfigMod
    {
        public static void Postfix(ref BuildingDef __result)
        {
            __result.GeneratorWattageRating = 2000f;
            __result.GeneratorBaseCapacity = 4500f;

        }
    }

    [HarmonyPatch(typeof(PetroleumGeneratorConfig), "CreateBuildingDef")]
    public static class PetroleumGeneratorConfigMod
    {
        public static void Postfix(ref BuildingDef __result)
        {
            __result.GeneratorWattageRating = 3800f;
            __result.GeneratorBaseCapacity = 6200f;
        }
    }

    [HarmonyPatch(typeof(MethaneGeneratorConfig), "CreateBuildingDef")]
    public static class MethaneGeneratorConfigMod
    {
        public static void Postfix(ref BuildingDef __result)
        {
            __result.GeneratorWattageRating = 6400f;
            __result.GeneratorBaseCapacity = 9200f;
        }
    }

    [HarmonyPatch(typeof(WoodGasGeneratorConfig), "CreateBuildingDef")]
    public static class WoodGasGeneratorConfigMod
    {
        public static void Postfix(ref BuildingDef __result)
        {
            __result.GeneratorWattageRating = 600f;
        }
    }

    [HarmonyPatch(typeof(GeneratorConfig), "CreateBuildingDef")]
    public static class CoalGeneratorConfigMod
    {
        public static void Postfix(ref BuildingDef __result)
        {
            __result.GeneratorWattageRating = 1200f;
        }
    }

    //-----------*******      END       *******-----------

}

// <-------------------------------------------------------------------------------- THIS PART HAVE SOME PROBLEMS DON'T KNOW WAY --------------------------------------------------------------------------------------->
namespace BalanceEnergyPart2
{
    //-----------*******   Better Buliding stat - CO2Scraber, GasTank, Electroyzer      *******-----------


    [HarmonyPatch(typeof(CO2ScrubberConfig), "CreateBuildingDef")]
    public static class CO2ScrubberConfigMod
    {
        public static void Postfix(ref BuildingDef __result)
        {
            __result.EnergyConsumptionWhenActive = 60f;
        }
    }

    [HarmonyPatch(typeof(CO2ScrubberConfig))]
    [HarmonyPatch("ConfigureBuildingTemplate")]
    public class CO2ScrubberTamplateMod
    {
        public static void Postfix(ref GameObject go)
        {
            go.GetComponent<PassiveElementConsumer>().consumptionRate = 3.6f;
            go.GetComponent<PassiveElementConsumer>().capacityKG = 3.6f;
            go.GetComponent<PassiveElementConsumer>().consumptionRadius = 8;

            go.GetComponent<ElementConverter>().consumedElements = new ElementConverter.ConsumedElement[]
                {
                    new ElementConverter.ConsumedElement(GameTagExtensions.Create(SimHashes.Water), 1f),
                    new ElementConverter.ConsumedElement(GameTagExtensions.Create(SimHashes.CarbonDioxide), 1.8f)
                };

            go.GetComponent<ElementConverter>().outputElements = new ElementConverter.OutputElement[]
            {
               new ElementConverter.OutputElement(2.5f, SimHashes.DirtyWater, 0f, false, true, 0f, 0.5f, 1f, byte.MaxValue, 0)
            };
            go.GetComponent<ConduitConsumer>().consumptionRate = 2f;
            go.GetComponent<ConduitConsumer>().capacityKG = 6f;
        }

    }

    [HarmonyPatch(typeof(GasReservoirConfig))]
    [HarmonyPatch("ConfigureBuildingTemplate")]
    public class GasResrvoirConfigMod
    {
        public static void Prefix(ref GameObject go)
        {
            go.GetComponent<Storage>().capacityKg = 25000f;

        }
    }


    [HarmonyPatch(typeof(ElectrolyzerConfig))]
    [HarmonyPatch("ConfigureBuildingTemplate")]
    public class ElectrolyzerConfigTamplateMod
    {
        public static void Prefix(ref GameObject go)
        {
            go.GetComponent<Electrolyzer>().maxMass = 3.6f;
            go.GetComponent<ConduitConsumer>().consumptionRate = 1.5f;
            go.GetComponent<Storage>().capacityKg = 4f;
            go.GetComponent<ElementConverter>().consumedElements = new ElementConverter.ConsumedElement[]
            {
                new ElementConverter.ConsumedElement(new Tag("Water"),1.5f)
            };
            go.GetComponent<ElementConverter>().outputElements = new ElementConverter.OutputElement[]
            {
                new ElementConverter.OutputElement(1.366f, SimHashes.Oxygen, 343.15f, false, false, 0f, 1f, 1f, byte.MaxValue, 0),
                new ElementConverter.OutputElement(0.666333323f, SimHashes.Hydrogen, 343.15f, false, false, 0f, 1f, 1f, byte.MaxValue, 0)
            };

        }
        public const float WATER2OXYGEN_RATIO = 0.744f;
    }

    //-----------*******      END       *******-----------
}


namespace BalanceEnergyPart3
{

    //-----------******* Incress Power Storage fot Batteies - Nomrla, Medium, Smart  *******-----------
    //-----------******* And power rating for wire's - Nomrla, Hevy, isulated  *******-----------

    [HarmonyPatch(typeof(BatteryConfig))]
    [HarmonyPatch("DoPostConfigureComplete")]
    public class BatteryConfigPostConfigMod
    {
        public static void Postfix(ref GameObject go)
        {
            go.GetComponent<Battery>().capacity = 20000f;
            go.GetComponent<Battery>().joulesLostPerSecond = go.GetComponent<Battery>().capacity * 0.1f / 3200f;
        }
    }

    [HarmonyPatch(typeof(BatteryMediumConfig))]
    [HarmonyPatch("DoPostConfigureComplete")]
    public class BatteryMediumConfigPostConfigMod
    {
        public static void Postfix(ref GameObject go)
        {
            go.GetComponent<Battery>().capacity = 80000f;
            go.GetComponent<Battery>().joulesLostPerSecond = go.GetComponent<Battery>().capacity * 0.1f / 3200f;
        }

    }

    [HarmonyPatch(typeof(BatterySmartConfig))]
    [HarmonyPatch("DoPostConfigureComplete")]
    public class BatterySmartConfigPostConfigMod
    {
        public static void Postfix(ref GameObject go)
        {
            go.GetComponent<Battery>().capacity = 100000f;
            go.GetComponent<Battery>().joulesLostPerSecond = go.GetComponent<Battery>().capacity * 0.2f / 9200f;
        }

    }

    [HarmonyPatch(typeof(Wire))]
    [HarmonyPatch("GetMaxWattageAsFloat")]
    public class WireConfigPostConfigMod
    {
        private static bool Prefix(Wire.WattageRating rating, ref float __result)
        {
            float num;
            switch (rating)
            {
                case Wire.WattageRating.Max500:
                    num = 1000f;
                    break;
                case Wire.WattageRating.Max1000:
                    num = 2000f;
                    break;
                case Wire.WattageRating.Max2000:
                    num = 4000f;
                    break;
                case Wire.WattageRating.Max20000:
                    num = 40000f;
                    break;
                case Wire.WattageRating.Max50000:
                    num = 100000f;
                    break;
                default:
                    num = 0f;
                    break;
            }
            __result = num;
            return false;
        }

    }


    //-----------*******      END       *******-----------

}

 

Share this post


Link to post
Share on other sites
Camaro69327    11

First and foremost, i have NO idea what i am talking about OR looking at ...yet, I am just starting to look at this stuff, and the more i ask I learn .

 

The thing i SEE in the above text is weirdness with a "semicolon" ?sp

 {
            go.GetComponent<Electrolyzer>().maxMass = 3.6f;
            go.GetComponent<ConduitConsumer>().consumptionRate = 1.5f;
            go.GetComponent<Storage>().capacityKg = 4f;
            go.GetComponent<ElementConverter>().consumedElements = new ElementConverter.ConsumedElement[]
            {
                new ElementConverter.ConsumedElement(new Tag("Water"),1.5f)
            };
            go.GetComponent<ElementConverter>().outputElements = new ElementConverter.OutputElement[]
            {
                new ElementConverter.OutputElement(1.366f, SimHashes.Oxygen, 343.15f, false, false, 0f, 1f, 1f, byte.MaxValue, 0),
                new ElementConverter.OutputElement(0.666333323f, SimHashes.Hydrogen, 343.15f, false, false, 0f, 1f, 1f, byte.MaxValue, 0)
            };

        }

DO the "semicolons belong INside the bracket thingy..??

This could be the way it is suppose to be, but if I don't ask i won't learn..lol

Besides this will put it back up so others can look and give you real advice...lol

???

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this