From b278eb43937eb2cfed7c5bd6ff9e9a410e91071f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Sun, 1 May 2022 19:20:55 +0200 Subject: [PATCH] New WTRV + BCOL -> OIL reaction in presence of PTNM Yes, Factorio is a good game. --- src/simulation/elements/PTNM.cpp | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/simulation/elements/PTNM.cpp b/src/simulation/elements/PTNM.cpp index 184bf76ad..34acfe507 100644 --- a/src/simulation/elements/PTNM.cpp +++ b/src/simulation/elements/PTNM.cpp @@ -48,6 +48,31 @@ void Element::Element_PTNM() Create = &create; } +static void wtrv_reactions(int wtrv1_id, UPDATE_FUNC_ARGS) +{ + for (int rx = -1; rx <= 1; rx++) + { + for (int ry = -1; ry <= 1; ry++) + { + if (BOUNDS_CHECK && (rx || ry)) + { + int r = pmap[y + ry][x + rx]; + if (!r || ID(r) == wtrv1_id) + continue; + int rt = TYP(r); + + // WTRV + BCOL -> OIL + if (rt == PT_BCOL && parts[ID(r)].temp > 200.0f + 273.15f && parts[wtrv1_id].temp > 200.0f + 273.15f && sim->pv[(y + ry) / CELL][(x + rx) / CELL] > 7.f) + { + sim->part_change_type(ID(r), x + rx, y + ry, PT_OIL); + sim->kill_part(wtrv1_id); + return; + } + } + } + } +} + static void hygn_reactions(int hygn1_id, UPDATE_FUNC_ARGS) { for (int rx = -1; rx <= 1; rx++) @@ -116,6 +141,7 @@ static void hygn_reactions(int hygn1_id, UPDATE_FUNC_ARGS) static int update(UPDATE_FUNC_ARGS) { int hygn1_id = -1; // Id of a hydrogen particle for hydrogen multi-particle reactions + int wtrv1_id = -1; // same but wtrv // Fast conduction (like GOLD) if (!parts[i].life) @@ -151,6 +177,9 @@ static int update(UPDATE_FUNC_ARGS) if (rt == PT_H2 && hygn1_id < 0) hygn1_id = ID(r); + if (rt == PT_WTRV && wtrv1_id < 0) + wtrv1_id = ID(r); + // These reactions will occur instantly in contact with PTNM // -------------------------------------------------------- @@ -219,6 +248,12 @@ static int update(UPDATE_FUNC_ARGS) hygn_reactions(hygn1_id, UPDATE_FUNC_SUBCALL_ARGS); } + // WTRV reactions + if (wtrv1_id >= 0) + { + wtrv_reactions(wtrv1_id, UPDATE_FUNC_SUBCALL_ARGS); + } + return 0; }