63 lines
2.8 KiB
Plaintext
63 lines
2.8 KiB
Plaintext
URL: https://wiki.studiominus.nl/tutorials/tutorialMixing.html
|
|
Title: People Playground Modding - Custom liquid mixers
|
|
==================================================
|
|
|
|
Custom liquid mixers
|
|
You can add global liquid mixing instructions. Mixing instructions are responsible for turning source liquids into target liquids inside liquid containers. For example, mixing Mending serum and Acid to create Osteomorphisis agent.
|
|
Simple example
|
|
var mixer = new LiquidMixInstructions(
|
|
Liquid.GetLiquid(WaterBreathingSyringe.WaterBreathingSerum.ID), //source liquid A
|
|
Liquid.GetLiquid(Chemistry.Tritium.ID), //source liquid B
|
|
Liquid.GetLiquid(Chemistry.ExoticLiquid.ID)); //target liquid
|
|
|
|
LiquidMixingController.MixInstructions.Add(mixer); //add mixer to global list
|
|
|
|
Creating instructions
|
|
Preferrably done using one of the three constructors:
|
|
LiquidMixInstructions(Liquid[] sourceLiquids, Liquid targetLiquid, float ratePerSecond = 0.05f)
|
|
|
|
LiquidMixInstructions(Liquid sourceA, Liquid sourceB, Liquid targetLiquid, float ratePerSecond = 0.05f)
|
|
|
|
LiquidMixInstructions(Liquid sourceA, Liquid sourceB, Liquid sourceC, Liquid targetLiquid, float ratePerSecond = 0.05f)
|
|
|
|
Instructions have other members that you can edit.
|
|
var mixer = new LiquidMixInstructions(
|
|
Liquid.GetLiquid(WaterBreathingSyringe.WaterBreathingSerum.ID),
|
|
Liquid.GetLiquid(Chemistry.Tritium.ID),
|
|
Liquid.GetLiquid(Chemistry.ExoticLiquid.ID));
|
|
|
|
// Amount of liquid units that are converted every second
|
|
mixer.RatePerSecond = 0.1f;
|
|
|
|
// The optional container filter function. If this function returns false, the mixing will not take place
|
|
mixer.ContainerFilter = container => {
|
|
// this function will only return true if the container is a flask.
|
|
return container is FlaskBehaviour;
|
|
};
|
|
|
|
LiquidMixingController.MixInstructions.Add(mixer);
|
|
|
|
Restrictions
|
|
All liquids that are involved in a mixing process have to be registered in the Liquid registry. Here's a chapter on how to do that..
|
|
They can be registered before or after adding the mixer to the controller, it doesn't matter. Do note that all mixer instructions are cleared on map load. This means that your mixers should be added in your Main method.
|
|
Full example
|
|
using UnityEngine;
|
|
|
|
namespace Mod
|
|
{
|
|
public class Mod
|
|
{
|
|
public static void Main()
|
|
{
|
|
var bloodOilMixture = new LiquidMixInstructions(
|
|
Liquid.GetLiquid(Blood.ID),
|
|
Liquid.GetLiquid(Oil.ID),
|
|
Liquid.GetLiquid(Nitroglycerine.ID));
|
|
|
|
// i dont wan't liquids to mix inside a limb
|
|
bloodOilMixture.ContainerFilter = container => !(container is CirculationBehaviour);
|
|
|
|
LiquidMixingController.MixInstructions.Add(bloodOilMixture);
|
|
}
|
|
}
|
|
} |