Barotrauma

Barotrauma

More Signal Components
fatherg.m  [developer] 16 Jun, 2024 @ 6:18am
Gameplay Question
Guide
I'll put some explanations to some of the not-so-straightforward components here.

`states` refers to if `id` received a signal. `id` is connection id.

Imply Component
https://simple.wikipedia.org/wiki/Implication_(logic)

Edge Detector

bool a = val != Zero && prev[id] == Zero; prev[id] = val; return a ? TrueOutput : FalseOutput;

Chain Comps


double prev = inputs[0];
for (byte i = 0; i < outputs.Length; ++i)
if (states[i] && states[i + 1])
{
prev = calc(prev, inputs[i + 1]);
item.SendSignal(new Signal(prev.ToString("G", CultureInfo.InvariantCulture), sender: senders[i], source: item), outputs[i]);
}
else
break;

Batch Greater Than Comparator

string z = null; if (float.TryParse(val, NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite | NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture, out float b)) { float a = shared; if (Reverse) (a, b) = (b, a); z = a > b ? TrueOutput : FalseOutput; } return z;

ARC
https://barotraumagame.com/wiki/Nuclear_Reactor#Circuit_Control
`idel turbine rate` is useful to prevent overheating on cold start when you suddenly put in 4 volatile fulgurium fuel rods.

float turbine, fission; if (cool) { turbine = 100f; fission = 0f; } else if (heatPotential > 0) { turbine = Math.Min(load / maxPower, 1f) * 100f; fission = turbine * balFac / heatPotential; } else { fission = 0f; turbine = idelTurbineRate; }

Voltage Analyzer
Used to be build battery buffer. Result is the amount of power needed to achieve stable voltage. When result<0, we need more load; when result>0, we need more power. Also, when building actual battery buffer, make sure to use real grid load and power as inputs(without influences caused by batteries).

int need; Signal sig = new(null, sender: senders[0] ?? senders[1], source: item); if (load > 0) { Half volt = (Half)((float)power / load); if (volt >= overvolt) need = (int)Math.Round(load * highvolt - power);//(power+a)/load=highvolt else if (volt <= undervolt) need = (int)Math.Round(load * lowvolt - power);//(power+a)/load=lowvolt else need = 0; sig.value = volt.ToString("G", CultureInfo.InvariantCulture); item.SendSignal(sig, "volt_out"); } else need = -power; sig.value = need.ToString("G", CultureInfo.InvariantCulture); item.SendSignal(sig, "res_out");

Airlock Controller
Sends a closing pulse to this door when other door opens, so depending on your config, you can connect `door_control` to either `toggle_state` or `set_state`. `pump_control` outputs continuously signal to control the pump. Pump is "turned on" when outer door is closed and water is detected; otherwise it's "off". All inputs requires continuous inputs.

case "in_state_in": {//when door_in opened and door_out is open, close door_out. bool a = Utils.Quantize(signal.value); if (IsOn && a && !innerDoorState) if (outerDoorState) if (!string.IsNullOrEmpty(signal.value = CloseOutput)) item.SendSignal(signal, "out_ctrl_out"); innerDoorState = a; } break; case "out_state_in": {//when door_out opend and door_in is open, close door_in bool a = Utils.Quantize(signal.value); if (IsOn && a && !outerDoorState) if (innerDoorState) if (!string.IsNullOrEmpty(signal.value = CloseOutput)) item.SendSignal(signal, "in_ctrl_out"); outerDoorState = a; } break; case "water_in"://when there's water and door_out is closed, turn on pump. if (IsOn) { signal.value = Utils.Quantize(signal.value) && !outerDoorState ? PumpOnOutput : PumpOffOutput; if (!string.IsNullOrEmpty(signal.value)) item.SendSignal(signal, "pump_out"); } break;

Helm Component
https://github.com/FakeFishGames/Barotrauma/blob/4a63dacbcee8e3829a44e9c16a5335704a979a4d/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Machines/Steering.cs#L713
Algorithm is enhanced upon the above algorithm using customizable stats of your sub. All `max_speed` input must be positive. Concat `vel_ctrl_x` with `vel_ctrl_y` using a ',' then use this as input to `vel_in` of nav term(similar how you'd do it in vanilla).
Adaptive
Last edited by fatherg.m; 19 Jun, 2024 @ 6:25am
< >
Showing 1-2 of 2 comments
Nupaska 16 Jun, 2024 @ 7:23am 
[сode] (code) [/сode]
fatherg.m  [developer] 17 Jun, 2024 @ 5:46am 
Originally posted by Nupaska:
[сode] (code) [/сode]
Thank you
< >
Showing 1-2 of 2 comments
Per page: 1530 50