Using Custom Engine Parts - theLeaxx/JaLoader GitHub Wiki
Custom engine parts can add a new level of complexity and uniqueness to your mod. Let's walk through the steps to integrate them into your project.
You should've mastered this first, as it'll help you out a ton here.
In your CustomObjectsRegistration method, after instantiating your object, you need to add engine parts logic. Refer to the following code:
public override void CustomObjectsRegistration()
{
base.CustomObjectsRegistration();
GameObject obj = Instantiate(LoadAsset<GameObject>("example", "example", "", ".prefab"));
ModHelper.Instance.AddBasicObjectLogic(obj, objName, objDescription, price, weight, canFindInCrates, canBuyInStore);
ModHelper.Instance.AddEnginePartLogic(obj, partType, durability, canFindInDealerships, canFindInJunkCars);
ModHelper.Instance.ConfigureCustom...(...); // this function varies from part to part, look below
CustomObjectsManager.Instance.RegisterObject(obj, "ObjectID");
}-
partTyperepresents the type of the part - you can choose from thePartTypesenum -
canfindInJunkCarsis currently not available but should still be set. -
canFindInCratesandcanBuyInStoresshould be set to false for all engine parts.
public enum PartTypes
{
Engine,
FuelTank,
Carburettor,
AirFilter,
IgnitionCoil,
Battery,
WaterTank,
Extra,
Custom,
Default
}Your engine parts can be any of those. As of JaLoader 1.2.0, Custom, Extra and WaterTank are not available. Default is for normal custom objects.
For each engine part, there exists a function that allows you to configure its properties. Here are all the functions:
ModHelper.Instance.ConfigureCustomEngine(obj, acceleration, topSpeed, useDefaultAudio);
ModHelper.Instance.ConfigureCustomCarburettor(obj, fuelConsumptionRate);
ModHelper.Instance.ConfigureCustomAirFilter(obj, engineWearRate);
ModHelper.Instance.ConfigureCustomIgnitionCoil(obj, initialFuelConsumption, ignitionTime);
ModHelper.Instance.ConfigureCustomFuelTank(obj, fuelCapacity, initialFuelCapacity);You can find more information about each function by hovering over it after writing it.
With these steps, you've successfully integrated custom engine parts into your mod.