From 78bc86d107b24a88da1ca7c95d858899870eddb7 Mon Sep 17 00:00:00 2001 From: Saveliy Skresanov Date: Mon, 2 Oct 2023 22:41:22 +0700 Subject: [PATCH] Add ctype mechanics. --- src/simulation/elements/NEUT.cpp | 19 ++++++++++++++++++- src/simulation/elements/PHOT.cpp | 20 ++++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/simulation/elements/NEUT.cpp b/src/simulation/elements/NEUT.cpp index d367556a5..1652e4fda 100644 --- a/src/simulation/elements/NEUT.cpp +++ b/src/simulation/elements/NEUT.cpp @@ -167,8 +167,25 @@ static int update(UPDATE_FUNC_ARGS) case PT_RSSS: if(!rx && !ry) { - sim->part_change_type(ID(r), x, y, PT_RSST); + int ct_under, tmp_under; + + ct_under = parts[ID(r)].ctype; + tmp_under = parts[ID(r)].tmp; + + //If there's a correct ctype set, use it + if(ct_under > 0 && ct_under < PT_NUM) + { + sim->create_part(ID(r), x, y, ct_under); + + //If there's a correct tmp set, use it for ctype + if(tmp_under > 0 && ct_under < PT_NUM) + parts[ID(r)].ctype = tmp_under; + } + else + sim->part_change_type(ID(r), x, y, PT_RSST); + sim->kill_part(i); + return 1; } break; diff --git a/src/simulation/elements/PHOT.cpp b/src/simulation/elements/PHOT.cpp index 74b03d395..524b06832 100644 --- a/src/simulation/elements/PHOT.cpp +++ b/src/simulation/elements/PHOT.cpp @@ -107,9 +107,25 @@ static int update(UPDATE_FUNC_ARGS) parts[i].vx = vx; parts[i].vy = vy; } - else if(TYP(r) == PT_RSST && !ry && !rx)//if on RSST + else if(TYP(r) == PT_RSST && !ry && !rx)//if on RSST, make it solid { - sim->part_change_type(ID(r),x,y,PT_RSSS); + int ct_under, tmp_under; + + ct_under = parts[ID(r)].ctype; + tmp_under = parts[ID(r)].tmp; + + //If there's a correct ctype set, use it + if(ct_under > 0 && ct_under < PT_NUM) + { + sim->create_part(ID(r), x, y, ct_under); + + //If there's a correct tmp set, use it for ctype + if(tmp_under > 0 && ct_under < PT_NUM) + parts[ID(r)].ctype = tmp_under; + } + else + sim->part_change_type(ID(r), x, y, PT_RSSS); + sim->kill_part(i); return 1;