From 51b17badf4c72270bb762ea795d05d51c8b355e3 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Mon, 7 May 2012 17:59:50 +0100 Subject: [PATCH] A bit of refactoring (elements) --- Makefile | 15 +- generator.py | 78 +++ src/Console.cpp | 2 +- src/Graphics.cpp | 2 +- src/Misc.cpp | 2 +- src/Renderer.cpp | 61 +- src/cat/CommandInterface.cpp | 4 +- src/cat/LuaScriptInterface.cpp | 38 +- src/elements/O2.cpp | 30 - src/elements/acel.cpp | 58 -- src/elements/acid.cpp | 76 --- src/elements/amtr.cpp | 28 - src/elements/anar.cpp | 27 - src/elements/bcln.cpp | 40 -- src/elements/bcol.cpp | 68 --- src/elements/bizr.cpp | 44 -- src/elements/bmtl.cpp | 29 - src/elements/brmt.cpp | 34 -- src/elements/btry.cpp | 24 - src/elements/c5.cpp | 24 - src/elements/caus.cpp | 35 -- src/elements/clne.cpp | 32 -- src/elements/clst.cpp | 38 -- src/elements/coal.cpp | 75 --- src/elements/dest.cpp | 66 --- src/elements/dlay.cpp | 48 -- src/elements/dstw.cpp | 39 -- src/elements/elementmisc.cpp | 12 - src/elements/fire.cpp | 19 - src/elements/firw.cpp | 65 --- src/elements/fog.cpp | 22 - src/elements/fray.cpp | 29 - src/elements/frzw.cpp | 30 - src/elements/frzz.cpp | 25 - src/elements/fsep.cpp | 35 -- src/elements/fuse.cpp | 41 -- src/elements/gbmb.cpp | 26 - src/elements/gel.cpp | 68 --- src/elements/glas.cpp | 11 - src/elements/glow.cpp | 28 - src/elements/goo.cpp | 13 - src/elements/gpmp.cpp | 34 -- src/elements/graphics_default.cpp | 23 - src/elements/hswc.cpp | 26 - src/elements/ice.cpp | 23 - src/elements/ignt.cpp | 44 -- src/elements/iron.cpp | 25 - src/elements/isz.cpp | 14 - src/elements/lava.cpp | 19 - src/elements/lcry.cpp | 61 -- src/elements/legacy.cpp | 120 ---- src/elements/mort.cpp | 6 - src/elements/nbhl.cpp | 6 - src/elements/nble.cpp | 27 - src/elements/newgraphics.cpp | 542 ------------------ src/elements/none.cpp | 6 - src/elements/nptct.cpp | 7 - src/elements/nwhl.cpp | 6 - src/elements/plsm.cpp | 20 - src/elements/plut.cpp | 9 - src/elements/prti.cpp | 80 --- src/elements/pump.cpp | 41 -- src/elements/pvod.cpp | 30 - src/elements/qrtz.cpp | 94 --- src/elements/repl.cpp | 22 - src/elements/rime.cpp | 26 - src/elements/shld.cpp | 162 ------ src/elements/sltw.cpp | 30 - src/elements/smke.cpp | 18 - src/elements/stkm2.cpp | 29 - src/elements/stor.cpp | 43 -- src/elements/thdr.cpp | 38 -- src/elements/thrm.cpp | 29 - src/elements/uran.cpp | 10 - src/elements/vine.cpp | 19 - src/elements/warp.cpp | 28 - src/elements/watr.cpp | 37 -- src/elements/wifi.cpp | 36 -- src/elements/wire.cpp | 72 --- src/elements/wtrv.cpp | 22 - src/elements/yest.cpp | 21 - src/game/EllipseBrush.h | 3 +- src/game/GameController.cpp | 4 +- src/game/GameModel.cpp | 10 +- src/interface/Spinner.cpp | 2 +- src/search/SearchModel.h | 2 +- src/simulation/Air.cpp | 2 +- src/simulation/Element.h | 13 +- src/simulation/ElementFunctions.h | 175 ------ src/simulation/Elements.h | 184 +----- src/simulation/Gravity.cpp | 8 +- src/simulation/SaveLoader.cpp | 6 +- src/simulation/Simulation.cpp | 297 +++++----- src/simulation/Simulation.h | 5 +- src/simulation/SimulationData.cpp | 27 +- src/simulation/SimulationData.h | 6 + src/simulation/elements/116.cpp | 49 ++ src/simulation/elements/144.cpp | 49 ++ src/simulation/elements/145.cpp | 49 ++ src/simulation/elements/146.cpp | 49 ++ src/simulation/elements/147.cpp | 49 ++ src/simulation/elements/ACEL.cpp | 85 +++ src/simulation/elements/ACID.cpp | 144 +++++ src/simulation/elements/AMTR.cpp | 79 +++ src/simulation/elements/ANAR.cpp | 78 +++ .../aray.cpp => simulation/elements/ARAY.cpp} | 57 +- .../bang.cpp => simulation/elements/BANG.cpp} | 55 +- src/simulation/elements/BCLN.cpp | 91 +++ src/simulation/elements/BCOL.cpp | 146 +++++ src/simulation/elements/BGLA.cpp | 49 ++ src/simulation/elements/BHOL.cpp | 49 ++ src/simulation/elements/BIZR.cpp | 124 ++++ src/simulation/elements/BIZRG.cpp | 124 ++++ src/simulation/elements/BIZRS.cpp | 124 ++++ src/simulation/elements/BMTL.cpp | 80 +++ .../bomb.cpp => simulation/elements/BOMB.cpp} | 63 +- .../boyl.cpp => simulation/elements/BOYL.cpp} | 55 +- src/simulation/elements/BRAY.cpp | 109 ++++ src/simulation/elements/BRCK.cpp | 49 ++ src/simulation/elements/BREC.cpp | 49 ++ src/simulation/elements/BRMT.cpp | 85 +++ src/simulation/elements/BTRY.cpp | 75 +++ src/simulation/elements/C5.cpp | 75 +++ src/simulation/elements/CAUS.cpp | 86 +++ .../cbnw.cpp => simulation/elements/CBNW.cpp} | 71 ++- src/simulation/elements/CLNE.cpp | 83 +++ src/simulation/elements/CLST.cpp | 101 ++++ src/simulation/elements/CNCT.cpp | 49 ++ .../co2.cpp => simulation/elements/CO2.cpp} | 55 +- src/simulation/elements/COAL.cpp | 153 +++++ .../conv.cpp => simulation/elements/CONV.cpp} | 55 +- src/simulation/elements/DESL.cpp | 49 ++ src/simulation/elements/DEST.cpp | 121 ++++ .../deut.cpp => simulation/elements/DEUT.cpp} | 61 +- src/simulation/elements/DLAY.cpp | 111 ++++ src/simulation/elements/DMND.cpp | 49 ++ src/simulation/elements/DRIC.cpp | 49 ++ src/simulation/elements/DSTW.cpp | 90 +++ src/simulation/elements/DUST.cpp | 76 +++ src/simulation/elements/DYST.cpp | 49 ++ .../elec.cpp => simulation/elements/ELEC.cpp} | 63 +- .../emp.cpp => simulation/elements/EMP.cpp} | 63 +- src/simulation/elements/ETRD.cpp | 49 ++ src/simulation/elements/Element.cpp | 69 +++ src/simulation/elements/Element.h | 56 ++ .../figh.cpp => simulation/elements/FIGH.cpp} | 73 ++- src/simulation/elements/FILT.cpp | 77 +++ .../pyro.cpp => simulation/elements/FIRE.cpp} | 92 ++- src/simulation/elements/FIRW.cpp | 154 +++++ src/simulation/elements/FOG.cpp | 73 +++ src/simulation/elements/FRAY.cpp | 80 +++ src/simulation/elements/FRZW.cpp | 81 +++ src/simulation/elements/FRZZ.cpp | 76 +++ src/simulation/elements/FSEP.cpp | 86 +++ src/simulation/elements/FUSE.cpp | 92 +++ .../fwrk.cpp => simulation/elements/FWRK.cpp} | 55 +- src/simulation/elements/GAS.cpp | 49 ++ src/simulation/elements/GBMB.cpp | 93 +++ src/simulation/elements/GEL.cpp | 123 ++++ src/simulation/elements/GLAS.cpp | 62 ++ src/simulation/elements/GLOW.cpp | 96 ++++ src/simulation/elements/GOO.cpp | 64 +++ src/simulation/elements/GPMP.cpp | 96 ++++ src/simulation/elements/GRAV.cpp | 101 ++++ src/simulation/elements/GUNP.cpp | 49 ++ .../h2.cpp => simulation/elements/H2.cpp} | 55 +- src/simulation/elements/HFLM.cpp | 70 +++ src/simulation/elements/HSWC.cpp | 87 +++ src/simulation/elements/ICEI.cpp | 74 +++ src/simulation/elements/IGNT.cpp | 95 +++ src/simulation/elements/INSL.cpp | 49 ++ src/simulation/elements/INST.cpp | 49 ++ src/simulation/elements/INVIS.cpp | 67 +++ src/simulation/elements/INWR.cpp | 49 ++ src/simulation/elements/IRON.cpp | 76 +++ src/simulation/elements/ISOZ.cpp | 65 +++ src/simulation/elements/ISZS.cpp | 65 +++ src/simulation/elements/LAVA.cpp | 71 +++ src/simulation/elements/LCRY.cpp | 154 +++++ src/simulation/elements/LIFE.cpp | 106 ++++ .../ligh.cpp => simulation/elements/LIGH.cpp} | 263 +++++---- src/simulation/elements/LNTG.cpp | 49 ++ src/simulation/elements/LO2.cpp | 49 ++ src/simulation/elements/LOLZ.cpp | 63 ++ src/simulation/elements/LOVE.cpp | 63 ++ src/simulation/elements/LRBD.cpp | 49 ++ .../merc.cpp => simulation/elements/MERC.cpp} | 55 +- src/simulation/elements/METL.cpp | 49 ++ src/simulation/elements/MORT.cpp | 57 ++ src/simulation/elements/MWAX.cpp | 49 ++ src/simulation/elements/NBHL.cpp | 57 ++ src/simulation/elements/NBLE.cpp | 78 +++ .../neut.cpp => simulation/elements/NEUT.cpp} | 151 +++-- src/simulation/elements/NICE.cpp | 49 ++ src/simulation/elements/NITR.cpp | 49 ++ src/simulation/elements/NONE.cpp | 49 ++ src/simulation/elements/NSCN.cpp | 49 ++ src/simulation/elements/NTCT.cpp | 58 ++ src/simulation/elements/NWHL.cpp | 57 ++ src/simulation/elements/O2.cpp | 81 +++ src/simulation/elements/OIL.cpp | 49 ++ .../pbcn.cpp => simulation/elements/PBCN.cpp} | 66 ++- .../pcln.cpp => simulation/elements/PCLN.cpp} | 66 ++- .../phot.cpp => simulation/elements/PHOT.cpp} | 63 +- .../pipe.cpp => simulation/elements/PIPE.cpp} | 216 ++++--- src/simulation/elements/PLEX.cpp | 49 ++ .../plnt.cpp => simulation/elements/PLNT.cpp} | 55 +- src/simulation/elements/PLSM.cpp | 70 +++ src/simulation/elements/PLUT.cpp | 60 ++ src/simulation/elements/PQRT.cpp | 168 ++++++ src/simulation/elements/PRTI.cpp | 139 +++++ .../prto.cpp => simulation/elements/PRTO.cpp} | 78 ++- src/simulation/elements/PSCN.cpp | 49 ++ src/simulation/elements/PSTE.cpp | 49 ++ src/simulation/elements/PSTS.cpp | 49 ++ src/simulation/elements/PTCT.cpp | 58 ++ src/simulation/elements/PUMP.cpp | 102 ++++ src/simulation/elements/PVOD.cpp | 91 +++ src/simulation/elements/QRTZ.cpp | 168 ++++++ src/simulation/elements/RBDM.cpp | 49 ++ src/simulation/elements/REPL.cpp | 73 +++ src/simulation/elements/RIME.cpp | 77 +++ src/simulation/elements/SALT.cpp | 49 ++ src/simulation/elements/SAND.cpp | 49 ++ src/simulation/elements/SHLD1.cpp | 88 +++ src/simulation/elements/SHLD2.cpp | 91 +++ src/simulation/elements/SHLD3.cpp | 101 ++++ src/simulation/elements/SHLD4.cpp | 92 +++ .../sing.cpp => simulation/elements/SING.cpp} | 55 +- src/simulation/elements/SLTW.cpp | 81 +++ src/simulation/elements/SMKE.cpp | 68 +++ src/simulation/elements/SNOW.cpp | 74 +++ .../soap.cpp => simulation/elements/SOAP.cpp} | 57 +- src/simulation/elements/SPAWN.cpp | 60 ++ src/simulation/elements/SPAWN2.cpp | 60 ++ .../spng.cpp => simulation/elements/SPNG.cpp} | 72 ++- .../sprk.cpp => simulation/elements/SPRK.cpp} | 67 ++- .../stkm.cpp => simulation/elements/STKM.cpp} | 105 +++- src/simulation/elements/STKM2.cpp | 77 +++ src/simulation/elements/STNE.cpp | 49 ++ src/simulation/elements/STOR.cpp | 112 ++++ .../swch.cpp => simulation/elements/SWCH.cpp} | 70 ++- src/simulation/elements/TESC.cpp | 49 ++ src/simulation/elements/THDR.cpp | 102 ++++ src/simulation/elements/THRM.cpp | 80 +++ .../tron.cpp => simulation/elements/TRON.cpp} | 290 ++++++---- src/simulation/elements/URAN.cpp | 61 ++ src/simulation/elements/VINE.cpp | 70 +++ src/simulation/elements/VOID.cpp | 49 ++ src/simulation/elements/WARP.cpp | 79 +++ src/simulation/elements/WATR.cpp | 87 +++ src/simulation/elements/WAX.cpp | 49 ++ src/simulation/elements/WHOL.cpp | 49 ++ src/simulation/elements/WIFI.cpp | 100 ++++ src/simulation/elements/WIRE.cpp | 127 ++++ src/simulation/elements/WOOD.cpp | 49 ++ src/simulation/elements/WTRV.cpp | 73 +++ src/simulation/elements/YEST.cpp | 72 +++ src/simulation/elements/dcel.cpp | 85 +++ src/stamps/StampsModel.h | 2 +- 260 files changed, 12606 insertions(+), 4204 deletions(-) create mode 100644 generator.py delete mode 100644 src/elements/O2.cpp delete mode 100644 src/elements/acel.cpp delete mode 100644 src/elements/acid.cpp delete mode 100644 src/elements/amtr.cpp delete mode 100644 src/elements/anar.cpp delete mode 100644 src/elements/bcln.cpp delete mode 100644 src/elements/bcol.cpp delete mode 100644 src/elements/bizr.cpp delete mode 100644 src/elements/bmtl.cpp delete mode 100644 src/elements/brmt.cpp delete mode 100644 src/elements/btry.cpp delete mode 100644 src/elements/c5.cpp delete mode 100644 src/elements/caus.cpp delete mode 100644 src/elements/clne.cpp delete mode 100644 src/elements/clst.cpp delete mode 100644 src/elements/coal.cpp delete mode 100644 src/elements/dest.cpp delete mode 100644 src/elements/dlay.cpp delete mode 100644 src/elements/dstw.cpp delete mode 100644 src/elements/elementmisc.cpp delete mode 100644 src/elements/fire.cpp delete mode 100644 src/elements/firw.cpp delete mode 100644 src/elements/fog.cpp delete mode 100644 src/elements/fray.cpp delete mode 100644 src/elements/frzw.cpp delete mode 100644 src/elements/frzz.cpp delete mode 100644 src/elements/fsep.cpp delete mode 100644 src/elements/fuse.cpp delete mode 100644 src/elements/gbmb.cpp delete mode 100644 src/elements/gel.cpp delete mode 100644 src/elements/glas.cpp delete mode 100644 src/elements/glow.cpp delete mode 100644 src/elements/goo.cpp delete mode 100644 src/elements/gpmp.cpp delete mode 100644 src/elements/graphics_default.cpp delete mode 100644 src/elements/hswc.cpp delete mode 100644 src/elements/ice.cpp delete mode 100644 src/elements/ignt.cpp delete mode 100644 src/elements/iron.cpp delete mode 100644 src/elements/isz.cpp delete mode 100644 src/elements/lava.cpp delete mode 100644 src/elements/lcry.cpp delete mode 100644 src/elements/legacy.cpp delete mode 100644 src/elements/mort.cpp delete mode 100644 src/elements/nbhl.cpp delete mode 100644 src/elements/nble.cpp delete mode 100644 src/elements/newgraphics.cpp delete mode 100644 src/elements/none.cpp delete mode 100644 src/elements/nptct.cpp delete mode 100644 src/elements/nwhl.cpp delete mode 100644 src/elements/plsm.cpp delete mode 100644 src/elements/plut.cpp delete mode 100644 src/elements/prti.cpp delete mode 100644 src/elements/pump.cpp delete mode 100644 src/elements/pvod.cpp delete mode 100644 src/elements/qrtz.cpp delete mode 100644 src/elements/repl.cpp delete mode 100644 src/elements/rime.cpp delete mode 100644 src/elements/shld.cpp delete mode 100644 src/elements/sltw.cpp delete mode 100644 src/elements/smke.cpp delete mode 100644 src/elements/stkm2.cpp delete mode 100644 src/elements/stor.cpp delete mode 100644 src/elements/thdr.cpp delete mode 100644 src/elements/thrm.cpp delete mode 100644 src/elements/uran.cpp delete mode 100644 src/elements/vine.cpp delete mode 100644 src/elements/warp.cpp delete mode 100644 src/elements/watr.cpp delete mode 100644 src/elements/wifi.cpp delete mode 100644 src/elements/wire.cpp delete mode 100644 src/elements/wtrv.cpp delete mode 100644 src/elements/yest.cpp delete mode 100644 src/simulation/ElementFunctions.h create mode 100644 src/simulation/elements/116.cpp create mode 100644 src/simulation/elements/144.cpp create mode 100644 src/simulation/elements/145.cpp create mode 100644 src/simulation/elements/146.cpp create mode 100644 src/simulation/elements/147.cpp create mode 100644 src/simulation/elements/ACEL.cpp create mode 100644 src/simulation/elements/ACID.cpp create mode 100644 src/simulation/elements/AMTR.cpp create mode 100644 src/simulation/elements/ANAR.cpp rename src/{elements/aray.cpp => simulation/elements/ARAY.cpp} (73%) rename src/{elements/bang.cpp => simulation/elements/BANG.cpp} (53%) create mode 100644 src/simulation/elements/BCLN.cpp create mode 100644 src/simulation/elements/BCOL.cpp create mode 100644 src/simulation/elements/BGLA.cpp create mode 100644 src/simulation/elements/BHOL.cpp create mode 100644 src/simulation/elements/BIZR.cpp create mode 100644 src/simulation/elements/BIZRG.cpp create mode 100644 src/simulation/elements/BIZRS.cpp create mode 100644 src/simulation/elements/BMTL.cpp rename src/{elements/bomb.cpp => simulation/elements/BOMB.cpp} (61%) rename src/{elements/boyl.cpp => simulation/elements/BOYL.cpp} (52%) create mode 100644 src/simulation/elements/BRAY.cpp create mode 100644 src/simulation/elements/BRCK.cpp create mode 100644 src/simulation/elements/BREC.cpp create mode 100644 src/simulation/elements/BRMT.cpp create mode 100644 src/simulation/elements/BTRY.cpp create mode 100644 src/simulation/elements/C5.cpp create mode 100644 src/simulation/elements/CAUS.cpp rename src/{elements/cbnw.cpp => simulation/elements/CBNW.cpp} (52%) create mode 100644 src/simulation/elements/CLNE.cpp create mode 100644 src/simulation/elements/CLST.cpp create mode 100644 src/simulation/elements/CNCT.cpp rename src/{elements/co2.cpp => simulation/elements/CO2.cpp} (51%) create mode 100644 src/simulation/elements/COAL.cpp rename src/{elements/conv.cpp => simulation/elements/CONV.cpp} (50%) create mode 100644 src/simulation/elements/DESL.cpp create mode 100644 src/simulation/elements/DEST.cpp rename src/{elements/deut.cpp => simulation/elements/DEUT.cpp} (60%) create mode 100644 src/simulation/elements/DLAY.cpp create mode 100644 src/simulation/elements/DMND.cpp create mode 100644 src/simulation/elements/DRIC.cpp create mode 100644 src/simulation/elements/DSTW.cpp create mode 100644 src/simulation/elements/DUST.cpp create mode 100644 src/simulation/elements/DYST.cpp rename src/{elements/elec.cpp => simulation/elements/ELEC.cpp} (60%) rename src/{elements/emp.cpp => simulation/elements/EMP.cpp} (70%) create mode 100644 src/simulation/elements/ETRD.cpp create mode 100644 src/simulation/elements/Element.cpp create mode 100644 src/simulation/elements/Element.h rename src/{elements/figh.cpp => simulation/elements/FIGH.cpp} (58%) create mode 100644 src/simulation/elements/FILT.cpp rename src/{elements/pyro.cpp => simulation/elements/FIRE.cpp} (52%) create mode 100644 src/simulation/elements/FIRW.cpp create mode 100644 src/simulation/elements/FOG.cpp create mode 100644 src/simulation/elements/FRAY.cpp create mode 100644 src/simulation/elements/FRZW.cpp create mode 100644 src/simulation/elements/FRZZ.cpp create mode 100644 src/simulation/elements/FSEP.cpp create mode 100644 src/simulation/elements/FUSE.cpp rename src/{elements/fwrk.cpp => simulation/elements/FWRK.cpp} (51%) create mode 100644 src/simulation/elements/GAS.cpp create mode 100644 src/simulation/elements/GBMB.cpp create mode 100644 src/simulation/elements/GEL.cpp create mode 100644 src/simulation/elements/GLAS.cpp create mode 100644 src/simulation/elements/GLOW.cpp create mode 100644 src/simulation/elements/GOO.cpp create mode 100644 src/simulation/elements/GPMP.cpp create mode 100644 src/simulation/elements/GRAV.cpp create mode 100644 src/simulation/elements/GUNP.cpp rename src/{elements/h2.cpp => simulation/elements/H2.cpp} (60%) create mode 100644 src/simulation/elements/HFLM.cpp create mode 100644 src/simulation/elements/HSWC.cpp create mode 100644 src/simulation/elements/ICEI.cpp create mode 100644 src/simulation/elements/IGNT.cpp create mode 100644 src/simulation/elements/INSL.cpp create mode 100644 src/simulation/elements/INST.cpp create mode 100644 src/simulation/elements/INVIS.cpp create mode 100644 src/simulation/elements/INWR.cpp create mode 100644 src/simulation/elements/IRON.cpp create mode 100644 src/simulation/elements/ISOZ.cpp create mode 100644 src/simulation/elements/ISZS.cpp create mode 100644 src/simulation/elements/LAVA.cpp create mode 100644 src/simulation/elements/LCRY.cpp create mode 100644 src/simulation/elements/LIFE.cpp rename src/{elements/ligh.cpp => simulation/elements/LIGH.cpp} (73%) create mode 100644 src/simulation/elements/LNTG.cpp create mode 100644 src/simulation/elements/LO2.cpp create mode 100644 src/simulation/elements/LOLZ.cpp create mode 100644 src/simulation/elements/LOVE.cpp create mode 100644 src/simulation/elements/LRBD.cpp rename src/{elements/merc.cpp => simulation/elements/MERC.cpp} (55%) create mode 100644 src/simulation/elements/METL.cpp create mode 100644 src/simulation/elements/MORT.cpp create mode 100644 src/simulation/elements/MWAX.cpp create mode 100644 src/simulation/elements/NBHL.cpp create mode 100644 src/simulation/elements/NBLE.cpp rename src/{elements/neut.cpp => simulation/elements/NEUT.cpp} (67%) create mode 100644 src/simulation/elements/NICE.cpp create mode 100644 src/simulation/elements/NITR.cpp create mode 100644 src/simulation/elements/NONE.cpp create mode 100644 src/simulation/elements/NSCN.cpp create mode 100644 src/simulation/elements/NTCT.cpp create mode 100644 src/simulation/elements/NWHL.cpp create mode 100644 src/simulation/elements/O2.cpp create mode 100644 src/simulation/elements/OIL.cpp rename src/{elements/pbcn.cpp => simulation/elements/PBCN.cpp} (62%) rename src/{elements/pcln.cpp => simulation/elements/PCLN.cpp} (60%) rename src/{elements/phot.cpp => simulation/elements/PHOT.cpp} (56%) rename src/{elements/pipe.cpp => simulation/elements/PIPE.cpp} (77%) create mode 100644 src/simulation/elements/PLEX.cpp rename src/{elements/plnt.cpp => simulation/elements/PLNT.cpp} (51%) create mode 100644 src/simulation/elements/PLSM.cpp create mode 100644 src/simulation/elements/PLUT.cpp create mode 100644 src/simulation/elements/PQRT.cpp create mode 100644 src/simulation/elements/PRTI.cpp rename src/{elements/prto.cpp => simulation/elements/PRTO.cpp} (69%) create mode 100644 src/simulation/elements/PSCN.cpp create mode 100644 src/simulation/elements/PSTE.cpp create mode 100644 src/simulation/elements/PSTS.cpp create mode 100644 src/simulation/elements/PTCT.cpp create mode 100644 src/simulation/elements/PUMP.cpp create mode 100644 src/simulation/elements/PVOD.cpp create mode 100644 src/simulation/elements/QRTZ.cpp create mode 100644 src/simulation/elements/RBDM.cpp create mode 100644 src/simulation/elements/REPL.cpp create mode 100644 src/simulation/elements/RIME.cpp create mode 100644 src/simulation/elements/SALT.cpp create mode 100644 src/simulation/elements/SAND.cpp create mode 100644 src/simulation/elements/SHLD1.cpp create mode 100644 src/simulation/elements/SHLD2.cpp create mode 100644 src/simulation/elements/SHLD3.cpp create mode 100644 src/simulation/elements/SHLD4.cpp rename src/{elements/sing.cpp => simulation/elements/SING.cpp} (70%) create mode 100644 src/simulation/elements/SLTW.cpp create mode 100644 src/simulation/elements/SMKE.cpp create mode 100644 src/simulation/elements/SNOW.cpp rename src/{elements/soap.cpp => simulation/elements/SOAP.cpp} (79%) create mode 100644 src/simulation/elements/SPAWN.cpp create mode 100644 src/simulation/elements/SPAWN2.cpp rename src/{elements/spng.cpp => simulation/elements/SPNG.cpp} (60%) rename src/{elements/sprk.cpp => simulation/elements/SPRK.cpp} (82%) rename src/{elements/stkm.cpp => simulation/elements/STKM.cpp} (79%) create mode 100644 src/simulation/elements/STKM2.cpp create mode 100644 src/simulation/elements/STNE.cpp create mode 100644 src/simulation/elements/STOR.cpp rename src/{elements/swch.cpp => simulation/elements/SWCH.cpp} (51%) create mode 100644 src/simulation/elements/TESC.cpp create mode 100644 src/simulation/elements/THDR.cpp create mode 100644 src/simulation/elements/THRM.cpp rename src/{elements/tron.cpp => simulation/elements/TRON.cpp} (68%) create mode 100644 src/simulation/elements/URAN.cpp create mode 100644 src/simulation/elements/VINE.cpp create mode 100644 src/simulation/elements/VOID.cpp create mode 100644 src/simulation/elements/WARP.cpp create mode 100644 src/simulation/elements/WATR.cpp create mode 100644 src/simulation/elements/WAX.cpp create mode 100644 src/simulation/elements/WHOL.cpp create mode 100644 src/simulation/elements/WIFI.cpp create mode 100644 src/simulation/elements/WIRE.cpp create mode 100644 src/simulation/elements/WOOD.cpp create mode 100644 src/simulation/elements/WTRV.cpp create mode 100644 src/simulation/elements/YEST.cpp create mode 100644 src/simulation/elements/dcel.cpp diff --git a/Makefile b/Makefile index 42b299d31..8c7952e53 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,15 @@ -HEADERS := $(wildcard src/*.h) $(wildcard src/*/*.h) +HEADERS := $(wildcard src/*.h) $(wildcard src/*/*.h) $(wildcard generated/*.h) -SOURCES := $(wildcard src/*.cpp) $(wildcard src/*/*.cpp) +SOURCES := $(wildcard src/*.cpp) $(wildcard src/*/*.cpp) $(wildcard src/*/*/*.cpp) $(wildcard generated/*.cpp) OBJS := $(patsubst src/%.cpp,build/obj/%.o,$(SOURCES)) +NEWLINE := $(`echo "d\nd"`) +ELEMENTFILES := $(patsubst src/simulation/%,\#include "%"$(NEWLINE),$(wildcard src/simulation/elements/*.cpp)) +#ELEMENTFILES := \#include "elements/watr.cpp" + FOLDERS := -CFLAGS := -w -Isrc/ -Idata/ +CFLAGS := -w -Isrc/ -Idata/ -Igenerated/ OFLAGS := -fkeep-inline-functions CPPC := g++ @@ -59,7 +63,7 @@ buildpaths-powder: $(shell mkdir -p build/obj/powder/) $(shell mkdir -p $(sort $(dir $(patsubst build/obj/%.o,build/obj/powder/%.o,$(OBJS))))) -build/powder-x: buildpaths-powder-x $(patsubst build/obj/%.o,build/obj/powder-x/%.o,$(OBJS)) +build/powder-x: buildpaths-powder-x generate $(patsubst build/obj/%.o,build/obj/powder-x/%.o,$(OBJS)) $(CPPC) $(CFLAGS) $(OFLAGS) $(LDFLAGS) $(patsubst build/obj/%.o,build/obj/powder-x/%.o,$(OBJS)) SDLmain.m $(LFLAGS) -o $@ -ggdb build/obj/powder-x/%.o: src/%.cpp $(HEADERS) $(CPPC) -c $(CFLAGS) $(OFLAGS) -o $@ $< -ggdb @@ -67,6 +71,9 @@ buildpaths-powder-x: $(shell mkdir -p build/obj/powder-x/) $(shell mkdir -p $(sort $(dir $(patsubst build/obj/%.o,build/obj/powder-x/%.o,$(OBJS))))) +generate: + python generator.py + clean: rm -r build/obj/* rm build/*.exe diff --git a/generator.py b/generator.py new file mode 100644 index 000000000..dc975949b --- /dev/null +++ b/generator.py @@ -0,0 +1,78 @@ +import re, os, shutil, string + +if os.path.isdir("generated/"): + shutil.rmtree("generated/") +os.mkdir("generated") + +elementClasses = dict() + +elementHeader = """#ifndef ELEMENTCLASSES_H +#define ELEMENTCLASSES_H +#include +#include "simulation/Element.h" +#include "simulation/elements/Element.h" +""" + +directives = [] + +elementFiles = os.listdir("src/simulation/Elements") +for elementFile in elementFiles: + f = open("src/simulation/Elements/"+elementFile, "r") + fileData = f.read() + f.close() + + directiveMatcher = '//#TPT-Directive\s+([^\r\n]+)' + matcher = re.compile(directiveMatcher) + directiveMatches = matcher.findall(fileData) + + for match in directiveMatches: + directives.append(match.split(" ")) + +classDirectives = [] +for d in directives: + if d[0] == "ElementClass": + elementClasses[d[1]] = [] + elementHeader += "#define %s %s\n" % (d[2], d[3]) + d[3] = string.atoi(d[3]) + classDirectives.append(d) + +for d in directives: + if d[0] == "ElementHeader": + elementClasses[d[1]].append(string.join(d[2:], " ")+";") + +for className, classMembers in elementClasses.items(): + elementHeader += """class {0}: public Element +{{ + public: + {0}(); + virtual ~{0}(); + {1} +}}; +""".format(className, string.join(classMembers, "\n")) + +elementHeader += """std::vector GetElements(); +#endif +""" + +elementContent = """#include "ElementClasses.h" +std::vector GetElements() +{ + std::vector elements; +"""; + +elementIDs = sorted(classDirectives, key=lambda directive: directive[3]) +for d in elementIDs: + elementContent += """ elements.push_back(%s()); +""" % (d[1]) + +elementContent += """ return elements; +} +"""; + +f = open("generated/ElementClasses.h", "w") +f.write(elementHeader) +f.close() + +f = open("generated/ElementClasses.cpp", "w") +f.write(elementContent) +f.close() \ No newline at end of file diff --git a/src/Console.cpp b/src/Console.cpp index 51f1155d8..7f5870b4f 100644 --- a/src/Console.cpp +++ b/src/Console.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include "Console.h" int Console::ParsePartref(char * txt) diff --git a/src/Graphics.cpp b/src/Graphics.cpp index 665da67fe..13c0457d8 100644 --- a/src/Graphics.cpp +++ b/src/Graphics.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/src/Misc.cpp b/src/Misc.cpp index 920145a24..7dcb5fe29 100644 --- a/src/Misc.cpp +++ b/src/Misc.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include "Config.h" #include "Misc.h" #include "icondoc.h" diff --git a/src/Renderer.cpp b/src/Renderer.cpp index 3a29d2002..167b062cb 100644 --- a/src/Renderer.cpp +++ b/src/Renderer.cpp @@ -5,7 +5,7 @@ * Author: Simon */ -#include +#include #include #include #include @@ -14,7 +14,6 @@ #include "Renderer.h" #include "Graphics.h" #include "simulation/Elements.h" -#include "simulation/ElementFunctions.h" #include "simulation/ElementGraphics.h" #include "simulation/Air.h" extern "C" @@ -840,12 +839,11 @@ void Renderer::render_parts() float gradv, flicker, fnx, fny; Particle * parts; part_transition *ptransitions; - part_type *ptypes; + Element *elements; if(!sim) return; parts = sim->parts; - ptransitions = sim->ptransitions; - ptypes = sim->ptypes; + elements = sim->elements; #ifdef OGLR int cfireV = 0, cfireC = 0, cfire = 0; int csmokeV = 0, csmokeC = 0, csmoke = 0; @@ -884,15 +882,15 @@ void Renderer::render_parts() fnx = sim->parts[i].x; fny = sim->parts[i].y; - if((sim->photons[ny][nx]&0xFF) && !(ptypes[t].properties & TYPE_ENERGY)) + if((sim->photons[ny][nx]&0xFF) && !(elements[t].Properties & TYPE_ENERGY)) continue; //Defaults pixel_mode = 0 | PMODE_FLAT; cola = 255; - colr = PIXR(ptypes[t].pcolors); - colg = PIXG(ptypes[t].pcolors); - colb = PIXB(ptypes[t].pcolors); + colr = PIXR(elements[t].Colour); + colg = PIXG(elements[t].Colour); + colb = PIXB(elements[t].Colour); firea = 0; deca = (sim->parts[i].dcolour>>24)&0xFF; @@ -915,9 +913,9 @@ void Renderer::render_parts() } else if(!(colour_mode & COLOUR_BASC)) { - if (ptypes[t].graphics_func) + if (elements[t].Graphics) { - if ((*(ptypes[t].graphics_func))(this, &(sim->parts[i]), nx, ny, &pixel_mode, &cola, &colr, &colg, &colb, &firea, &firer, &fireg, &fireb)) //That's a lot of args, a struct might be better + if ((*(elements[t].Graphics))(this, &(sim->parts[i]), nx, ny, &pixel_mode, &cola, &colr, &colg, &colb, &firea, &firer, &fireg, &fireb)) //That's a lot of args, a struct might be better { graphicscache[t].isready = 1; graphicscache[t].pixel_mode = pixel_mode; @@ -933,25 +931,22 @@ void Renderer::render_parts() } else { - if(graphics_DEFAULT(this, &(sim->parts[i]), nx, ny, &pixel_mode, &cola, &colr, &colg, &colb, &firea, &firer, &fireg, &fireb)) - { - graphicscache[t].isready = 1; - graphicscache[t].pixel_mode = pixel_mode; - graphicscache[t].cola = cola; - graphicscache[t].colr = colr; - graphicscache[t].colg = colg; - graphicscache[t].colb = colb; - graphicscache[t].firea = firea; - graphicscache[t].firer = firer; - graphicscache[t].fireg = fireg; - graphicscache[t].fireb = fireb; - } + graphicscache[t].isready = 1; + graphicscache[t].pixel_mode = pixel_mode; + graphicscache[t].cola = cola; + graphicscache[t].colr = colr; + graphicscache[t].colg = colg; + graphicscache[t].colb = colb; + graphicscache[t].firea = firea; + graphicscache[t].firer = firer; + graphicscache[t].fireg = fireg; + graphicscache[t].fireb = fireb; } } - if((ptypes[t].properties & PROP_HOT_GLOW) && sim->parts[i].temp>(ptransitions[t].thv-800.0f)) + if((elements[t].Properties & PROP_HOT_GLOW) && sim->parts[i].temp>(elements[t].HighTemperature-800.0f)) { - gradv = 3.1415/(2*ptransitions[t].thv-(ptransitions[t].thv-800.0f)); - caddress = (sim->parts[i].temp>ptransitions[t].thv)?ptransitions[t].thv-(ptransitions[t].thv-800.0f):sim->parts[i].temp-(ptransitions[t].thv-800.0f); + gradv = 3.1415/(2*elements[t].HighTemperature-(elements[t].HighTemperature-800.0f)); + caddress = (sim->parts[i].temp>elements[t].HighTemperature)?elements[t].HighTemperature-(elements[t].HighTemperature-800.0f):sim->parts[i].temp-(elements[t].HighTemperature-800.0f); colr += sin(gradv*caddress) * 226;; colg += sin(gradv*caddress*4.55 +3.14) * 34; colb += sin(gradv*caddress*2.22 +3.14) * 64; @@ -994,9 +989,9 @@ void Renderer::render_parts() } else if(colour_mode & COLOUR_BASC) { - colr = PIXR(ptypes[t].pcolors); - colg = PIXG(ptypes[t].pcolors); - colb = PIXB(ptypes[t].pcolors); + colr = PIXR(elements[t].Colour); + colg = PIXG(elements[t].Colour); + colb = PIXB(elements[t].Colour); pixel_mode = PMODE_FLAT; } @@ -1066,9 +1061,9 @@ void Renderer::render_parts() { if (cplayer->elemelem].pcolors); - colg = PIXG(ptypes[cplayer->elem].pcolors); - colb = PIXB(ptypes[cplayer->elem].pcolors); + colr = PIXR(elements[cplayer->elem].Colour); + colg = PIXG(elements[cplayer->elem].Colour); + colb = PIXB(elements[cplayer->elem].Colour); } else { diff --git a/src/cat/CommandInterface.cpp b/src/cat/CommandInterface.cpp index 4554b9f4f..e8fc7b8c4 100644 --- a/src/cat/CommandInterface.cpp +++ b/src/cat/CommandInterface.cpp @@ -88,14 +88,14 @@ int CommandInterface::GetParticleType(std::string type) char * txt = (char*)type.c_str(); //Scope - part_type *ptypes = m->GetSimulation()->ptypes; + Element * elements = m->GetSimulation()->elements; // alternative names for some elements if (strcasecmp(txt,"C4")==0) i = PT_PLEX; else if (strcasecmp(txt,"C5")==0) i = PT_C5; else if (strcasecmp(txt,"NONE")==0) i = PT_NONE; for (i=1; iptypes[i].name); j++) - tmpname[j] = tolower(luacon_sim->ptypes[i].name[j]); - tmpname[strlen(luacon_sim->ptypes[i].name)] = 0; + for(j = 0; j < strlen(luacon_sim->elements[i].Name); j++) + tmpname[j] = tolower(luacon_sim->elements[i].Name[j]); + tmpname[strlen(luacon_sim->elements[i].Name)] = 0; lua_newtable(l); currentElement = lua_gettop(l); @@ -190,9 +190,9 @@ tpt.partsdata = nil"); tptElementTransitions = lua_gettop(l); for(i = 1; i < PT_NUM; i++) { - for(j = 0; j < strlen(luacon_sim->ptypes[i].name); j++) - tmpname[j] = tolower(luacon_sim->ptypes[i].name[j]); - tmpname[strlen(luacon_sim->ptypes[i].name)] = 0; + for(j = 0; j < strlen(luacon_sim->elements[i].Name); j++) + tmpname[j] = tolower(luacon_sim->elements[i].Name[j]); + tmpname[strlen(luacon_sim->elements[i].Name)] = 0; lua_newtable(l); currentElement = lua_gettop(l); @@ -488,11 +488,11 @@ int luacon_transitionread(lua_State* l){ switch(format) { case 0: - tempinteger = *((int*)(((unsigned char*)&luacon_sim->ptransitions[i])+offset)); + tempinteger = *((int*)(((unsigned char*)&luacon_sim->elements[i])+offset)); lua_pushnumber(l, tempinteger); break; case 1: - tempfloat = *((float*)(((unsigned char*)&luacon_sim->ptransitions[i])+offset)); + tempfloat = *((float*)(((unsigned char*)&luacon_sim->elements[i])+offset)); lua_pushnumber(l, tempfloat); break; } @@ -522,10 +522,10 @@ int luacon_transitionwrite(lua_State* l){ switch(format) { case 0: - *((int*)(((unsigned char*)&luacon_sim->ptransitions[i])+offset)) = luaL_optinteger(l, 3, 0); + *((int*)(((unsigned char*)&luacon_sim->elements[i])+offset)) = luaL_optinteger(l, 3, 0); break; case 1: - *((float*)(((unsigned char*)&luacon_sim->ptransitions[i])+offset)) = luaL_optnumber(l, 3, 0); + *((float*)(((unsigned char*)&luacon_sim->elements[i])+offset)) = luaL_optnumber(l, 3, 0); break; } return 0; @@ -675,19 +675,19 @@ int luacon_elementread(lua_State* l){ switch(format) { case 0: - tempinteger = *((int*)(((unsigned char*)&luacon_sim->ptypes[i])+offset)); + tempinteger = *((int*)(((unsigned char*)&luacon_sim->elements[i])+offset)); lua_pushnumber(l, tempinteger); break; case 1: - tempfloat = *((float*)(((unsigned char*)&luacon_sim->ptypes[i])+offset)); + tempfloat = *((float*)(((unsigned char*)&luacon_sim->elements[i])+offset)); lua_pushnumber(l, tempfloat); break; case 2: - tempstring = *((char**)(((unsigned char*)&luacon_sim->ptypes[i])+offset)); + tempstring = *((char**)(((unsigned char*)&luacon_sim->elements[i])+offset)); lua_pushstring(l, tempstring); break; case 3: - tempinteger = *((unsigned char*)(((unsigned char*)&luacon_sim->ptypes[i])+offset)); + tempinteger = *((unsigned char*)(((unsigned char*)&luacon_sim->elements[i])+offset)); lua_pushnumber(l, tempinteger); break; } @@ -719,10 +719,10 @@ int luacon_elementwrite(lua_State* l){ switch(format) { case 0: - *((int*)(((unsigned char*)&luacon_sim->ptypes[i])+offset)) = luaL_optinteger(l, 3, 0); + *((int*)(((unsigned char*)&luacon_sim->elements[i])+offset)) = luaL_optinteger(l, 3, 0); break; case 1: - *((float*)(((unsigned char*)&luacon_sim->ptypes[i])+offset)) = luaL_optnumber(l, 3, 0); + *((float*)(((unsigned char*)&luacon_sim->elements[i])+offset)) = luaL_optnumber(l, 3, 0); break; case 2: tempstring = mystrdup((char*)luaL_optstring(l, 3, "")); @@ -745,11 +745,11 @@ int luacon_elementwrite(lua_State* l){ return luaL_error(l, "Name in use"); } } - *((char**)(((unsigned char*)&luacon_sim->ptypes[i])+offset)) = tempstring; + *((char**)(((unsigned char*)&luacon_sim->elements[i])+offset)) = tempstring; //Need some way of cleaning up previous values break; case 3: - *((unsigned char*)(((unsigned char*)&luacon_sim->ptypes[i])+offset)) = luaL_optinteger(l, 3, 0); + *((unsigned char*)(((unsigned char*)&luacon_sim->elements[i])+offset)) = luaL_optinteger(l, 3, 0); break; } if (modified_stuff) @@ -953,7 +953,7 @@ int luatpt_create(lua_State* l) if(x < XRES && y < YRES){ if(lua_isnumber(l, 3)){ t = luaL_optint(l, 3, 0); - if (t<0 || t >= PT_NUM || !luacon_sim->ptypes[t].enabled) + if (t<0 || t >= PT_NUM || !luacon_sim->elements[t].Enabled) return luaL_error(l, "Unrecognised element number '%d'", t); } else { name = (char*)luaL_optstring(l, 3, "dust"); diff --git a/src/elements/O2.cpp b/src/elements/O2.cpp deleted file mode 100644 index 864d9e803..000000000 --- a/src/elements/O2.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "simulation/Element.h" - -int update_O2(UPDATE_FUNC_ARGS) -{ - int r,rx,ry; - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>=0 && x+rx>8].temp+=(rand()/(RAND_MAX/100)); - if(parts[r>>8].tmp&0x01) - parts[r>>8].temp=3473; - parts[r>>8].tmp |= 2; - } - if ((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) - { - sim->create_part(i,x,y,PT_FIRE); - parts[i].temp+=(rand()/(RAND_MAX/100)); - parts[i].tmp |= 2; - } - - } - return 0; -} diff --git a/src/elements/acel.cpp b/src/elements/acel.cpp deleted file mode 100644 index 0d69894b0..000000000 --- a/src/elements/acel.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "simulation/Element.h" - -int update_ACEL(UPDATE_FUNC_ARGS) { - int r, rx, ry; - parts[i].tmp = 0; - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rxphotons[y+ry][x+rx]; - if ((r>>8)>=NPART || !r) - continue; - if(sim->ptypes[r&0xFF].properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) - { - parts[r>>8].vx *= 1.1f; - parts[r>>8].vy *= 1.1f; - parts[i].tmp = 1; - } - } - return 0; -} - -int graphics_ACEL(GRAPHICS_FUNC_ARGS) -{ - if(cpart->tmp) - *pixel_mode |= PMODE_GLOW; - return 0; -} -int update_DCEL(UPDATE_FUNC_ARGS) { - int r, rx, ry; - parts[i].tmp = 0; - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rxphotons[y+ry][x+rx]; - if ((r>>8)>=NPART || !r) - continue; - if(sim->ptypes[r&0xFF].properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) - { - parts[r>>8].vx *= 0.9f; - parts[r>>8].vy *= 0.9f; - parts[i].tmp = 1; - } - } - return 0; -} - -int graphics_DCEL(GRAPHICS_FUNC_ARGS) -{ - if(cpart->tmp) - *pixel_mode |= PMODE_GLOW; - return 0; -} diff --git a/src/elements/acid.cpp b/src/elements/acid.cpp deleted file mode 100644 index 8d881fd84..000000000 --- a/src/elements/acid.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "simulation/Element.h" - -int update_ACID(UPDATE_FUNC_ARGS) { - int r, rx, ry, trade, np; - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rxpart_change_type(i,x,y,PT_FIRE); - sim->part_change_type(r>>8,x+rx,y+ry,PT_FIRE); - parts[i].life = 4; - parts[r>>8].life = 4; - } - else if ((r&0xFF)==PT_WTRV) - { - if(!(rand()%250)) - { - sim->part_change_type(i, x, y, PT_CAUS); - parts[i].life = (rand()%50)+25; - sim->kill_part(r>>8); - } - } - else if (((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && sim->ptypes[r&0xFF].hardness>(rand()%1000))&&parts[i].life>=50) - { - if (sim->parts_avg(i, r>>8,PT_GLAS)!= PT_GLAS)//GLAS protects stuff from acid - { - float newtemp = ((60.0f-(float)sim->ptypes[r&0xFF].hardness))*7.0f; - if(newtemp < 0){ - newtemp = 0; - } - parts[i].temp += newtemp; - parts[i].life--; - sim->kill_part(r>>8); - } - } - else if (parts[i].life<=50) - { - sim->kill_part(i); - return 1; - } - } - } - for ( trade = 0; trade<2; trade ++) - { - rx = rand()%5-2; - ry = rand()%5-2; - if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) - continue; - if ((r&0xFF)==PT_ACID&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion - { - int temp = parts[i].life - parts[r>>8].life; - if (temp ==1) - { - parts[r>>8].life ++; - parts[i].life --; - } - else if (temp>0) - { - parts[r>>8].life += temp/2; - parts[i].life -= temp/2; - } - } - } - } - return 0; -} diff --git a/src/elements/amtr.cpp b/src/elements/amtr.cpp deleted file mode 100644 index 5ff45292d..000000000 --- a/src/elements/amtr.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "simulation/Element.h" - -int update_AMTR(UPDATE_FUNC_ARGS) { - int r, rx, ry; - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rxkill_part(i); - return 1; - } - if (10>(rand()/(RAND_MAX/100))) - sim->create_part(r>>8, x+rx, y+ry, PT_PHOT); - else - sim->kill_part(r>>8); - sim->pv[y/CELL][x/CELL] -= 2.0f; - } - } - return 0; -} diff --git a/src/elements/anar.cpp b/src/elements/anar.cpp deleted file mode 100644 index 6db0d2e91..000000000 --- a/src/elements/anar.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "simulation/Element.h" - -int update_ANAR(UPDATE_FUNC_ARGS) { - int r, rx, ry; - - //if (parts[i].temp >= 0.23) - // parts[i].temp --; - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rxrand()%22) - { - sim->part_change_type(i,x,y,PT_HFLM); - parts[i].life = rand()%150+50; - parts[r>>8].temp = parts[i].temp = 0; - sim->pv[y/CELL][x/CELL] -= 0.5; - } - } - } - return 0; -} diff --git a/src/elements/bcln.cpp b/src/elements/bcln.cpp deleted file mode 100644 index 702b32219..000000000 --- a/src/elements/bcln.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "simulation/Element.h" - -int update_BCLN(UPDATE_FUNC_ARGS) { - if (!parts[i].life && sim->pv[y/CELL][x/CELL]>4.0f) - parts[i].life = rand()%40+80; - if (parts[i].life) - { - float advection = 0.1f; - parts[i].vx += advection*sim->vx[y/CELL][x/CELL]; - parts[i].vy += advection*sim->vy[y/CELL][x/CELL]; - } - if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT))) - { - int r, rx, ry; - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>=0 && x+rxphotons[y+ry][x+rx]; - if (!r) - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && - (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_STKM && - (r&0xFF)!=PT_STKM2 && (r&0xFF)!=PT_PBCN && - (r&0xFF)>8].ctype; - } - } - } - else { - if (parts[i].ctype==PT_LIFE) sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype|(parts[i].tmp<<8)); - else sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); - } - return 0; -} diff --git a/src/elements/bcol.cpp b/src/elements/bcol.cpp deleted file mode 100644 index d727abfc2..000000000 --- a/src/elements/bcol.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "simulation/Element.h" - -int update_BCOL(UPDATE_FUNC_ARGS) { - int r, rx, ry, trade, temp; - if (parts[i].life<=0) { - sim->create_part(i, x, y, PT_FIRE); - return 1; - } else if (parts[i].life < 100) { - parts[i].life--; - sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE); - } - - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx(rand()%500)) - { - if (parts[i].life>100) { - parts[i].life = 99; - } - } - if ((r&0xFF)==PT_LAVA && 1>(rand()%500)) - { - if (parts[r>>8].ctype == PT_IRON) { - parts[r>>8].ctype = PT_METL; - sim->kill_part(i); - return 1; - } - } - } - /*if(100-parts[i].life > parts[i].tmp2) - parts[i].tmp2 = 100-parts[i].life; - if(parts[i].tmp2 < 0) parts[i].tmp2 = 0; - for ( trade = 0; trade<4; trade ++) - { - rx = rand()%5-2; - ry = rand()%5-2; - if (x+rx>=0 && y+ry>0 && x+rxparts[r>>8].tmp2)&&parts[i].tmp2>0)//diffusion - { - int temp = parts[i].tmp2 - parts[r>>8].tmp2; - if(temp < 10) - continue; - if (temp ==1) - { - parts[r>>8].tmp2 ++; - parts[i].tmp2 --; - } - else if (temp>0) - { - parts[r>>8].tmp2 += temp/2; - parts[i].tmp2 -= temp/2; - } - } - } - }*/ - if(parts[i].temp > parts[i].tmp2) - parts[i].tmp2 = parts[i].temp; - return 0; -} diff --git a/src/elements/bizr.cpp b/src/elements/bizr.cpp deleted file mode 100644 index aae09d954..000000000 --- a/src/elements/bizr.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "simulation/Element.h" - -//Used by ALL 3 BIZR states -int update_BIZR(UPDATE_FUNC_ARGS) { - int r, rx, ry, nr, ng, nb, na; - float tr, tg, tb, ta, mr, mg, mb, ma; - float blend; - if(parts[i].dcolour){ - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx>8].dcolour>>16)&0xFF; - tg = (parts[r>>8].dcolour>>8)&0xFF; - tb = (parts[r>>8].dcolour)&0xFF; - ta = (parts[r>>8].dcolour>>24)&0xFF; - - mr = (parts[i].dcolour>>16)&0xFF; - mg = (parts[i].dcolour>>8)&0xFF; - mb = (parts[i].dcolour)&0xFF; - ma = (parts[i].dcolour>>24)&0xFF; - - nr = (tr*blend) + (mr*(1-blend)); - ng = (tg*blend) + (mg*(1-blend)); - nb = (tb*blend) + (mb*(1-blend)); - na = (ta*blend) + (ma*(1-blend)); - - parts[r>>8].dcolour = nr<<16 | ng<<8 | nb | na<<24; - } - } - } - if(((r = sim->photons[y][x])&0xFF)==PT_PHOT || ((r = pmap[y][x])&0xFF)==PT_PHOT) - { - sim->part_change_type(r>>8, x, y, PT_ELEC); - parts[r>>8].ctype = 0; - } - return 0; -} diff --git a/src/elements/bmtl.cpp b/src/elements/bmtl.cpp deleted file mode 100644 index 8682561c9..000000000 --- a/src/elements/bmtl.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "simulation/Element.h" - -int update_BMTL(UPDATE_FUNC_ARGS) { - int r, rx, ry, rt, tempFactor; - if (parts[i].tmp>1) - { - parts[i].tmp--; - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rx>8].type; - if ((rt==PT_METL || rt==PT_IRON) && 1>(rand()/(RAND_MAX/100))) - { - sim->part_change_type(r>>8,x+rx,y+ry,PT_BMTL); - parts[r>>8].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100; - } - } - } - else if (parts[i].tmp==1 && 1>rand()%1000) - { - parts[i].tmp = 0; - sim->part_change_type(i,x,y,PT_BRMT); - } - return 0; -} diff --git a/src/elements/brmt.cpp b/src/elements/brmt.cpp deleted file mode 100644 index c5be61f76..000000000 --- a/src/elements/brmt.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "simulation/Element.h" - -int update_BRMT(UPDATE_FUNC_ARGS) { - int r, rx, ry, rt, tempFactor; - if (parts[i].temp > (250.0f+273.15f)) - { - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rx>8].type; - tempFactor = 1000 - (((250.0f+273.15f)-parts[i].temp)*2); - if(tempFactor < 2) - tempFactor = 2; - if ((rt==PT_BREC) && 1 > (rand()%tempFactor)) - { - if(rand()%2) - { - sim->create_part(r>>8, x+rx, y+ry, PT_THRM); - } - else - { sim->create_part(i, x, y, PT_THRM); - } - return 1; - //part_change_type(r>>8,x+rx,y+ry,PT_BMTL); - //parts[r>>8].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100; - } - } - } - return 0; -} diff --git a/src/elements/btry.cpp b/src/elements/btry.cpp deleted file mode 100644 index 0168e0851..000000000 --- a/src/elements/btry.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "simulation/Element.h" - -int update_BTRY(UPDATE_FUNC_ARGS) { - int r, rx, ry, rt; - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx>8].type; - if (sim->parts_avg(i,r>>8,PT_INSL) != PT_INSL) - { - if ((sim->ptypes[rt].properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[r>>8].life==0 && abs(rx)+abs(ry) < 4) - { - parts[r>>8].life = 4; - parts[r>>8].ctype = rt; - sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK); - } - } - } - return 0; -} diff --git a/src/elements/c5.cpp b/src/elements/c5.cpp deleted file mode 100644 index 8a10915e3..000000000 --- a/src/elements/c5.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "simulation/Element.h" - -int update_C5(UPDATE_FUNC_ARGS) { - int r, rx, ry; - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx>8].temp<100)||(r&0xFF)==PT_HFLM) - { - if (1>rand()%6) - { - sim->part_change_type(i,x,y,PT_HFLM); - parts[r>>8].temp = parts[i].temp = 0; - parts[i].life = rand()%150+50; - sim->pv[y/CELL][x/CELL] += 1.5; - } - } - } - return 0; -} diff --git a/src/elements/caus.cpp b/src/elements/caus.cpp deleted file mode 100644 index fb71969a6..000000000 --- a/src/elements/caus.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "simulation/Element.h" - -int update_CAUS(UPDATE_FUNC_ARGS) { - int r, rx, ry, trade, np; - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rxptypes[r&0xFF].hardness>(rand()%1000))&&parts[i].life>=50) - { - if (sim->parts_avg(i, r>>8,PT_GLAS)!= PT_GLAS)//GLAS protects stuff from acid - { - float newtemp = ((60.0f-(float)sim->ptypes[r&0xFF].hardness))*7.0f; - if(newtemp < 0){ - newtemp = 0; - } - parts[i].temp += newtemp; - parts[i].life--; - sim->kill_part(r>>8); - } - } - else if (parts[i].life<=50) - { - sim->kill_part(i); - return 1; - } - } - } - return 0; -} diff --git a/src/elements/clne.cpp b/src/elements/clne.cpp deleted file mode 100644 index 303908e16..000000000 --- a/src/elements/clne.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "simulation/Element.h" - -int update_CLNE(UPDATE_FUNC_ARGS) { - if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT))) - { - int r, rx, ry; - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>=0 && x+rxphotons[y+ry][x+rx]; - if (!r) - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && - (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_STKM && - (r&0xFF)!=PT_PBCN && (r&0xFF)!=PT_STKM2 && - (r&0xFF)>8].ctype; - } - } - } - else { - if (parts[i].ctype==PT_LIFE) sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype|(parts[i].tmp<<8)); - else sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); - } - return 0; -} diff --git a/src/elements/clst.cpp b/src/elements/clst.cpp deleted file mode 100644 index f8653bee4..000000000 --- a/src/elements/clst.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "simulation/Element.h" - -int update_CLST(UPDATE_FUNC_ARGS) { - int r, rx, ry; - float cxy; - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx(rand()%1500)) - { - sim->part_change_type(i,x,y,PT_PSTS); - sim->kill_part(r>>8); - } - if ((r&0xFF)==PT_NITR) - { - sim->create_part(i, x, y, PT_BANG); - sim->create_part(r>>8, x+rx, y+ry, PT_BANG); - } - if ((r&0xFF)==PT_CLST) - { - if(parts[i].temp <195) - cxy = 0.05; - if(parts[i].temp >= 195 && parts[i].temp <295) - cxy = 0.015; - if(parts[i].temp >= 295 && parts[i].temp <350) - cxy = 0.01; - if(parts[i].temp > 350) - cxy = 0.005; - parts[i].vx += cxy*rx; - parts[i].vy += cxy*ry;//These two can be set not to calculate over 350 later. They do virtually nothing over 0.005. - } - } - return 0; -} diff --git a/src/elements/coal.cpp b/src/elements/coal.cpp deleted file mode 100644 index 23d20ba67..000000000 --- a/src/elements/coal.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include "simulation/Element.h" - -int update_COAL(UPDATE_FUNC_ARGS) { - int r, rx, ry, trade, temp; - if (parts[i].life<=0) { - sim->create_part(i, x, y, PT_FIRE); - return 1; - } else if (parts[i].life < 100) { - parts[i].life--; - sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE); - } - if ((sim->pv[y/CELL][x/CELL] > 4.3f)&&parts[i].tmp>40) - parts[i].tmp=39; - else if (parts[i].tmp<40&&parts[i].tmp>0) - parts[i].tmp--; - else if (parts[i].tmp<=0) { - sim->create_part(i, x, y, PT_BCOL); - return 1; - } - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx(rand()%500)) - { - if (parts[i].life>100) { - parts[i].life = 99; - } - } - if ((r&0xFF)==PT_LAVA && 1>(rand()%500)) - { - if (parts[r>>8].ctype == PT_IRON) { - parts[r>>8].ctype = PT_METL; - sim->kill_part(i); - return 1; - } - } - } - /*if(100-parts[i].life > parts[i].tmp2) - parts[i].tmp2 = 100-parts[i].life; - if(parts[i].tmp2 < 0) parts[i].tmp2 = 0; - for ( trade = 0; trade<4; trade ++) - { - rx = rand()%5-2; - ry = rand()%5-2; - if (x+rx>=0 && y+ry>0 && x+rxparts[r>>8].tmp2)&&parts[i].tmp2>0)//diffusion - { - int temp = parts[i].tmp2 - parts[r>>8].tmp2; - if(temp < 10) - continue; - if (temp ==1) - { - parts[r>>8].tmp2 ++; - parts[i].tmp2 --; - } - else if (temp>0) - { - parts[r>>8].tmp2 += temp/2; - parts[i].tmp2 -= temp/2; - } - } - } - }*/ - if(parts[i].temp > parts[i].tmp2) - parts[i].tmp2 = parts[i].temp; - return 0; -} diff --git a/src/elements/dest.cpp b/src/elements/dest.cpp deleted file mode 100644 index 5c18d5584..000000000 --- a/src/elements/dest.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "simulation/Element.h" - -int update_DEST(UPDATE_FUNC_ARGS) { - int r,rx,ry,topv; - rx=rand()%5-2; - ry=rand()%5-2; - - r = pmap[y+ry][x+rx]; - if (!r || (r&0xFF)==PT_DEST || (r&0xFF)==PT_DMND || (r&0xFF)==PT_BCLN || (r&0xFF)==PT_CLNE || (r&0xFF)==PT_PCLN || (r&0xFF)==PT_PBCN) - return 0; - - if (parts[i].life<=0 || parts[i].life>37) - { - parts[i].life=30+rand()%20; - parts[i].temp+=20000; - sim->pv[y/CELL][x/CELL]+=60.0f; - } - parts[i].temp+=10000; - if ((r&0xFF)==PT_PLUT || (r&0xFF)==PT_DEUT) - { - sim->pv[y/CELL][x/CELL]+=20.0f; - parts[i].temp+=18000; - if (rand()%2==0) - { - float orig_temp = parts[r>>8].temp; - sim->create_part(r>>8, x+rx, y+ry, PT_NEUT); - parts[r>>8].temp = restrict_flt(orig_temp+40000.0f, MIN_TEMP, MAX_TEMP); - sim->pv[y/CELL][x/CELL] += 10.0f; - parts[i].life-=4; - } - } - else if ((r&0xFF)==PT_INSL) - { - sim->create_part(r>>8, x+rx, y+ry, PT_PLSM); - } - else if (rand()%3==0) - { - sim->kill_part(r>>8); - parts[i].life -= 4*((sim->ptypes[r&0xFF].properties&TYPE_SOLID)?3:1); - if (parts[i].life<=0) - parts[i].life=1; - parts[i].temp+=10000; - } - else - { - if (sim->ptypes[r&0xFF].hconduct) parts[r>>8].temp = restrict_flt(parts[r>>8].temp+10000.0f, MIN_TEMP, MAX_TEMP); - } - topv=sim->pv[y/CELL][x/CELL]/9+parts[r>>8].temp/900; - if (topv>40.0f) - topv=40.0f; - sim->pv[y/CELL][x/CELL]+=40.0f+topv; - parts[i].temp = restrict_flt(parts[i].temp, MIN_TEMP, MAX_TEMP); - return 0; -} -int graphics_DEST(GRAPHICS_FUNC_ARGS) -{ - if(cpart->life) - { - *pixel_mode |= PMODE_LFLARE; - } - else - { - *pixel_mode |= PMODE_SPARK; - } - return 0; -} diff --git a/src/elements/dlay.cpp b/src/elements/dlay.cpp deleted file mode 100644 index fe2d175ab..000000000 --- a/src/elements/dlay.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "simulation/Element.h" - -int update_DLAY(UPDATE_FUNC_ARGS) { - int r, rx, ry, oldl; - oldl = parts[i].life; - if (parts[i].life>0) - parts[i].life--; - //if (parts[i].life==1) - //{ - if (parts[i].temp>=MAX_TEMP+273.15f) - parts[i].temp = MAX_TEMP+273.15f; - if (parts[i].temp<= 1.0f+273.15f) - parts[i].temp = 1.0f+273.15f; - - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rxparts_avg(r>>8, i,PT_INSL)==PT_INSL) - continue; - if ((r&0xFF)==PT_SPRK && parts[i].life==0 && parts[r>>8].life>0 && parts[r>>8].life<4 && parts[r>>8].ctype==PT_PSCN) - { - parts[i].life = (int)(parts[i].temp-273.15); - } - else if ((r&0xFF)==PT_DLAY) - { - if(!parts[i].life && parts[r>>8].life) - { - parts[i].life = parts[r>>8].life; - if((r>>8)>i) //If the other particle hasn't been life updated - parts[i].life--; - } - else if(parts[i].life && !parts[r>>8].life) - { - parts[r>>8].life = parts[i].life; - if((r>>8)>i) //If the other particle hasn't been life updated - parts[r>>8].life++; - } - } - else if((r&0xFF)==PT_NSCN && oldl==1) - { - sim->create_part(-1, x+rx, y+ry, PT_SPRK); - } - } - //} - return 0; -} diff --git a/src/elements/dstw.cpp b/src/elements/dstw.cpp deleted file mode 100644 index 21d7db290..000000000 --- a/src/elements/dstw.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "simulation/Element.h" - -int update_DSTW(UPDATE_FUNC_ARGS) { - int r, rx, ry; - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx(rand()%250)) - { - sim->part_change_type(i,x,y,PT_SLTW); - sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW); - } - if (((r&0xFF)==PT_WATR||(r&0xFF)==PT_SLTW) && 1>(rand()%500)) - { - sim->part_change_type(i,x,y,PT_WATR); - } - if ((r&0xFF)==PT_SLTW && 1>(rand()%500)) - { - sim->part_change_type(i,x,y,PT_SLTW); - } - if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>12.0f) && 1>(rand()%500)) - { - sim->part_change_type(i,x,y,PT_FIRE); - parts[i].life = 4; - } - if ((r&0xFF)==PT_FIRE){ - sim->kill_part(r>>8); - if(1>(rand()%150)){ - sim->kill_part(i); - return 1; - } - } - } - return 0; -} diff --git a/src/elements/elementmisc.cpp b/src/elements/elementmisc.cpp deleted file mode 100644 index 4df53f4a6..000000000 --- a/src/elements/elementmisc.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "simulation/Element.h" - -int update_MISC(UPDATE_FUNC_ARGS) { - /*int t = parts[i].type; - if (t==PT_LOVE) - ISLOVE=1; - else if (t==PT_LOLZ) - ISLOLZ=1; - else if (t==PT_GRAV) - ISGRAV=1;*/ - return 0; -} diff --git a/src/elements/fire.cpp b/src/elements/fire.cpp deleted file mode 100644 index 3f36916d0..000000000 --- a/src/elements/fire.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "simulation/Element.h" - -int graphics_FIRE(GRAPHICS_FUNC_ARGS) -{ - int caddress = restrict_flt(restrict_flt((float)cpart->life, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); - *colr = (unsigned char)ren->flm_data[caddress]; - *colg = (unsigned char)ren->flm_data[caddress+1]; - *colb = (unsigned char)ren->flm_data[caddress+2]; - - *firea = 255; - *firer = *colr; - *fireg = *colg; - *fireb = *colb; - - *pixel_mode = PMODE_NONE; //Clear default, don't draw pixel - *pixel_mode |= FIRE_ADD; - //Returning 0 means dynamic, do not cache - return 0; -} diff --git a/src/elements/firw.cpp b/src/elements/firw.cpp deleted file mode 100644 index 712d416f3..000000000 --- a/src/elements/firw.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include "simulation/Element.h" - -int update_FIRW(UPDATE_FUNC_ARGS) { - int r, rx, ry, rt, np; - if (parts[i].tmp==0) { - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rx>8].type; - if (rt==PT_FIRE||rt==PT_PLSM||rt==PT_THDR) - { - parts[i].tmp = 1; - parts[i].life = rand()%50+60; - } - } - } - else if (parts[i].tmp==1) { - if (parts[i].life==0) { - parts[i].tmp=2; - } else { - float newVel = parts[i].life/25; - parts[i].flags &= ~FLAG_STAGNANT; - /* TODO: - if ((pmap[(int)(ly-newVel)][(int)lx]&0xFF)==PT_NONE && ly-newVel>0) { - parts[i].vy = -newVel; - ly-=newVel; - iy-=newVel; - }*/ - parts[i].vy = -newVel; - } - } - else if (parts[i].tmp==2) { - int col = rand()%200+4; - int tmul; - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rxcreate_part(-1, x+rx, y+ry, PT_FIRW); - if (np>-1) - { - parts[np].vx = (rand()%3-1)*tmul; - parts[np].vy = (rand()%3-1)*tmul; - parts[np].tmp = col; - parts[np].life = rand()%100+100; - parts[np].temp = 6000.0f; - parts[np].dcolour = parts[i].dcolour; - } - } - sim->pv[y/CELL][x/CELL] += 20; - sim->kill_part(i); - return 1; - } else if (parts[i].tmp>=3) { - if (parts[i].life<=0) { - sim->kill_part(i); - return 1; - } - } - return 0; -} diff --git a/src/elements/fog.cpp b/src/elements/fog.cpp deleted file mode 100644 index 24ea9537c..000000000 --- a/src/elements/fog.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "simulation/Element.h" - -int update_FOG(UPDATE_FUNC_ARGS) { - int r, rx, ry; - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rxptypes[r&0xFF].state==ST_SOLID&&5>=rand()%50&&parts[i].life==0&&!((r&0xFF)==PT_CLNE||(r&0xFF)==PT_PCLN)) // TODO: should this also exclude BCLN? - { - sim->part_change_type(i,x,y,PT_RIME); - } - if ((r&0xFF)==PT_SPRK) - { - parts[i].life += rand()%20; - } - } - return 0; -} diff --git a/src/elements/fray.cpp b/src/elements/fray.cpp deleted file mode 100644 index eaf82a01f..000000000 --- a/src/elements/fray.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "simulation/Element.h" - -int update_FRAY(UPDATE_FUNC_ARGS) { - int r, nxx, nyy, docontinue, len, nxi, nyi, rx, ry, nr, ry1, rx1; - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rx= 0 && y+nyi+nyy >= 0) || len>10) { - break; - } - r = pmap[y+nyi+nyy][x+nxi+nxx]; - if (!r) - r = sim->photons[y+nyi+nyy][x+nxi+nxx]; - - if (r && !(sim->ptypes[r&0xFF].properties & TYPE_SOLID)){ - parts[r>>8].vx += nxi*((parts[i].temp-273.15)/10.0f); - parts[r>>8].vy += nyi*((parts[i].temp-273.15)/10.0f); - } - } - } - } - return 0; -} diff --git a/src/elements/frzw.cpp b/src/elements/frzw.cpp deleted file mode 100644 index 4569911d3..000000000 --- a/src/elements/frzw.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "simulation/Element.h" - -int update_FRZW(UPDATE_FUNC_ARGS) { - int r, rx, ry; - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rxrand()%70) - { - sim->part_change_type(r>>8,x+rx,y+ry,PT_FRZW); - } - } - if (parts[i].life==0&&13>rand()%2500) - { - sim->part_change_type(i,x,y,PT_ICEI); - parts[i].ctype=PT_FRZW; - parts[i].temp = restrict_flt(parts[i].temp-200.0f, MIN_TEMP, MAX_TEMP); - } - else if ((100-(parts[i].life))>rand()%50000) - { - sim->part_change_type(i,x,y,PT_ICEI); - parts[i].ctype=PT_FRZW; - parts[i].temp = restrict_flt(parts[i].temp-200.0f, MIN_TEMP, MAX_TEMP); - } - return 0; -} diff --git a/src/elements/frzz.cpp b/src/elements/frzz.cpp deleted file mode 100644 index b412cbc47..000000000 --- a/src/elements/frzz.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "simulation/Element.h" - -int update_FRZZ(UPDATE_FUNC_ARGS) { - int r, rx, ry; - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rxrand()%100) - { - sim->part_change_type(r>>8,x+rx,y+ry,PT_FRZW); - parts[r>>8].life = 100; - parts[i].type = PT_NONE; - } - - } - if (parts[i].type==PT_NONE) { - sim->kill_part(i); - return 1; - } - return 0; -} diff --git a/src/elements/fsep.cpp b/src/elements/fsep.cpp deleted file mode 100644 index 347fc463c..000000000 --- a/src/elements/fsep.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "simulation/Element.h" - -int update_FSEP(UPDATE_FUNC_ARGS) { - int r, rx, ry; - if (parts[i].life<=0) { - r = sim->create_part(i, x, y, PT_PLSM); - if (r!=-1) - parts[r].life = 50; - return 1; - } else if (parts[i].life < 40) { - parts[i].life--; - if ((rand()%10)==0) { - r = sim->create_part(-1, (rx=x+rand()%3-1), (ry=y+rand()%3-1), PT_PLSM); - if (r!=-1) - parts[r].life = 50; - } - } - else { - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx=(273.15+400.0f))) && 1>(rand()%15)) - { - if (parts[i].life>40) { - parts[i].life = 39; - } - } - } - } - return 0; -} diff --git a/src/elements/fuse.cpp b/src/elements/fuse.cpp deleted file mode 100644 index 9081b211b..000000000 --- a/src/elements/fuse.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "simulation/Element.h" - -int update_FUSE(UPDATE_FUNC_ARGS) { - int r, rx, ry; - if (parts[i].life<=0) { - r = sim->create_part(i, x, y, PT_PLSM); - if (r!=-1) - parts[r].life = 50; - return 1; - } else if (parts[i].life < 40) { - parts[i].life--; - if ((rand()%100)==0) { - r = sim->create_part(-1, (rx=x+rand()%3-1), (ry=y+rand()%3-1), PT_PLSM); - if (r!=-1) - parts[r].life = 50; - } - } - if ((sim->pv[y/CELL][x/CELL] > 2.7f)&&parts[i].tmp>40) - parts[i].tmp=39; - else if (parts[i].tmp<40&&parts[i].tmp>0) - parts[i].tmp--; - else if (parts[i].tmp<=0) { - sim->create_part(i, x, y, PT_FSEP); - return 1; - } - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx=(273.15+700.0f)) && 1>(rand()%20))) - { - if (parts[i].life>40) { - parts[i].life = 39; - } - } - } - return 0; -} diff --git a/src/elements/gbmb.cpp b/src/elements/gbmb.cpp deleted file mode 100644 index d1d7c204e..000000000 --- a/src/elements/gbmb.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "simulation/Element.h" -int update_GBMB(UPDATE_FUNC_ARGS) { - int rx,ry,r; - if (parts[i].life<=0) - { - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - { - r = pmap[y+ry][x+rx]; - if(!r) - continue; - if((r&0xFF)!=PT_BOMB && (r&0xFF)!=PT_GBMB && - (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && - (r&0xFF)!=PT_DMND) - { - parts[i].life=60; - break; - } - } - } - if(parts[i].life>20) - sim->gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] = 20; - if(parts[i].life<20 && parts[i].life>=1) - sim->gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] = -80; - return 0; -} diff --git a/src/elements/gel.cpp b/src/elements/gel.cpp deleted file mode 100644 index 0853a5f32..000000000 --- a/src/elements/gel.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include "simulation/Element.h" - -int update_GEL(UPDATE_FUNC_ARGS) { - int r, rx, ry; - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rxkill_part(r>>8); - } - - char gel = 0; - if ((r&0xFF)==PT_GEL) - gel = 1; - - //Concentration diffusion - if (gel && (parts[r>>8].tmp+1)>8].tmp++; - parts[i].tmp--; - } - - if ((r&0xFF)==PT_SPNG && (parts[r>>8].life+1)>8].life++; - parts[i].tmp--; - } - - float dx, dy; - dx = parts[i].x - parts[r>>8].x; - dy = parts[i].y - parts[r>>8].y; - - //Stickness - if ((dx*dx + dy*dy)>1.5 && (gel || !sim->ptypes[r&0xFF].falldown || (fabs(rx)<2 && fabs(ry)<2))) - { - float per, nd; - nd = dx*dx + dy*dy - 0.5; - - per = 5*(1 - parts[i].tmp/100)*(nd/(dx*dx + dy*dy + nd) - 0.5); - if (sim->ptypes[r&0xFF].state==ST_LIQUID) - per *= 0.1; - - dx *= per; dy *= per; - parts[i].vx += dx; parts[r>>8].vx -= dx; - parts[i].vy += dy; parts[r>>8].vy -= dy; - } - } - return 0; -} - -int graphics_GEL(GRAPHICS_FUNC_ARGS) -{ - int q = cpart->tmp; - *colr = q*(32-255)/120+255; - *colg = q*(48-186)/120+186; - *colb = q*208/120; - return 0; -} - diff --git a/src/elements/glas.cpp b/src/elements/glas.cpp deleted file mode 100644 index ef9e7f7eb..000000000 --- a/src/elements/glas.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "simulation/Element.h" - -int update_GLAS(UPDATE_FUNC_ARGS) { - parts[i].pavg[0] = parts[i].pavg[1]; - parts[i].pavg[1] = sim->pv[y/CELL][x/CELL]; - if (parts[i].pavg[1]-parts[i].pavg[0] > 0.25f || parts[i].pavg[1]-parts[i].pavg[0] < -0.25f) - { - sim->part_change_type(i,x,y,PT_BGLA); - } - return 0; -} diff --git a/src/elements/glow.cpp b/src/elements/glow.cpp deleted file mode 100644 index 38f714003..000000000 --- a/src/elements/glow.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "simulation/Element.h" - -int update_GLOW(UPDATE_FUNC_ARGS) { - int r, rx, ry; - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rx(rand()%2000)) - { - parts[i].type = PT_NONE; - sim->part_change_type(r>>8,x+rx,y+ry,PT_DEUT); - parts[r>>8].life = 10; - } - } - parts[i].ctype = sim->pv[y/CELL][x/CELL]*16; - - parts[i].tmp = abs((int)((sim->vx[y/CELL][x/CELL]+sim->vy[y/CELL][x/CELL])*16.0f)) + abs((int)((parts[i].vx+parts[i].vy)*64.0f)); - //printf("%f %f\n", parts[i].vx, parts[i].vy); - if (parts[i].type==PT_NONE) { - sim->kill_part(i); - return 1; - } - return 0; -} diff --git a/src/elements/goo.cpp b/src/elements/goo.cpp deleted file mode 100644 index 6e664688e..000000000 --- a/src/elements/goo.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "simulation/Element.h" - -int update_GOO(UPDATE_FUNC_ARGS) { - if (!parts[i].life && sim->pv[y/CELL][x/CELL]>1.0f) - parts[i].life = rand()%80+300; - if (parts[i].life) - { - float advection = 0.1f; - parts[i].vx += advection*sim->vx[y/CELL][x/CELL]; - parts[i].vy += advection*sim->vy[y/CELL][x/CELL]; - } - return 0; -} diff --git a/src/elements/gpmp.cpp b/src/elements/gpmp.cpp deleted file mode 100644 index 3ad552be7..000000000 --- a/src/elements/gpmp.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "simulation/Element.h" - -int update_GPMP(UPDATE_FUNC_ARGS) { - int r, rx, ry; - if (parts[i].life>0 && parts[i].life!=10) - parts[i].life--; - if (parts[i].life==10) - { - if (parts[i].temp>=256.0+273.15) - parts[i].temp=256.0+273.15; - if (parts[i].temp<= -256.0+273.15) - parts[i].temp = -256.0+273.15; - - sim->gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] = 0.2f*(parts[i].temp-273.15); - if (y+CELLpv[y/CELL+1][x/CELL]<(parts[i].temp-273.15)) - sim->gravmap[(y/CELL+1)*(XRES/CELL)+(x/CELL)] += 0.1f*((parts[i].temp-273.15)-sim->gravmap[(y/CELL+1)*(XRES/CELL)+(x/CELL)]); - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx>8].life<10&&parts[r>>8].life>0) - parts[i].life = 9; - else if (parts[r>>8].life==0) - parts[r>>8].life = 10; - } - } - } - return 0; -} diff --git a/src/elements/graphics_default.cpp b/src/elements/graphics_default.cpp deleted file mode 100644 index cf394aae7..000000000 --- a/src/elements/graphics_default.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "simulation/Element.h" - -int graphics_DEFAULT(GRAPHICS_FUNC_ARGS) -{ - int t = cpart->type; - //Property based defaults - if(ren->sim->ptypes[t].properties & PROP_RADIOACTIVE) *pixel_mode |= PMODE_GLOW; - if(ren->sim->ptypes[t].properties & TYPE_LIQUID) - { - *pixel_mode |= PMODE_BLUR; - } - if(ren->sim->ptypes[t].properties & TYPE_GAS) - { - *pixel_mode &= ~PMODE; - *pixel_mode |= FIRE_BLEND; - *firer = *colr/2; - *fireg = *colg/2; - *fireb = *colb/2; - *firea = 125; - *pixel_mode |= DECO_FIRE; - } - return 1; -} diff --git a/src/elements/hswc.cpp b/src/elements/hswc.cpp deleted file mode 100644 index a2799471e..000000000 --- a/src/elements/hswc.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "simulation/Element.h" - -int update_HSWC(UPDATE_FUNC_ARGS) { - int r, rx, ry; - if (parts[i].life>0 && parts[i].life!=10) - parts[i].life--; - if (parts[i].life==10) - { - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx>8].life<10&&parts[r>>8].life>0) - parts[i].life = 9; - else if (parts[r>>8].life==0) - parts[r>>8].life = 10; - } - } - } - return 0; -} diff --git a/src/elements/ice.cpp b/src/elements/ice.cpp deleted file mode 100644 index aab4e0e43..000000000 --- a/src/elements/ice.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "simulation/Element.h" - -int update_ICEI(UPDATE_FUNC_ARGS) { //currently used for snow as well - int r, rx, ry; - if (parts[i].ctype==PT_FRZW)//get colder if it is from FRZW - { - parts[i].temp = restrict_flt(parts[i].temp-1.0f, MIN_TEMP, MAX_TEMP); - } - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx(rand()%1000)) - { - sim->part_change_type(i,x,y,PT_SLTW); - sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW); - } - } - return 0; -} diff --git a/src/elements/ignt.cpp b/src/elements/ignt.cpp deleted file mode 100644 index 66b0e18da..000000000 --- a/src/elements/ignt.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "simulation/Element.h" - -int update_IGNT(UPDATE_FUNC_ARGS) { - int r, rx, ry; - if(parts[i].tmp==0) - { - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rx>8].life==1)) - { - parts[i].tmp = 1; - } - } - } - else if(parts[i].life > 0) - { - if(rand()%3) - { - int nb = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_BOMB); - if (nb!=-1) { - parts[nb].tmp = 1; - parts[nb].life = 30; - parts[nb].vx = rand()%20-10; - parts[nb].vy = rand()%20-10; - parts[nb].temp = restrict_flt(400.0f+parts[i].temp-273.15, MIN_TEMP, MAX_TEMP); - } - } - else - { - sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE); - } - parts[i].life--; - } - return 0; -} diff --git a/src/elements/iron.cpp b/src/elements/iron.cpp deleted file mode 100644 index 391b7087e..000000000 --- a/src/elements/iron.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "simulation/Element.h" - -int update_IRON(UPDATE_FUNC_ARGS) { - int r, rx, ry; - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rx(rand()/(RAND_MAX/700))) || - ((r&0xFF) == PT_SLTW && 30>(rand()/(RAND_MAX/2000))) || - ((r&0xFF) == PT_WATR && 5 >(rand()/(RAND_MAX/6000))) || - ((r&0xFF) == PT_O2 && 2 >(rand()/(RAND_MAX/500))) || - ((r&0xFF) == PT_LO2))&& - (!(parts[i].life)) - ) - { - sim->part_change_type(i,x,y,PT_BMTL); - parts[i].tmp=(rand()/(RAND_MAX/10))+20; - } - } - return 0; -} diff --git a/src/elements/isz.cpp b/src/elements/isz.cpp deleted file mode 100644 index 22e6c773a..000000000 --- a/src/elements/isz.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "simulation/Element.h" - -int update_ISZ(UPDATE_FUNC_ARGS) { // for both ISZS and ISOZ - float rr, rrr; - if (1>rand()%200 && ((int)(-4.0f*(sim->pv[y/CELL][x/CELL])))>(rand()%1000)) - { - sim->create_part(i, x, y, PT_PHOT); - rr = (rand()%228+128)/127.0f; - rrr = (rand()%360)*3.14159f/180.0f; - parts[i].vx = rr*cosf(rrr); - parts[i].vy = rr*sinf(rrr); - } - return 0; -} diff --git a/src/elements/lava.cpp b/src/elements/lava.cpp deleted file mode 100644 index cc0fbb329..000000000 --- a/src/elements/lava.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "simulation/Element.h" - -int graphics_LAVA(GRAPHICS_FUNC_ARGS) -{ - *colr = cpart->life * 2 + 0xE0; - *colg = cpart->life * 1 + 0x50; - *colb = cpart->life / 2 + 0x10; - if (*colr>255) *colr = 255; - if (*colg>192) *colg = 192; - if (*colb>128) *colb = 128; - *firea = 40; - *firer = *colr; - *fireg = *colg; - *fireb = *colb; - *pixel_mode |= FIRE_ADD; - *pixel_mode |= PMODE_BLUR; - //Returning 0 means dynamic, do not cache - return 0; -} diff --git a/src/elements/lcry.cpp b/src/elements/lcry.cpp deleted file mode 100644 index 0ecb84c4b..000000000 --- a/src/elements/lcry.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "simulation/Element.h" - -int update_LCRY(UPDATE_FUNC_ARGS) -{ - int r, rx, ry; - if(parts[i].tmp==1 || parts[i].tmp==0) - { - if(parts[i].tmp==1) - { - if(parts[i].life<=0) - parts[i].tmp = 0; - else - { - parts[i].life-=2; - if(parts[i].life < 0) - parts[i].life = 0; - parts[i].tmp2 = parts[i].life; - } - } - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rx>8].tmp == 3) - { - parts[r>>8].tmp = 1; - } - } - } - else if(parts[i].tmp==2 || parts[i].tmp==3) - { - if(parts[i].tmp==2) - { - if(parts[i].life>=10) - parts[i].tmp = 3; - else - { - parts[i].life+=2; - if(parts[i].life > 10) - parts[i].life = 10; - parts[i].tmp2 = parts[i].life; - } - } - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rx>8].tmp == 0) - { - parts[r>>8].tmp = 2; - } - } - } - return 0; -} diff --git a/src/elements/legacy.cpp b/src/elements/legacy.cpp deleted file mode 100644 index f1fcf03d2..000000000 --- a/src/elements/legacy.cpp +++ /dev/null @@ -1,120 +0,0 @@ -#include "simulation/Element.h" - -// Interactions which only occur when legacy_enable is on -int update_legacy_all(UPDATE_FUNC_ARGS) { - int r, rx, ry, rt; - int t = parts[i].type; - if (!sim->legacy_enable) return 0; - if (t==PT_WTRV) { - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && - x+rx(rand()%1000)) - { - sim->part_change_type(i,x,y,PT_WATR); - sim->part_change_type(r>>8,x+rx,y+ry,PT_WATR); - } - if (((r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW) && 1>(rand()%1000)) - { - sim->part_change_type(i,x,y,PT_WATR); - if (1>(rand()%1000)) - sim->part_change_type(r>>8,x+rx,y+ry,PT_WATR); - } - } - } - else if (t==PT_WATR) { - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && - x+rx(rand()%10)) - { - sim->part_change_type(i,x,y,PT_WTRV); - } - } - } - else if (t==PT_SLTW) { - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && - x+rx(rand()%10)) - { - sim->part_change_type(i,x,y,PT_SALT); - sim->part_change_type(r>>8,x+rx,y+ry,PT_WTRV); - } - } - } - else if (t==PT_DSTW) { - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && - x+rx(rand()%10)) - { - sim->part_change_type(i,x,y,PT_WTRV); - } - } - } - else if (t==PT_ICEI) { - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx(rand()%1000)) - { - sim->part_change_type(i,x,y,PT_ICEI); - sim->part_change_type(r>>8,x+rx,y+ry,PT_ICEI); - } - } - } - else if (t==PT_SNOW) { - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx(rand()%1000)) - { - sim->part_change_type(i,x,y,PT_ICEI); - sim->part_change_type(r>>8,x+rx,y+ry,PT_ICEI); - } - if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 15>(rand()%1000)) - sim->part_change_type(i,x,y,PT_WATR); - } - } - if (t==PT_WTRV && sim->pv[y/CELL][x/CELL]>4.0f) - sim->part_change_type(i,x,y,PT_DSTW); - if (t==PT_OIL && sim->pv[y/CELL][x/CELL]<-6.0f) - sim->part_change_type(i,x,y,PT_GAS); - if (t==PT_GAS && sim->pv[y/CELL][x/CELL]>6.0f) - sim->part_change_type(i,x,y,PT_OIL); - if (t==PT_DESL && sim->pv[y/CELL][x/CELL]>12.0f) - { - sim->part_change_type(i,x,y,PT_FIRE); - parts[i].life = rand()%50+120; - } - return 0; -} diff --git a/src/elements/mort.cpp b/src/elements/mort.cpp deleted file mode 100644 index 9de088f0f..000000000 --- a/src/elements/mort.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "simulation/Element.h" - -int update_MORT(UPDATE_FUNC_ARGS) { - sim->create_part(-1, x, y-1, PT_SMKE); - return 0; -} diff --git a/src/elements/nbhl.cpp b/src/elements/nbhl.cpp deleted file mode 100644 index 565416f43..000000000 --- a/src/elements/nbhl.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "simulation/Element.h" - -int update_NBHL(UPDATE_FUNC_ARGS) { - sim->gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] += 0.1f; - return 0; -} diff --git a/src/elements/nble.cpp b/src/elements/nble.cpp deleted file mode 100644 index 13e484504..000000000 --- a/src/elements/nble.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "simulation/Element.h" - -int update_NBLE(UPDATE_FUNC_ARGS) -{ - if (parts[i].temp > 5273.15 && sim->pv[y/CELL][x/CELL] > 100.0f) - { - parts[i].tmp = 1; - if (rand()%5 < 1) - { - int j; - float temp = parts[i].temp; - sim->part_change_type(i,x,y,PT_PLSM); - parts[i].life = rand()%150+50; - j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); if (j != -1) - j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1) - j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PHOT); - if (j != -1) { parts[j].ctype = 0xFF0000; parts[j].temp = temp; } - - j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_CO2); - if (j != -1) parts[j].temp = temp-1000; - - parts[i].temp += 10000; - sim->pv[y/CELL][x/CELL] += 30; - } - } - return 0; -} diff --git a/src/elements/newgraphics.cpp b/src/elements/newgraphics.cpp deleted file mode 100644 index f0fbdae4a..000000000 --- a/src/elements/newgraphics.cpp +++ /dev/null @@ -1,542 +0,0 @@ -#include "simulation/Element.h" -#include "hmap.h" - -int graphics_QRTZ(GRAPHICS_FUNC_ARGS) //QRTZ and PQRT -{ - int t = cpart->type, z = cpart->tmp - 5;//speckles! - /*if (cpart->temp>(ptransitions[t].thv-800.0f))//hotglow for quartz - { - float frequency = 3.1415/(2*ptransitions[t].thv-(ptransitions[t].thv-800.0f)); - int q = (cpart->temp>ptransitions[t].thv)?ptransitions[t].thv-(ptransitions[t].thv-800.0f):cpart->temp-(ptransitions[t].thv-800.0f); - *colr += sin(frequency*q) * 226 + (z * 16); - *colg += sin(frequency*q*4.55 +3.14) * 34 + (z * 16); - *colb += sin(frequency*q*2.22 +3.14) * 64 + (z * 16); - } - else*/ - { - *colr += z * 16; - *colg += z * 16; - *colb += z * 16; - } - return 0; -} -int graphics_CLST(GRAPHICS_FUNC_ARGS) -{ - int z = cpart->tmp - 5;//speckles! - *colr += z * 16; - *colg += z * 16; - *colb += z * 16; - return 0; -} -int graphics_CBNW(GRAPHICS_FUNC_ARGS) -{ - int z = cpart->tmp2 - 20;//speckles! - *colr += z * 1; - *colg += z * 2; - *colb += z * 8; - return 0; -} -int graphics_SPNG(GRAPHICS_FUNC_ARGS) -{ - *colr -= cpart->life*15; - *colg -= cpart->life*15; - *colb -= cpart->life*15; - if (*colr<=50) - *colr = 50; - if (*colg<=50) - *colg = 50; - if (*colb<=20) - *colb = 20; - return 0; -} -int graphics_LIFE(GRAPHICS_FUNC_ARGS) -{ - pixel pc; - if (cpart->ctype==NGT_LOTE)//colors for life states - { - if (cpart->tmp==2) - pc = PIXRGB(255, 128, 0); - else if (cpart->tmp==1) - pc = PIXRGB(255, 255, 0); - else - pc = PIXRGB(255, 0, 0); - } - else if (cpart->ctype==NGT_FRG2)//colors for life states - { - if (cpart->tmp==2) - pc = PIXRGB(0, 100, 50); - else - pc = PIXRGB(0, 255, 90); - } - else if (cpart->ctype==NGT_STAR)//colors for life states - { - if (cpart->tmp==4) - pc = PIXRGB(0, 0, 128); - else if (cpart->tmp==3) - pc = PIXRGB(0, 0, 150); - else if (cpart->tmp==2) - pc = PIXRGB(0, 0, 190); - else if (cpart->tmp==1) - pc = PIXRGB(0, 0, 230); - else - pc = PIXRGB(0, 0, 70); - } - else if (cpart->ctype==NGT_FROG)//colors for life states - { - if (cpart->tmp==2) - pc = PIXRGB(0, 100, 0); - else - pc = PIXRGB(0, 255, 0); - } - else if (cpart->ctype==NGT_BRAN)//colors for life states - { - if (cpart->tmp==1) - pc = PIXRGB(150, 150, 0); - else - pc = PIXRGB(255, 255, 0); - } else { - pc = PIXRGB(255, 255, 0);//sim->gmenu[cpart->ctype].colour; - } - *colr = PIXR(pc); - *colg = PIXG(pc); - *colb = PIXB(pc); - return 0; -} -int graphics_DUST(GRAPHICS_FUNC_ARGS) -{ - if(cpart->life >= 1) - { - *firea = 120; - *firer = *colr = cpart->flags; - *fireg = *colg = cpart->tmp; - *fireb = *colb = cpart->ctype; - if (ren->decorations_enable && cpart->dcolour) - { - int a = (cpart->dcolour>>24)&0xFF; - *firer = *colr = (a*((cpart->dcolour>>16)&0xFF) + (255-a)**colr) >> 8; - *fireg = *colg = (a*((cpart->dcolour>>8)&0xFF) + (255-a)**colg) >> 8; - *fireb = *colb = (a*((cpart->dcolour)&0xFF) + (255-a)**colb) >> 8; - } - *pixel_mode |= PMODE_GLOW | FIRE_ADD; - /**firea = 255; - *firer = *colr; - *fireg = *colg; - *fireb = *colb;*/ - } - return 0; -} -int graphics_GRAV(GRAPHICS_FUNC_ARGS) -{ - int GRAV_R, GRAV_B, GRAV_G, GRAV_R2, GRAV_B2, GRAV_G2; - *colr = 20; - *colg = 20; - *colb = 20; - if (cpart->vx>0) - { - *colr += (cpart->vx)*GRAV_R; - *colg += (cpart->vx)*GRAV_G; - *colb += (cpart->vx)*GRAV_B; - } - if (cpart->vy>0) - { - *colr += (cpart->vy)*GRAV_G; - *colg += (cpart->vy)*GRAV_B; - *colb += (cpart->vy)*GRAV_R; - - } - if (cpart->vx<0) - { - *colr -= (cpart->vx)*GRAV_B; - *colg -= (cpart->vx)*GRAV_R; - *colb -= (cpart->vx)*GRAV_G; - - } - if (cpart->vy<0) - { - *colr -= (cpart->vy)*GRAV_R2; - *colg -= (cpart->vy)*GRAV_G2; - *colb -= (cpart->vy)*GRAV_B2; - } - return 0; -} -int graphics_WIFI(GRAPHICS_FUNC_ARGS) -{ - float frequency = 0.0628; - int q = cpart->tmp; - *colr = sin(frequency*q + 0) * 127 + 128; - *colg = sin(frequency*q + 2) * 127 + 128; - *colb = sin(frequency*q + 4) * 127 + 128; - return 0; -} -int graphics_PRTI(GRAPHICS_FUNC_ARGS) -{ - *firea = 8; - *firer = 255; - *fireg = 0; - *fireb = 0; - *pixel_mode |= EFFECT_GRAVIN; - *pixel_mode &= ~PMODE; - *pixel_mode |= PMODE_ADD; - return 1; -} -int graphics_PRTO(GRAPHICS_FUNC_ARGS) -{ - *firea = 8; - *firer = 0; - *fireg = 0; - *fireb = 255; - *pixel_mode |= EFFECT_GRAVOUT; - *pixel_mode &= ~PMODE; - *pixel_mode |= PMODE_ADD; - return 1; -} -int graphics_BIZR(GRAPHICS_FUNC_ARGS) //BIZR, BIZRG, BIZRS -{ - int x = 0; - *colg = 0; - *colb = 0; - *colr = 0; - for (x=0; x<12; x++) { - *colr += (cpart->ctype >> (x+18)) & 1; - *colb += (cpart->ctype >> x) & 1; - } - for (x=0; x<12; x++) - *colg += (cpart->ctype >> (x+9)) & 1; - x = 624/(*colr+*colg+*colb+1); - *colr *= x; - *colg *= x; - *colb *= x; - if(fabs(cpart->vx)+fabs(cpart->vy)>0) - { - *firea = 255; - *fireg = *colg/5 * fabs(cpart->vx)+fabs(cpart->vy); - *fireb = *colb/5 * fabs(cpart->vx)+fabs(cpart->vy); - *firer = *colr/5 * fabs(cpart->vx)+fabs(cpart->vy); - *pixel_mode |= FIRE_ADD; - } - return 0; -} -int graphics_INVS(GRAPHICS_FUNC_ARGS) -{ - //pv[ny/CELL][nx/CELL]>4.0f || pv[ny/CELL][nx/CELL]<-4.0f - if(cpart->tmp) - { - *cola = 100; - *colr = 15; - *colg = 0; - *colb = 150; - *pixel_mode &= PMODE; - *pixel_mode |= PMODE_BLEND; - } - return 0; -} -int graphics_ACID(GRAPHICS_FUNC_ARGS) -{ - int s = cpart->life; - if (s>75) s = 75; //These two should not be here. - if (s<49) s = 49; - s = (s-49)*3; - if (s==0) s = 1; - *colr += s*4; - *colg += s*1; - *colb += s*2; - *pixel_mode |= PMODE_BLUR; - return 0; -} -int graphics_FILT(GRAPHICS_FUNC_ARGS) -{ - int x, temp_bin = (int)((cpart->temp-273.0f)*0.025f); - if (temp_bin < 0) temp_bin = 0; - if (temp_bin > 25) temp_bin = 25; - cpart->ctype = 0x1F << temp_bin; - *colg = 0; - *colb = 0; - *colr = 0; - for (x=0; x<12; x++) { - *colr += (cpart->ctype >> (x+18)) & 1; - *colb += (cpart->ctype >> x) & 1; - } - for (x=0; x<12; x++) - *colg += (cpart->ctype >> (x+9)) & 1; - x = 624/(*colr+*colg+*colb+1); - *cola = 127; - *colr *= x; - *colg *= x; - *colb *= x; - *pixel_mode &= ~PMODE; - *pixel_mode |= PMODE_BLEND; - return 0; -} -int graphics_BRAY(GRAPHICS_FUNC_ARGS) -{ - int x, trans = 255; - if(cpart->tmp==0) - { - trans = cpart->life * 7; - if (trans>255) trans = 255; - if (cpart->ctype) { - *colg = 0; - *colb = 0; - *colr = 0; - for (x=0; x<12; x++) { - *colr += (cpart->ctype >> (x+18)) & 1; - *colb += (cpart->ctype >> x) & 1; - } - for (x=0; x<12; x++) - *colg += (cpart->ctype >> (x+9)) & 1; - x = 624/(*colr+*colg+*colb+1); - *colr *= x; - *colg *= x; - *colb *= x; - } - } - else if(cpart->tmp==1) - { - trans = cpart->life/4; - if (trans>255) trans = 255; - if (cpart->ctype) { - *colg = 0; - *colb = 0; - *colr = 0; - for (x=0; x<12; x++) { - *colr += (cpart->ctype >> (x+18)) & 1; - *colb += (cpart->ctype >> x) & 1; - } - for (x=0; x<12; x++) - *colg += (cpart->ctype >> (x+9)) & 1; - x = 624/(*colr+*colg+*colb+1); - *colr *= x; - *colg *= x; - *colb *= x; - } - } - else if(cpart->tmp==2) - { - trans = cpart->life*100; - if (trans>255) trans = 255; - *colr = 255; - *colg = 150; - *colb = 50; - } - *cola = trans; - *pixel_mode &= ~PMODE; - *pixel_mode |= PMODE_BLEND | PMODE_GLOW; - return 0; -} -int graphics_SWCH(GRAPHICS_FUNC_ARGS) -{ - if(cpart->life >= 10) - { - *colr = 17; - *colg = 217; - *colb = 24; - *pixel_mode |= PMODE_GLOW; - } - return 0; -} -int graphics_THDR(GRAPHICS_FUNC_ARGS) -{ - *firea = 160; - *fireg = 192; - *fireb = 255; - *firer = 144; - *pixel_mode |= FIRE_ADD; - return 1; -} -int graphics_GLOW(GRAPHICS_FUNC_ARGS) -{ - *firer = restrict_flt(cpart->temp-(275.13f+32.0f), 0, 128)/50.0f; - *fireg = restrict_flt(cpart->ctype, 0, 128)/50.0f; - *fireb = restrict_flt(cpart->tmp, 0, 128)/50.0f; - - *colr = restrict_flt(64.0f+cpart->temp-(275.13f+32.0f), 0, 255); - *colg = restrict_flt(64.0f+cpart->ctype, 0, 255); - *colb = restrict_flt(64.0f+cpart->tmp, 0, 255); - - *pixel_mode |= FIRE_ADD; - return 0; -} -int graphics_LCRY(GRAPHICS_FUNC_ARGS) -{ - if(ren->decorations_enable && cpart->dcolour && (cpart->dcolour&0xFF000000)) - { - *colr = (cpart->dcolour>>16)&0xFF; - *colg = (cpart->dcolour>>8)&0xFF; - *colb = (cpart->dcolour)&0xFF; - - if(cpart->tmp2<10){ - *colr /= 10-cpart->tmp2; - *colg /= 10-cpart->tmp2; - *colb /= 10-cpart->tmp2; - } - - } - else - { - *colr = *colg = *colb = 0x50+((cpart->tmp2>10?10:cpart->tmp2)*10); - } - *pixel_mode |= NO_DECO; - return 0; - - /*int lifemod = ((cpart->tmp2>10?10:cpart->tmp2)*10); - *colr += lifemod; - *colg += lifemod; - *colb += lifemod; - if(decorations_enable && cpart->dcolour && cpart->dcolour&0xFF000000) - { - lifemod *= 2.5f; - if(lifemod < 40) - lifemod = 40; - *colr = (lifemod*((cpart->dcolour>>16)&0xFF) + (255-lifemod)**colr) >> 8; - *colg = (lifemod*((cpart->dcolour>>8)&0xFF) + (255-lifemod)**colg) >> 8; - *colb = (lifemod*((cpart->dcolour)&0xFF) + (255-lifemod)**colb) >> 8; - } - *pixel_mode |= NO_DECO; - return 0;*/ -} -int graphics_PCLN(GRAPHICS_FUNC_ARGS) -{ - int lifemod = ((cpart->life>10?10:cpart->life)*10); - *colr += lifemod; - *colg += lifemod; - return 0; -} -int graphics_PBCN(GRAPHICS_FUNC_ARGS) -{ - int lifemod = ((cpart->life>10?10:cpart->life)*10); - *colr += lifemod; - *colg += lifemod/2; - return 0; -} -int graphics_DLAY(GRAPHICS_FUNC_ARGS) -{ - int stage = (int)(((float)cpart->life/(cpart->temp-273.15))*100.0f); - *colr += stage; - *colg += stage; - *colb += stage; - return 0; -} -int graphics_HSWC(GRAPHICS_FUNC_ARGS) -{ - int lifemod = ((cpart->life>10?10:cpart->life)*19); - *colr += lifemod; - return 0; -} -int graphics_PVOD(GRAPHICS_FUNC_ARGS) -{ - int lifemod = ((cpart->life>10?10:cpart->life)*16); - *colr += lifemod; - return 0; -} -int graphics_STOR(GRAPHICS_FUNC_ARGS) -{ - if(cpart->tmp){ - *pixel_mode |= PMODE_GLOW; - *colr = 0x50; - *colg = 0xDF; - *colb = 0xDF; - } else { - *colr = 0x20; - *colg = 0xAF; - *colb = 0xAF; - } - return 0; -} -int graphics_PUMP(GRAPHICS_FUNC_ARGS) -{ - int lifemod = ((cpart->life>10?10:cpart->life)*19); - *colb += lifemod; - return 0; -} -int graphics_GPMP(GRAPHICS_FUNC_ARGS) -{ - int lifemod = ((cpart->life>10?10:cpart->life)*19); - *colg += lifemod; - *colb += lifemod; - return 0; -} -int graphics_HFLM(GRAPHICS_FUNC_ARGS) -{ - int caddress = restrict_flt(restrict_flt((float)((int)(cpart->life/2)), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); - *colr = (unsigned char)hflm_data[caddress]; - *colg = (unsigned char)hflm_data[caddress+1]; - *colb = (unsigned char)hflm_data[caddress+2]; - - *firea = 255; - *firer = *colr; - *fireg = *colg; - *fireb = *colb; - - *pixel_mode = PMODE_NONE; //Clear default, don't draw pixel - *pixel_mode |= FIRE_ADD; - //Returning 0 means dynamic, do not cache - return 0; -} -int graphics_FIRW(GRAPHICS_FUNC_ARGS) -{ - if(cpart->tmp>=3) - { - int caddress = restrict_flt(restrict_flt((float)(cpart->tmp-4), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); - *colr = (unsigned char)firw_data[caddress]; - *colg = (unsigned char)firw_data[caddress+1]; - *colb = (unsigned char)firw_data[caddress+2]; - - if (ren->decorations_enable && cpart->dcolour) - { - int a = (cpart->dcolour>>24)&0xFF; - *colr = (a*((cpart->dcolour>>16)&0xFF) + (255-a)**colr) >> 8; - *colg = (a*((cpart->dcolour>>8)&0xFF) + (255-a)**colg) >> 8; - *colb = (a*((cpart->dcolour)&0xFF) + (255-a)**colb) >> 8; - } - - *firea = cpart->life*4; - if(*firea > 240) - *firea = 240; - *firer = *colr; - *fireg = *colg; - *fireb = *colb; - - *pixel_mode = PMODE_NONE; //Clear default, don't draw pixel - *pixel_mode |= FIRE_ADD; - //Returning 0 means dynamic, do not cache - } - else if(cpart->tmp > 0) - { - *pixel_mode |= PMODE_GLOW; - } - return 0; -} -int graphics_GBMB(GRAPHICS_FUNC_ARGS) -{ - if (cpart->life <= 0) { - *pixel_mode |= PMODE_FLARE; - } - else - { - *pixel_mode |= PMODE_SPARK; - } - return 0; -} -int graphics_COAL(GRAPHICS_FUNC_ARGS) //Both COAL and Broken Coal -{ - *colr += (cpart->tmp2-295.15f)/3; - - if (*colr > 170) - *colr = 170; - if (*colr < *colg) - *colr = *colg; - - *colg = *colb = *colr; - - if((cpart->temp-295.15f) > 300.0f-200.0f) - { - float frequency = 3.1415/(2*300.0f-(300.0f-200.0f)); - int q = ((cpart->temp-295.15f)>300.0f)?300.0f-(300.0f-200.0f):(cpart->temp-295.15f)-(300.0f-200.0f); - - *colr += sin(frequency*q) * 226; - *colg += sin(frequency*q*4.55 +3.14) * 34; - *colb += sin(frequency*q*2.22 +3.14) * 64; - } - return 0; -} - diff --git a/src/elements/none.cpp b/src/elements/none.cpp deleted file mode 100644 index 6974e6ce0..000000000 --- a/src/elements/none.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "simulation/Element.h" - -int update_(UPDATE_FUNC_ARGS) { - - return 0; -} diff --git a/src/elements/nptct.cpp b/src/elements/nptct.cpp deleted file mode 100644 index f8e29e681..000000000 --- a/src/elements/nptct.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "simulation/Element.h" - -int update_NPTCT(UPDATE_FUNC_ARGS) { - if (parts[i].temp>295.0f) - parts[i].temp -= 2.5f; - return 0; -} diff --git a/src/elements/nwhl.cpp b/src/elements/nwhl.cpp deleted file mode 100644 index cae189aa6..000000000 --- a/src/elements/nwhl.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "simulation/Element.h" - -int update_NWHL(UPDATE_FUNC_ARGS) { - sim->gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] -= 0.1f; - return 0; -} diff --git a/src/elements/plsm.cpp b/src/elements/plsm.cpp deleted file mode 100644 index f8b3865c8..000000000 --- a/src/elements/plsm.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "simulation/Element.h" -#include "hmap.h" - -int graphics_PLSM(GRAPHICS_FUNC_ARGS) -{ - int caddress = restrict_flt(restrict_flt((float)cpart->life, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); - *colr = (unsigned char)ren->plasma_data[caddress]; - *colg = (unsigned char)ren->plasma_data[caddress+1]; - *colb = (unsigned char)ren->plasma_data[caddress+2]; - - *firea = 255; - *firer = *colr; - *fireg = *colg; - *fireb = *colb; - - *pixel_mode = PMODE_GLOW | PMODE_ADD; //Clear default, don't draw pixel - *pixel_mode |= FIRE_ADD; - //Returning 0 means dynamic, do not cache - return 0; -} diff --git a/src/elements/plut.cpp b/src/elements/plut.cpp deleted file mode 100644 index 7c51b2d91..000000000 --- a/src/elements/plut.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "simulation/Element.h" - -int update_PLUT(UPDATE_FUNC_ARGS) { - if (1>rand()%100 && ((int)(5.0f*sim->pv[y/CELL][x/CELL]))>(rand()%1000)) - { - sim->create_part(i, x, y, PT_NEUT); - } - return 0; -} diff --git a/src/elements/prti.cpp b/src/elements/prti.cpp deleted file mode 100644 index cb2030db2..000000000 --- a/src/elements/prti.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include "simulation/Element.h" -/*these are the count values of where the particle gets stored, depending on where it came from - 0 1 2 - 7 . 3 - 6 5 4 - PRTO does (count+4)%8, so that it will come out at the opposite place to where it came in - PRTO does +/-1 to the count, so it doesn't jam as easily -*/ - -int update_PRTI(UPDATE_FUNC_ARGS) { - int r, nnx, rx, ry, fe = 0; - int count =0; - parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1); - if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1; - else if (parts[i].tmp<0) parts[i].tmp = 0; - for (count=0; count<8; count++) - { - rx = sim->portal_rx[count]; - ry = sim->portal_ry[count]; - if (x+rx>=0 && y+ry>0 && x+rxptypes[r&0xFF].falldown== 0 && sim->ptypes[r&0xFF].state != ST_GAS && (r&0xFF)!=PT_SPRK)) - { - r = sim->photons[y+ry][x+rx]; - if (!r || (r&0xFF)==PT_PRTI || (r&0xFF)==PT_PRTO || (sim->ptypes[r&0xFF].falldown== 0 && sim->ptypes[r&0xFF].state != ST_GAS && (r&0xFF)!=PT_SPRK)) - continue; - } - - if ((r&0xFF)==PT_STKM || (r&0xFF)==PT_STKM2 || (r&0xFF)==PT_FIGH) - continue;// Handling these is a bit more complicated, and is done in STKM_interact() - - if ((r&0xFF) == PT_SOAP) - sim->detach(r>>8); - - for ( nnx=0; nnx<80; nnx++) - if (!sim->portalp[parts[i].tmp][count][nnx].type) - { - sim->portalp[parts[i].tmp][count][nnx] = parts[r>>8]; - if ((r&0xFF)==PT_SPRK) - sim->part_change_type(r>>8,x+rx,y+ry,parts[r>>8].ctype); - else - sim->kill_part(r>>8); - fe = 1; - break; - } - } - } - - - if (fe) { - int orbd[4] = {0, 0, 0, 0}; //Orbital distances - int orbl[4] = {0, 0, 0, 0}; //Orbital locations - if (!sim->parts[i].life) parts[i].life = rand()*rand()*rand(); - if (!sim->parts[i].ctype) parts[i].ctype = rand()*rand()*rand(); - sim->orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl); - for (r = 0; r < 4; r++) { - if (orbd[r]>1) { - orbd[r] -= 12; - if (orbd[r]<1) { - orbd[r] = (rand()%128)+128; - orbl[r] = rand()%255; - } else { - orbl[r] += 2; - orbl[r] = orbl[r]%255; - } - } else { - orbd[r] = (rand()%128)+128; - orbl[r] = rand()%255; - } - } - sim->orbitalparts_set(&parts[i].life, &parts[i].ctype, orbd, orbl); - } else { - parts[i].life = 0; - parts[i].ctype = 0; - } - return 0; -} diff --git a/src/elements/pump.cpp b/src/elements/pump.cpp deleted file mode 100644 index af05c027a..000000000 --- a/src/elements/pump.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "simulation/Element.h" - -int update_PUMP(UPDATE_FUNC_ARGS) { - int r, rx, ry; - if (parts[i].life>0 && parts[i].life!=10) - parts[i].life--; - if (parts[i].life==10) - { - if (parts[i].temp>=256.0+273.15) - parts[i].temp=256.0+273.15; - if (parts[i].temp<= -256.0+273.15) - parts[i].temp = -256.0+273.15; - - if (sim->pv[y/CELL][x/CELL]<(parts[i].temp-273.15)) - sim->pv[y/CELL][x/CELL] += 0.1f*((parts[i].temp-273.15)-sim->pv[y/CELL][x/CELL]); - if (y+CELLpv[y/CELL+1][x/CELL]<(parts[i].temp-273.15)) - sim->pv[y/CELL+1][x/CELL] += 0.1f*((parts[i].temp-273.15)-sim->pv[y/CELL+1][x/CELL]); - if (x+CELLpv[y/CELL][x/CELL+1] += 0.1f*((parts[i].temp-273.15)-sim->pv[y/CELL][x/CELL+1]); - if (y+CELLpv[y/CELL+1][x/CELL+1] += 0.1f*((parts[i].temp-273.15)-sim->pv[y/CELL+1][x/CELL+1]); - } - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx>8].life<10&&parts[r>>8].life>0) - parts[i].life = 9; - else if (parts[r>>8].life==0) - parts[r>>8].life = 10; - } - } - } - return 0; -} diff --git a/src/elements/pvod.cpp b/src/elements/pvod.cpp deleted file mode 100644 index 921d59651..000000000 --- a/src/elements/pvod.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "simulation/Element.h" - -int update_PVOD(UPDATE_FUNC_ARGS) { - int r, rx, ry; - if (parts[i].life>0 && parts[i].life!=10) - parts[i].life--; - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx>8].life>0 && parts[r>>8].life<4) - { - if (parts[r>>8].ctype==PT_PSCN) - parts[i].life = 10; - else if (parts[r>>8].ctype==PT_NSCN) - parts[i].life = 9; - } - if ((r&0xFF)==PT_PVOD) - { - if (parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0) - parts[i].life = 9; - else if (parts[i].life==0&&parts[r>>8].life==10) - parts[i].life = 10; - } - } - return 0; -} diff --git a/src/elements/qrtz.cpp b/src/elements/qrtz.cpp deleted file mode 100644 index c33cacb57..000000000 --- a/src/elements/qrtz.cpp +++ /dev/null @@ -1,94 +0,0 @@ -#include "simulation/Element.h" - -int update_QRTZ(UPDATE_FUNC_ARGS) { - int r, tmp, trade, rx, ry, np, t; - t = parts[i].type; - if (t == PT_QRTZ) - { - parts[i].pavg[0] = parts[i].pavg[1]; - parts[i].pavg[1] = sim->pv[y/CELL][x/CELL]; - if (parts[i].pavg[1]-parts[i].pavg[0] > 0.05*(parts[i].temp/3) || parts[i].pavg[1]-parts[i].pavg[0] < -0.05*(parts[i].temp/3)) - { - sim->part_change_type(i,x,y,PT_PQRT); - } - } - // absorb SLTW - if (parts[i].ctype!=-1) - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rxrand()%2500)) - { - sim->kill_part(r>>8); - parts[i].ctype ++; - } - } - // grow if absorbed SLTW - if (parts[i].ctype>0) - { - for ( trade = 0; trade<5; trade ++) - { - rx = rand()%3-1; - ry = rand()%3-1; - if (x+rx>=0 && y+ry>0 && x+rxcreate_part(-1,x+rx,y+ry,PT_QRTZ); - if (np>-1) - { - parts[np].tmp = parts[i].tmp; - parts[i].ctype--; - if (5>rand()%10) - { - parts[np].ctype=-1;//dead qrtz - } - else if (!parts[i].ctype && 1>rand()%15) - { - parts[i].ctype=-1; - } - - break; - } - } - } - } - } - // diffuse absorbed SLTW - if (parts[i].ctype>0) - { - for ( trade = 0; trade<9; trade ++) - { - rx = rand()%5-2; - ry = rand()%5-2; - if (x+rx>=0 && y+ry>0 && x+rxparts[r>>8].ctype) && parts[r>>8].ctype>=0 )//diffusion - { - tmp = parts[i].ctype - parts[r>>8].ctype; - if (tmp ==1) - { - parts[r>>8].ctype ++; - parts[i].ctype --; - break; - } - if (tmp>0) - { - parts[r>>8].ctype += tmp/2; - parts[i].ctype -= tmp/2; - break; - } - } - } - } - } - return 0; -} diff --git a/src/elements/repl.cpp b/src/elements/repl.cpp deleted file mode 100644 index faa9c58ad..000000000 --- a/src/elements/repl.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "simulation/Element.h" - -int update_REPL(UPDATE_FUNC_ARGS) { - int r, rx, ry, ri; - for(ri = 0; ri <= 10; ri++) - { - rx = (rand()%20)-10; - ry = (rand()%20)-10; - if (x+rx>=0 && y+ry>0 && x+rxphotons[y+ry][x+rx]; - - if (r && !(sim->ptypes[r&0xFF].properties & TYPE_SOLID)){ - parts[r>>8].vx += isign(rx)*((parts[i].temp-273.15)/10.0f); - parts[r>>8].vy += isign(ry)*((parts[i].temp-273.15)/10.0f); - } - } - } - return 0; -} diff --git a/src/elements/rime.cpp b/src/elements/rime.cpp deleted file mode 100644 index 878b9287d..000000000 --- a/src/elements/rime.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "simulation/Element.h" - -int update_RIME(UPDATE_FUNC_ARGS) { - int r, rx, ry; - parts[i].vx = 0; - parts[i].vy = 0; - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rxpart_change_type(i,x,y,PT_FOG); - parts[i].life = rand()%50 + 60; - } - else if ((r&0xFF)==PT_FOG&&parts[r>>8].life>0) - { - sim->part_change_type(i,x,y,PT_FOG); - parts[i].life = parts[r>>8].life; - } - } - return 0; -} diff --git a/src/elements/shld.cpp b/src/elements/shld.cpp deleted file mode 100644 index ade7edbbf..000000000 --- a/src/elements/shld.cpp +++ /dev/null @@ -1,162 +0,0 @@ -#include "simulation/Element.h" - -int update_SHLD1(UPDATE_FUNC_ARGS) { - int r, nnx, nny, rx, ry; - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rxrand()%200&&parts[i].life==0) - { - sim->part_change_type(i,x,y,PT_SHLD2); - parts[i].life = 7; - } - for ( nnx=-1; nnx<2; nnx++) - for ( nny=-1; nny<2; nny++) - { - if (!pmap[y+ry+nny][x+rx+nnx]) - { - sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1); - //parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7; - } - } - } - else if ((r&0xFF)==PT_SHLD3&&4>rand()%10) - { - sim->part_change_type(i,x,y,PT_SHLD2); - parts[i].life = 7; - } - } - return 0; -} - -int update_SHLD2(UPDATE_FUNC_ARGS) { - int r, nnx, nny, rx, ry, np; - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rx0) - sim->create_part(-1,x+rx,y+ry,PT_SHLD1); - if (!r) - continue; - else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) - { - if (25>rand()%200&&parts[i].life==0) - { - sim->part_change_type(i,x,y,PT_SHLD3); - parts[i].life = 7; - } - for ( nnx=-1; nnx<2; nnx++) - for ( nny=-1; nny<2; nny++) - { - if (!pmap[y+ry+nny][x+rx+nnx]) - { - np = sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1); - if (np<0) continue; - parts[np].life=7; - } - } - } - else if ((r&0xFF)==PT_SHLD4&&4>rand()%10) - { - sim->part_change_type(i,x,y,PT_SHLD3); - parts[i].life = 7; - } - } - return 0; -} - -int update_SHLD3(UPDATE_FUNC_ARGS) { - int r, nnx, nny, rx, ry, np; - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rxrand()%2500) - { - np = sim->create_part(-1,x+rx,y+ry,PT_SHLD1); - if (np<0) continue; - parts[np].life=7; - sim->part_change_type(i,x,y,PT_SHLD2); - } - else - continue; - - } - if ((r&0xFF)==PT_SHLD1 && parts[i].life>3) - { - sim->part_change_type(r>>8,x+rx,y+ry,PT_SHLD2); - parts[r>>8].life=7; - } - else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) - { - if (18>rand()%3000&&parts[i].life==0) - { - sim->part_change_type(i,x,y,PT_SHLD4); - parts[i].life = 7; - } - for ( nnx=-1; nnx<2; nnx++) - for ( nny=-1; nny<2; nny++) - { - - if (!pmap[y+ry+nny][x+rx+nnx]) - { - np = sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1); - if (np<0) continue; - parts[np].life=7; - } - } - } - } - return 0; -} - -int update_SHLD4(UPDATE_FUNC_ARGS) { - int r, nnx, nny, rx, ry, np; - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rxrand()%5500) - { - np = sim->create_part(-1,x+rx,y+ry,PT_SHLD1); - if (np<0) continue; - parts[np].life=7; - sim->part_change_type(i,x,y,PT_SHLD2); - } - else - continue; - - } - if ((r&0xFF)==PT_SHLD2 && parts[i].life>3) - { - sim->part_change_type(r>>8,x+rx,y+ry,PT_SHLD3); - parts[r>>8].life = 7; - } - else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) - for ( nnx=-1; nnx<2; nnx++) - for ( nny=-1; nny<2; nny++) - { - if (!pmap[y+ry+nny][x+rx+nnx]) - { - np = sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1); - if (np<0) continue; - parts[np].life=7; - } - } - } - return 0; -} diff --git a/src/elements/sltw.cpp b/src/elements/sltw.cpp deleted file mode 100644 index 507602c17..000000000 --- a/src/elements/sltw.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "simulation/Element.h" - -int update_SLTW(UPDATE_FUNC_ARGS) { - int r, rx, ry; - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx(rand()%10000)) - sim->kill_part(r>>8); - if ((r&0xFF)==PT_PLNT&&5>(rand()%1000)) - sim->kill_part(r>>8); - if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && !sim->legacy_enable && parts[i].temp>(273.15f+12.0f) && 1>(rand()%500)) - { - sim->part_change_type(i,x,y,PT_FIRE); - parts[i].life = 4; - } - if ((r&0xFF)==PT_FIRE){ - sim->kill_part(r>>8); - if(1>(rand()%150)){ - sim->kill_part(i); - return 1; - } - } - } - return 0; -} diff --git a/src/elements/smke.cpp b/src/elements/smke.cpp deleted file mode 100644 index e9311bd38..000000000 --- a/src/elements/smke.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "simulation/Element.h" - -int graphics_SMKE(GRAPHICS_FUNC_ARGS) -{ - *colr = 55; - *colg = 55; - *colb = 55; - - *firea = 75; - *firer = 55; - *fireg = 55; - *fireb = 55; - - *pixel_mode = PMODE_NONE; //Clear default, don't draw pixel - *pixel_mode |= FIRE_BLEND; - //Returning 1 means static, cache as we please - return 1; -} \ No newline at end of file diff --git a/src/elements/stkm2.cpp b/src/elements/stkm2.cpp deleted file mode 100644 index d18a7acab..000000000 --- a/src/elements/stkm2.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "simulation/Element.h" - -int update_SPAWN2(UPDATE_FUNC_ARGS) { - if (!sim->player2.spwn) - sim->create_part(-1, x, y, PT_STKM2); - - return 0; -} - -int update_STKM2(UPDATE_FUNC_ARGS) { - run_stickman(&sim->player2, UPDATE_FUNC_SUBCALL_ARGS); - return 0; -} - -int graphics_STKM2(GRAPHICS_FUNC_ARGS) -{ - /**pixel_mode = PSPEC_STICKMAN; - if ((int)sim->player2.elemplayer2.elem].pcolors); - *colg = PIXG(ptypes[sim->player2.elem].pcolors); - *colb = PIXB(ptypes[sim->player2.elem].pcolors); - } - else*/ - { - *colr = *colg = *colb = 255; - } - return 1; -} diff --git a/src/elements/stor.cpp b/src/elements/stor.cpp deleted file mode 100644 index 01c341546..000000000 --- a/src/elements/stor.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "simulation/Element.h" - -int update_STOR(UPDATE_FUNC_ARGS) { - int r, rx, ry, np, rx1, ry1; - if(parts[i].life && !parts[i].tmp) - parts[i].life--; - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) - continue; - if (!parts[i].tmp && !parts[i].life && (r&0xFF)!=PT_STOR && !(sim->ptypes[(r&0xFF)].properties&TYPE_SOLID) && (!parts[i].ctype || (r&0xFF)==parts[i].ctype)) - { - parts[i].tmp = parts[r>>8].type; - parts[i].temp = parts[r>>8].temp; - parts[i].tmp2 = parts[r>>8].life; - parts[i].pavg[0] = parts[r>>8].tmp; - parts[i].pavg[1] = parts[r>>8].ctype; - sim->kill_part(r>>8); - } - if(parts[i].tmp && (r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_PSCN && parts[r>>8].life>0 && parts[r>>8].life<4) - { - for(ry1 = 1; ry1 >= -1; ry1--){ - for(rx1 = 0; rx1 >= -1 && rx1 <= 1; rx1 = -rx1-rx1+1){ // Oscilate the X starting at 0, 1, -1, 3, -5, etc (Though stop at -1) - np = sim->create_part(-1,x+rx1,y+ry1,parts[i].tmp); - if (np!=-1) - { - parts[np].temp = parts[i].temp; - parts[np].life = parts[i].tmp2; - parts[np].tmp = parts[i].pavg[0]; - parts[np].ctype = parts[i].pavg[1]; - parts[i].tmp = 0; - parts[i].life = 10; - break; - } - } - } - } - } - return 0; -} diff --git a/src/elements/thdr.cpp b/src/elements/thdr.cpp deleted file mode 100644 index 1e3d0ab6c..000000000 --- a/src/elements/thdr.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "simulation/Element.h" - -int update_THDR(UPDATE_FUNC_ARGS) { - int r, rx, ry; - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rxptypes[r&0xFF].properties&PROP_CONDUCTS) && parts[r>>8].life==0 && !((r&0xFF)==PT_WATR||(r&0xFF)==PT_SLTW) && parts[r>>8].ctype!=PT_SPRK) - { - parts[i].type = PT_NONE; - parts[r>>8].ctype = parts[r>>8].type; - sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK); - parts[r>>8].life = 4; - } - else if ((r&0xFF)!=PT_CLNE&&(r&0xFF)!=PT_THDR&&(r&0xFF)!=PT_SPRK&&(r&0xFF)!=PT_DMND&&(r&0xFF)!=PT_FIRE&&(r&0xFF)!=PT_NEUT&&(r&0xFF)!=PT_PHOT&&(r&0xFF)) - { - sim->pv[y/CELL][x/CELL] += 100.0f; - if (sim->legacy_enable&&1>(rand()%200)) - { - parts[i].life = rand()%50+120; - sim->part_change_type(i,x,y,PT_FIRE); - } - else - { - parts[i].type = PT_NONE; - } - } - } - if (parts[i].type==PT_NONE) { - sim->kill_part(i); - return 1; - } - return 0; -} diff --git a/src/elements/thrm.cpp b/src/elements/thrm.cpp deleted file mode 100644 index 2075e1356..000000000 --- a/src/elements/thrm.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "simulation/Element.h" - -int update_THRM(UPDATE_FUNC_ARGS) { - int r, rx, ry; - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx(rand()%500)) { - sim->part_change_type(i,x,y,PT_LAVA); - parts[i].ctype = PT_BMTL; - parts[i].temp = 3500.0f; - sim->pv[y/CELL][x/CELL] += 50.0f; - } else { - sim->part_change_type(i,x,y,PT_LAVA); - parts[i].life = 400; - parts[i].ctype = PT_THRM; - parts[i].temp = 3500.0f; - parts[i].tmp = 20; - } - } - } - return 0; -} diff --git a/src/elements/uran.cpp b/src/elements/uran.cpp deleted file mode 100644 index 31e93a7da..000000000 --- a/src/elements/uran.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "simulation/Element.h" - -int update_URAN(UPDATE_FUNC_ARGS) { - if (!sim->legacy_enable && sim->pv[y/CELL][x/CELL]>0.0f) - { - float atemp = parts[i].temp + (-MIN_TEMP); - parts[i].temp = restrict_flt((atemp*(1+(sim->pv[y/CELL][x/CELL]/2000)))+MIN_TEMP, MIN_TEMP, MAX_TEMP); - } - return 0; -} diff --git a/src/elements/vine.cpp b/src/elements/vine.cpp deleted file mode 100644 index c8d51ba81..000000000 --- a/src/elements/vine.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "simulation/Element.h" - -int update_VINE(UPDATE_FUNC_ARGS) { - int r, np, rx =(rand()%3)-1, ry=(rand()%3)-1; - if (x+rx>=0 && y+ry>0 && x+rxrand()%15) - sim->part_change_type(i,x,y,PT_PLNT); - else if (!r) - { - np = sim->create_part(-1,x+rx,y+ry,PT_VINE); - if (np<0) return 0; - parts[np].temp = parts[i].temp; - sim->part_change_type(i,x,y,PT_PLNT); - } - } - return 0; -} diff --git a/src/elements/warp.cpp b/src/elements/warp.cpp deleted file mode 100644 index 88315a968..000000000 --- a/src/elements/warp.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "simulation/Element.h" - -int update_WARP(UPDATE_FUNC_ARGS) { - int trade, r, rx, ry; - for ( trade = 0; trade<5; trade ++) - { - rx = rand()%3-1; - ry = rand()%3-1; - if (x+rx>=0 && y+ry>0 && x+rx=rand()%200)) - { - parts[i].x = parts[r>>8].x; - parts[i].y = parts[r>>8].y; - parts[r>>8].x = x; - parts[r>>8].y = y; - parts[i].life += 4; - pmap[y][x] = r; - pmap[y+ry][x+rx] = (i<<8)|parts[i].type; - trade = 5; - } - } - } - return 0; -} diff --git a/src/elements/watr.cpp b/src/elements/watr.cpp deleted file mode 100644 index f6a99339e..000000000 --- a/src/elements/watr.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "simulation/Element.h" - -int update_WATR(UPDATE_FUNC_ARGS) { - int r, rx, ry; - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx(rand()%250)) - { - sim->part_change_type(i,x,y,PT_SLTW); - sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW); - } - if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && 1>(rand()%500)) - { - sim->part_change_type(i,x,y,PT_FIRE); - parts[i].life = 4; - parts[i].ctype = PT_WATR; - } - if ((r&0xFF)==PT_FIRE && parts[r>>8].ctype!=PT_WATR){ - sim->kill_part(r>>8); - if(1>(rand()%150)){ - sim->kill_part(i); - return 1; - } - } - /*if ((r&0xFF)==PT_CNCT && 1>(rand()%500)) Concrete+Water to paste, not very popular - { - part_change_type(i,x,y,PT_PSTE); - sim.kill_part(r>>8); - }*/ - } - return 0; -} diff --git a/src/elements/wifi.cpp b/src/elements/wifi.cpp deleted file mode 100644 index 9a2512886..000000000 --- a/src/elements/wifi.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "simulation/Element.h" - -int update_WIFI(UPDATE_FUNC_ARGS) { - int r, rx, ry; - parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1); - if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1; - else if (parts[i].tmp<0) parts[i].tmp = 0; - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rxwireless[parts[i].tmp][0]) - { - if (((r&0xFF)==PT_NSCN||(r&0xFF)==PT_PSCN||(r&0xFF)==PT_INWR)&&parts[r>>8].life==0 && sim->wireless[parts[i].tmp][0]) - { - parts[r>>8].ctype = r&0xFF; - sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK); - parts[r>>8].life = 4; - } - } - else - { - if ((r&0xFF)==PT_SPRK && parts[r>>8].ctype!=PT_NSCN && parts[r>>8].life>=3) - { - sim->wireless[parts[i].tmp][1] = 1; - sim->ISWIRE = 2; - } - } - } - return 0; -} diff --git a/src/elements/wire.cpp b/src/elements/wire.cpp deleted file mode 100644 index 88d2a5e64..000000000 --- a/src/elements/wire.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include "simulation/Element.h" - -int update_WIRE(UPDATE_FUNC_ARGS) { - int s,r,rx,ry,count; - /* - 0: wire - 1: spark head - 2: spark tail - - tmp is previous state, ctype is current state - */ - //parts[i].tmp=parts[i].ctype; - parts[i].ctype=0; - if(parts[i].tmp==1) - { - parts[i].ctype=2; - } - if(parts[i].tmp==2) - { - parts[i].ctype=0; - } - - count=0; - for(rx=-1; rx<2; rx++) - for(ry=-1; ry<2; ry++) - { - if(x+rx>=0 && y+ry>0 && x+rx>8].life==3 && parts[r>>8].ctype==PT_PSCN) - { - parts[i].ctype=1; - return 0; - } - else if((r&0xFF)==PT_NSCN && parts[i].tmp==1){sim->create_part(-1, x+rx, y+ry, PT_SPRK);} - else if((r&0xFF)==PT_WIRE && parts[r>>8].tmp==1 && !parts[i].tmp){count++;} - } - } - if(count==1 || count==2) - parts[i].ctype=1; - return 0; -} - -int graphics_WIRE(GRAPHICS_FUNC_ARGS) -{ - if (cpart->ctype==0) - { - *colr = 255; - *colg = 204; - *colb = 0; - return 0; - } - if (cpart->ctype==1) - { - *colr = 50; - *colg = 100; - *colb = 255; - //*pixel_mode |= PMODE_GLOW; - return 0; - } - if (cpart->ctype==2) - { - *colr = 255; - *colg = 100; - *colb = 50; - //*pixel_mode |= PMODE_GLOW; - return 0; - } - return 0; -} diff --git a/src/elements/wtrv.cpp b/src/elements/wtrv.cpp deleted file mode 100644 index 9c07e9fd1..000000000 --- a/src/elements/wtrv.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "simulation/Element.h" - -int update_WTRV(UPDATE_FUNC_ARGS) { - int r, rx, ry; - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rxlegacy_enable && parts[i].temp>(273.15f+12.0f) && 1>(rand()%500)) - { - sim->part_change_type(i,x,y,PT_FIRE); - parts[i].life = 4; - parts[i].ctype = PT_WATR; - } - } - if(parts[i].temp>1273&&parts[i].ctype==PT_FIRE) - parts[i].temp-=parts[i].temp/1000; - return 0; -} diff --git a/src/elements/yest.cpp b/src/elements/yest.cpp deleted file mode 100644 index 5b3fc95ee..000000000 --- a/src/elements/yest.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include "simulation/Element.h" - -int update_YEST(UPDATE_FUNC_ARGS) { - int r, rx, ry; - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx(rand()%30) && !sim->legacy_enable) - { - sim->part_change_type(i,x,y,PT_DYST); - } - } - if (parts[i].temp>303&&parts[i].temp<317) { - sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_YEST); - } - return 0; -} diff --git a/src/game/EllipseBrush.h b/src/game/EllipseBrush.h index 26b3cf88d..8a1dc9aaa 100644 --- a/src/game/EllipseBrush.h +++ b/src/game/EllipseBrush.h @@ -8,6 +8,7 @@ #ifndef ELIPSEBRUSH_H_ #define ELIPSEBRUSH_H_ +#include #include "Brush.h" class EllipseBrush: public Brush @@ -29,7 +30,7 @@ public: { for(int y = 0; y <= radius.Y*2; y++) { - if((pow(x-radius.X,2)*pow(ry,2)+pow(y-radius.Y,2)*pow(rx,2)<=pow(rx,2)*pow(ry,2))) + if((pow(x-radius.X,2.0f)*pow(ry,2.0f)+pow(y-radius.Y,2.0f)*pow(rx,2.0f)<=pow(rx,2.0f)*pow(ry,2.0f))) { bitmap[y*(size.X)+x] = 255; } diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index 4f94ab834..529137a33 100644 --- a/src/game/GameController.cpp +++ b/src/game/GameController.cpp @@ -580,8 +580,8 @@ void GameController::ReloadSim() std::string GameController::ElementResolve(int type) { - if(gameModel && gameModel->GetSimulation() && gameModel->GetSimulation()->ptypes && type >= 0 && type < PT_NUM) - return std::string(gameModel->GetSimulation()->ptypes[type].name); + if(gameModel && gameModel->GetSimulation() && gameModel->GetSimulation()->elements && type >= 0 && type < PT_NUM) + return std::string(gameModel->GetSimulation()->elements[type].Name); else return ""; } diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp index 4dd14ef4b..bb6947935 100644 --- a/src/game/GameModel.cpp +++ b/src/game/GameModel.cpp @@ -71,10 +71,10 @@ GameModel::GameModel(): //Build menus from Simulation elements for(int i = 0; i < PT_NUM; i++) { - if(sim->ptypes[i].menusection < 12 && sim->ptypes[i].enabled && sim->ptypes[i].menu) + if(sim->elements[i].MenuSection < 12 && sim->elements[i].Enabled && sim->elements[i].MenuVisible) { - Tool * tempTool = new ElementTool(i, sim->ptypes[i].name, PIXR(sim->ptypes[i].pcolors), PIXG(sim->ptypes[i].pcolors), PIXB(sim->ptypes[i].pcolors)); - menuList[sim->ptypes[i].menusection]->AddTool(tempTool); + Tool * tempTool = new ElementTool(i, sim->elements[i].Name, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour)); + menuList[sim->elements[i].MenuSection]->AddTool(tempTool); } } @@ -106,8 +106,8 @@ GameModel::GameModel(): brushList.push_back(new EllipseBrush(ui::Point(4, 4))); //Set default tools - activeTools[0] = menuList[SC_POWDERS]->GetToolList()[0]; - activeTools[1] = menuList[SC_SPECIAL]->GetToolList()[0]; + //activeTools[0] = menuList[SC_POWDERS]->GetToolList()[0]; + //activeTools[1] = menuList[SC_SPECIAL]->GetToolList()[0]; //Set default menu activeMenu = menuList[SC_POWDERS]; diff --git a/src/interface/Spinner.cpp b/src/interface/Spinner.cpp index b988674fc..a98be2bec 100644 --- a/src/interface/Spinner.cpp +++ b/src/interface/Spinner.cpp @@ -6,7 +6,7 @@ */ -#include +#include #include #include "Spinner.h" diff --git a/src/search/SearchModel.h b/src/search/SearchModel.h index 980c06d78..fef9f6aa4 100644 --- a/src/search/SearchModel.h +++ b/src/search/SearchModel.h @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include "Save.h" #include "SearchView.h" diff --git a/src/simulation/Air.cpp b/src/simulation/Air.cpp index ff61bac45..e798181de 100644 --- a/src/simulation/Air.cpp +++ b/src/simulation/Air.cpp @@ -1,4 +1,4 @@ -#include +#include #include "Config.h" #include "Air.h" //#include diff --git a/src/simulation/Element.h b/src/simulation/Element.h index f00751e7b..7cd379edb 100644 --- a/src/simulation/Element.h +++ b/src/simulation/Element.h @@ -5,10 +5,19 @@ #include #include "Simulation.h" #include "Renderer.h" -#include "ElementFunctions.h" -//#include "powder.h" #include "Gravity.h" #include "Misc.h" #include "ElementGraphics.h" +#define IPL -257.0f +#define IPH 257.0f +#define ITL MIN_TEMP-1 +#define ITH MAX_TEMP+1 + +// no transition (PT_NONE means kill part) +#define NT -1 + +// special transition - lava ctypes etc need extra code, which is only found and run if ST is given +#define ST PT_NUM + #endif diff --git a/src/simulation/ElementFunctions.h b/src/simulation/ElementFunctions.h deleted file mode 100644 index b1d640955..000000000 --- a/src/simulation/ElementFunctions.h +++ /dev/null @@ -1,175 +0,0 @@ -/* - * ElementFunctions.h - * - * Created on: Jan 5, 2012 - * Author: Simon - */ - -#ifndef ELEMENTFUNCTIONS_H_ -#define ELEMENTFUNCTIONS_H_ -#include "Elements.h" - -int update_ACID(UPDATE_FUNC_ARGS); -int update_ANAR(UPDATE_FUNC_ARGS); -int update_AMTR(UPDATE_FUNC_ARGS); -int update_ARAY(UPDATE_FUNC_ARGS); -int update_BCLN(UPDATE_FUNC_ARGS); -int update_BCOL(UPDATE_FUNC_ARGS); -int update_BMTL(UPDATE_FUNC_ARGS); -int update_BRMT(UPDATE_FUNC_ARGS); -int update_BOMB(UPDATE_FUNC_ARGS); -int update_BOYL(UPDATE_FUNC_ARGS); -int update_BTRY(UPDATE_FUNC_ARGS); -int update_C5(UPDATE_FUNC_ARGS); -int update_CLNE(UPDATE_FUNC_ARGS); -int update_COAL(UPDATE_FUNC_ARGS); -int update_DEUT(UPDATE_FUNC_ARGS); -int update_DSTW(UPDATE_FUNC_ARGS); -int update_FOG(UPDATE_FUNC_ARGS); -int update_FRZW(UPDATE_FUNC_ARGS); -int update_FRZZ(UPDATE_FUNC_ARGS); -int update_FSEP(UPDATE_FUNC_ARGS); -int update_FUSE(UPDATE_FUNC_ARGS); -int update_FIRW(UPDATE_FUNC_ARGS); -int update_FWRK(UPDATE_FUNC_ARGS); -int update_GLAS(UPDATE_FUNC_ARGS); -int update_GLOW(UPDATE_FUNC_ARGS); -int update_GOO(UPDATE_FUNC_ARGS); -int update_HSWC(UPDATE_FUNC_ARGS); -int update_IRON(UPDATE_FUNC_ARGS); -int update_ICEI(UPDATE_FUNC_ARGS); -int update_ISZ(UPDATE_FUNC_ARGS); -int update_LCRY(UPDATE_FUNC_ARGS); -int update_MORT(UPDATE_FUNC_ARGS); -int update_NEUT(UPDATE_FUNC_ARGS); -int update_NPTCT(UPDATE_FUNC_ARGS); -int update_PCLN(UPDATE_FUNC_ARGS); -int update_PHOT(UPDATE_FUNC_ARGS); -int update_PIPE(UPDATE_FUNC_ARGS); -int update_PLNT(UPDATE_FUNC_ARGS); -int update_PLUT(UPDATE_FUNC_ARGS); -int update_PRTI(UPDATE_FUNC_ARGS); -int update_PRTO(UPDATE_FUNC_ARGS); -int update_PYRO(UPDATE_FUNC_ARGS); -int update_PUMP(UPDATE_FUNC_ARGS); -int update_QRTZ(UPDATE_FUNC_ARGS); -int update_RIME(UPDATE_FUNC_ARGS); -int update_SHLD1(UPDATE_FUNC_ARGS); -int update_SHLD2(UPDATE_FUNC_ARGS); -int update_SHLD3(UPDATE_FUNC_ARGS); -int update_SHLD4(UPDATE_FUNC_ARGS); -int update_SING(UPDATE_FUNC_ARGS); -int update_SLTW(UPDATE_FUNC_ARGS); -int update_SPAWN(UPDATE_FUNC_ARGS); -int update_SPAWN2(UPDATE_FUNC_ARGS); -int update_SPNG(UPDATE_FUNC_ARGS); -int update_SPRK(UPDATE_FUNC_ARGS); -int update_STKM(UPDATE_FUNC_ARGS); -int update_STKM2(UPDATE_FUNC_ARGS); -int update_SWCH(UPDATE_FUNC_ARGS); -int update_THDR(UPDATE_FUNC_ARGS); -int update_THRM(UPDATE_FUNC_ARGS); -int update_URAN(UPDATE_FUNC_ARGS); -int update_VINE(UPDATE_FUNC_ARGS); -int update_WARP(UPDATE_FUNC_ARGS); -int update_WATR(UPDATE_FUNC_ARGS); -int update_WIFI(UPDATE_FUNC_ARGS); -int update_WTRV(UPDATE_FUNC_ARGS); -int update_YEST(UPDATE_FUNC_ARGS); -int update_SOAP(UPDATE_FUNC_ARGS); -int update_O2(UPDATE_FUNC_ARGS); -int update_H2(UPDATE_FUNC_ARGS); -int update_NBHL(UPDATE_FUNC_ARGS); -int update_NWHL(UPDATE_FUNC_ARGS); -int update_MERC(UPDATE_FUNC_ARGS); -int update_PBCN(UPDATE_FUNC_ARGS); -int update_GPMP(UPDATE_FUNC_ARGS); -int update_CLST(UPDATE_FUNC_ARGS); -int update_DLAY(UPDATE_FUNC_ARGS); -int update_WIRE(UPDATE_FUNC_ARGS); -int update_GBMB(UPDATE_FUNC_ARGS); -int update_CO2(UPDATE_FUNC_ARGS); -int update_CBNW(UPDATE_FUNC_ARGS); -int update_STOR(UPDATE_FUNC_ARGS); -int update_BIZR(UPDATE_FUNC_ARGS); -int update_PVOD(UPDATE_FUNC_ARGS); -int update_CONV(UPDATE_FUNC_ARGS); -int update_CAUS(UPDATE_FUNC_ARGS); -int update_DEST(UPDATE_FUNC_ARGS); -int update_EMP(UPDATE_FUNC_ARGS); -int update_LIGH(UPDATE_FUNC_ARGS); -int update_FIGH(UPDATE_FUNC_ARGS); -int update_ELEC(UPDATE_FUNC_ARGS); -int update_ACEL(UPDATE_FUNC_ARGS); -int update_DCEL(UPDATE_FUNC_ARGS); -int update_BANG(UPDATE_FUNC_ARGS); -int update_IGNT(UPDATE_FUNC_ARGS); -int update_MISC(UPDATE_FUNC_ARGS); -int update_FRAY(UPDATE_FUNC_ARGS); -int update_REPL(UPDATE_FUNC_ARGS); -int update_NBLE(UPDATE_FUNC_ARGS); -int update_GEL(UPDATE_FUNC_ARGS); -int update_TRON(UPDATE_FUNC_ARGS); -int update_legacy_PYRO(UPDATE_FUNC_ARGS); -int update_legacy_all(UPDATE_FUNC_ARGS); -int run_stickman(playerst* playerp, UPDATE_FUNC_ARGS); -void STKM_init_legs(Simulation * sim, playerst* playerp, int i); -void STKM_interact(Simulation * sim, playerst* playerp, int i, int x, int y); - - -int graphics_FIRE(GRAPHICS_FUNC_ARGS); -int graphics_SMKE(GRAPHICS_FUNC_ARGS); -int graphics_PLSM(GRAPHICS_FUNC_ARGS); -int graphics_DEUT(GRAPHICS_FUNC_ARGS); -int graphics_PHOT(GRAPHICS_FUNC_ARGS); -int graphics_NEUT(GRAPHICS_FUNC_ARGS); -int graphics_LAVA(GRAPHICS_FUNC_ARGS); -int graphics_SPRK(GRAPHICS_FUNC_ARGS); -int graphics_QRTZ(GRAPHICS_FUNC_ARGS); -int graphics_CLST(GRAPHICS_FUNC_ARGS); -int graphics_CBNW(GRAPHICS_FUNC_ARGS); -int graphics_SPNG(GRAPHICS_FUNC_ARGS); -int graphics_LIFE(GRAPHICS_FUNC_ARGS); -int graphics_DUST(GRAPHICS_FUNC_ARGS); -int graphics_GRAV(GRAPHICS_FUNC_ARGS); -int graphics_WIFI(GRAPHICS_FUNC_ARGS); -int graphics_PRTI(GRAPHICS_FUNC_ARGS); -int graphics_PRTO(GRAPHICS_FUNC_ARGS); -int graphics_BIZR(GRAPHICS_FUNC_ARGS); -int graphics_PIPE(GRAPHICS_FUNC_ARGS); -int graphics_INVS(GRAPHICS_FUNC_ARGS); -int graphics_ACID(GRAPHICS_FUNC_ARGS); -int graphics_FILT(GRAPHICS_FUNC_ARGS); -int graphics_BRAY(GRAPHICS_FUNC_ARGS); -int graphics_SWCH(GRAPHICS_FUNC_ARGS); -int graphics_THDR(GRAPHICS_FUNC_ARGS); -int graphics_GLOW(GRAPHICS_FUNC_ARGS); -int graphics_LCRY(GRAPHICS_FUNC_ARGS); -int graphics_PCLN(GRAPHICS_FUNC_ARGS); -int graphics_PBCN(GRAPHICS_FUNC_ARGS); -int graphics_DLAY(GRAPHICS_FUNC_ARGS); -int graphics_HSWC(GRAPHICS_FUNC_ARGS); -int graphics_PVOD(GRAPHICS_FUNC_ARGS); -int graphics_STOR(GRAPHICS_FUNC_ARGS); -int graphics_PUMP(GRAPHICS_FUNC_ARGS); -int graphics_GPMP(GRAPHICS_FUNC_ARGS); -int graphics_HFLM(GRAPHICS_FUNC_ARGS); -int graphics_FIRW(GRAPHICS_FUNC_ARGS); -int graphics_BOMB(GRAPHICS_FUNC_ARGS); -int graphics_GBMB(GRAPHICS_FUNC_ARGS); -int graphics_COAL(GRAPHICS_FUNC_ARGS); -int graphics_STKM(GRAPHICS_FUNC_ARGS); -int graphics_STKM2(GRAPHICS_FUNC_ARGS); -int graphics_DEST(GRAPHICS_FUNC_ARGS); -int graphics_EMP(GRAPHICS_FUNC_ARGS); -int graphics_LIGH(GRAPHICS_FUNC_ARGS); -int graphics_FIGH(GRAPHICS_FUNC_ARGS); -int graphics_ELEC(GRAPHICS_FUNC_ARGS); -int graphics_WIRE(GRAPHICS_FUNC_ARGS); -int graphics_ACEL(GRAPHICS_FUNC_ARGS); -int graphics_DCEL(GRAPHICS_FUNC_ARGS); -int graphics_GEL(GRAPHICS_FUNC_ARGS); -int graphics_TRON(GRAPHICS_FUNC_ARGS); -int graphics_DEFAULT(GRAPHICS_FUNC_ARGS); - -#endif /* ELEMENTFUNCTIONS_H_ */ diff --git a/src/simulation/Elements.h b/src/simulation/Elements.h index 5106c5fb3..2753b52c7 100644 --- a/src/simulation/Elements.h +++ b/src/simulation/Elements.h @@ -5,21 +5,12 @@ * Author: Simon */ -//#ifndef ELEMENTS_H_ -//#define ELEMENTS_H_ +#ifndef ELEMENTS_H_ +#define ELEMENTS_H_ //#include "Config.h" //#include "Simulation.h" -#define IPL -257.0f -#define IPH 257.0f -#define ITL MIN_TEMP-1 -#define ITH MAX_TEMP+1 -// no transition (PT_NONE means kill part) -#define NT -1 -// special transition - lava ctypes etc need extra code, which is only found and run if ST is given -#define ST PT_NUM - #define R_TEMP 22 #define MAX_TEMP 9999 #define MIN_TEMP 0 @@ -55,7 +46,6 @@ #define ST_GAS 3 #define UPDATE_FUNC_ARGS Simulation* sim, int i, int x, int y, int surround_space, int nt, Particle *parts, int pmap[YRES][XRES] -// to call another update function with same arguments: #define UPDATE_FUNC_SUBCALL_ARGS sim, i, x, y, surround_space, nt, parts, pmap #define GRAPHICS_FUNC_ARGS Renderer * ren, Particle *cpart, int nx, int ny, int *pixel_mode, int* cola, int *colr, int *colg, int *colb, int *firea, int *firer, int *fireg, int *fireb @@ -119,168 +109,14 @@ #define NGT_FROG 22 #define NGT_BRAN 23 -#define PT_NONE 0 -#define PT_DUST 1 -#define PT_WATR 2 -#define PT_OIL 3 -#define PT_FIRE 4 -#define PT_STNE 5 -#define PT_LAVA 6 -#define PT_GUNP 7 -#define PT_NITR 8 -#define PT_CLNE 9 -#define PT_GAS 10 -#define PT_PLEX 11 -#define PT_GOO 12 -#define PT_ICEI 13 -#define PT_METL 14 -#define PT_SPRK 15 -#define PT_SNOW 16 -#define PT_WOOD 17 -#define PT_NEUT 18 -#define PT_PLUT 19 -#define PT_PLNT 20 -#define PT_ACID 21 -#define PT_VOID 22 -#define PT_WTRV 23 -#define PT_CNCT 24 -#define PT_DSTW 25 -#define PT_SALT 26 -#define PT_SLTW 27 -#define PT_DMND 28 -#define PT_BMTL 29 -#define PT_BRMT 30 -#define PT_PHOT 31 -#define PT_URAN 32 -#define PT_WAX 33 -#define PT_MWAX 34 -#define PT_PSCN 35 -#define PT_NSCN 36 -#define PT_LNTG 37 -#define PT_INSL 38 -#define PT_BHOL 39 -#define PT_WHOL 40 -#define PT_RBDM 41 -#define PT_LRBD 42 -#define PT_NTCT 43 -#define PT_SAND 44 -#define PT_GLAS 45 -#define PT_PTCT 46 -#define PT_BGLA 47 -#define PT_THDR 48 -#define PT_PLSM 49 -#define PT_ETRD 50 -#define PT_NICE 51 -#define PT_NBLE 52 -#define PT_BTRY 53 -#define PT_LCRY 54 -#define PT_STKM 55 -#define PT_SWCH 56 -#define PT_SMKE 57 -#define PT_DESL 58 -#define PT_COAL 59 -#define PT_LO2 60 -#define PT_O2 61 -#define PT_INWR 62 -#define PT_YEST 63 -#define PT_DYST 64 -#define PT_THRM 65 -#define PT_GLOW 66 -#define PT_BRCK 67 -#define PT_HFLM 68 -#define PT_FIRW 69 -#define PT_FUSE 70 -#define PT_FSEP 71 -#define PT_AMTR 72 -#define PT_BCOL 73 -#define PT_PCLN 74 -#define PT_HSWC 75 -#define PT_IRON 76 -#define PT_MORT 77 -#define PT_LIFE 78 -#define PT_DLAY 79 -#define PT_CO2 80 -#define PT_DRIC 81 -#define PT_CBNW 82 -#define PT_STOR 83 -#define PT_PVOD 84 -#define PT_CONV 85 -#define PT_CAUS 86 - -#define PT_LIGH 87 -#define PT_TESC 88 -#define PT_DEST 89 - -#define PT_SPNG 90 -#define PT_RIME 91 -#define PT_FOG 92 -#define PT_BCLN 93 -#define PT_LOVE 94 -#define PT_DEUT 95 -#define PT_WARP 96 -#define PT_PUMP 97 -#define PT_FWRK 98 -#define PT_PIPE 99 -#define PT_FRZZ 100 -#define PT_FRZW 101 -#define PT_GRAV 102 -#define PT_BIZR 103 -#define PT_BIZRG 104 -#define PT_BIZRS 105 -#define PT_INST 106 -#define PT_ISOZ 107 -#define PT_ISZS 108 -#define PT_PRTI 109 -#define PT_PRTO 110 -#define PT_PSTE 111 -#define PT_PSTS 112 -#define PT_ANAR 113 -#define PT_VINE 114 -#define PT_INVIS 115 -#define PT_EQUALVEL 116 //all particles equal their velocities -#define PT_SPAWN2 117 -#define PT_SPAWN 118 -#define PT_SHLD1 119 -#define PT_SHLD2 120 -#define PT_SHLD3 121 -#define PT_SHLD4 122 -#define PT_LOLZ 123 -#define PT_WIFI 124 -#define PT_FILT 125 -#define PT_ARAY 126 -#define PT_BRAY 127 -#define PT_STKM2 128 -#define PT_BOMB 129 -#define PT_C5 130 -#define PT_SING 131 -#define PT_QRTZ 132 -#define PT_PQRT 133 -#define PT_EMP 134 -#define PT_BREC 135 -#define PT_ELEC 136 -#define PT_ACEL 137 -#define PT_DCEL 138 -#define PT_BANG 139 -#define PT_IGNT 140 -#define PT_BOYL 141 -#define PT_GEL 142 -#define PT_TRON 143 - #define OLD_PT_WIND 147 -#define PT_H2 148 -#define PT_SOAP 149 -#define PT_NBHL 150 -#define PT_NWHL 151 -#define PT_MERC 152 -#define PT_PBCN 153 -#define PT_GPMP 154 -#define PT_CLST 155 -#define PT_WIRE 156 -#define PT_GBMB 157 -#define PT_FIGH 158 -#define PT_FRAY 159 -#define PT_REPL 160 -#define PT_NUM 161 + +//#define PT_NUM 161 +#define PT_NUM 256 + +struct playerst; + +#include "ElementClasses.h" -//#endif /* ELEMENTS_H_ */ +#endif /* ELEMENTS_H_ */ diff --git a/src/simulation/Gravity.cpp b/src/simulation/Gravity.cpp index 1a7456697..b0372a3eb 100644 --- a/src/simulation/Gravity.cpp +++ b/src/simulation/Gravity.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include "Config.h" @@ -237,9 +237,9 @@ void Gravity::grav_fft_init() for (x=0; x -#include +#include #include "SaveLoader.h" //!TODO: enum for LoadSave return @@ -497,7 +497,7 @@ int SaveLoader::PSVLoad(unsigned char * data, int dataLength, Simulation * sim, } else { - parts[i-1].temp = sim->ptypes[parts[i-1].type].heat; + parts[i-1].temp = sim->elements[parts[i-1].type].Temperature; } } } @@ -607,7 +607,7 @@ int SaveLoader::PSVLoad(unsigned char * data, int dataLength, Simulation * sim, parts[i-1].tmp2 = parts[i-1].life; } } - if (!sim->ptypes[parts[i-1].type].enabled) + if (!sim->elements[parts[i-1].type].Enabled) parts[i-1].type = PT_NONE; } } diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 0a69c7b74..89295f457 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -3,10 +3,11 @@ #include "Config.h" #include "Simulation.h" #include "Elements.h" -#include "ElementFunctions.h" +//#include "ElementFunctions.h" #include "Air.h" #include "Gravity.h" #include "SaveLoader.h" +#include "elements/Element.h" #undef LUACONSOLE //#include "cat/LuaScriptHelper.h" @@ -263,7 +264,7 @@ int Simulation::flood_water(int x, int y, int i, int originaly, int check) while (x1>=CELL) { - if ((ptypes[(pmap[y][x1-1]&0xFF)].falldown)!=2) + if ((elements[(pmap[y][x1-1]&0xFF)].Falldown)!=2) { break; } @@ -271,7 +272,7 @@ int Simulation::flood_water(int x, int y, int i, int originaly, int check) } while (x2=CELL+1) for (x=x1; x<=x2; x++) - if ((ptypes[(pmap[y-1][x]&0xFF)].falldown)==2 && parts[pmap[y-1][x]>>8].tmp2 == check) + if ((elements[(pmap[y-1][x]&0xFF)].Falldown)==2 && parts[pmap[y-1][x]>>8].tmp2 == check) if (!flood_water(x, y-1, i, originaly, check)) return 0; if (y>8].tmp2 == check) + if ((elements[(pmap[y+1][x]&0xFF)].Falldown)==2 && parts[pmap[y+1][x]>>8].tmp2 == check) if (!flood_water(x, y+1, i, originaly, check)) return 0; return 1; @@ -1175,16 +1176,16 @@ void Simulation::init_can_move() for (rt=1;rt>8].temp = parts[i].temp; - if ((r & 0xFF) < PT_NUM && ptypes[r&0xFF].hconduct && ((r&0xFF)!=PT_HSWC||parts[r>>8].life==10) && (r&0xFF)!=PT_FILT) + if ((r & 0xFF) < PT_NUM && elements[r&0xFF].HeatConduct && ((r&0xFF)!=PT_HSWC||parts[r>>8].life==10) && (r&0xFF)!=PT_FILT) parts[i].temp = parts[r>>8].temp = restrict_flt((parts[r>>8].temp+parts[i].temp)/2, MIN_TEMP, MAX_TEMP); } if ((parts[i].type==PT_NEUT || parts[i].type==PT_ELEC) && ((r&0xFF)==PT_CLNE || (r&0xFF)==PT_PCLN || (r&0xFF)==PT_BCLN || (r&0xFF)==PT_PBCN)) { @@ -1403,7 +1404,7 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny) } //else e=1 , we are trying to swap the particles, return 0 no swap/move, 1 is still overlap/move, because the swap takes place later - if (parts[i].type == PT_NEUT && (ptypes[r & 0xFF].properties & PROP_NEUTABSORB)) + if (parts[i].type == PT_NEUT && (elements[r & 0xFF].Properties & PROP_NEUTABSORB)) { kill_part(i); return 0; @@ -1447,7 +1448,7 @@ int Simulation::try_move(int i, int x, int y, int nx, int ny) if (parts[i].type==PT_NEUT) { // target material is NEUTPENETRATE, meaning it gets moved around when neutron passes unsigned s = pmap[y][x]; - if (!(ptypes[s&0xFF].properties&PROP_NEUTPENETRATE)) + if (!(elements[s&0xFF].Properties&PROP_NEUTPENETRATE)) return 1; // if the element currently underneath neutron isn't NEUTPENETRATE, don't move anything except the neutron // if nothing is currently underneath neutron, only move target particle if (s) @@ -1746,7 +1747,7 @@ void Simulation::part_change_type(int i, int x, int y, int t)//changes the type { if (x<0 || y<0 || x>=XRES || y>=YRES || i>=NPART || t<0 || t>=PT_NUM) return; - if (!ptypes[t].enabled) + if (!elements[t].Enabled) t = PT_NONE; if (parts[i].type == PT_STKM) @@ -1785,7 +1786,7 @@ int Simulation::create_part(int p, int x, int y, int tv)//the function for creat if (x<0 || y<0 || x>=XRES || y>=YRES || ((t<0 || t>=PT_NUM)&&t!=SPC_HEAT&&t!=SPC_COOL&&t!=SPC_AIR&&t!=SPC_VACUUM&&t!=SPC_PGRV&&t!=SPC_NGRV)) return -1; - if (t>=0 && t=0 && t>8].ctype=PT_DUST; } - if (!((pmap[y][x]&0xFF)==PT_INST||(ptypes[pmap[y][x]&0xFF].properties&PROP_CONDUCTS))) + if (!((pmap[y][x]&0xFF)==PT_INST||(elements[pmap[y][x]&0xFF].Properties&PROP_CONDUCTS))) return -1; if (parts[pmap[y][x]>>8].life!=0) return -1; @@ -1905,7 +1906,7 @@ int Simulation::create_part(int p, int x, int y, int tv)//the function for creat if (pmap[y][x]) { if (( - ((pmap[y][x]&0xFF)==PT_STOR&&!(ptypes[t].properties&TYPE_SOLID))|| + ((pmap[y][x]&0xFF)==PT_STOR&&!(elements[t].Properties&TYPE_SOLID))|| (pmap[y][x]&0xFF)==PT_CLNE|| (pmap[y][x]&0xFF)==PT_BCLN|| (pmap[y][x]&0xFF)==PT_CONV|| @@ -1973,7 +1974,7 @@ int Simulation::create_part(int p, int x, int y, int tv)//the function for creat parts[i].vy = 0; parts[i].life = 0; parts[i].ctype = 0; - parts[i].temp = ptypes[t].heat; + parts[i].temp = elements[t].Temperature; parts[i].tmp = 0; parts[i].tmp2 = 0; } @@ -2016,7 +2017,7 @@ int Simulation::create_part(int p, int x, int y, int tv)//the function for creat parts[i].life = 50; parts[i].tmp = 50; } - /*if (ptypes[t].properties&PROP_LIFE) { + /*if (elements[t].Properties&PROP_LIFE) { int r; for (r = 0; r255 ? 255 : (colr<0 ? 0 : colr); colg = colg>255 ? 255 : (colg<0 ? 0 : colg); colb = colb>255 ? 255 : (colb<0 ? 0 : colb); @@ -2463,7 +2464,7 @@ void Simulation::update_particles_i(int start, int inc) continue; } - elem_properties = ptypes[t].properties; + elem_properties = elements[t].Properties; if (parts[i].life>0 && (elem_properties&PROP_LIFE_DEC)) { // automatically decrease life @@ -2499,10 +2500,10 @@ void Simulation::update_particles_i(int start, int inc) bmap[y/CELL][x/CELL]==WL_WALLELEC || bmap[y/CELL][x/CELL]==WL_ALLOWAIR || (bmap[y/CELL][x/CELL]==WL_DESTROYALL) || - (bmap[y/CELL][x/CELL]==WL_ALLOWLIQUID && ptypes[t].falldown!=2) || - (bmap[y/CELL][x/CELL]==WL_ALLOWSOLID && ptypes[t].falldown!=1) || - (bmap[y/CELL][x/CELL]==WL_ALLOWGAS && !(ptypes[t].properties&TYPE_GAS)) || //&& ptypes[t].falldown!=0 && parts[i].type!=PT_FIRE && parts[i].type!=PT_SMKE && parts[i].type!=PT_HFLM) || - (bmap[y/CELL][x/CELL]==WL_ALLOWENERGY && !(ptypes[t].properties&TYPE_ENERGY)) || + (bmap[y/CELL][x/CELL]==WL_ALLOWLIQUID && elements[t].Falldown!=2) || + (bmap[y/CELL][x/CELL]==WL_ALLOWSOLID && elements[t].Falldown!=1) || + (bmap[y/CELL][x/CELL]==WL_ALLOWGAS && !(elements[t].Properties&TYPE_GAS)) || //&& elements[t].Falldown!=0 && parts[i].type!=PT_FIRE && parts[i].type!=PT_SMKE && parts[i].type!=PT_HFLM) || + (bmap[y/CELL][x/CELL]==WL_ALLOWENERGY && !(elements[t].Properties&TYPE_ENERGY)) || (bmap[y/CELL][x/CELL]==WL_DETECT && (t==PT_METL || t==PT_SPRK)) || (bmap[y/CELL][x/CELL]==WL_EWALL && !emap[y/CELL][x/CELL])) && (t!=PT_STKM) && (t!=PT_STKM2) && (t!=PT_FIGH))) { @@ -2513,33 +2514,33 @@ void Simulation::update_particles_i(int start, int inc) set_emap(x/CELL, y/CELL); //adding to velocity from the particle's velocity - vx[y/CELL][x/CELL] = vx[y/CELL][x/CELL]*ptypes[t].airloss + ptypes[t].airdrag*parts[i].vx; - vy[y/CELL][x/CELL] = vy[y/CELL][x/CELL]*ptypes[t].airloss + ptypes[t].airdrag*parts[i].vy; + vx[y/CELL][x/CELL] = vx[y/CELL][x/CELL]*elements[t].AirLoss + elements[t].AirDrag*parts[i].vx; + vy[y/CELL][x/CELL] = vy[y/CELL][x/CELL]*elements[t].AirLoss + elements[t].AirDrag*parts[i].vy; if (t==PT_GAS||t==PT_NBLE) { if (pv[y/CELL][x/CELL]<3.5f) - pv[y/CELL][x/CELL] += ptypes[t].hotair*(3.5f-pv[y/CELL][x/CELL]); + pv[y/CELL][x/CELL] += elements[t].HotAir*(3.5f-pv[y/CELL][x/CELL]); if (y+CELL= 0 && y-2 < YRES && (ptypes[t].properties&TYPE_LIQUID) && (t!=PT_GEL || gel_scale>(1+rand()%255))) {//some heat convection for liquids + if (y-2 >= 0 && y-2 < YRES && (elements[t].Properties&TYPE_LIQUID) && (t!=PT_GEL || gel_scale>(1+rand()%255))) {//some heat convection for liquids r = pmap[y-2][x]; if (!(!r || parts[i].type != (r&0xFF))) { if (parts[i].temp>parts[r>>8].temp) { @@ -2628,19 +2629,19 @@ void Simulation::update_particles_i(int start, int inc) //heat transfer code h_count = 0; #ifdef REALISTIC - if (t&&(t!=PT_HSWC||parts[i].life==10)&&(ptypes[t].hconduct*gel_scale)) + if (t&&(t!=PT_HSWC||parts[i].life==10)&&(elements[t].HeatConduct*gel_scale)) { float c_Cm = 0.0f; #else - if (t&&(t!=PT_HSWC||parts[i].life==10)&&(ptypes[t].hconduct*gel_scale)>(rand()%250)) + if (t&&(t!=PT_HSWC||parts[i].life==10)&&(elements[t].HeatConduct*gel_scale)>(rand()%250)) { float c_Cm = 0.0f; #endif if (aheat_enable) { #ifdef REALISTIC - c_heat = parts[i].temp*96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight) + hv[y/CELL][x/CELL]*100*(pv[y/CELL][x/CELL]+273.15f)/256; - c_Cm = 96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight) + 100*(pv[y/CELL][x/CELL]+273.15f)/256; + c_heat = parts[i].temp*96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight) + hv[y/CELL][x/CELL]*100*(pv[y/CELL][x/CELL]+273.15f)/256; + c_Cm = 96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight) + 100*(pv[y/CELL][x/CELL]+273.15f)/256; pt = c_heat/c_Cm; pt = restrict_flt(pt, -MAX_TEMP+MIN_TEMP, MAX_TEMP-MIN_TEMP); parts[i].temp = pt; @@ -2663,7 +2664,7 @@ void Simulation::update_particles_i(int start, int inc) if (!r) continue; rt = r&0xFF; - if (rt&&ptypes[rt].hconduct&&(rt!=PT_HSWC||parts[r>>8].life==10) + if (rt&&elements[rt].HeatConduct&&(rt!=PT_HSWC||parts[r>>8].life==10) &&(t!=PT_FILT||(rt!=PT_BRAY&&rt!=PT_BIZR&&rt!=PT_BIZRG)) &&(rt!=PT_FILT||(t!=PT_BRAY&&t!=PT_PHOT&&t!=PT_BIZR&&t!=PT_BIZRG))) { @@ -2673,8 +2674,8 @@ void Simulation::update_particles_i(int start, int inc) gel_scale = parts[r>>8].tmp*2.55f; else gel_scale = 1.0f; - c_heat += parts[r>>8].temp*96.645/ptypes[rt].hconduct*gel_scale*fabs(ptypes[rt].weight); - c_Cm += 96.645/ptypes[rt].hconduct*gel_scale*fabs(ptypes[rt].weight); + c_heat += parts[r>>8].temp*96.645/elements[rt].HeatConduct*gel_scale*fabs(elements[rt].Weight); + c_Cm += 96.645/elements[rt].HeatConduct*gel_scale*fabs(elements[rt].Weight); #else c_heat += parts[r>>8].temp; #endif @@ -2689,10 +2690,10 @@ void Simulation::update_particles_i(int start, int inc) if (t == PT_PHOT) pt = (c_heat+parts[i].temp*96.645)/(c_Cm+96.645); else - pt = (c_heat+parts[i].temp*96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight))/(c_Cm+96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight)); + pt = (c_heat+parts[i].temp*96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight))/(c_Cm+96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight)); - c_heat += parts[i].temp*96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight); - c_Cm += 96.645/ptypes[t].hconduct*gel_scale*fabs(ptypes[t].weight); + c_heat += parts[i].temp*96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight); + c_Cm += 96.645/elements[t].HeatConduct*gel_scale*fabs(elements[t].Weight); parts[i].temp = restrict_flt(pt, MIN_TEMP, MAX_TEMP); #else pt = (c_heat+parts[i].temp)/(h_count+1); @@ -2705,10 +2706,10 @@ void Simulation::update_particles_i(int start, int inc) ctemph = ctempl = pt; // change boiling point with pressure - if ((ptypes[t].state==ST_LIQUID && ptransitions[t].tht>-1 && ptransitions[t].tht-1 && elements[t].HighTemperatureTransition-1 && ptransitions[t].tlt-1 && elements[t].LowTemperatureTransition=PT_NUM || parts[i].ctype==PT_ICEI)) parts[i].ctype = PT_WATR; - if (ctemph>ptransitions[t].thv&&ptransitions[t].tht>-1) { + if (ctemph>elements[t].HighTemperature&&elements[t].HighTemperatureTransition>-1) { // particle type change due to high temperature #ifdef REALISTIC float dbt = ctempl - pt; - if (ptransitions[t].tht!=PT_NUM) + if (elements[t].HighTemperatureTransition!=PT_NUM) { - if (platent[t] <= (c_heat - (ptransitions[t].thv - dbt)*c_Cm)) + if (platent[t] <= (c_heat - (elements[t].HighTemperature - dbt)*c_Cm)) { pt = (c_heat - platent[t])/c_Cm; - t = ptransitions[t].tht; + t = elements[t].HighTemperatureTransition; } else { - parts[i].temp = restrict_flt(ptransitions[t].thv - dbt, MIN_TEMP, MAX_TEMP); + parts[i].temp = restrict_flt(elements[t].HighTemperature - dbt, MIN_TEMP, MAX_TEMP); s = 0; } } #else - if (ptransitions[t].tht!=PT_NUM) - t = ptransitions[t].tht; + if (elements[t].HighTemperatureTransition!=PT_NUM) + t = elements[t].HighTemperatureTransition; #endif else if (t==PT_ICEI) { if (parts[i].ctype-1) { + } else if (ctempl-1) { // particle type change due to low temperature #ifdef REALISTIC float dbt = ctempl - pt; - if (ptransitions[t].tlt!=PT_NUM) + if (elements[t].LowTemperatureTransition!=PT_NUM) { - if (platent[ptransitions[t].tlt] >= (c_heat - (ptransitions[t].tlv - dbt)*c_Cm)) + if (platent[elements[t].LowTemperatureTransition] >= (c_heat - (elements[t].LowTemperature - dbt)*c_Cm)) { - pt = (c_heat + platent[ptransitions[t].tlt])/c_Cm; - t = ptransitions[t].tlt; + pt = (c_heat + platent[elements[t].LowTemperatureTransition])/c_Cm; + t = elements[t].LowTemperatureTransition; } else { - parts[i].temp = restrict_flt(ptransitions[t].tlv - dbt, MIN_TEMP, MAX_TEMP); + parts[i].temp = restrict_flt(elements[t].LowTemperature - dbt, MIN_TEMP, MAX_TEMP); s = 0; } } #else - if (ptransitions[t].tlt!=PT_NUM) - t = ptransitions[t].tlt; + if (elements[t].LowTemperatureTransition!=PT_NUM) + t = elements[t].LowTemperatureTransition; #endif else if (t==PT_WTRV) { if (pt<273.0f) t = PT_RIME; @@ -2812,9 +2813,9 @@ void Simulation::update_particles_i(int start, int inc) } else if (t==PT_LAVA) { if (parts[i].ctype>0 && parts[i].ctype=ptransitions[PT_BMTL].thv) s = 0; - else if (ptransitions[parts[i].ctype].tht==PT_LAVA) { - if (pt>=ptransitions[parts[i].ctype].thv) s = 0; + if (parts[i].ctype==PT_THRM&&pt>=elements[PT_BMTL].HighTemperature) s = 0; + else if (elements[parts[i].ctype].HighTemperatureTransition==PT_LAVA) { + if (pt>=elements[parts[i].ctype].HighTemperature) s = 0; } else if (pt>=973.0f) s = 0; // freezing point for lava with any other (not listed in ptransitions as turning into lava) ctype if (s) { @@ -2848,7 +2849,7 @@ void Simulation::update_particles_i(int start, int inc) if (t==PT_ICEI||t==PT_LAVA) parts[i].ctype = parts[i].type; if (!(t==PT_ICEI&&parts[i].ctype==PT_FRZW)) parts[i].life = 0; - if (ptypes[t].state==ST_GAS&&ptypes[parts[i].type].state!=ST_GAS) + if (elements[t].State==ST_GAS&&elements[parts[i].type].State!=ST_GAS) pv[y/CELL][x/CELL] += 0.50f; part_change_type(i,x,y,t); if (t==PT_FIRE||t==PT_PLSM||t==PT_HFLM) @@ -2894,7 +2895,7 @@ void Simulation::update_particles_i(int start, int inc) //wire_placed = 1; } //spark updates from walls - if ((ptypes[t].properties&PROP_CONDUCTS) || t==PT_SPRK) + if ((elements[t].Properties&PROP_CONDUCTS) || t==PT_SPRK) { nx = x % CELL; if (nx == 0) @@ -2928,10 +2929,10 @@ void Simulation::update_particles_i(int start, int inc) } //the basic explosion, from the .explosive variable - if ((ptypes[t].explosive&2) && pv[y/CELL][x/CELL]>2.5f) + if ((elements[t].Explosive&2) && pv[y/CELL][x/CELL]>2.5f) { parts[i].life = rand()%80+180; - parts[i].temp = restrict_flt(ptypes[PT_FIRE].heat + (ptypes[t].flammable/2), MIN_TEMP, MAX_TEMP); + parts[i].temp = restrict_flt(elements[PT_FIRE].Temperature + (elements[t].Flammable/2), MIN_TEMP, MAX_TEMP); t = PT_FIRE; part_change_type(i,x,y,t); pv[y/CELL][x/CELL] += 0.25f * CFDS; @@ -2940,10 +2941,10 @@ void Simulation::update_particles_i(int start, int inc) s = 1; gravtot = fabs(gravy[(y/CELL)*(XRES/CELL)+(x/CELL)])+fabs(gravx[(y/CELL)*(XRES/CELL)+(x/CELL)]); - if (pv[y/CELL][x/CELL]>ptransitions[t].phv&&ptransitions[t].pht>-1) { + if (pv[y/CELL][x/CELL]>elements[t].HighPressure&&elements[t].HighPressureTransition>-1) { // particle type change due to high pressure - if (ptransitions[t].pht!=PT_NUM) - t = ptransitions[t].pht; + if (elements[t].HighPressureTransition!=PT_NUM) + t = elements[t].HighPressureTransition; else if (t==PT_BMTL) { if (pv[y/CELL][x/CELL]>2.5f) t = PT_BRMT; @@ -2952,15 +2953,15 @@ void Simulation::update_particles_i(int start, int inc) else s = 0; } else s = 0; - } else if (pv[y/CELL][x/CELL]-1) { + } else if (pv[y/CELL][x/CELL]-1) { // particle type change due to low pressure - if (ptransitions[t].plt!=PT_NUM) - t = ptransitions[t].plt; + if (elements[t].LowPressureTransition!=PT_NUM) + t = elements[t].LowPressureTransition; else s = 0; - } else if (gravtot>(ptransitions[t].phv/4.0f)&&ptransitions[t].pht>-1) { + } else if (gravtot>(elements[t].HighPressure/4.0f)&&elements[t].HighPressureTransition>-1) { // particle type change due to high gravity - if (ptransitions[t].pht!=PT_NUM) - t = ptransitions[t].pht; + if (elements[t].HighPressureTransition!=PT_NUM) + t = elements[t].HighPressureTransition; else if (t==PT_BMTL) { if (gravtot>0.625f) t = PT_BRMT; @@ -2983,12 +2984,12 @@ void Simulation::update_particles_i(int start, int inc) //call the particle update function, if there is one #ifdef LUACONSOLE - if (ptypes[t].update_func && lua_el_mode[t] != 2) + if (elements[t].Update && lua_el_mode[t] != 2) #else - if (ptypes[t].update_func) + if (elements[t].Update) #endif { - if ((*(ptypes[t].update_func))(this, i,x,y,surround_space,nt, parts, pmap)) + if ((*(elements[t].Update))(this, i,x,y,surround_space,nt, parts, pmap)) continue; else if (t==PT_WARP) { @@ -3007,8 +3008,8 @@ void Simulation::update_particles_i(int start, int inc) y = (int)(parts[i].y+0.5f); } #endif - if (legacy_enable)//if heat sim is off - update_legacy_all(this, i,x,y,surround_space,nt, parts, pmap); + //if (legacy_enable)//if heat sim is off + //update_legacy_all(this, i,x,y,surround_space,nt, parts, pmap); //TODO:pop killed: if (parts[i].type == PT_NONE)//if its dead, skip to next particle @@ -3191,7 +3192,7 @@ killed: } } } - else if (ptypes[t].falldown==0) + else if (elements[t].Falldown==0) { // gasses and solids (but not powders) if (!do_move(i, x, y, fin_xf, fin_yf)) @@ -3207,22 +3208,22 @@ killed: if (fin_y= rand()%400)//checking stagnant is cool, but then it doesn't update when you change it later. + if (water_equal_test && elements[t].Falldown == 2 && 1>= rand()%400)//checking stagnant is cool, but then it doesn't update when you change it later. { if (!flood_water(x,y,i,y, parts[i].tmp2)) goto movedone; @@ -3234,13 +3235,13 @@ killed: continue; if (fin_x!=x && do_move(i, x, y, fin_xf, clear_yf)) { - parts[i].vx *= ptypes[t].collision; - parts[i].vy *= ptypes[t].collision; + parts[i].vx *= elements[t].Collision; + parts[i].vy *= elements[t].Collision; } else if (fin_y!=y && do_move(i, x, y, clear_xf, fin_yf)) { - parts[i].vx *= ptypes[t].collision; - parts[i].vy *= ptypes[t].collision; + parts[i].vx *= elements[t].Collision; + parts[i].vy *= elements[t].Collision; } else { @@ -3261,8 +3262,8 @@ killed: dy /= mv; if (do_move(i, x, y, clear_xf+dx, clear_yf+dy)) { - parts[i].vx *= ptypes[t].collision; - parts[i].vy *= ptypes[t].collision; + parts[i].vx *= elements[t].Collision; + parts[i].vy *= elements[t].Collision; goto movedone; } swappage = dx; @@ -3270,12 +3271,12 @@ killed: dy = -swappage*r; if (do_move(i, x, y, clear_xf+dx, clear_yf+dy)) { - parts[i].vx *= ptypes[t].collision; - parts[i].vy *= ptypes[t].collision; + parts[i].vx *= elements[t].Collision; + parts[i].vy *= elements[t].Collision; goto movedone; } } - if (ptypes[t].falldown>1 && !ngrav_enable && gravityMode==0 && parts[i].vy>fabsf(parts[i].vx)) + if (elements[t].Falldown>1 && !ngrav_enable && gravityMode==0 && parts[i].vy>fabsf(parts[i].vx)) { s = 0; // stagnant is true if FLAG_STAGNANT was set for this particle in previous frame @@ -3321,12 +3322,12 @@ killed: else if (s==-1) {} // particle is out of bounds else if ((clear_x!=x||clear_y!=y) && do_move(i, x, y, clear_xf, clear_yf)) {} else parts[i].flags |= FLAG_STAGNANT; - parts[i].vx *= ptypes[t].collision; - parts[i].vy *= ptypes[t].collision; + parts[i].vx *= elements[t].Collision; + parts[i].vy *= elements[t].Collision; } - else if (ptypes[t].falldown>1 && fabsf(pGravX*parts[i].vx+pGravY*parts[i].vy)>fabsf(pGravY*parts[i].vx-pGravX*parts[i].vy)) + else if (elements[t].Falldown>1 && fabsf(pGravX*parts[i].vx+pGravY*parts[i].vy)>fabsf(pGravY*parts[i].vx-pGravX*parts[i].vy)) { - float nxf, nyf, prev_pGravX, prev_pGravY, ptGrav = ptypes[t].gravity; + float nxf, nyf, prev_pGravX, prev_pGravY, ptGrav = elements[t].Gravity; s = 0; // stagnant is true if FLAG_STAGNANT was set for this particle in previous frame if (!stagnant || nt) //nt is if there is an something else besides the current particle type, around the particle @@ -3439,16 +3440,16 @@ killed: else if (s==-1) {} // particle is out of bounds else if ((clear_x!=x||clear_y!=y) && do_move(i, x, y, clear_xf, clear_yf)) {} else parts[i].flags |= FLAG_STAGNANT; - parts[i].vx *= ptypes[t].collision; - parts[i].vy *= ptypes[t].collision; + parts[i].vx *= elements[t].Collision; + parts[i].vy *= elements[t].Collision; } else { // if interpolation was done, try moving to last clear position if ((clear_x!=x||clear_y!=y) && do_move(i, x, y, clear_xf, clear_yf)) {} else parts[i].flags |= FLAG_STAGNANT; - parts[i].vx *= ptypes[t].collision; - parts[i].vy *= ptypes[t].collision; + parts[i].vx *= elements[t].Collision; + parts[i].vy *= elements[t].Collision; } } } @@ -3615,20 +3616,18 @@ Simulation::Simulation(): memcpy(wtypes, wtypesT, wallCount * sizeof(wall_type)); free(wtypesT); - int elementCount; - part_type * ptypesT = LoadElements(elementCount); - memcpy(ptypes, ptypesT, elementCount * sizeof(part_type)); - free(ptypesT); - + platent = new unsigned[PT_NUM]; int latentCount; unsigned int * platentT = LoadLatent(latentCount); memcpy(platent, platentT, latentCount * sizeof(unsigned int)); free(platentT); - - int transitionCount; - part_transition * ptransitionsT = LoadTransitions(transitionCount); - memcpy(ptransitions, ptransitionsT, sizeof(part_transition) * transitionCount); - free(ptransitionsT); + + elements = new Element[PT_NUM]; + std::vector elementList = GetElements(); + for(int i = 0; i < elementList.size(); i++) + { + elements[i] = elementList[i]; + } int golRulesCount; int * golRulesT = LoadGOLRules(golRulesCount); diff --git a/src/simulation/Simulation.h b/src/simulation/Simulation.h index 125837351..62427fc5b 100644 --- a/src/simulation/Simulation.h +++ b/src/simulation/Simulation.h @@ -139,9 +139,8 @@ public: Gravity * grav; Air * air; - part_type ptypes[PT_NUM]; - unsigned int platent[PT_NUM]; - part_transition ptransitions[PT_NUM]; + Element * elements; + unsigned int * platent; wall_type wtypes[UI_WALLCOUNT]; gol_menu gmenu[NGOL]; int goltype[NGOL]; diff --git a/src/simulation/SimulationData.cpp b/src/simulation/SimulationData.cpp index 043091e28..60def195e 100644 --- a/src/simulation/SimulationData.cpp +++ b/src/simulation/SimulationData.cpp @@ -5,9 +5,22 @@ * Author: Simon */ #include "SimulationData.h" -#include "ElementFunctions.h" +//#include "ElementFunctions.h" #include "ElementGraphics.h" +std::vector GetDefaultElements() +{ + std::vector elements; + //class Element; + //elements.push_back(dynamic_cast(new NULLElement())); + //elements.push_back(dynamic_cast(new DUSTElement())); + //elements.push_back(dynamic_cast(new WATRElement())); + //for(int i = 3; i < PT_NUM; i++) + // elements.push_back(dynamic_cast(new DUSTElement())); + + return elements; +} + gol_menu * LoadGOLMenu(int & golMenuCount) { gol_menu golMenu[NGOL] = @@ -185,7 +198,7 @@ part_type * LoadElements(int & elementCount) part_type ptypes[PT_NUM] = { //Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Use Weight Section H Ins Description - {"", PIXPACK(0x000000), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "Erases particles.", ST_NONE, 0, NULL, NULL}, + /*{"", PIXPACK(0x000000), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "Erases particles.", ST_NONE, 0, NULL, NULL}, {"DUST", PIXPACK(0xFFE0A0), 0.7f, 0.02f * CFDS, 0.96f, 0.80f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 10, 0, 0, 30, 1, 1, 85, SC_POWDERS, R_TEMP+0.0f +273.15f, 70, "Very light dust. Flammable.", ST_SOLID, TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC, NULL, &graphics_DUST}, {"WATR", PIXPACK(0x2030D0), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 1, 30, SC_LIQUID, R_TEMP-2.0f +273.15f, 29, "Liquid. Conducts electricity. Freezes. Extinguishes fires.", ST_LIQUID, TYPE_LIQUID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_NEUTPENETRATE, &update_WATR, NULL}, {"OIL", PIXPACK(0x404010), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 20, 0, 0, 5, 1, 1, 20, SC_LIQUID, R_TEMP+0.0f +273.15f, 42, "Liquid. Flammable.", ST_LIQUID, TYPE_LIQUID, NULL, NULL}, @@ -333,10 +346,10 @@ part_type * LoadElements(int & elementCount) {"BOYL", PIXPACK(0x0A3200), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 0.18f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 1, SC_GAS, R_TEMP+2.0f +273.15f, 42, "Boyle, variable pressure gas. Expands when heated.", ST_GAS, TYPE_GAS, &update_BOYL, NULL}, {"GEL", PIXPACK(0xFF9900), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 1, 35, SC_LIQUID, R_TEMP-2.0f +273.15f, 29, "Gel. A liquid with variable viscosity and heat conductivity", ST_LIQUID, TYPE_LIQUID|PROP_LIFE_DEC|PROP_NEUTPENETRATE, &update_GEL, &graphics_GEL}, {"TRON", PIXPACK(0x000000), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 100, SC_SPECIAL, 0.0f, 40, "Smart particles, Travels in straight lines and avoids obstacles. Grows with time.", ST_NONE, TYPE_SOLID|PROP_LIFE_DEC|PROP_LIFE_KILL, &update_TRON, &graphics_TRON}, - /*FREE*/{"STAR", PIXPACK(0x0000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Like Star Wars rule S3456/B278/6", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL}, - /*FREE*/{"FROG", PIXPACK(0x00AA00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Frogs S12/B34/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL}, - /*FREE*/{"BRAN", PIXPACK(0xCCCC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Brian 6 S6/B246/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL}, - /*FREE*/{"WIND", PIXPACK(0x101010), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_SPECIAL, 0.0f, 40, "", ST_NONE, ST_NONE, NULL, NULL}, + {"STAR", PIXPACK(0x0000FF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Like Star Wars rule S3456/B278/6", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL}, + {"FROG", PIXPACK(0x00AA00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Frogs S12/B34/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL}, + {"BRAN", PIXPACK(0xCCCC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_LIFE, 9000.0f, 40, "Brian 6 S6/B246/3", ST_NONE, TYPE_SOLID|PROP_LIFE, NULL, NULL}, + {"WIND", PIXPACK(0x101010), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 0, 0, 100, SC_SPECIAL, 0.0f, 40, "", ST_NONE, ST_NONE, NULL, NULL}, {"HYGN", PIXPACK(0x5070FF), 2.0f, 0.00f * CFDS, 0.99f, 0.30f, -0.10f, 0.00f, 3.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 1, SC_GAS, R_TEMP+0.0f +273.15f, 251, "Combines with O2 to make WATR", ST_GAS, TYPE_GAS, &update_H2, NULL}, {"SOAP", PIXPACK(0xF5F5DC), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 0, 0, 0, 20, 1, 1, 35, SC_LIQUID, R_TEMP-2.0f +273.15f, 29, "Soap. Creates bubbles.", ST_LIQUID, TYPE_LIQUID|PROP_NEUTPENETRATE|PROP_LIFE_DEC, &update_SOAP, NULL}, {"BHOL", PIXPACK(0x202020), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 186, "Black hole (Requires newtonian gravity)", ST_SOLID, TYPE_SOLID, &update_NBHL, NULL}, @@ -349,7 +362,7 @@ part_type * LoadElements(int & elementCount) {"GBMB", PIXPACK(0x1144BB), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 20, 1, 1, 30, SC_EXPLOSIVE, R_TEMP-2.0f +273.15f, 29, "Sticks to first object it touches then produces strong gravity push.", ST_NONE, TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC, &update_GBMB, &graphics_GBMB}, {"FIGH", PIXPACK(0x000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Fighter. Tries to kill stickmen.", ST_NONE, 0, &update_FIGH, &graphics_FIGH}, {"FRAY", PIXPACK(0x00BBFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_FORCE, 20.0f+0.0f +273.15f, 0, "Force Emitter. Push or pull objects based on temp value, use like ARAY", ST_SOLID, TYPE_SOLID|PROP_LIFE_DEC, &update_FRAY, NULL}, - {"RPEL", PIXPACK(0x99CC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_FORCE, 20.0f+0.0f +273.15f, 0, "Repel or attract particles based on temp value.", ST_NONE, TYPE_SOLID, &update_REPL, NULL}, + {"RPEL", PIXPACK(0x99CC00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_FORCE, 20.0f+0.0f +273.15f, 0, "Repel or attract particles based on temp value.", ST_NONE, TYPE_SOLID, &update_REPL, NULL},*/ //Name Colour Advec Airdrag Airloss Loss Collid Grav Diffus Hotair Fal Burn Exp Mel Hrd M Use Weight Section H Ins Description }; elementCount = PT_NUM; diff --git a/src/simulation/SimulationData.h b/src/simulation/SimulationData.h index 03c491af5..0624322ea 100644 --- a/src/simulation/SimulationData.h +++ b/src/simulation/SimulationData.h @@ -5,6 +5,8 @@ * Author: Simon */ +#include + #define SC_WALL 0 #define SC_ELEC 1 #define SC_POWERED 2 @@ -118,6 +120,7 @@ #ifndef SIMULATIONDATA_H_ #define SIMULATIONDATA_H_ +//#include "elements/NULLElement.h" #include "Simulation.h" /*class Simulation; @@ -136,6 +139,9 @@ struct menu_section; struct wall_type; +class Element; +std::vector GetDefaultElements(); + gol_menu * LoadGOLMenu(int & golMenuCount); int * LoadGOLTypes(int & golTypeCount); diff --git a/src/simulation/elements/116.cpp b/src/simulation/elements/116.cpp new file mode 100644 index 000000000..9b939ffcd --- /dev/null +++ b/src/simulation/elements/116.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_116 PT_116 116 +Element_116::Element_116() +{ + Identifier = "DEFAULT_PT_116"; + Name = "EQVE"; + Colour = PIXPACK(0xFFE0A0); + MenuVisible = 0; + MenuSection = SC_CRACKER2; + Enabled = 1; + + Advection = 0.7f; + AirDrag = 0.02f * CFDS; + AirLoss = 0.96f; + Loss = 0.80f; + Collision = 0.0f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 30; + + Weight = 85; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 70; + Description = "Shared velocity test"; + + State = ST_SOLID; + Properties = TYPE_PART; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = NULL; + Graphics = NULL; +} + +Element_116::~Element_116() {} \ No newline at end of file diff --git a/src/simulation/elements/144.cpp b/src/simulation/elements/144.cpp new file mode 100644 index 000000000..82f1d7e78 --- /dev/null +++ b/src/simulation/elements/144.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_144 PT_144 144 +Element_144::Element_144() +{ + Identifier = "DEFAULT_PT_144"; + Name = "STAR"; + Colour = PIXPACK(0x0000FF); + MenuVisible = 0; + MenuSection = SC_LIFE; + Enabled = 0; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 100; + + Temperature = 9000.0f; + HeatConduct = 40; + Description = "Like Star Wars rule S3456/B278/6"; + + State = ST_NONE; + Properties = TYPE_SOLID|PROP_LIFE; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = NULL; + Graphics = NULL; +} + +Element_144::~Element_144() {} \ No newline at end of file diff --git a/src/simulation/elements/145.cpp b/src/simulation/elements/145.cpp new file mode 100644 index 000000000..de9b4c26c --- /dev/null +++ b/src/simulation/elements/145.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_145 PT_145 145 +Element_145::Element_145() +{ + Identifier = "DEFAULT_PT_145"; + Name = "FROG"; + Colour = PIXPACK(0x00AA00); + MenuVisible = 0; + MenuSection = SC_LIFE; + Enabled = 0; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 100; + + Temperature = 9000.0f; + HeatConduct = 40; + Description = "Frogs S12/B34/3"; + + State = ST_NONE; + Properties = TYPE_SOLID|PROP_LIFE; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = NULL; + Graphics = NULL; +} + +Element_145::~Element_145() {} \ No newline at end of file diff --git a/src/simulation/elements/146.cpp b/src/simulation/elements/146.cpp new file mode 100644 index 000000000..8afb8e45b --- /dev/null +++ b/src/simulation/elements/146.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_146 PT_146 146 +Element_146::Element_146() +{ + Identifier = "DEFAULT_PT_146"; + Name = "BRAN"; + Colour = PIXPACK(0xCCCC00); + MenuVisible = 0; + MenuSection = SC_LIFE; + Enabled = 0; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 100; + + Temperature = 9000.0f; + HeatConduct = 40; + Description = "Brian 6 S6/B246/3"; + + State = ST_NONE; + Properties = TYPE_SOLID|PROP_LIFE; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = NULL; + Graphics = NULL; +} + +Element_146::~Element_146() {} \ No newline at end of file diff --git a/src/simulation/elements/147.cpp b/src/simulation/elements/147.cpp new file mode 100644 index 000000000..868c766e6 --- /dev/null +++ b/src/simulation/elements/147.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_147 PT_147 147 +Element_147::Element_147() +{ + Identifier = "DEFAULT_PT_147"; + Name = "WIND"; + Colour = PIXPACK(0x101010); + MenuVisible = 0; + MenuSection = SC_SPECIAL; + Enabled = 0; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 100; + + Temperature = 0.0f; + HeatConduct = 40; + Description = ""; + + State = ST_NONE; + Properties = ST_NONE; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = NULL; + Graphics = NULL; +} + +Element_147::~Element_147() {} \ No newline at end of file diff --git a/src/simulation/elements/ACEL.cpp b/src/simulation/elements/ACEL.cpp new file mode 100644 index 000000000..8dfad7932 --- /dev/null +++ b/src/simulation/elements/ACEL.cpp @@ -0,0 +1,85 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_ACEL PT_ACEL 137 +Element_ACEL::Element_ACEL() +{ + Identifier = "DEFAULT_PT_ACEL"; + Name = "ACEL"; + Colour = PIXPACK(0x0099CC); + MenuVisible = 1; + MenuSection = SC_FORCE; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Accelerator"; + + State = ST_NONE; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_ACEL::update; + Graphics = &Element_ACEL::graphics; +} + +//#TPT-Directive ElementHeader Element_ACEL static int update(UPDATE_FUNC_ARGS) +int Element_ACEL::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + parts[i].tmp = 0; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rxphotons[y+ry][x+rx]; + if ((r>>8)>=NPART || !r) + continue; + if(sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) + { + parts[r>>8].vx *= 1.1f; + parts[r>>8].vy *= 1.1f; + parts[i].tmp = 1; + } + } + return 0; +} + + + +//#TPT-Directive ElementHeader Element_ACEL static int graphics(GRAPHICS_FUNC_ARGS) +int Element_ACEL::graphics(GRAPHICS_FUNC_ARGS) + +{ + if(cpart->tmp) + *pixel_mode |= PMODE_GLOW; + return 0; +} + + +Element_ACEL::~Element_ACEL() {} \ No newline at end of file diff --git a/src/simulation/elements/ACID.cpp b/src/simulation/elements/ACID.cpp new file mode 100644 index 000000000..fb6cb81b6 --- /dev/null +++ b/src/simulation/elements/ACID.cpp @@ -0,0 +1,144 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_ACID PT_ACID 21 +Element_ACID::Element_ACID() +{ + Identifier = "DEFAULT_PT_ACID"; + Name = "ACID"; + Colour = PIXPACK(0xED55FF); + MenuVisible = 1; + MenuSection = SC_LIQUID; + Enabled = 1; + + Advection = 0.6f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.98f; + Loss = 0.95f; + Collision = 0.0f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 2; + + Flammable = 40; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 10; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 34; + Description = "Dissolves almost everything."; + + State = ST_LIQUID; + Properties = TYPE_LIQUID|PROP_DEADLY; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_ACID::update; + Graphics = &Element_ACID::graphics; +} + +//#TPT-Directive ElementHeader Element_ACID static int update(UPDATE_FUNC_ARGS) +int Element_ACID::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry, trade, np; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rxpart_change_type(i,x,y,PT_FIRE); + sim->part_change_type(r>>8,x+rx,y+ry,PT_FIRE); + parts[i].life = 4; + parts[r>>8].life = 4; + } + else if ((r&0xFF)==PT_WTRV) + { + if(!(rand()%250)) + { + sim->part_change_type(i, x, y, PT_CAUS); + parts[i].life = (rand()%50)+25; + sim->kill_part(r>>8); + } + } + else if (((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && sim->elements[r&0xFF].Hardness>(rand()%1000))&&parts[i].life>=50) + { + if (sim->parts_avg(i, r>>8,PT_GLAS)!= PT_GLAS)//GLAS protects stuff from acid + { + float newtemp = ((60.0f-(float)sim->elements[r&0xFF].Hardness))*7.0f; + if(newtemp < 0){ + newtemp = 0; + } + parts[i].temp += newtemp; + parts[i].life--; + sim->kill_part(r>>8); + } + } + else if (parts[i].life<=50) + { + sim->kill_part(i); + return 1; + } + } + } + for ( trade = 0; trade<2; trade ++) + { + rx = rand()%5-2; + ry = rand()%5-2; + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if ((r&0xFF)==PT_ACID&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion + { + int temp = parts[i].life - parts[r>>8].life; + if (temp ==1) + { + parts[r>>8].life ++; + parts[i].life --; + } + else if (temp>0) + { + parts[r>>8].life += temp/2; + parts[i].life -= temp/2; + } + } + } + } + return 0; +} + + +//#TPT-Directive ElementHeader Element_ACID static int graphics(GRAPHICS_FUNC_ARGS) +int Element_ACID::graphics(GRAPHICS_FUNC_ARGS) + +{ + int s = cpart->life; + if (s>75) s = 75; //These two should not be here. + if (s<49) s = 49; + s = (s-49)*3; + if (s==0) s = 1; + *colr += s*4; + *colg += s*1; + *colb += s*2; + *pixel_mode |= PMODE_BLUR; + return 0; +} + + +Element_ACID::~Element_ACID() {} \ No newline at end of file diff --git a/src/simulation/elements/AMTR.cpp b/src/simulation/elements/AMTR.cpp new file mode 100644 index 000000000..a93d1cd17 --- /dev/null +++ b/src/simulation/elements/AMTR.cpp @@ -0,0 +1,79 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_AMTR PT_AMTR 72 +Element_AMTR::Element_AMTR() +{ + Identifier = "DEFAULT_PT_AMTR"; + Name = "AMTR"; + Colour = PIXPACK(0x808080); + MenuVisible = 1; + MenuSection = SC_NUCLEAR; + Enabled = 1; + + Advection = 0.7f; + AirDrag = 0.02f * CFDS; + AirLoss = 0.96f; + Loss = 0.80f; + Collision = 0.00f; + Gravity = 0.10f; + Diffusion = 1.00f; + HotAir = 0.0000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 70; + Description = "Anti-Matter, Destroys a majority of particles"; + + State = ST_NONE; + Properties = TYPE_PART; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_AMTR::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_AMTR static int update(UPDATE_FUNC_ARGS) +int Element_AMTR::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rxkill_part(i); + return 1; + } + if (10>(rand()/(RAND_MAX/100))) + sim->create_part(r>>8, x+rx, y+ry, PT_PHOT); + else + sim->kill_part(r>>8); + sim->pv[y/CELL][x/CELL] -= 2.0f; + } + } + return 0; +} + + +Element_AMTR::~Element_AMTR() {} \ No newline at end of file diff --git a/src/simulation/elements/ANAR.cpp b/src/simulation/elements/ANAR.cpp new file mode 100644 index 000000000..c35c58cf0 --- /dev/null +++ b/src/simulation/elements/ANAR.cpp @@ -0,0 +1,78 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_ANAR PT_ANAR 113 +Element_ANAR::Element_ANAR() +{ + Identifier = "DEFAULT_PT_ANAR"; + Name = "ANAR"; + Colour = PIXPACK(0xFFFFEE); + MenuVisible = 1; + MenuSection = SC_POWDERS; + Enabled = 1; + + Advection = -0.7f; + AirDrag = -0.02f * CFDS; + AirLoss = 0.96f; + Loss = 0.80f; + Collision = 0.1f; + Gravity = -0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 30; + + Weight = 85; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 70; + Description = "Very light dust. Behaves opposite gravity"; + + State = ST_SOLID; + Properties = TYPE_PART; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_ANAR::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_ANAR static int update(UPDATE_FUNC_ARGS) +int Element_ANAR::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + + //if (parts[i].temp >= 0.23) + // parts[i].temp --; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rxrand()%22) + { + sim->part_change_type(i,x,y,PT_HFLM); + parts[i].life = rand()%150+50; + parts[r>>8].temp = parts[i].temp = 0; + sim->pv[y/CELL][x/CELL] -= 0.5; + } + } + } + return 0; +} + + +Element_ANAR::~Element_ANAR() {} \ No newline at end of file diff --git a/src/elements/aray.cpp b/src/simulation/elements/ARAY.cpp similarity index 73% rename from src/elements/aray.cpp rename to src/simulation/elements/ARAY.cpp index a4e8c6310..c455f072e 100644 --- a/src/elements/aray.cpp +++ b/src/simulation/elements/ARAY.cpp @@ -1,6 +1,54 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_ARAY PT_ARAY 126 +Element_ARAY::Element_ARAY() +{ + Identifier = "DEFAULT_PT_ARAY"; + Name = "ARAY"; + Colour = PIXPACK(0xFFBB00); + MenuVisible = 1; + MenuSection = SC_ELEC; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 0; + Description = "Ray Emitter. Rays create points when they collide"; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_ARAY::update; + Graphics = NULL; +} -int update_ARAY(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_ARAY static int update(UPDATE_FUNC_ARGS) +int Element_ARAY::update(UPDATE_FUNC_ARGS) + { int r, nxx, nyy, docontinue, nxi, nyi, rx, ry, nr, ry1, rx1; if (parts[i].life==0) { int colored =0; @@ -48,7 +96,7 @@ int update_ARAY(UPDATE_FUNC_ARGS) { if (nyy!=0 || nxx!=0) { sim->create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_SPRK); } - if (!(nostop && parts[r>>8].type==PT_SPRK && parts[r>>8].ctype >= 0 && parts[r>>8].ctype < PT_NUM && (sim->ptypes[parts[r>>8].ctype].properties&PROP_CONDUCTS))) { + if (!(nostop && parts[r>>8].type==PT_SPRK && parts[r>>8].ctype >= 0 && parts[r>>8].ctype < PT_NUM && (sim->elements[parts[r>>8].ctype].Properties&PROP_CONDUCTS))) { docontinue = 0; } else { docontinue = 1; @@ -101,3 +149,6 @@ int update_ARAY(UPDATE_FUNC_ARGS) { } return 0; } + + +Element_ARAY::~Element_ARAY() {} \ No newline at end of file diff --git a/src/elements/bang.cpp b/src/simulation/elements/BANG.cpp similarity index 53% rename from src/elements/bang.cpp rename to src/simulation/elements/BANG.cpp index 7a1f6730c..ac538caaf 100644 --- a/src/elements/bang.cpp +++ b/src/simulation/elements/BANG.cpp @@ -1,6 +1,54 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_BANG PT_BANG 139 +Element_BANG::Element_BANG() +{ + Identifier = "DEFAULT_PT_BANG"; + Name = "TNT"; + Colour = PIXPACK(0xC05050); + MenuVisible = 1; + MenuSection = SC_EXPLOSIVE; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 88; + Description = "Explosive."; + + State = ST_SOLID; + Properties = TYPE_SOLID | PROP_NEUTPENETRATE; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_BANG::update; + Graphics = NULL; +} -int update_BANG(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_BANG static int update(UPDATE_FUNC_ARGS) +int Element_BANG::update(UPDATE_FUNC_ARGS) + { int r, rx, ry, nb; if(parts[i].tmp==0) { @@ -73,3 +121,6 @@ int update_BANG(UPDATE_FUNC_ARGS) { } return 0; } + + +Element_BANG::~Element_BANG() {} \ No newline at end of file diff --git a/src/simulation/elements/BCLN.cpp b/src/simulation/elements/BCLN.cpp new file mode 100644 index 000000000..3db065426 --- /dev/null +++ b/src/simulation/elements/BCLN.cpp @@ -0,0 +1,91 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_BCLN PT_BCLN 93 +Element_BCLN::Element_BCLN() +{ + Identifier = "DEFAULT_PT_BCLN"; + Name = "BCLN"; + Colour = PIXPACK(0xFFD040); + MenuVisible = 1; + MenuSection = SC_SPECIAL; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.97f; + Loss = 0.50f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 12; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Breakable Clone."; + + State = ST_NONE; + Properties = TYPE_SOLID|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_BCLN::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_BCLN static int update(UPDATE_FUNC_ARGS) +int Element_BCLN::update(UPDATE_FUNC_ARGS) + { + if (!parts[i].life && sim->pv[y/CELL][x/CELL]>4.0f) + parts[i].life = rand()%40+80; + if (parts[i].life) + { + float advection = 0.1f; + parts[i].vx += advection*sim->vx[y/CELL][x/CELL]; + parts[i].vy += advection*sim->vy[y/CELL][x/CELL]; + } + if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT))) + { + int r, rx, ry; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>=0 && x+rxphotons[y+ry][x+rx]; + if (!r) + r = pmap[y+ry][x+rx]; + if (!r) + continue; + if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && + (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_STKM && + (r&0xFF)!=PT_STKM2 && (r&0xFF)!=PT_PBCN && + (r&0xFF)>8].ctype; + } + } + } + else { + if (parts[i].ctype==PT_LIFE) sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype|(parts[i].tmp<<8)); + else sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); + } + return 0; +} + + +Element_BCLN::~Element_BCLN() {} \ No newline at end of file diff --git a/src/simulation/elements/BCOL.cpp b/src/simulation/elements/BCOL.cpp new file mode 100644 index 000000000..1fb6f8254 --- /dev/null +++ b/src/simulation/elements/BCOL.cpp @@ -0,0 +1,146 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_BCOL PT_BCOL 73 +Element_BCOL::Element_BCOL() +{ + Identifier = "DEFAULT_PT_BCOL"; + Name = "BCOL"; + Colour = PIXPACK(0x333333); + MenuVisible = 1; + MenuSection = SC_POWDERS; + Enabled = 1; + + Advection = 0.4f; + AirDrag = 0.04f * CFDS; + AirLoss = 0.94f; + Loss = 0.95f; + Collision = -0.1f; + Gravity = 0.3f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 5; + Hardness = 2; + + Weight = 90; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 150; + Description = "Broken Coal. Heavy particles. See COAL"; + + State = ST_SOLID; + Properties = TYPE_PART; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_BCOL::update; + Graphics = &Element_BCOL::graphics; +} + +//#TPT-Directive ElementHeader Element_BCOL static int update(UPDATE_FUNC_ARGS) +int Element_BCOL::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry, trade, temp; + if (parts[i].life<=0) { + sim->create_part(i, x, y, PT_FIRE); + return 1; + } else if (parts[i].life < 100) { + parts[i].life--; + sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE); + } + + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx(rand()%500)) + { + if (parts[i].life>100) { + parts[i].life = 99; + } + } + if ((r&0xFF)==PT_LAVA && 1>(rand()%500)) + { + if (parts[r>>8].ctype == PT_IRON) { + parts[r>>8].ctype = PT_METL; + sim->kill_part(i); + return 1; + } + } + } + /*if(100-parts[i].life > parts[i].tmp2) + parts[i].tmp2 = 100-parts[i].life; + if(parts[i].tmp2 < 0) parts[i].tmp2 = 0; + for ( trade = 0; trade<4; trade ++) + { + rx = rand()%5-2; + ry = rand()%5-2; + if (x+rx>=0 && y+ry>0 && x+rxparts[r>>8].tmp2)&&parts[i].tmp2>0)//diffusion + { + int temp = parts[i].tmp2 - parts[r>>8].tmp2; + if(temp < 10) + continue; + if (temp ==1) + { + parts[r>>8].tmp2 ++; + parts[i].tmp2 --; + } + else if (temp>0) + { + parts[r>>8].tmp2 += temp/2; + parts[i].tmp2 -= temp/2; + } + } + } + }*/ + if(parts[i].temp > parts[i].tmp2) + parts[i].tmp2 = parts[i].temp; + return 0; +} + + +//#TPT-Directive ElementHeader Element_BCOL static int graphics(GRAPHICS_FUNC_ARGS) +int Element_BCOL::graphics(GRAPHICS_FUNC_ARGS) + //Both COAL and Broken Coal +{ + *colr += (cpart->tmp2-295.15f)/3; + + if (*colr > 170) + *colr = 170; + if (*colr < *colg) + *colr = *colg; + + *colg = *colb = *colr; + + if((cpart->temp-295.15f) > 300.0f-200.0f) + { + float frequency = 3.1415/(2*300.0f-(300.0f-200.0f)); + int q = ((cpart->temp-295.15f)>300.0f)?300.0f-(300.0f-200.0f):(cpart->temp-295.15f)-(300.0f-200.0f); + + *colr += sin(frequency*q) * 226; + *colg += sin(frequency*q*4.55 +3.14) * 34; + *colb += sin(frequency*q*2.22 +3.14) * 64; + } + return 0; +} + + + +Element_BCOL::~Element_BCOL() {} \ No newline at end of file diff --git a/src/simulation/elements/BGLA.cpp b/src/simulation/elements/BGLA.cpp new file mode 100644 index 000000000..756842a92 --- /dev/null +++ b/src/simulation/elements/BGLA.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_BGLA PT_BGLA 47 +Element_BGLA::Element_BGLA() +{ + Identifier = "DEFAULT_PT_BGLA"; + Name = "BGLA"; + Colour = PIXPACK(0x606060); + MenuVisible = 1; + MenuSection = SC_POWDERS; + Enabled = 1; + + Advection = 0.4f; + AirDrag = 0.04f * CFDS; + AirLoss = 0.94f; + Loss = 0.95f; + Collision = -0.1f; + Gravity = 0.3f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 5; + Hardness = 2; + + Weight = 90; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 150; + Description = "Broken Glass, Heavy particles. Meltable. Bagels."; + + State = ST_SOLID; + Properties = TYPE_PART | PROP_HOT_GLOW; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 1973.0f; + HighTemperatureTransition = PT_LAVA; + + Update = NULL; + Graphics = NULL; +} + +Element_BGLA::~Element_BGLA() {} \ No newline at end of file diff --git a/src/simulation/elements/BHOL.cpp b/src/simulation/elements/BHOL.cpp new file mode 100644 index 000000000..7a119855d --- /dev/null +++ b/src/simulation/elements/BHOL.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_BHOL PT_BHOL 39 +Element_BHOL::Element_BHOL() +{ + Identifier = "DEFAULT_PT_BHOL"; + Name = "VACU"; + Colour = PIXPACK(0x303030); + MenuVisible = 1; + MenuSection = SC_SPECIAL; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.95f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = -0.01f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 100; + + Temperature = R_TEMP+70.0f+273.15f; + HeatConduct = 255; + Description = "Vacuum, sucks in other particles and heats up."; + + State = ST_NONE; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = NULL; + Graphics = NULL; +} + +Element_BHOL::~Element_BHOL() {} \ No newline at end of file diff --git a/src/simulation/elements/BIZR.cpp b/src/simulation/elements/BIZR.cpp new file mode 100644 index 000000000..13df996bc --- /dev/null +++ b/src/simulation/elements/BIZR.cpp @@ -0,0 +1,124 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_BIZR PT_BIZR 103 +Element_BIZR::Element_BIZR() +{ + Identifier = "DEFAULT_PT_BIZR"; + Name = "BIZR"; + Colour = PIXPACK(0x00FF77); + MenuVisible = 1; + MenuSection = SC_LIQUID; + Enabled = 1; + + Advection = 0.6f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.98f; + Loss = 0.95f; + Collision = 0.0f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 2; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 20; + + Weight = 30; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 29; + Description = "Bizarre... contradicts the normal state changes."; + + State = ST_LIQUID; + Properties = TYPE_LIQUID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = 100.0f; + LowTemperatureTransition = PT_BIZRG; + HighTemperature = 400.0f; + HighTemperatureTransition = PT_BIZRS; + + Update = &Element_BIZR::update; + Graphics = &Element_BIZR::graphics; +} + +//#TPT-Directive ElementHeader Element_BIZR static int update(UPDATE_FUNC_ARGS) +int Element_BIZR::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry, nr, ng, nb, na; + float tr, tg, tb, ta, mr, mg, mb, ma; + float blend; + if(parts[i].dcolour){ + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8].dcolour>>16)&0xFF; + tg = (parts[r>>8].dcolour>>8)&0xFF; + tb = (parts[r>>8].dcolour)&0xFF; + ta = (parts[r>>8].dcolour>>24)&0xFF; + + mr = (parts[i].dcolour>>16)&0xFF; + mg = (parts[i].dcolour>>8)&0xFF; + mb = (parts[i].dcolour)&0xFF; + ma = (parts[i].dcolour>>24)&0xFF; + + nr = (tr*blend) + (mr*(1-blend)); + ng = (tg*blend) + (mg*(1-blend)); + nb = (tb*blend) + (mb*(1-blend)); + na = (ta*blend) + (ma*(1-blend)); + + parts[r>>8].dcolour = nr<<16 | ng<<8 | nb | na<<24; + } + } + } + if(((r = sim->photons[y][x])&0xFF)==PT_PHOT || ((r = pmap[y][x])&0xFF)==PT_PHOT) + { + sim->part_change_type(r>>8, x, y, PT_ELEC); + parts[r>>8].ctype = 0; + } + return 0; +} + + +//#TPT-Directive ElementHeader Element_BIZR static int graphics(GRAPHICS_FUNC_ARGS) +int Element_BIZR::graphics(GRAPHICS_FUNC_ARGS) + //BIZR, BIZRG, BIZRS +{ + int x = 0; + *colg = 0; + *colb = 0; + *colr = 0; + for (x=0; x<12; x++) { + *colr += (cpart->ctype >> (x+18)) & 1; + *colb += (cpart->ctype >> x) & 1; + } + for (x=0; x<12; x++) + *colg += (cpart->ctype >> (x+9)) & 1; + x = 624/(*colr+*colg+*colb+1); + *colr *= x; + *colg *= x; + *colb *= x; + if(fabs(cpart->vx)+fabs(cpart->vy)>0) + { + *firea = 255; + *fireg = *colg/5 * fabs(cpart->vx)+fabs(cpart->vy); + *fireb = *colb/5 * fabs(cpart->vx)+fabs(cpart->vy); + *firer = *colr/5 * fabs(cpart->vx)+fabs(cpart->vy); + *pixel_mode |= FIRE_ADD; + } + return 0; +} + + +Element_BIZR::~Element_BIZR() {} \ No newline at end of file diff --git a/src/simulation/elements/BIZRG.cpp b/src/simulation/elements/BIZRG.cpp new file mode 100644 index 000000000..1e5f27ffe --- /dev/null +++ b/src/simulation/elements/BIZRG.cpp @@ -0,0 +1,124 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_BIZRG PT_BIZRG 104 +Element_BIZRG::Element_BIZRG() +{ + Identifier = "DEFAULT_PT_BIZRG"; + Name = "BIZG"; + Colour = PIXPACK(0x00FFBB); + MenuVisible = 1; + MenuSection = SC_CRACKER2; + Enabled = 1; + + Advection = 1.0f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.99f; + Loss = 0.30f; + Collision = -0.1f; + Gravity = 0.0f; + Diffusion = 2.75f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 1; + + Temperature = R_TEMP-200.0f+273.15f; + HeatConduct = 42; + Description = "Bizarre gas"; + + State = ST_GAS; + Properties = TYPE_GAS; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 100.0f; + HighTemperatureTransition = PT_BIZR; + + Update = &Element_BIZRG::update; + Graphics = &Element_BIZRG::graphics; +} + +//#TPT-Directive ElementHeader Element_BIZRG static int update(UPDATE_FUNC_ARGS) +int Element_BIZRG::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry, nr, ng, nb, na; + float tr, tg, tb, ta, mr, mg, mb, ma; + float blend; + if(parts[i].dcolour){ + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8].dcolour>>16)&0xFF; + tg = (parts[r>>8].dcolour>>8)&0xFF; + tb = (parts[r>>8].dcolour)&0xFF; + ta = (parts[r>>8].dcolour>>24)&0xFF; + + mr = (parts[i].dcolour>>16)&0xFF; + mg = (parts[i].dcolour>>8)&0xFF; + mb = (parts[i].dcolour)&0xFF; + ma = (parts[i].dcolour>>24)&0xFF; + + nr = (tr*blend) + (mr*(1-blend)); + ng = (tg*blend) + (mg*(1-blend)); + nb = (tb*blend) + (mb*(1-blend)); + na = (ta*blend) + (ma*(1-blend)); + + parts[r>>8].dcolour = nr<<16 | ng<<8 | nb | na<<24; + } + } + } + if(((r = sim->photons[y][x])&0xFF)==PT_PHOT || ((r = pmap[y][x])&0xFF)==PT_PHOT) + { + sim->part_change_type(r>>8, x, y, PT_ELEC); + parts[r>>8].ctype = 0; + } + return 0; +} + + +//#TPT-Directive ElementHeader Element_BIZRG static int graphics(GRAPHICS_FUNC_ARGS) +int Element_BIZRG::graphics(GRAPHICS_FUNC_ARGS) + //BIZR, BIZRG, BIZRS +{ + int x = 0; + *colg = 0; + *colb = 0; + *colr = 0; + for (x=0; x<12; x++) { + *colr += (cpart->ctype >> (x+18)) & 1; + *colb += (cpart->ctype >> x) & 1; + } + for (x=0; x<12; x++) + *colg += (cpart->ctype >> (x+9)) & 1; + x = 624/(*colr+*colg+*colb+1); + *colr *= x; + *colg *= x; + *colb *= x; + if(fabs(cpart->vx)+fabs(cpart->vy)>0) + { + *firea = 255; + *fireg = *colg/5 * fabs(cpart->vx)+fabs(cpart->vy); + *fireb = *colb/5 * fabs(cpart->vx)+fabs(cpart->vy); + *firer = *colr/5 * fabs(cpart->vx)+fabs(cpart->vy); + *pixel_mode |= FIRE_ADD; + } + return 0; +} + + +Element_BIZRG::~Element_BIZRG() {} \ No newline at end of file diff --git a/src/simulation/elements/BIZRS.cpp b/src/simulation/elements/BIZRS.cpp new file mode 100644 index 000000000..439a72355 --- /dev/null +++ b/src/simulation/elements/BIZRS.cpp @@ -0,0 +1,124 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_BIZRS PT_BIZRS 105 +Element_BIZRS::Element_BIZRS() +{ + Identifier = "DEFAULT_PT_BIZRS"; + Name = "BIZS"; + Colour = PIXPACK(0x00E455); + MenuVisible = 1; + MenuSection = SC_CRACKER2; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+300.0f+273.15f; + HeatConduct = 251; + Description = "Bizarre solid"; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = 400.0f; + LowTemperatureTransition = PT_BIZR; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_BIZRS::update; + Graphics = &Element_BIZRS::graphics; +} + +//#TPT-Directive ElementHeader Element_BIZRS static int update(UPDATE_FUNC_ARGS) +int Element_BIZRS::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry, nr, ng, nb, na; + float tr, tg, tb, ta, mr, mg, mb, ma; + float blend; + if(parts[i].dcolour){ + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8].dcolour>>16)&0xFF; + tg = (parts[r>>8].dcolour>>8)&0xFF; + tb = (parts[r>>8].dcolour)&0xFF; + ta = (parts[r>>8].dcolour>>24)&0xFF; + + mr = (parts[i].dcolour>>16)&0xFF; + mg = (parts[i].dcolour>>8)&0xFF; + mb = (parts[i].dcolour)&0xFF; + ma = (parts[i].dcolour>>24)&0xFF; + + nr = (tr*blend) + (mr*(1-blend)); + ng = (tg*blend) + (mg*(1-blend)); + nb = (tb*blend) + (mb*(1-blend)); + na = (ta*blend) + (ma*(1-blend)); + + parts[r>>8].dcolour = nr<<16 | ng<<8 | nb | na<<24; + } + } + } + if(((r = sim->photons[y][x])&0xFF)==PT_PHOT || ((r = pmap[y][x])&0xFF)==PT_PHOT) + { + sim->part_change_type(r>>8, x, y, PT_ELEC); + parts[r>>8].ctype = 0; + } + return 0; +} + + +//#TPT-Directive ElementHeader Element_BIZRS static int graphics(GRAPHICS_FUNC_ARGS) +int Element_BIZRS::graphics(GRAPHICS_FUNC_ARGS) + //BIZR, BIZRG, BIZRS +{ + int x = 0; + *colg = 0; + *colb = 0; + *colr = 0; + for (x=0; x<12; x++) { + *colr += (cpart->ctype >> (x+18)) & 1; + *colb += (cpart->ctype >> x) & 1; + } + for (x=0; x<12; x++) + *colg += (cpart->ctype >> (x+9)) & 1; + x = 624/(*colr+*colg+*colb+1); + *colr *= x; + *colg *= x; + *colb *= x; + if(fabs(cpart->vx)+fabs(cpart->vy)>0) + { + *firea = 255; + *fireg = *colg/5 * fabs(cpart->vx)+fabs(cpart->vy); + *fireb = *colb/5 * fabs(cpart->vx)+fabs(cpart->vy); + *firer = *colr/5 * fabs(cpart->vx)+fabs(cpart->vy); + *pixel_mode |= FIRE_ADD; + } + return 0; +} + + +Element_BIZRS::~Element_BIZRS() {} \ No newline at end of file diff --git a/src/simulation/elements/BMTL.cpp b/src/simulation/elements/BMTL.cpp new file mode 100644 index 000000000..66a9af2e2 --- /dev/null +++ b/src/simulation/elements/BMTL.cpp @@ -0,0 +1,80 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_BMTL PT_BMTL 29 +Element_BMTL::Element_BMTL() +{ + Identifier = "DEFAULT_PT_BMTL"; + Name = "BMTL"; + Colour = PIXPACK(0x505070); + MenuVisible = 1; + MenuSection = SC_SOLIDS; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Breakable metal."; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = 1.0f; + HighPressureTransition = ST; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 1273.0f; + HighTemperatureTransition = PT_LAVA; + + Update = &Element_BMTL::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_BMTL static int update(UPDATE_FUNC_ARGS) +int Element_BMTL::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry, rt, tempFactor; + if (parts[i].tmp>1) + { + parts[i].tmp--; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8].type; + if ((rt==PT_METL || rt==PT_IRON) && 1>(rand()/(RAND_MAX/100))) + { + sim->part_change_type(r>>8,x+rx,y+ry,PT_BMTL); + parts[r>>8].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100; + } + } + } + else if (parts[i].tmp==1 && 1>rand()%1000) + { + parts[i].tmp = 0; + sim->part_change_type(i,x,y,PT_BRMT); + } + return 0; +} + + +Element_BMTL::~Element_BMTL() {} \ No newline at end of file diff --git a/src/elements/bomb.cpp b/src/simulation/elements/BOMB.cpp similarity index 61% rename from src/elements/bomb.cpp rename to src/simulation/elements/BOMB.cpp index 99eb7f0bc..ca3be8d9a 100644 --- a/src/elements/bomb.cpp +++ b/src/simulation/elements/BOMB.cpp @@ -1,6 +1,54 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_BOMB PT_BOMB 129 +Element_BOMB::Element_BOMB() +{ + Identifier = "DEFAULT_PT_BOMB"; + Name = "BOMB"; + Colour = PIXPACK(0xFFF288); + MenuVisible = 1; + MenuSection = SC_EXPLOSIVE; + Enabled = 1; + + Advection = 0.6f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.98f; + Loss = 0.95f; + Collision = 0.0f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 20; + + Weight = 30; + + Temperature = R_TEMP-2.0f +273.15f; + HeatConduct = 29; + Description = "Bomb."; + + State = ST_NONE; + Properties = TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC|PROP_SPARKSETTLE; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_BOMB::update; + Graphics = &Element_BOMB::graphics; +} -int update_BOMB(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_BOMB static int update(UPDATE_FUNC_ARGS) +int Element_BOMB::update(UPDATE_FUNC_ARGS) + { int r, rx, ry, nb; //Spark is used so much now that it should be a seperate element. if (parts[i].tmp==1) { @@ -11,7 +59,7 @@ int update_BOMB(UPDATE_FUNC_ARGS) { r = pmap[y+ry][x+rx]; if (!r) continue; - if ((sim->ptypes[r&0xFF].properties & (TYPE_SOLID | TYPE_PART | TYPE_LIQUID)) && !(sim->ptypes[r&0xFF].properties & PROP_SPARKSETTLE)) { + if ((sim->elements[r&0xFF].Properties & (TYPE_SOLID | TYPE_PART | TYPE_LIQUID)) && !(sim->elements[r&0xFF].Properties & PROP_SPARKSETTLE)) { sim->kill_part(i); return 1; } @@ -63,7 +111,11 @@ int update_BOMB(UPDATE_FUNC_ARGS) { } return 0; } -int graphics_BOMB(GRAPHICS_FUNC_ARGS) + + +//#TPT-Directive ElementHeader Element_BOMB static int graphics(GRAPHICS_FUNC_ARGS) +int Element_BOMB::graphics(GRAPHICS_FUNC_ARGS) + { if (cpart->tmp==0) { //Normal bomb @@ -83,3 +135,6 @@ int graphics_BOMB(GRAPHICS_FUNC_ARGS) } return 0; } + + +Element_BOMB::~Element_BOMB() {} \ No newline at end of file diff --git a/src/elements/boyl.cpp b/src/simulation/elements/BOYL.cpp similarity index 52% rename from src/elements/boyl.cpp rename to src/simulation/elements/BOYL.cpp index 7c0fc24ee..3fd36c960 100644 --- a/src/elements/boyl.cpp +++ b/src/simulation/elements/BOYL.cpp @@ -1,6 +1,54 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_BOYL PT_BOYL 141 +Element_BOYL::Element_BOYL() +{ + Identifier = "DEFAULT_PT_BOYL"; + Name = "BOYL"; + Colour = PIXPACK(0x0A3200); + MenuVisible = 1; + MenuSection = SC_GAS; + Enabled = 1; + + Advection = 1.0f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.99f; + Loss = 0.30f; + Collision = -0.1f; + Gravity = 0.0f; + Diffusion = 0.18f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 1; + + Temperature = R_TEMP+2.0f +273.15f; + HeatConduct = 42; + Description = "Boyle, variable pressure gas. Expands when heated."; + + State = ST_GAS; + Properties = TYPE_GAS; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_BOYL::update; + Graphics = NULL; +} -int update_BOYL(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_BOYL static int update(UPDATE_FUNC_ARGS) +int Element_BOYL::update(UPDATE_FUNC_ARGS) + { int r, rx, ry; if (sim->pv[y/CELL][x/CELL]<(parts[i].temp/100)) sim->pv[y/CELL][x/CELL] += 0.001f*((parts[i].temp/100)-sim->pv[y/CELL][x/CELL]); @@ -41,3 +89,6 @@ int update_BOYL(UPDATE_FUNC_ARGS) { } return 0; } + + +Element_BOYL::~Element_BOYL() {} \ No newline at end of file diff --git a/src/simulation/elements/BRAY.cpp b/src/simulation/elements/BRAY.cpp new file mode 100644 index 000000000..7b9c40749 --- /dev/null +++ b/src/simulation/elements/BRAY.cpp @@ -0,0 +1,109 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_BRAY PT_BRAY 127 +Element_BRAY::Element_BRAY() +{ + Identifier = "DEFAULT_PT_BRAY"; + Name = "BRAY"; + Colour = PIXPACK(0xFFFFFF); + MenuVisible = 0; + MenuSection = SC_ELEC; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Ray Point. Rays create points when they collide"; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_LIFE_DEC|PROP_LIFE_KILL; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = NULL; + Graphics = &Element_BRAY::graphics; +} + +//#TPT-Directive ElementHeader Element_BRAY static int graphics(GRAPHICS_FUNC_ARGS) +int Element_BRAY::graphics(GRAPHICS_FUNC_ARGS) + +{ + int x, trans = 255; + if(cpart->tmp==0) + { + trans = cpart->life * 7; + if (trans>255) trans = 255; + if (cpart->ctype) { + *colg = 0; + *colb = 0; + *colr = 0; + for (x=0; x<12; x++) { + *colr += (cpart->ctype >> (x+18)) & 1; + *colb += (cpart->ctype >> x) & 1; + } + for (x=0; x<12; x++) + *colg += (cpart->ctype >> (x+9)) & 1; + x = 624/(*colr+*colg+*colb+1); + *colr *= x; + *colg *= x; + *colb *= x; + } + } + else if(cpart->tmp==1) + { + trans = cpart->life/4; + if (trans>255) trans = 255; + if (cpart->ctype) { + *colg = 0; + *colb = 0; + *colr = 0; + for (x=0; x<12; x++) { + *colr += (cpart->ctype >> (x+18)) & 1; + *colb += (cpart->ctype >> x) & 1; + } + for (x=0; x<12; x++) + *colg += (cpart->ctype >> (x+9)) & 1; + x = 624/(*colr+*colg+*colb+1); + *colr *= x; + *colg *= x; + *colb *= x; + } + } + else if(cpart->tmp==2) + { + trans = cpart->life*100; + if (trans>255) trans = 255; + *colr = 255; + *colg = 150; + *colb = 50; + } + *cola = trans; + *pixel_mode &= ~PMODE; + *pixel_mode |= PMODE_BLEND | PMODE_GLOW; + return 0; +} + + +Element_BRAY::~Element_BRAY() {} \ No newline at end of file diff --git a/src/simulation/elements/BRCK.cpp b/src/simulation/elements/BRCK.cpp new file mode 100644 index 000000000..0a1bba7ee --- /dev/null +++ b/src/simulation/elements/BRCK.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_BRCK PT_BRCK 67 +Element_BRCK::Element_BRCK() +{ + Identifier = "DEFAULT_PT_BRCK"; + Name = "BRCK"; + Colour = PIXPACK(0x808080); + MenuVisible = 1; + MenuSection = SC_SOLIDS; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Brick, breakable building material."; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_HOT_GLOW; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = 8.8f; + HighPressureTransition = PT_STNE; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 1223.0f; + HighTemperatureTransition = PT_LAVA; + + Update = NULL; + Graphics = NULL; +} + +Element_BRCK::~Element_BRCK() {} \ No newline at end of file diff --git a/src/simulation/elements/BREC.cpp b/src/simulation/elements/BREC.cpp new file mode 100644 index 000000000..966878523 --- /dev/null +++ b/src/simulation/elements/BREC.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_BREC PT_BREC 135 +Element_BREC::Element_BREC() +{ + Identifier = "DEFAULT_PT_BREC"; + Name = "BREL"; + Colour = PIXPACK(0x707060); + MenuVisible = 1; + MenuSection = SC_POWDERS; + Enabled = 1; + + Advection = 0.4f; + AirDrag = 0.04f * CFDS; + AirLoss = 0.94f; + Loss = 0.95f; + Collision = -0.1f; + Gravity = 0.18f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 2; + Hardness = 2; + + Weight = 90; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 211; + Description = "Broken electronics"; + + State = ST_SOLID; + Properties = TYPE_PART|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = NULL; + Graphics = NULL; +} + +Element_BREC::~Element_BREC() {} \ No newline at end of file diff --git a/src/simulation/elements/BRMT.cpp b/src/simulation/elements/BRMT.cpp new file mode 100644 index 000000000..11773e223 --- /dev/null +++ b/src/simulation/elements/BRMT.cpp @@ -0,0 +1,85 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_BRMT PT_BRMT 30 +Element_BRMT::Element_BRMT() +{ + Identifier = "DEFAULT_PT_BRMT"; + Name = "BRMT"; + Colour = PIXPACK(0x705060); + MenuVisible = 1; + MenuSection = SC_POWDERS; + Enabled = 1; + + Advection = 0.4f; + AirDrag = 0.04f * CFDS; + AirLoss = 0.94f; + Loss = 0.95f; + Collision = -0.1f; + Gravity = 0.3f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 2; + Hardness = 2; + + Weight = 90; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 211; + Description = "Broken metal."; + + State = ST_SOLID; + Properties = TYPE_PART|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 1273.0f; + HighTemperatureTransition = PT_LAVA; + + Update = &Element_BRMT::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_BRMT static int update(UPDATE_FUNC_ARGS) +int Element_BRMT::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry, rt, tempFactor; + if (parts[i].temp > (250.0f+273.15f)) + { + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8].type; + tempFactor = 1000 - (((250.0f+273.15f)-parts[i].temp)*2); + if(tempFactor < 2) + tempFactor = 2; + if ((rt==PT_BREC) && 1 > (rand()%tempFactor)) + { + if(rand()%2) + { + sim->create_part(r>>8, x+rx, y+ry, PT_THRM); + } + else + { sim->create_part(i, x, y, PT_THRM); + } + return 1; + //part_change_type(r>>8,x+rx,y+ry,PT_BMTL); + //parts[r>>8].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100; + } + } + } + return 0; +} + + +Element_BRMT::~Element_BRMT() {} \ No newline at end of file diff --git a/src/simulation/elements/BTRY.cpp b/src/simulation/elements/BTRY.cpp new file mode 100644 index 000000000..6aa00ecbf --- /dev/null +++ b/src/simulation/elements/BTRY.cpp @@ -0,0 +1,75 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_BTRY PT_BTRY 53 +Element_BTRY::Element_BTRY() +{ + Identifier = "DEFAULT_PT_BTRY"; + Name = "BTRY"; + Colour = PIXPACK(0x858505); + MenuVisible = 1; + MenuSection = SC_ELEC; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Solid. Generates Electricity."; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 2273.0f; + HighTemperatureTransition = PT_PLSM; + + Update = &Element_BTRY::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_BTRY static int update(UPDATE_FUNC_ARGS) +int Element_BTRY::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry, rt; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8].type; + if (sim->parts_avg(i,r>>8,PT_INSL) != PT_INSL) + { + if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[r>>8].life==0 && abs(rx)+abs(ry) < 4) + { + parts[r>>8].life = 4; + parts[r>>8].ctype = rt; + sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK); + } + } + } + return 0; +} + + +Element_BTRY::~Element_BTRY() {} \ No newline at end of file diff --git a/src/simulation/elements/C5.cpp b/src/simulation/elements/C5.cpp new file mode 100644 index 000000000..8524f9bd0 --- /dev/null +++ b/src/simulation/elements/C5.cpp @@ -0,0 +1,75 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_C5 PT_C5 130 +Element_C5::Element_C5() +{ + Identifier = "DEFAULT_PT_C5"; + Name = "C-5"; + Colour = PIXPACK(0x2050E0); + MenuVisible = 1; + MenuSection = SC_EXPLOSIVE; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 88; + Description = "Cold explosive"; + + State = ST_SOLID; + Properties = TYPE_SOLID | PROP_NEUTPENETRATE; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_C5::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_C5 static int update(UPDATE_FUNC_ARGS) +int Element_C5::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8].temp<100)||(r&0xFF)==PT_HFLM) + { + if (1>rand()%6) + { + sim->part_change_type(i,x,y,PT_HFLM); + parts[r>>8].temp = parts[i].temp = 0; + parts[i].life = rand()%150+50; + sim->pv[y/CELL][x/CELL] += 1.5; + } + } + } + return 0; +} + + +Element_C5::~Element_C5() {} \ No newline at end of file diff --git a/src/simulation/elements/CAUS.cpp b/src/simulation/elements/CAUS.cpp new file mode 100644 index 000000000..b336f9ef9 --- /dev/null +++ b/src/simulation/elements/CAUS.cpp @@ -0,0 +1,86 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_CAUS PT_CAUS 86 +Element_CAUS::Element_CAUS() +{ + Identifier = "DEFAULT_PT_CAUS"; + Name = "CAUS"; + Colour = PIXPACK(0x80FFA0); + MenuVisible = 1; + MenuSection = SC_GAS; + Enabled = 1; + + Advection = 2.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.99f; + Loss = 0.30f; + Collision = -0.1f; + Gravity = 0.0f; + Diffusion = 1.50f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 1; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 70; + Description = "Caustic Gas, acts like Acid"; + + State = ST_GAS; + Properties = TYPE_GAS|PROP_DEADLY; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_CAUS::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_CAUS static int update(UPDATE_FUNC_ARGS) +int Element_CAUS::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry, trade, np; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rxelements[r&0xFF].Hardness>(rand()%1000))&&parts[i].life>=50) + { + if (sim->parts_avg(i, r>>8,PT_GLAS)!= PT_GLAS)//GLAS protects stuff from acid + { + float newtemp = ((60.0f-(float)sim->elements[r&0xFF].Hardness))*7.0f; + if(newtemp < 0){ + newtemp = 0; + } + parts[i].temp += newtemp; + parts[i].life--; + sim->kill_part(r>>8); + } + } + else if (parts[i].life<=50) + { + sim->kill_part(i); + return 1; + } + } + } + return 0; +} + + +Element_CAUS::~Element_CAUS() {} \ No newline at end of file diff --git a/src/elements/cbnw.cpp b/src/simulation/elements/CBNW.cpp similarity index 52% rename from src/elements/cbnw.cpp rename to src/simulation/elements/CBNW.cpp index b480ed558..433175061 100644 --- a/src/elements/cbnw.cpp +++ b/src/simulation/elements/CBNW.cpp @@ -1,6 +1,54 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_CBNW PT_CBNW 82 +Element_CBNW::Element_CBNW() +{ + Identifier = "DEFAULT_PT_CBNW"; + Name = "BUBW"; + Colour = PIXPACK(0x2030D0); + MenuVisible = 1; + MenuSection = SC_LIQUID; + Enabled = 1; + + Advection = 0.6f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.98f; + Loss = 0.95f; + Collision = 0.0f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 2; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 20; + + Weight = 30; + + Temperature = R_TEMP-2.0f +273.15f; + HeatConduct = 29; + Description = "Carbonated water. Conducts electricity. Freezes. Extinguishes fires."; + + State = ST_LIQUID; + Properties = TYPE_LIQUID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_NEUTPENETRATE; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = 273.15f; + LowTemperatureTransition = PT_ICEI; + HighTemperature = 373.0f; + HighTemperatureTransition = PT_WTRV; + + Update = &Element_CBNW::update; + Graphics = &Element_CBNW::graphics; +} -int update_CBNW(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_CBNW static int update(UPDATE_FUNC_ARGS) +int Element_CBNW::update(UPDATE_FUNC_ARGS) + { int r, rx, ry, oldt; oldt = parts[i].tmp; if (sim->pv[y/CELL][x/CELL]<=3) @@ -43,12 +91,12 @@ int update_CBNW(UPDATE_FUNC_ARGS) { r = pmap[y+ry][x+rx]; if (!r) continue; - if ((sim->ptypes[r&0xFF].properties&TYPE_PART) && parts[i].tmp == 0 && 1>(rand()%250)) + if ((sim->elements[r&0xFF].Properties&TYPE_PART) && parts[i].tmp == 0 && 1>(rand()%250)) { //Start explode parts[i].tmp = rand()%25;//(rand()%100)+50; } - else if((sim->ptypes[r&0xFF].properties&TYPE_SOLID) && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_GLAS && parts[i].tmp == 0 && (2-sim->pv[y/CELL][x/CELL])>(rand()%20000)) + else if((sim->elements[r&0xFF].Properties&TYPE_SOLID) && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_GLAS && parts[i].tmp == 0 && (2-sim->pv[y/CELL][x/CELL])>(rand()%20000)) { if(rand()%2) { @@ -88,3 +136,18 @@ int update_CBNW(UPDATE_FUNC_ARGS) { } return 0; } + + +//#TPT-Directive ElementHeader Element_CBNW static int graphics(GRAPHICS_FUNC_ARGS) +int Element_CBNW::graphics(GRAPHICS_FUNC_ARGS) + +{ + int z = cpart->tmp2 - 20;//speckles! + *colr += z * 1; + *colg += z * 2; + *colb += z * 8; + return 0; +} + + +Element_CBNW::~Element_CBNW() {} \ No newline at end of file diff --git a/src/simulation/elements/CLNE.cpp b/src/simulation/elements/CLNE.cpp new file mode 100644 index 000000000..56839f07a --- /dev/null +++ b/src/simulation/elements/CLNE.cpp @@ -0,0 +1,83 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_CLNE PT_CLNE 9 +Element_CLNE::Element_CLNE() +{ + Identifier = "DEFAULT_PT_CLNE"; + Name = "CLNE"; + Colour = PIXPACK(0xFFD010); + MenuVisible = 1; + MenuSection = SC_SPECIAL; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Solid. Duplicates any particles it touches."; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_CLNE::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_CLNE static int update(UPDATE_FUNC_ARGS) +int Element_CLNE::update(UPDATE_FUNC_ARGS) + { + if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT))) + { + int r, rx, ry; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>=0 && x+rxphotons[y+ry][x+rx]; + if (!r) + r = pmap[y+ry][x+rx]; + if (!r) + continue; + if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && + (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_STKM && + (r&0xFF)!=PT_PBCN && (r&0xFF)!=PT_STKM2 && + (r&0xFF)>8].ctype; + } + } + } + else { + if (parts[i].ctype==PT_LIFE) sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype|(parts[i].tmp<<8)); + else sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, parts[i].ctype); + } + return 0; +} + + +Element_CLNE::~Element_CLNE() {} \ No newline at end of file diff --git a/src/simulation/elements/CLST.cpp b/src/simulation/elements/CLST.cpp new file mode 100644 index 000000000..3cab1f716 --- /dev/null +++ b/src/simulation/elements/CLST.cpp @@ -0,0 +1,101 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_CLST PT_CLST 155 +Element_CLST::Element_CLST() +{ + Identifier = "DEFAULT_PT_CLST"; + Name = "CLST"; + Colour = PIXPACK(0xE4A4A4); + MenuVisible = 1; + MenuSection = SC_POWDERS; + Enabled = 1; + + Advection = 0.7f; + AirDrag = 0.02f * CFDS; + AirLoss = 0.94f; + Loss = 0.95f; + Collision = 0.0f; + Gravity = 0.2f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 2; + Hardness = 2; + + Weight = 55; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 70; + Description = "Clay dust. Produces paste when mixed with water."; + + State = ST_SOLID; + Properties = TYPE_PART; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 1256.0f; + HighTemperatureTransition = PT_LAVA; + + Update = &Element_CLST::update; + Graphics = &Element_CLST::graphics; +} + +//#TPT-Directive ElementHeader Element_CLST static int update(UPDATE_FUNC_ARGS) +int Element_CLST::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + float cxy; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx(rand()%1500)) + { + sim->part_change_type(i,x,y,PT_PSTS); + sim->kill_part(r>>8); + } + if ((r&0xFF)==PT_NITR) + { + sim->create_part(i, x, y, PT_BANG); + sim->create_part(r>>8, x+rx, y+ry, PT_BANG); + } + if ((r&0xFF)==PT_CLST) + { + if(parts[i].temp <195) + cxy = 0.05; + if(parts[i].temp >= 195 && parts[i].temp <295) + cxy = 0.015; + if(parts[i].temp >= 295 && parts[i].temp <350) + cxy = 0.01; + if(parts[i].temp > 350) + cxy = 0.005; + parts[i].vx += cxy*rx; + parts[i].vy += cxy*ry;//These two can be set not to calculate over 350 later. They do virtually nothing over 0.005. + } + } + return 0; +} + + +//#TPT-Directive ElementHeader Element_CLST static int graphics(GRAPHICS_FUNC_ARGS) +int Element_CLST::graphics(GRAPHICS_FUNC_ARGS) + +{ + int z = cpart->tmp - 5;//speckles! + *colr += z * 16; + *colg += z * 16; + *colb += z * 16; + return 0; +} + + +Element_CLST::~Element_CLST() {} \ No newline at end of file diff --git a/src/simulation/elements/CNCT.cpp b/src/simulation/elements/CNCT.cpp new file mode 100644 index 000000000..3ef01369f --- /dev/null +++ b/src/simulation/elements/CNCT.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_CNCT PT_CNCT 24 +Element_CNCT::Element_CNCT() +{ + Identifier = "DEFAULT_PT_CNCT"; + Name = "CNCT"; + Colour = PIXPACK(0xC0C0C0); + MenuVisible = 1; + MenuSection = SC_POWDERS; + Enabled = 1; + + Advection = 0.4f; + AirDrag = 0.04f * CFDS; + AirLoss = 0.94f; + Loss = 0.95f; + Collision = -0.1f; + Gravity = 0.3f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 2; + Hardness = 2; + + Weight = 55; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 100; + Description = "Concrete, stronger than stone."; + + State = ST_SOLID; + Properties = TYPE_PART|PROP_HOT_GLOW; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 1123.0f; + HighTemperatureTransition = PT_LAVA; + + Update = NULL; + Graphics = NULL; +} + +Element_CNCT::~Element_CNCT() {} \ No newline at end of file diff --git a/src/elements/co2.cpp b/src/simulation/elements/CO2.cpp similarity index 51% rename from src/elements/co2.cpp rename to src/simulation/elements/CO2.cpp index b267a73bf..2015883d7 100644 --- a/src/elements/co2.cpp +++ b/src/simulation/elements/CO2.cpp @@ -1,6 +1,54 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_CO2 PT_CO2 80 +Element_CO2::Element_CO2() +{ + Identifier = "DEFAULT_PT_CO2"; + Name = "CO2"; + Colour = PIXPACK(0x666666); + MenuVisible = 1; + MenuSection = SC_GAS; + Enabled = 1; + + Advection = 2.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.99f; + Loss = 0.30f; + Collision = -0.1f; + Gravity = 0.1f; + Diffusion = 1.0f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 1; + + Temperature = R_TEMP+273.15f; + HeatConduct = 88; + Description = "Carbon Dioxide"; + + State = ST_GAS; + Properties = TYPE_GAS; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = 194.65f; + LowTemperatureTransition = PT_DRIC; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_CO2::update; + Graphics = NULL; +} -int update_CO2(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_CO2 static int update(UPDATE_FUNC_ARGS) +int Element_CO2::update(UPDATE_FUNC_ARGS) + { int r, rx, ry; for (rx=-2; rx<3; rx++) for (ry=-2; ry<3; ry++) @@ -44,3 +92,6 @@ int update_CO2(UPDATE_FUNC_ARGS) { } return 0; } + + +Element_CO2::~Element_CO2() {} \ No newline at end of file diff --git a/src/simulation/elements/COAL.cpp b/src/simulation/elements/COAL.cpp new file mode 100644 index 000000000..eae745024 --- /dev/null +++ b/src/simulation/elements/COAL.cpp @@ -0,0 +1,153 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_COAL PT_COAL 59 +Element_COAL::Element_COAL() +{ + Identifier = "DEFAULT_PT_COAL"; + Name = "COAL"; + Colour = PIXPACK(0x222222); + MenuVisible = 1; + MenuSection = SC_SOLIDS; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.0f; + HotAir = 0.0f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 20; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 200; + Description = "Solid. Burns slowly."; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_COAL::update; + Graphics = &Element_COAL::graphics; +} + +//#TPT-Directive ElementHeader Element_COAL static int update(UPDATE_FUNC_ARGS) +int Element_COAL::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry, trade, temp; + if (parts[i].life<=0) { + sim->create_part(i, x, y, PT_FIRE); + return 1; + } else if (parts[i].life < 100) { + parts[i].life--; + sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE); + } + if ((sim->pv[y/CELL][x/CELL] > 4.3f)&&parts[i].tmp>40) + parts[i].tmp=39; + else if (parts[i].tmp<40&&parts[i].tmp>0) + parts[i].tmp--; + else if (parts[i].tmp<=0) { + sim->create_part(i, x, y, PT_BCOL); + return 1; + } + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx(rand()%500)) + { + if (parts[i].life>100) { + parts[i].life = 99; + } + } + if ((r&0xFF)==PT_LAVA && 1>(rand()%500)) + { + if (parts[r>>8].ctype == PT_IRON) { + parts[r>>8].ctype = PT_METL; + sim->kill_part(i); + return 1; + } + } + } + /*if(100-parts[i].life > parts[i].tmp2) + parts[i].tmp2 = 100-parts[i].life; + if(parts[i].tmp2 < 0) parts[i].tmp2 = 0; + for ( trade = 0; trade<4; trade ++) + { + rx = rand()%5-2; + ry = rand()%5-2; + if (x+rx>=0 && y+ry>0 && x+rxparts[r>>8].tmp2)&&parts[i].tmp2>0)//diffusion + { + int temp = parts[i].tmp2 - parts[r>>8].tmp2; + if(temp < 10) + continue; + if (temp ==1) + { + parts[r>>8].tmp2 ++; + parts[i].tmp2 --; + } + else if (temp>0) + { + parts[r>>8].tmp2 += temp/2; + parts[i].tmp2 -= temp/2; + } + } + } + }*/ + if(parts[i].temp > parts[i].tmp2) + parts[i].tmp2 = parts[i].temp; + return 0; +} + + +//#TPT-Directive ElementHeader Element_COAL static int graphics(GRAPHICS_FUNC_ARGS) +int Element_COAL::graphics(GRAPHICS_FUNC_ARGS) + //Both COAL and Broken Coal +{ + *colr += (cpart->tmp2-295.15f)/3; + + if (*colr > 170) + *colr = 170; + if (*colr < *colg) + *colr = *colg; + + *colg = *colb = *colr; + + if((cpart->temp-295.15f) > 300.0f-200.0f) + { + float frequency = 3.1415/(2*300.0f-(300.0f-200.0f)); + int q = ((cpart->temp-295.15f)>300.0f)?300.0f-(300.0f-200.0f):(cpart->temp-295.15f)-(300.0f-200.0f); + + *colr += sin(frequency*q) * 226; + *colg += sin(frequency*q*4.55 +3.14) * 34; + *colb += sin(frequency*q*2.22 +3.14) * 64; + } + return 0; +} + + + +Element_COAL::~Element_COAL() {} \ No newline at end of file diff --git a/src/elements/conv.cpp b/src/simulation/elements/CONV.cpp similarity index 50% rename from src/elements/conv.cpp rename to src/simulation/elements/CONV.cpp index a62cd552f..82e0594b0 100644 --- a/src/elements/conv.cpp +++ b/src/simulation/elements/CONV.cpp @@ -1,6 +1,54 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_CONV PT_CONV 85 +Element_CONV::Element_CONV() +{ + Identifier = "DEFAULT_PT_CONV"; + Name = "CONV"; + Colour = PIXPACK(0x0AAB0A); + MenuVisible = 1; + MenuSection = SC_SPECIAL; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Solid. Converts whatever touches it into its ctype."; + + State = ST_NONE; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_CONV::update; + Graphics = NULL; +} -int update_CONV(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_CONV static int update(UPDATE_FUNC_ARGS) +int Element_CONV::update(UPDATE_FUNC_ARGS) + { int r, rx, ry; if (parts[i].ctype<=0 || parts[i].ctype>=PT_NUM || (parts[i].ctype==PT_LIFE && (parts[i].tmp<0 || parts[i].tmp>=NGOLALT))) { @@ -43,3 +91,6 @@ int update_CONV(UPDATE_FUNC_ARGS) { } return 0; } + + +Element_CONV::~Element_CONV() {} \ No newline at end of file diff --git a/src/simulation/elements/DESL.cpp b/src/simulation/elements/DESL.cpp new file mode 100644 index 000000000..6401b3cf5 --- /dev/null +++ b/src/simulation/elements/DESL.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_DESL PT_DESL 58 +Element_DESL::Element_DESL() +{ + Identifier = "DEFAULT_PT_DESL"; + Name = "DESL"; + Colour = PIXPACK(0x440000); + MenuVisible = 1; + MenuSection = SC_LIQUID; + Enabled = 1; + + Advection = 1.0f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.98f; + Loss = 0.95f; + Collision = 0.0f; + Gravity = 0.1f; + Diffusion = 0.0f; + HotAir = 0.0f * CFDS; + Falldown = 2; + + Flammable = 2; + Explosive = 0; + Meltable = 0; + Hardness = 5; + + Weight = 15; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 42; + Description = "Liquid. Explodes under high pressure and temperatures"; + + State = ST_LIQUID; + Properties = TYPE_LIQUID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = 5.0f; + HighPressureTransition = PT_FIRE; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 335.0f; + HighTemperatureTransition = PT_FIRE; + + Update = NULL; + Graphics = NULL; +} + +Element_DESL::~Element_DESL() {} \ No newline at end of file diff --git a/src/simulation/elements/DEST.cpp b/src/simulation/elements/DEST.cpp new file mode 100644 index 000000000..a4f789154 --- /dev/null +++ b/src/simulation/elements/DEST.cpp @@ -0,0 +1,121 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_DEST PT_DEST 89 +Element_DEST::Element_DEST() +{ + Identifier = "DEFAULT_PT_DEST"; + Name = "DEST"; + Colour = PIXPACK(0xFF3311); + MenuVisible = 1; + MenuSection = SC_EXPLOSIVE; + Enabled = 1; + + Advection = -0.05f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.95f; + Loss = 0.95f; + Collision = -0.1f; + Gravity = 0.4f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 101; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 150; + Description = "More destructive Bomb."; + + State = ST_SOLID; + Properties = TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_DEST::update; + Graphics = &Element_DEST::graphics; +} + +//#TPT-Directive ElementHeader Element_DEST static int update(UPDATE_FUNC_ARGS) +int Element_DEST::update(UPDATE_FUNC_ARGS) + { + int r,rx,ry,topv; + rx=rand()%5-2; + ry=rand()%5-2; + + r = pmap[y+ry][x+rx]; + if (!r || (r&0xFF)==PT_DEST || (r&0xFF)==PT_DMND || (r&0xFF)==PT_BCLN || (r&0xFF)==PT_CLNE || (r&0xFF)==PT_PCLN || (r&0xFF)==PT_PBCN) + return 0; + + if (parts[i].life<=0 || parts[i].life>37) + { + parts[i].life=30+rand()%20; + parts[i].temp+=20000; + sim->pv[y/CELL][x/CELL]+=60.0f; + } + parts[i].temp+=10000; + if ((r&0xFF)==PT_PLUT || (r&0xFF)==PT_DEUT) + { + sim->pv[y/CELL][x/CELL]+=20.0f; + parts[i].temp+=18000; + if (rand()%2==0) + { + float orig_temp = parts[r>>8].temp; + sim->create_part(r>>8, x+rx, y+ry, PT_NEUT); + parts[r>>8].temp = restrict_flt(orig_temp+40000.0f, MIN_TEMP, MAX_TEMP); + sim->pv[y/CELL][x/CELL] += 10.0f; + parts[i].life-=4; + } + } + else if ((r&0xFF)==PT_INSL) + { + sim->create_part(r>>8, x+rx, y+ry, PT_PLSM); + } + else if (rand()%3==0) + { + sim->kill_part(r>>8); + parts[i].life -= 4*((sim->elements[r&0xFF].Properties&TYPE_SOLID)?3:1); + if (parts[i].life<=0) + parts[i].life=1; + parts[i].temp+=10000; + } + else + { + if (sim->elements[r&0xFF].HeatConduct) parts[r>>8].temp = restrict_flt(parts[r>>8].temp+10000.0f, MIN_TEMP, MAX_TEMP); + } + topv=sim->pv[y/CELL][x/CELL]/9+parts[r>>8].temp/900; + if (topv>40.0f) + topv=40.0f; + sim->pv[y/CELL][x/CELL]+=40.0f+topv; + parts[i].temp = restrict_flt(parts[i].temp, MIN_TEMP, MAX_TEMP); + return 0; +} + + +//#TPT-Directive ElementHeader Element_DEST static int graphics(GRAPHICS_FUNC_ARGS) +int Element_DEST::graphics(GRAPHICS_FUNC_ARGS) + +{ + if(cpart->life) + { + *pixel_mode |= PMODE_LFLARE; + } + else + { + *pixel_mode |= PMODE_SPARK; + } + return 0; +} + + +Element_DEST::~Element_DEST() {} \ No newline at end of file diff --git a/src/elements/deut.cpp b/src/simulation/elements/DEUT.cpp similarity index 60% rename from src/elements/deut.cpp rename to src/simulation/elements/DEUT.cpp index 98fa69b3b..b8209e442 100644 --- a/src/elements/deut.cpp +++ b/src/simulation/elements/DEUT.cpp @@ -1,6 +1,54 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_DEUT PT_DEUT 95 +Element_DEUT::Element_DEUT() +{ + Identifier = "DEFAULT_PT_DEUT"; + Name = "DEUT"; + Colour = PIXPACK(0x00153F); + MenuVisible = 1; + MenuSection = SC_NUCLEAR; + Enabled = 1; + + Advection = 0.6f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.98f; + Loss = 0.95f; + Collision = 0.0f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 2; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 20; + + Weight = 31; + + Temperature = R_TEMP-2.0f +273.15f; + HeatConduct = 251; + Description = "Deuterium oxide. Volume changes with temp, radioactive with neutrons."; + + State = ST_LIQUID; + Properties = TYPE_LIQUID|PROP_NEUTPENETRATE; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_DEUT::update; + Graphics = &Element_DEUT::graphics; +} -int update_DEUT(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_DEUT static int update(UPDATE_FUNC_ARGS) +int Element_DEUT::update(UPDATE_FUNC_ARGS) + { int r, rx, ry, trade, np; float gravtot = fabs(sim->gravy[(y/CELL)*(XRES/CELL)+(x/CELL)])+fabs(sim->gravx[(y/CELL)*(XRES/CELL)+(x/CELL)]); int maxlife = ((10000/(parts[i].temp + 1))-1); @@ -73,7 +121,11 @@ int update_DEUT(UPDATE_FUNC_ARGS) { return 0; } -int graphics_DEUT(GRAPHICS_FUNC_ARGS) + + +//#TPT-Directive ElementHeader Element_DEUT static int graphics(GRAPHICS_FUNC_ARGS) +int Element_DEUT::graphics(GRAPHICS_FUNC_ARGS) + { if(cpart->life>=700) { @@ -92,3 +144,6 @@ int graphics_DEUT(GRAPHICS_FUNC_ARGS) } return 0; } + + +Element_DEUT::~Element_DEUT() {} \ No newline at end of file diff --git a/src/simulation/elements/DLAY.cpp b/src/simulation/elements/DLAY.cpp new file mode 100644 index 000000000..0ac76c59e --- /dev/null +++ b/src/simulation/elements/DLAY.cpp @@ -0,0 +1,111 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_DLAY PT_DLAY 79 +Element_DLAY::Element_DLAY() +{ + Identifier = "DEFAULT_PT_DLAY"; + Name = "DLAY"; + Colour = PIXPACK(0x753590); + MenuVisible = 1; + MenuSection = SC_POWERED; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 1; + + Weight = 100; + + Temperature = 4.0f+273.15f; + HeatConduct = 0; + Description = "Conducts with temperature-dependent delay. (use HEAT/COOL)."; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_DLAY::update; + Graphics = &Element_DLAY::graphics; +} + +//#TPT-Directive ElementHeader Element_DLAY static int update(UPDATE_FUNC_ARGS) +int Element_DLAY::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry, oldl; + oldl = parts[i].life; + if (parts[i].life>0) + parts[i].life--; + //if (parts[i].life==1) + //{ + if (parts[i].temp>=MAX_TEMP+273.15f) + parts[i].temp = MAX_TEMP+273.15f; + if (parts[i].temp<= 1.0f+273.15f) + parts[i].temp = 1.0f+273.15f; + + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rxparts_avg(r>>8, i,PT_INSL)==PT_INSL) + continue; + if ((r&0xFF)==PT_SPRK && parts[i].life==0 && parts[r>>8].life>0 && parts[r>>8].life<4 && parts[r>>8].ctype==PT_PSCN) + { + parts[i].life = (int)(parts[i].temp-273.15); + } + else if ((r&0xFF)==PT_DLAY) + { + if(!parts[i].life && parts[r>>8].life) + { + parts[i].life = parts[r>>8].life; + if((r>>8)>i) //If the other particle hasn't been life updated + parts[i].life--; + } + else if(parts[i].life && !parts[r>>8].life) + { + parts[r>>8].life = parts[i].life; + if((r>>8)>i) //If the other particle hasn't been life updated + parts[r>>8].life++; + } + } + else if((r&0xFF)==PT_NSCN && oldl==1) + { + sim->create_part(-1, x+rx, y+ry, PT_SPRK); + } + } + //} + return 0; +} + + +//#TPT-Directive ElementHeader Element_DLAY static int graphics(GRAPHICS_FUNC_ARGS) +int Element_DLAY::graphics(GRAPHICS_FUNC_ARGS) + +{ + int stage = (int)(((float)cpart->life/(cpart->temp-273.15))*100.0f); + *colr += stage; + *colg += stage; + *colb += stage; + return 0; +} + + +Element_DLAY::~Element_DLAY() {} \ No newline at end of file diff --git a/src/simulation/elements/DMND.cpp b/src/simulation/elements/DMND.cpp new file mode 100644 index 000000000..fe158f865 --- /dev/null +++ b/src/simulation/elements/DMND.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_DMND PT_DMND 28 +Element_DMND::Element_DMND() +{ + Identifier = "DEFAULT_PT_DMND"; + Name = "DMND"; + Colour = PIXPACK(0xCCFFFF); + MenuVisible = 1; + MenuSection = SC_SOLIDS; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 186; + Description = "Diamond. Indestructible."; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = NULL; + Graphics = NULL; +} + +Element_DMND::~Element_DMND() {} \ No newline at end of file diff --git a/src/simulation/elements/DRIC.cpp b/src/simulation/elements/DRIC.cpp new file mode 100644 index 000000000..7112bbc69 --- /dev/null +++ b/src/simulation/elements/DRIC.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_DRIC PT_DRIC 81 +Element_DRIC::Element_DRIC() +{ + Identifier = "DEFAULT_PT_DRIC"; + Name = "DRIC"; + Colour = PIXPACK(0xE0E0E0); + MenuVisible = 1; + MenuSection = SC_SOLIDS; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = -0.0005f* CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 20; + + Weight = 100; + + Temperature = 172.65f; + HeatConduct = 2; + Description = "Dry Ice."; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 195.65f; + HighTemperatureTransition = PT_CO2; + + Update = NULL; + Graphics = NULL; +} + +Element_DRIC::~Element_DRIC() {} \ No newline at end of file diff --git a/src/simulation/elements/DSTW.cpp b/src/simulation/elements/DSTW.cpp new file mode 100644 index 000000000..c04bf5bfb --- /dev/null +++ b/src/simulation/elements/DSTW.cpp @@ -0,0 +1,90 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_DSTW PT_DSTW 25 +Element_DSTW::Element_DSTW() +{ + Identifier = "DEFAULT_PT_DSTW"; + Name = "DSTW"; + Colour = PIXPACK(0x1020C0); + MenuVisible = 1; + MenuSection = SC_LIQUID; + Enabled = 1; + + Advection = 0.6f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.98f; + Loss = 0.95f; + Collision = 0.0f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 2; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 20; + + Weight = 30; + + Temperature = R_TEMP-2.0f +273.15f; + HeatConduct = 23; + Description = "Distilled water, does not conduct electricity."; + + State = ST_LIQUID; + Properties = TYPE_LIQUID|PROP_NEUTPENETRATE; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = 273.15f; + LowTemperatureTransition = PT_ICEI; + HighTemperature = 373.0f; + HighTemperatureTransition = PT_WTRV; + + Update = &Element_DSTW::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_DSTW static int update(UPDATE_FUNC_ARGS) +int Element_DSTW::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx(rand()%250)) + { + sim->part_change_type(i,x,y,PT_SLTW); + sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW); + } + if (((r&0xFF)==PT_WATR||(r&0xFF)==PT_SLTW) && 1>(rand()%500)) + { + sim->part_change_type(i,x,y,PT_WATR); + } + if ((r&0xFF)==PT_SLTW && 1>(rand()%500)) + { + sim->part_change_type(i,x,y,PT_SLTW); + } + if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>12.0f) && 1>(rand()%500)) + { + sim->part_change_type(i,x,y,PT_FIRE); + parts[i].life = 4; + } + if ((r&0xFF)==PT_FIRE){ + sim->kill_part(r>>8); + if(1>(rand()%150)){ + sim->kill_part(i); + return 1; + } + } + } + return 0; +} + + +Element_DSTW::~Element_DSTW() {} \ No newline at end of file diff --git a/src/simulation/elements/DUST.cpp b/src/simulation/elements/DUST.cpp new file mode 100644 index 000000000..353bfbdfc --- /dev/null +++ b/src/simulation/elements/DUST.cpp @@ -0,0 +1,76 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_DUST PT_DUST 1 +Element_DUST::Element_DUST() +{ + Identifier = "DEFAULT_PT_DUST"; + Name = "DUST"; + Colour = PIXPACK(0xFFE0A0); + MenuVisible = 1; + MenuSection = SC_POWDERS; + Enabled = 1; + + Advection = 0.7f; + AirDrag = 0.02f * CFDS; + AirLoss = 0.96f; + Loss = 0.80f; + Collision = 0.0f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 10; + Explosive = 0; + Meltable = 0; + Hardness = 30; + + Weight = 85; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 70; + Description = "Very light dust. Flammable."; + + State = ST_SOLID; + Properties = TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = NULL; + Graphics = &Element_DUST::graphics; +} + +//#TPT-Directive ElementHeader Element_DUST static int graphics(GRAPHICS_FUNC_ARGS) +int Element_DUST::graphics(GRAPHICS_FUNC_ARGS) + +{ + if(cpart->life >= 1) + { + *firea = 120; + *firer = *colr = cpart->flags; + *fireg = *colg = cpart->tmp; + *fireb = *colb = cpart->ctype; + if (ren->decorations_enable && cpart->dcolour) + { + int a = (cpart->dcolour>>24)&0xFF; + *firer = *colr = (a*((cpart->dcolour>>16)&0xFF) + (255-a)**colr) >> 8; + *fireg = *colg = (a*((cpart->dcolour>>8)&0xFF) + (255-a)**colg) >> 8; + *fireb = *colb = (a*((cpart->dcolour)&0xFF) + (255-a)**colb) >> 8; + } + *pixel_mode |= PMODE_GLOW | FIRE_ADD; + /**firea = 255; + *firer = *colr; + *fireg = *colg; + *fireb = *colb;*/ + } + return 0; +} + + +Element_DUST::~Element_DUST() {} \ No newline at end of file diff --git a/src/simulation/elements/DYST.cpp b/src/simulation/elements/DYST.cpp new file mode 100644 index 000000000..5db167fa9 --- /dev/null +++ b/src/simulation/elements/DYST.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_DYST PT_DYST 64 +Element_DYST::Element_DYST() +{ + Identifier = "DEFAULT_PT_DYST"; + Name = "DYST"; + Colour = PIXPACK(0xBBB0A0); + MenuVisible = 0; + MenuSection = SC_POWDERS; + Enabled = 1; + + Advection = 0.7f; + AirDrag = 0.02f * CFDS; + AirLoss = 0.96f; + Loss = 0.80f; + Collision = 0.0f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 20; + Explosive = 0; + Meltable = 0; + Hardness = 30; + + Weight = 80; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 70; + Description = "Dead Yeast."; + + State = ST_SOLID; + Properties = TYPE_PART; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 473.0f; + HighTemperatureTransition = PT_DUST; + + Update = NULL; + Graphics = NULL; +} + +Element_DYST::~Element_DYST() {} \ No newline at end of file diff --git a/src/elements/elec.cpp b/src/simulation/elements/ELEC.cpp similarity index 60% rename from src/elements/elec.cpp rename to src/simulation/elements/ELEC.cpp index 317d9f537..16bad1adf 100644 --- a/src/elements/elec.cpp +++ b/src/simulation/elements/ELEC.cpp @@ -1,6 +1,54 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_ELEC PT_ELEC 136 +Element_ELEC::Element_ELEC() +{ + Identifier = "DEFAULT_PT_ELEC"; + Name = "ELEC"; + Colour = PIXPACK(0xDFEFFF); + MenuVisible = 1; + MenuSection = SC_NUCLEAR; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 1.00f; + Loss = 1.00f; + Collision = -0.99f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = -1; + + Temperature = R_TEMP+200.0f+273.15f; + HeatConduct = 251; + Description = "Electrons"; + + State = ST_GAS; + Properties = TYPE_ENERGY|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_ELEC::update; + Graphics = &Element_ELEC::graphics; +} -int update_ELEC(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_ELEC static int update(UPDATE_FUNC_ARGS) +int Element_ELEC::update(UPDATE_FUNC_ARGS) + { int r, rt, rx, ry, nb, rrx, rry; float rr, rrr; parts[i].pavg[0] = x; @@ -79,7 +127,7 @@ int update_ELEC(UPDATE_FUNC_ARGS) { sim->kill_part(i); return 1; } - if ((sim->ptypes[r&0xFF].properties & PROP_CONDUCTS) && ((r&0xFF)!=PT_H2||parts[i].tmp!=1)) + if ((sim->elements[r&0xFF].Properties & PROP_CONDUCTS) && ((r&0xFF)!=PT_H2||parts[i].tmp!=1)) { sim->create_part(-1, x+rx, y+ry, PT_SPRK); sim->kill_part(i); @@ -89,7 +137,11 @@ int update_ELEC(UPDATE_FUNC_ARGS) { return 0; } -int graphics_ELEC(GRAPHICS_FUNC_ARGS) + + +//#TPT-Directive ElementHeader Element_ELEC static int graphics(GRAPHICS_FUNC_ARGS) +int Element_ELEC::graphics(GRAPHICS_FUNC_ARGS) + { *firea = 70; *firer = *colr; @@ -99,3 +151,6 @@ int graphics_ELEC(GRAPHICS_FUNC_ARGS) *pixel_mode |= FIRE_ADD; return 0; } + + +Element_ELEC::~Element_ELEC() {} \ No newline at end of file diff --git a/src/elements/emp.cpp b/src/simulation/elements/EMP.cpp similarity index 70% rename from src/elements/emp.cpp rename to src/simulation/elements/EMP.cpp index 66256109c..175e7e764 100644 --- a/src/elements/emp.cpp +++ b/src/simulation/elements/EMP.cpp @@ -1,6 +1,54 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_EMP PT_EMP 134 +Element_EMP::Element_EMP() +{ + Identifier = "DEFAULT_PT_EMP"; + Name = "EMP"; + Colour = PIXPACK(0x66AAFF); + MenuVisible = 1; + MenuSection = SC_ELEC; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.0f; + HotAir = 0.0f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 3; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 121; + Description = "Breaks activated electronics."; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_EMP::update; + Graphics = &Element_EMP::graphics; +} -int update_EMP(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_EMP static int update(UPDATE_FUNC_ARGS) +int Element_EMP::update(UPDATE_FUNC_ARGS) + { int r,rx,ry,ok=0,t,n,nx,ny; if (parts[i].life) return 0; @@ -35,7 +83,7 @@ int update_EMP(UPDATE_FUNC_ARGS) { parts[r].ctype==PT_NTCT || parts[r].ctype==PT_INST || parts[r].ctype==PT_SWCH) || t==PT_WIRE || t==PT_SWCH) { is_elec=1; - if (sim->ptypes[parts[r].type].hconduct && rand()%100==0) + if (sim->elements[parts[r].type].HeatConduct && rand()%100==0) parts[r].temp = restrict_flt(parts[r].temp+3000.0f, MIN_TEMP, MAX_TEMP); if (rand()%80==0) sim->part_change_type(r, rx, ry, PT_BREC); @@ -108,7 +156,11 @@ int update_EMP(UPDATE_FUNC_ARGS) { } return 0; } -int graphics_EMP(GRAPHICS_FUNC_ARGS) + + +//#TPT-Directive ElementHeader Element_EMP static int graphics(GRAPHICS_FUNC_ARGS) +int Element_EMP::graphics(GRAPHICS_FUNC_ARGS) + { if(cpart->life) { @@ -126,3 +178,6 @@ int graphics_EMP(GRAPHICS_FUNC_ARGS) } return 0; } + + +Element_EMP::~Element_EMP() {} \ No newline at end of file diff --git a/src/simulation/elements/ETRD.cpp b/src/simulation/elements/ETRD.cpp new file mode 100644 index 000000000..b3eacfb3f --- /dev/null +++ b/src/simulation/elements/ETRD.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_ETRD PT_ETRD 50 +Element_ETRD::Element_ETRD() +{ + Identifier = "DEFAULT_PT_ETRD"; + Name = "ETRD"; + Colour = PIXPACK(0x404040); + MenuVisible = 1; + MenuSection = SC_ELEC; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Electrode. Creates a surface that allows Plasma arcs. (Use sparingly)"; + + State = ST_NONE; + Properties = TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = NULL; + Graphics = NULL; +} + +Element_ETRD::~Element_ETRD() {} \ No newline at end of file diff --git a/src/simulation/elements/Element.cpp b/src/simulation/elements/Element.cpp new file mode 100644 index 000000000..44e725117 --- /dev/null +++ b/src/simulation/elements/Element.cpp @@ -0,0 +1,69 @@ +#include "simulation/Elements.h" + +Element::Element(): + Identifier("DEFAULT_INVALID"), + Name(""), + Colour(PIXPACK(0xFFFFFF)), + MenuVisible(0), + MenuSection(0), + Enabled(0), + + Advection(0.0f), + AirDrag(-0.0f * CFDS), + AirLoss(1.0f), + Loss(1.0f), + Collision(0.0f), + Gravity(0.0f), + Diffusion(0.0f), + HotAir(0.0f * CFDS), + Falldown(0), + + Flammable(0), + Explosive(0), + Meltable(0), + Hardness(30), + + Weight(50), + + Temperature(273.15f), + HeatConduct(128), + Description("No description"), + + State(ST_SOLID), + Properties(TYPE_SOLID), + + LowPressure(IPL), + LowPressureTransition(NT), + HighPressure(IPH), + HighPressureTransition(NT), + LowTemperature(ITL), + LowTemperatureTransition(NT), + HighTemperature(ITH), + HighTemperatureTransition(NT), + + Update(NULL), + Graphics(&Element::defaultGraphics) +{ +} + +int Element::defaultGraphics(GRAPHICS_FUNC_ARGS) +{ + int t = cpart->type; + //Property based defaults + if(ren->sim->elements[t].Properties & PROP_RADIOACTIVE) *pixel_mode |= PMODE_GLOW; + if(ren->sim->elements[t].Properties & TYPE_LIQUID) + { + *pixel_mode |= PMODE_BLUR; + } + if(ren->sim->elements[t].Properties & TYPE_GAS) + { + *pixel_mode &= ~PMODE; + *pixel_mode |= FIRE_BLEND; + *firer = *colr/2; + *fireg = *colg/2; + *fireb = *colb/2; + *firea = 125; + *pixel_mode |= DECO_FIRE; + } + return 1; +} \ No newline at end of file diff --git a/src/simulation/elements/Element.h b/src/simulation/elements/Element.h new file mode 100644 index 000000000..b5845063c --- /dev/null +++ b/src/simulation/elements/Element.h @@ -0,0 +1,56 @@ +#ifndef ELEMENTCLASS_H +#define ELEMENTCLASS_H + +#include "simulation/Simulation.h" +#include "Renderer.h" +#include "simulation/Elements.h" + +class Simulation; +class Renderer; +struct Particle; +class Element +{ +public: + char *Identifier; + char *Name; + pixel Colour; + float Advection; + float AirDrag; + float AirLoss; + float Loss; + float Collision; + float Gravity; + float Diffusion; + float HotAir; + int Falldown; + int Flammable; + int Explosive; + int Meltable; + int Hardness; + int MenuVisible; + int Enabled; + int Weight; + int MenuSection; + float Temperature; + unsigned char HeatConduct; + char *Description; + char State; + unsigned int Properties; + int (*Update) (UPDATE_FUNC_ARGS); + int (*Graphics) (GRAPHICS_FUNC_ARGS); + + float HighPressure; + int HighPressureTransition; + float LowPressure; + int LowPressureTransition; + float HighTemperature; + int HighTemperatureTransition; + float LowTemperature; + int LowTemperatureTransition; + + Element(); + virtual ~Element() {} + static int defaultGraphics(GRAPHICS_FUNC_ARGS); +}; + +#endif \ No newline at end of file diff --git a/src/elements/figh.cpp b/src/simulation/elements/FIGH.cpp similarity index 58% rename from src/elements/figh.cpp rename to src/simulation/elements/FIGH.cpp index 6b67a275e..a28060e93 100644 --- a/src/elements/figh.cpp +++ b/src/simulation/elements/FIGH.cpp @@ -1,6 +1,54 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_FIGH PT_FIGH 158 +Element_FIGH::Element_FIGH() +{ + Identifier = "DEFAULT_PT_FIGH"; + Name = "FIGH"; + Colour = PIXPACK(0x000000); + MenuVisible = 1; + MenuSection = SC_SPECIAL; + Enabled = 1; + + Advection = 0.5f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.2f; + Loss = 1.0f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.0f; + HotAir = 0.00f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 50; + + Temperature = R_TEMP+14.6f+273.15f; + HeatConduct = 0; + Description = "Fighter. Tries to kill stickmen."; + + State = ST_NONE; + Properties = 0; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 620.0f; + HighTemperatureTransition = PT_FIRE; + + Update = &Element_FIGH::update; + Graphics = &Element_FIGH::graphics; +} + +//#TPT-Directive ElementHeader Element_FIGH static int update(UPDATE_FUNC_ARGS) +int Element_FIGH::update(UPDATE_FUNC_ARGS) -int update_FIGH(UPDATE_FUNC_ARGS) { playerst* figh = &sim->fighters[(unsigned char)parts[i].tmp]; @@ -46,8 +94,8 @@ int update_FIGH(UPDATE_FUNC_ARGS) if ((pow(float(tarx-x), 2) + pow(float(tary-y), 2))<600) { if (figh->elem == PT_LIGH || figh->elem == PT_NEUT - || sim->ptypes[figh->elem].properties&(PROP_DEADLY|PROP_RADIOACTIVE) - || sim->ptypes[figh->elem].heat>=323 || sim->ptypes[figh->elem].heat<=243) + || sim->elements[figh->elem].Properties&(PROP_DEADLY|PROP_RADIOACTIVE) + || sim->elements[figh->elem].Temperature>=323 || sim->elements[figh->elem].Temperature<=243) figh->comm = (int)figh->comm | 0x08; } else @@ -85,19 +133,23 @@ int update_FIGH(UPDATE_FUNC_ARGS) figh->pcomm = figh->comm; - run_stickman(figh, UPDATE_FUNC_SUBCALL_ARGS); + Element_STKM::run_stickman(figh, UPDATE_FUNC_SUBCALL_ARGS); return 0; } -int graphics_FIGH(GRAPHICS_FUNC_ARGS) + + +//#TPT-Directive ElementHeader Element_FIGH static int graphics(GRAPHICS_FUNC_ARGS) +int Element_FIGH::graphics(GRAPHICS_FUNC_ARGS) + { playerst * cplayer;// = &sim->fighters[(unsigned char)cpart->tmp]; *pixel_mode = PSPEC_STICKMAN; /*if (cplayer->elemptypes[cplayer->elem].pcolors); - *colg = PIXG(sim->ptypes[cplayer->elem].pcolors); - *colb = PIXB(sim->ptypes[cplayer->elem].pcolors); + *colr = PIXR(sim->elements[cplayer->elem].pcolors); + *colg = PIXG(sim->elements[cplayer->elem].pcolors); + *colb = PIXB(sim->elements[cplayer->elem].pcolors); } else*/ { @@ -105,3 +157,6 @@ int graphics_FIGH(GRAPHICS_FUNC_ARGS) } return 1; } + + +Element_FIGH::~Element_FIGH() {} \ No newline at end of file diff --git a/src/simulation/elements/FILT.cpp b/src/simulation/elements/FILT.cpp new file mode 100644 index 000000000..c9786904e --- /dev/null +++ b/src/simulation/elements/FILT.cpp @@ -0,0 +1,77 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_FILT PT_FILT 125 +Element_FILT::Element_FILT() +{ + Identifier = "DEFAULT_PT_FILT"; + Name = "FILT"; + Colour = PIXPACK(0x000056); + MenuVisible = 1; + MenuSection = SC_SOLIDS; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Filter for photons, changes the color."; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = NULL; + Graphics = &Element_FILT::graphics; +} + +//#TPT-Directive ElementHeader Element_FILT static int graphics(GRAPHICS_FUNC_ARGS) +int Element_FILT::graphics(GRAPHICS_FUNC_ARGS) + +{ + int x, temp_bin = (int)((cpart->temp-273.0f)*0.025f); + if (temp_bin < 0) temp_bin = 0; + if (temp_bin > 25) temp_bin = 25; + cpart->ctype = 0x1F << temp_bin; + *colg = 0; + *colb = 0; + *colr = 0; + for (x=0; x<12; x++) { + *colr += (cpart->ctype >> (x+18)) & 1; + *colb += (cpart->ctype >> x) & 1; + } + for (x=0; x<12; x++) + *colg += (cpart->ctype >> (x+9)) & 1; + x = 624/(*colr+*colg+*colb+1); + *cola = 127; + *colr *= x; + *colg *= x; + *colb *= x; + *pixel_mode &= ~PMODE; + *pixel_mode |= PMODE_BLEND; + return 0; +} + + +Element_FILT::~Element_FILT() {} \ No newline at end of file diff --git a/src/elements/pyro.cpp b/src/simulation/elements/FIRE.cpp similarity index 52% rename from src/elements/pyro.cpp rename to src/simulation/elements/FIRE.cpp index 6ffe64474..0a9814986 100644 --- a/src/elements/pyro.cpp +++ b/src/simulation/elements/FIRE.cpp @@ -1,6 +1,54 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_FIRE PT_FIRE 4 +Element_FIRE::Element_FIRE() +{ + Identifier = "DEFAULT_PT_FIRE"; + Name = "FIRE"; + Colour = PIXPACK(0xFF1000); + MenuVisible = 1; + MenuSection = SC_EXPLOSIVE; + Enabled = 1; + + Advection = 0.9f; + AirDrag = 0.04f * CFDS; + AirLoss = 0.97f; + Loss = 0.20f; + Collision = 0.0f; + Gravity = -0.1f; + Diffusion = 0.00f; + HotAir = 0.001f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 2; + + Temperature = R_TEMP+400.0f+273.15f; + HeatConduct = 88; + Description = "Ignites flammable materials. Heats air."; + + State = ST_GAS; + Properties = TYPE_GAS|PROP_LIFE_DEC|PROP_LIFE_KILL; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 2773.0f; + HighTemperatureTransition = PT_PLSM; + + Update = &Element_FIRE::update; + Graphics = &Element_FIRE::graphics; +} -int update_PYRO(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_FIRE static int update(UPDATE_FUNC_ARGS) +int Element_FIRE::update(UPDATE_FUNC_ARGS) + { int r, rx, ry, rt, t = parts[i].type; if (t==PT_PLSM&&parts[i].ctype == PT_NBLE&&parts[i].life <=1) { @@ -42,26 +90,27 @@ int update_PYRO(UPDATE_FUNC_ARGS) { if (sim->bmap[(y+ry)/CELL][(x+rx)/CELL] && sim->bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_STREAM) continue; rt = parts[r>>8].type; - if ((surround_space || sim->ptypes[rt].explosive) && + if ((surround_space || sim->elements[rt].Explosive) && (t!=PT_SPRK || (rt!=PT_RBDM && rt!=PT_LRBD && rt!=PT_INSL)) && (t!=PT_PHOT || rt!=PT_INSL) && (rt!=PT_SPNG || parts[r>>8].life==0) && (rt!=PT_H2 || (parts[r>>8].temp < 2273.15 && sim->pv[y/CELL][x/CELL] < 50.0f)) && - sim->ptypes[rt].flammable && (sim->ptypes[rt].flammable + (int)(sim->pv[(y+ry)/CELL][(x+rx)/CELL]*10.0f))>(rand()%1000)) + sim->elements[rt].Flammable && (sim->elements[rt].Flammable + (int)(sim->pv[(y+ry)/CELL][(x+rx)/CELL]*10.0f))>(rand()%1000)) { sim->part_change_type(r>>8,x+rx,y+ry,PT_FIRE); - parts[r>>8].temp = restrict_flt(sim->ptypes[PT_FIRE].heat + (sim->ptypes[rt].flammable/2), MIN_TEMP, MAX_TEMP); + parts[r>>8].temp = restrict_flt(sim->elements[PT_FIRE].Temperature + (sim->elements[rt].Flammable/2), MIN_TEMP, MAX_TEMP); parts[r>>8].life = rand()%80+180; parts[r>>8].tmp = parts[r>>8].ctype = 0; - if (sim->ptypes[rt].explosive) + if (sim->elements[rt].Explosive) sim->pv[y/CELL][x/CELL] += 0.25f * CFDS; } } - if (sim->legacy_enable) update_legacy_PYRO(UPDATE_FUNC_SUBCALL_ARGS); + if (sim->legacy_enable) updateLegacy(UPDATE_FUNC_SUBCALL_ARGS); return 0; } -int update_legacy_PYRO(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_FIRE static int updateLegacy(UPDATE_FUNC_ARGS) +int Element_FIRE::updateLegacy(UPDATE_FUNC_ARGS) { int r, rx, ry, rt, lpv, t = parts[i].type; for (rx=-2; rx<3; rx++) for (ry=-2; ry<3; ry++) @@ -75,8 +124,8 @@ int update_legacy_PYRO(UPDATE_FUNC_ARGS) { rt = r&0xFF; lpv = (int)sim->pv[(y+ry)/CELL][(x+rx)/CELL]; if (lpv < 1) lpv = 1; - if (t!=PT_SPRK && sim->ptypes[rt].meltable && ((rt!=PT_RBDM && rt!=PT_LRBD) || t!=PT_SPRK) && ((t!=PT_FIRE&&t!=PT_PLSM) || (rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SALT && rt!=PT_INWR)) && - sim->ptypes[rt].meltable*lpv>(rand()%1000)) + if (t!=PT_SPRK && sim->elements[rt].Meltable && ((rt!=PT_RBDM && rt!=PT_LRBD) || t!=PT_SPRK) && ((t!=PT_FIRE&&t!=PT_PLSM) || (rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SALT && rt!=PT_INWR)) && + sim->elements[rt].Meltable*lpv>(rand()%1000)) { if (t!=PT_LAVA || parts[i].life>0) { @@ -128,3 +177,26 @@ int update_legacy_PYRO(UPDATE_FUNC_ARGS) { } return 0; } + + +//#TPT-Directive ElementHeader Element_FIRE static int graphics(GRAPHICS_FUNC_ARGS) +int Element_FIRE::graphics(GRAPHICS_FUNC_ARGS) + +{ + int caddress = restrict_flt(restrict_flt((float)cpart->life, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); + *colr = (unsigned char)ren->flm_data[caddress]; + *colg = (unsigned char)ren->flm_data[caddress+1]; + *colb = (unsigned char)ren->flm_data[caddress+2]; + + *firea = 255; + *firer = *colr; + *fireg = *colg; + *fireb = *colb; + + *pixel_mode = PMODE_NONE; //Clear default, don't draw pixel + *pixel_mode |= FIRE_ADD; + //Returning 0 means dynamic, do not cache + return 0; +} + +Element_FIRE::~Element_FIRE() {} \ No newline at end of file diff --git a/src/simulation/elements/FIRW.cpp b/src/simulation/elements/FIRW.cpp new file mode 100644 index 000000000..a23d013c3 --- /dev/null +++ b/src/simulation/elements/FIRW.cpp @@ -0,0 +1,154 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_FIRW PT_FIRW 69 +Element_FIRW::Element_FIRW() +{ + Identifier = "DEFAULT_PT_FIRW"; + Name = "FIRW"; + Colour = PIXPACK(0xFFA040); + MenuVisible = 1; + MenuSection = SC_EXPLOSIVE; + Enabled = 1; + + Advection = 0.7f; + AirDrag = 0.02f * CFDS; + AirLoss = 0.96f; + Loss = 0.80f; + Collision = -0.99f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 30; + + Weight = 55; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 70; + Description = "Fireworks!"; + + State = ST_SOLID; + Properties = TYPE_PART|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_FIRW::update; + Graphics = &Element_FIRW::graphics; +} + +//#TPT-Directive ElementHeader Element_FIRW static int update(UPDATE_FUNC_ARGS) +int Element_FIRW::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry, rt, np; + if (parts[i].tmp==0) { + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8].type; + if (rt==PT_FIRE||rt==PT_PLSM||rt==PT_THDR) + { + parts[i].tmp = 1; + parts[i].life = rand()%50+60; + } + } + } + else if (parts[i].tmp==1) { + if (parts[i].life==0) { + parts[i].tmp=2; + } else { + float newVel = parts[i].life/25; + parts[i].flags &= ~FLAG_STAGNANT; + /* TODO: + if ((pmap[(int)(ly-newVel)][(int)lx]&0xFF)==PT_NONE && ly-newVel>0) { + parts[i].vy = -newVel; + ly-=newVel; + iy-=newVel; + }*/ + parts[i].vy = -newVel; + } + } + else if (parts[i].tmp==2) { + int col = rand()%200+4; + int tmul; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rxcreate_part(-1, x+rx, y+ry, PT_FIRW); + if (np>-1) + { + parts[np].vx = (rand()%3-1)*tmul; + parts[np].vy = (rand()%3-1)*tmul; + parts[np].tmp = col; + parts[np].life = rand()%100+100; + parts[np].temp = 6000.0f; + parts[np].dcolour = parts[i].dcolour; + } + } + sim->pv[y/CELL][x/CELL] += 20; + sim->kill_part(i); + return 1; + } else if (parts[i].tmp>=3) { + if (parts[i].life<=0) { + sim->kill_part(i); + return 1; + } + } + return 0; +} + + +//#TPT-Directive ElementHeader Element_FIRW static int graphics(GRAPHICS_FUNC_ARGS) +int Element_FIRW::graphics(GRAPHICS_FUNC_ARGS) + +{ + if(cpart->tmp>=3) + { + int caddress = restrict_flt(restrict_flt((float)(cpart->tmp-4), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); + *colr = 0;//(unsigned char)firw_data[caddress]; + *colg = 0;//(unsigned char)firw_data[caddress+1]; + *colb = 0;//(unsigned char)firw_data[caddress+2]; + + if (ren->decorations_enable && cpart->dcolour) + { + int a = (cpart->dcolour>>24)&0xFF; + *colr = (a*((cpart->dcolour>>16)&0xFF) + (255-a)**colr) >> 8; + *colg = (a*((cpart->dcolour>>8)&0xFF) + (255-a)**colg) >> 8; + *colb = (a*((cpart->dcolour)&0xFF) + (255-a)**colb) >> 8; + } + + *firea = cpart->life*4; + if(*firea > 240) + *firea = 240; + *firer = *colr; + *fireg = *colg; + *fireb = *colb; + + *pixel_mode = PMODE_NONE; //Clear default, don't draw pixel + *pixel_mode |= FIRE_ADD; + //Returning 0 means dynamic, do not cache + } + else if(cpart->tmp > 0) + { + *pixel_mode |= PMODE_GLOW; + } + return 0; +} + + +Element_FIRW::~Element_FIRW() {} \ No newline at end of file diff --git a/src/simulation/elements/FOG.cpp b/src/simulation/elements/FOG.cpp new file mode 100644 index 000000000..ca2beb4ef --- /dev/null +++ b/src/simulation/elements/FOG.cpp @@ -0,0 +1,73 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_FOG PT_FOG 92 +Element_FOG::Element_FOG() +{ + Identifier = "DEFAULT_PT_FOG"; + Name = "FOG"; + Colour = PIXPACK(0xAAAAAA); + MenuVisible = 1; + MenuSection = SC_CRACKER2; + Enabled = 1; + + Advection = 0.8f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.4f; + Loss = 0.70f; + Collision = -0.1f; + Gravity = 0.0f; + Diffusion = 0.99f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 30; + + Weight = 1; + + Temperature = 243.15f; + HeatConduct = 100; + Description = "Not quite Steam"; + + State = ST_GAS; + Properties = TYPE_GAS|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 373.15f; + HighTemperatureTransition = PT_WTRV; + + Update = &Element_FOG::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_FOG static int update(UPDATE_FUNC_ARGS) +int Element_FOG::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rxelements[r&0xFF].State==ST_SOLID&&5>=rand()%50&&parts[i].life==0&&!((r&0xFF)==PT_CLNE||(r&0xFF)==PT_PCLN)) // TODO: should this also exclude BCLN? + { + sim->part_change_type(i,x,y,PT_RIME); + } + if ((r&0xFF)==PT_SPRK) + { + parts[i].life += rand()%20; + } + } + return 0; +} + + +Element_FOG::~Element_FOG() {} \ No newline at end of file diff --git a/src/simulation/elements/FRAY.cpp b/src/simulation/elements/FRAY.cpp new file mode 100644 index 000000000..b81db073d --- /dev/null +++ b/src/simulation/elements/FRAY.cpp @@ -0,0 +1,80 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_FRAY PT_FRAY 159 +Element_FRAY::Element_FRAY() +{ + Identifier = "DEFAULT_PT_FRAY"; + Name = "FRAY"; + Colour = PIXPACK(0x00BBFF); + MenuVisible = 1; + MenuSection = SC_FORCE; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 1; + + Weight = 100; + + Temperature = 20.0f+0.0f +273.15f; + HeatConduct = 0; + Description = "Force Emitter. Push or pull objects based on temp value, use like ARAY"; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_FRAY::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_FRAY static int update(UPDATE_FUNC_ARGS) +int Element_FRAY::update(UPDATE_FUNC_ARGS) + { + int r, nxx, nyy, docontinue, len, nxi, nyi, rx, ry, nr, ry1, rx1; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx= 0 && y+nyi+nyy >= 0) || len>10) { + break; + } + r = pmap[y+nyi+nyy][x+nxi+nxx]; + if (!r) + r = sim->photons[y+nyi+nyy][x+nxi+nxx]; + + if (r && !(sim->elements[r&0xFF].Properties & TYPE_SOLID)){ + parts[r>>8].vx += nxi*((parts[i].temp-273.15)/10.0f); + parts[r>>8].vy += nyi*((parts[i].temp-273.15)/10.0f); + } + } + } + } + return 0; +} + + +Element_FRAY::~Element_FRAY() {} \ No newline at end of file diff --git a/src/simulation/elements/FRZW.cpp b/src/simulation/elements/FRZW.cpp new file mode 100644 index 000000000..5c124b44f --- /dev/null +++ b/src/simulation/elements/FRZW.cpp @@ -0,0 +1,81 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_FRZW PT_FRZW 101 +Element_FRZW::Element_FRZW() +{ + Identifier = "DEFAULT_PT_FRZW"; + Name = "FRZW"; + Colour = PIXPACK(0x1020C0); + MenuVisible = 1; + MenuSection = SC_CRACKER2; + Enabled = 1; + + Advection = 0.6f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.98f; + Loss = 0.95f; + Collision = 0.0f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 2; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 20; + + Weight = 30; + + Temperature = 120.0f; + HeatConduct = 29; + Description = "FREEZE WATER"; + + State = ST_LIQUID; + Properties = TYPE_LIQUID||PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 53.0f; + HighTemperatureTransition = PT_ICEI; + + Update = &Element_FRZW::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_FRZW static int update(UPDATE_FUNC_ARGS) +int Element_FRZW::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rxrand()%70) + { + sim->part_change_type(r>>8,x+rx,y+ry,PT_FRZW); + } + } + if (parts[i].life==0&&13>rand()%2500) + { + sim->part_change_type(i,x,y,PT_ICEI); + parts[i].ctype=PT_FRZW; + parts[i].temp = restrict_flt(parts[i].temp-200.0f, MIN_TEMP, MAX_TEMP); + } + else if ((100-(parts[i].life))>rand()%50000) + { + sim->part_change_type(i,x,y,PT_ICEI); + parts[i].ctype=PT_FRZW; + parts[i].temp = restrict_flt(parts[i].temp-200.0f, MIN_TEMP, MAX_TEMP); + } + return 0; +} + + +Element_FRZW::~Element_FRZW() {} \ No newline at end of file diff --git a/src/simulation/elements/FRZZ.cpp b/src/simulation/elements/FRZZ.cpp new file mode 100644 index 000000000..14d2f1a6f --- /dev/null +++ b/src/simulation/elements/FRZZ.cpp @@ -0,0 +1,76 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_FRZZ PT_FRZZ 100 +Element_FRZZ::Element_FRZZ() +{ + Identifier = "DEFAULT_PT_FRZZ"; + Name = "FRZZ"; + Colour = PIXPACK(0xC0E0FF); + MenuVisible = 1; + MenuSection = SC_POWDERS; + Enabled = 1; + + Advection = 0.7f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.96f; + Loss = 0.90f; + Collision = -0.1f; + Gravity = 0.05f; + Diffusion = 0.01f; + HotAir = -0.00005f* CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 20; + + Weight = 50; + + Temperature = 90.0f; + HeatConduct = 46; + Description = "FREEZE"; + + State = ST_SOLID; + Properties = TYPE_PART; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_FRZZ::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_FRZZ static int update(UPDATE_FUNC_ARGS) +int Element_FRZZ::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rxrand()%100) + { + sim->part_change_type(r>>8,x+rx,y+ry,PT_FRZW); + parts[r>>8].life = 100; + parts[i].type = PT_NONE; + } + + } + if (parts[i].type==PT_NONE) { + sim->kill_part(i); + return 1; + } + return 0; +} + + +Element_FRZZ::~Element_FRZZ() {} \ No newline at end of file diff --git a/src/simulation/elements/FSEP.cpp b/src/simulation/elements/FSEP.cpp new file mode 100644 index 000000000..80b10f4f5 --- /dev/null +++ b/src/simulation/elements/FSEP.cpp @@ -0,0 +1,86 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_FSEP PT_FSEP 71 +Element_FSEP::Element_FSEP() +{ + Identifier = "DEFAULT_PT_FSEP"; + Name = "FSEP"; + Colour = PIXPACK(0x63AD5F); + MenuVisible = 1; + MenuSection = SC_POWDERS; + Enabled = 1; + + Advection = 0.7f; + AirDrag = 0.02f * CFDS; + AirLoss = 0.96f; + Loss = 0.80f; + Collision = 0.0f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 30; + + Weight = 70; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 70; + Description = "Fuse Powder. See FUSE."; + + State = ST_SOLID; + Properties = TYPE_PART; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_FSEP::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_FSEP static int update(UPDATE_FUNC_ARGS) +int Element_FSEP::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + if (parts[i].life<=0) { + r = sim->create_part(i, x, y, PT_PLSM); + if (r!=-1) + parts[r].life = 50; + return 1; + } else if (parts[i].life < 40) { + parts[i].life--; + if ((rand()%10)==0) { + r = sim->create_part(-1, (rx=x+rand()%3-1), (ry=y+rand()%3-1), PT_PLSM); + if (r!=-1) + parts[r].life = 50; + } + } + else { + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx=(273.15+400.0f))) && 1>(rand()%15)) + { + if (parts[i].life>40) { + parts[i].life = 39; + } + } + } + } + return 0; +} + + +Element_FSEP::~Element_FSEP() {} \ No newline at end of file diff --git a/src/simulation/elements/FUSE.cpp b/src/simulation/elements/FUSE.cpp new file mode 100644 index 000000000..e066afa05 --- /dev/null +++ b/src/simulation/elements/FUSE.cpp @@ -0,0 +1,92 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_FUSE PT_FUSE 70 +Element_FUSE::Element_FUSE() +{ + Identifier = "DEFAULT_PT_FUSE"; + Name = "FUSE"; + Colour = PIXPACK(0x0A5706); + MenuVisible = 1; + MenuSection = SC_SOLIDS; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.0f; + HotAir = 0.0f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 20; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 200; + Description = "Solid. Burns slowly. Ignites at somewhat high temperatures and electricity."; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_FUSE::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_FUSE static int update(UPDATE_FUNC_ARGS) +int Element_FUSE::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + if (parts[i].life<=0) { + r = sim->create_part(i, x, y, PT_PLSM); + if (r!=-1) + parts[r].life = 50; + return 1; + } else if (parts[i].life < 40) { + parts[i].life--; + if ((rand()%100)==0) { + r = sim->create_part(-1, (rx=x+rand()%3-1), (ry=y+rand()%3-1), PT_PLSM); + if (r!=-1) + parts[r].life = 50; + } + } + if ((sim->pv[y/CELL][x/CELL] > 2.7f)&&parts[i].tmp>40) + parts[i].tmp=39; + else if (parts[i].tmp<40&&parts[i].tmp>0) + parts[i].tmp--; + else if (parts[i].tmp<=0) { + sim->create_part(i, x, y, PT_FSEP); + return 1; + } + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx=(273.15+700.0f)) && 1>(rand()%20))) + { + if (parts[i].life>40) { + parts[i].life = 39; + } + } + } + return 0; +} + + +Element_FUSE::~Element_FUSE() {} \ No newline at end of file diff --git a/src/elements/fwrk.cpp b/src/simulation/elements/FWRK.cpp similarity index 51% rename from src/elements/fwrk.cpp rename to src/simulation/elements/FWRK.cpp index 64da2871d..6876447f0 100644 --- a/src/elements/fwrk.cpp +++ b/src/simulation/elements/FWRK.cpp @@ -1,6 +1,54 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_FWRK PT_FWRK 98 +Element_FWRK::Element_FWRK() +{ + Identifier = "DEFAULT_PT_FWRK"; + Name = "FWRK"; + Colour = PIXPACK(0x666666); + MenuVisible = 1; + MenuSection = SC_EXPLOSIVE; + Enabled = 1; + + Advection = 0.4f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.99f; + Loss = 0.95f; + Collision = 0.0f; + Gravity = 0.4f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 97; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 100; + Description = "First fireworks made, activated by heat/neutrons."; + + State = ST_SOLID; + Properties = TYPE_PART|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_FWRK::update; + Graphics = NULL; +} -int update_FWRK(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_FWRK static int update(UPDATE_FUNC_ARGS) +int Element_FWRK::update(UPDATE_FUNC_ARGS) + { int r, rx, ry, np; if ((parts[i].temp>400&&(9+parts[i].temp/40)>rand()%100000&&parts[i].life==0&&!pmap[y-1][x])||parts[i].ctype==PT_DUST) { @@ -51,3 +99,6 @@ int update_FWRK(UPDATE_FUNC_ARGS) { } return 0; } + + +Element_FWRK::~Element_FWRK() {} \ No newline at end of file diff --git a/src/simulation/elements/GAS.cpp b/src/simulation/elements/GAS.cpp new file mode 100644 index 000000000..3c406a9d4 --- /dev/null +++ b/src/simulation/elements/GAS.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_GAS PT_GAS 10 +Element_GAS::Element_GAS() +{ + Identifier = "DEFAULT_PT_GAS"; + Name = "GAS"; + Colour = PIXPACK(0xE0FF20); + MenuVisible = 1; + MenuSection = SC_GAS; + Enabled = 1; + + Advection = 1.0f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.99f; + Loss = 0.30f; + Collision = -0.1f; + Gravity = 0.0f; + Diffusion = 0.75f; + HotAir = 0.001f * CFDS; + Falldown = 0; + + Flammable = 600; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 1; + + Temperature = R_TEMP+2.0f +273.15f; + HeatConduct = 42; + Description = "Gas. Diffuses. Flammable. Liquefies under pressure."; + + State = ST_GAS; + Properties = TYPE_GAS; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = 6.0f; + HighPressureTransition = PT_OIL; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 573.0f; + HighTemperatureTransition = PT_FIRE; + + Update = NULL; + Graphics = NULL; +} + +Element_GAS::~Element_GAS() {} \ No newline at end of file diff --git a/src/simulation/elements/GBMB.cpp b/src/simulation/elements/GBMB.cpp new file mode 100644 index 000000000..827f062c9 --- /dev/null +++ b/src/simulation/elements/GBMB.cpp @@ -0,0 +1,93 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_GBMB PT_GBMB 157 +Element_GBMB::Element_GBMB() +{ + Identifier = "DEFAULT_PT_GBMB"; + Name = "GBMB"; + Colour = PIXPACK(0x1144BB); + MenuVisible = 1; + MenuSection = SC_EXPLOSIVE; + Enabled = 1; + + Advection = 0.6f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.98f; + Loss = 0.95f; + Collision = 0.0f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 20; + + Weight = 30; + + Temperature = R_TEMP-2.0f +273.15f; + HeatConduct = 29; + Description = "Sticks to first object it touches then produces strong gravity push."; + + State = ST_NONE; + Properties = TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_GBMB::update; + Graphics = &Element_GBMB::graphics; +} + +//#TPT-Directive ElementHeader Element_GBMB static int update(UPDATE_FUNC_ARGS) +int Element_GBMB::update(UPDATE_FUNC_ARGS) + { + int rx,ry,r; + if (parts[i].life<=0) + { + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + { + r = pmap[y+ry][x+rx]; + if(!r) + continue; + if((r&0xFF)!=PT_BOMB && (r&0xFF)!=PT_GBMB && + (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && + (r&0xFF)!=PT_DMND) + { + parts[i].life=60; + break; + } + } + } + if(parts[i].life>20) + sim->gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] = 20; + if(parts[i].life<20 && parts[i].life>=1) + sim->gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] = -80; + return 0; +} + + +//#TPT-Directive ElementHeader Element_GBMB static int graphics(GRAPHICS_FUNC_ARGS) +int Element_GBMB::graphics(GRAPHICS_FUNC_ARGS) + +{ + if (cpart->life <= 0) { + *pixel_mode |= PMODE_FLARE; + } + else + { + *pixel_mode |= PMODE_SPARK; + } + return 0; +} + + +Element_GBMB::~Element_GBMB() {} \ No newline at end of file diff --git a/src/simulation/elements/GEL.cpp b/src/simulation/elements/GEL.cpp new file mode 100644 index 000000000..2d3baeb0a --- /dev/null +++ b/src/simulation/elements/GEL.cpp @@ -0,0 +1,123 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_GEL PT_GEL 142 +Element_GEL::Element_GEL() +{ + Identifier = "DEFAULT_PT_GEL"; + Name = "GEL"; + Colour = PIXPACK(0xFF9900); + MenuVisible = 1; + MenuSection = SC_LIQUID; + Enabled = 1; + + Advection = 0.6f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.98f; + Loss = 0.95f; + Collision = 0.0f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 2; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 20; + + Weight = 35; + + Temperature = R_TEMP-2.0f +273.15f; + HeatConduct = 29; + Description = "Gel. A liquid with variable viscosity and heat conductivity"; + + State = ST_LIQUID; + Properties = TYPE_LIQUID|PROP_LIFE_DEC|PROP_NEUTPENETRATE; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_GEL::update; + Graphics = &Element_GEL::graphics; +} + +//#TPT-Directive ElementHeader Element_GEL static int update(UPDATE_FUNC_ARGS) +int Element_GEL::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rxkill_part(r>>8); + } + + char gel = 0; + if ((r&0xFF)==PT_GEL) + gel = 1; + + //Concentration diffusion + if (gel && (parts[r>>8].tmp+1)>8].tmp++; + parts[i].tmp--; + } + + if ((r&0xFF)==PT_SPNG && (parts[r>>8].life+1)>8].life++; + parts[i].tmp--; + } + + float dx, dy; + dx = parts[i].x - parts[r>>8].x; + dy = parts[i].y - parts[r>>8].y; + + //Stickness + if ((dx*dx + dy*dy)>1.5 && (gel || !sim->elements[r&0xFF].Falldown || (fabs(rx)<2 && fabs(ry)<2))) + { + float per, nd; + nd = dx*dx + dy*dy - 0.5; + + per = 5*(1 - parts[i].tmp/100)*(nd/(dx*dx + dy*dy + nd) - 0.5); + if (sim->elements[r&0xFF].State==ST_LIQUID) + per *= 0.1; + + dx *= per; dy *= per; + parts[i].vx += dx; parts[r>>8].vx -= dx; + parts[i].vy += dy; parts[r>>8].vy -= dy; + } + } + return 0; +} + + + +//#TPT-Directive ElementHeader Element_GEL static int graphics(GRAPHICS_FUNC_ARGS) +int Element_GEL::graphics(GRAPHICS_FUNC_ARGS) + +{ + int q = cpart->tmp; + *colr = q*(32-255)/120+255; + *colg = q*(48-186)/120+186; + *colb = q*208/120; + return 0; +} + + + +Element_GEL::~Element_GEL() {} \ No newline at end of file diff --git a/src/simulation/elements/GLAS.cpp b/src/simulation/elements/GLAS.cpp new file mode 100644 index 000000000..58fc55dce --- /dev/null +++ b/src/simulation/elements/GLAS.cpp @@ -0,0 +1,62 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_GLAS PT_GLAS 45 +Element_GLAS::Element_GLAS() +{ + Identifier = "DEFAULT_PT_GLAS"; + Name = "GLAS"; + Colour = PIXPACK(0x404040); + MenuVisible = 1; + MenuSection = SC_SOLIDS; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 150; + Description = "Solid. Meltable. Shatters under pressure"; + + State = ST_SOLID; + Properties = TYPE_SOLID | PROP_NEUTPASS | PROP_HOT_GLOW | PROP_SPARKSETTLE; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 1973.0f; + HighTemperatureTransition = PT_LAVA; + + Update = &Element_GLAS::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_GLAS static int update(UPDATE_FUNC_ARGS) +int Element_GLAS::update(UPDATE_FUNC_ARGS) + { + parts[i].pavg[0] = parts[i].pavg[1]; + parts[i].pavg[1] = sim->pv[y/CELL][x/CELL]; + if (parts[i].pavg[1]-parts[i].pavg[0] > 0.25f || parts[i].pavg[1]-parts[i].pavg[0] < -0.25f) + { + sim->part_change_type(i,x,y,PT_BGLA); + } + return 0; +} + + +Element_GLAS::~Element_GLAS() {} \ No newline at end of file diff --git a/src/simulation/elements/GLOW.cpp b/src/simulation/elements/GLOW.cpp new file mode 100644 index 000000000..775e1881e --- /dev/null +++ b/src/simulation/elements/GLOW.cpp @@ -0,0 +1,96 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_GLOW PT_GLOW 66 +Element_GLOW::Element_GLOW() +{ + Identifier = "DEFAULT_PT_GLOW"; + Name = "GLOW"; + Colour = PIXPACK(0x445464); + MenuVisible = 1; + MenuSection = SC_LIQUID; + Enabled = 1; + + Advection = 0.3f; + AirDrag = 0.02f * CFDS; + AirLoss = 0.98f; + Loss = 0.80f; + Collision = 0.0f; + Gravity = 0.15f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 2; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 2; + + Weight = 40; + + Temperature = R_TEMP+20.0f+273.15f; + HeatConduct = 44; + Description = "Glow, Glows under pressure"; + + State = ST_LIQUID; + Properties = TYPE_LIQUID|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_GLOW::update; + Graphics = &Element_GLOW::graphics; +} + +//#TPT-Directive ElementHeader Element_GLOW static int update(UPDATE_FUNC_ARGS) +int Element_GLOW::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx(rand()%2000)) + { + parts[i].type = PT_NONE; + sim->part_change_type(r>>8,x+rx,y+ry,PT_DEUT); + parts[r>>8].life = 10; + } + } + parts[i].ctype = sim->pv[y/CELL][x/CELL]*16; + + parts[i].tmp = abs((int)((sim->vx[y/CELL][x/CELL]+sim->vy[y/CELL][x/CELL])*16.0f)) + abs((int)((parts[i].vx+parts[i].vy)*64.0f)); + //printf("%f %f\n", parts[i].vx, parts[i].vy); + if (parts[i].type==PT_NONE) { + sim->kill_part(i); + return 1; + } + return 0; +} + + +//#TPT-Directive ElementHeader Element_GLOW static int graphics(GRAPHICS_FUNC_ARGS) +int Element_GLOW::graphics(GRAPHICS_FUNC_ARGS) + +{ + *firer = restrict_flt(cpart->temp-(275.13f+32.0f), 0, 128)/50.0f; + *fireg = restrict_flt(cpart->ctype, 0, 128)/50.0f; + *fireb = restrict_flt(cpart->tmp, 0, 128)/50.0f; + + *colr = restrict_flt(64.0f+cpart->temp-(275.13f+32.0f), 0, 255); + *colg = restrict_flt(64.0f+cpart->ctype, 0, 255); + *colb = restrict_flt(64.0f+cpart->tmp, 0, 255); + + *pixel_mode |= FIRE_ADD; + return 0; +} + + +Element_GLOW::~Element_GLOW() {} \ No newline at end of file diff --git a/src/simulation/elements/GOO.cpp b/src/simulation/elements/GOO.cpp new file mode 100644 index 000000000..c0ea21be6 --- /dev/null +++ b/src/simulation/elements/GOO.cpp @@ -0,0 +1,64 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_GOO PT_GOO 12 +Element_GOO::Element_GOO() +{ + Identifier = "DEFAULT_PT_GOO"; + Name = "GOO"; + Colour = PIXPACK(0x804000); + MenuVisible = 1; + MenuSection = SC_SOLIDS; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.97f; + Loss = 0.50f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 12; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 75; + Description = "Solid. Deforms and disappears under pressure."; + + State = ST_SOLID; + Properties = TYPE_SOLID | PROP_NEUTPENETRATE|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_GOO::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_GOO static int update(UPDATE_FUNC_ARGS) +int Element_GOO::update(UPDATE_FUNC_ARGS) + { + if (!parts[i].life && sim->pv[y/CELL][x/CELL]>1.0f) + parts[i].life = rand()%80+300; + if (parts[i].life) + { + float advection = 0.1f; + parts[i].vx += advection*sim->vx[y/CELL][x/CELL]; + parts[i].vy += advection*sim->vy[y/CELL][x/CELL]; + } + return 0; +} + + +Element_GOO::~Element_GOO() {} \ No newline at end of file diff --git a/src/simulation/elements/GPMP.cpp b/src/simulation/elements/GPMP.cpp new file mode 100644 index 000000000..d36579ca5 --- /dev/null +++ b/src/simulation/elements/GPMP.cpp @@ -0,0 +1,96 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_GPMP PT_GPMP 154 +Element_GPMP::Element_GPMP() +{ + Identifier = "DEFAULT_PT_GPMP"; + Name = "GPMP"; + Colour = PIXPACK(0x0A3B3B); + MenuVisible = 1; + MenuSection = SC_POWERED; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 1; + + Weight = 100; + + Temperature = 0.0f +273.15f; + HeatConduct = 0; + Description = "Changes gravity to its temp when activated. (use HEAT/COOL)."; + + State = ST_NONE; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_GPMP::update; + Graphics = &Element_GPMP::graphics; +} + +//#TPT-Directive ElementHeader Element_GPMP static int update(UPDATE_FUNC_ARGS) +int Element_GPMP::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + if (parts[i].life>0 && parts[i].life!=10) + parts[i].life--; + if (parts[i].life==10) + { + if (parts[i].temp>=256.0+273.15) + parts[i].temp=256.0+273.15; + if (parts[i].temp<= -256.0+273.15) + parts[i].temp = -256.0+273.15; + + sim->gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] = 0.2f*(parts[i].temp-273.15); + if (y+CELLpv[y/CELL+1][x/CELL]<(parts[i].temp-273.15)) + sim->gravmap[(y/CELL+1)*(XRES/CELL)+(x/CELL)] += 0.1f*((parts[i].temp-273.15)-sim->gravmap[(y/CELL+1)*(XRES/CELL)+(x/CELL)]); + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8].life<10&&parts[r>>8].life>0) + parts[i].life = 9; + else if (parts[r>>8].life==0) + parts[r>>8].life = 10; + } + } + } + return 0; +} + + +//#TPT-Directive ElementHeader Element_GPMP static int graphics(GRAPHICS_FUNC_ARGS) +int Element_GPMP::graphics(GRAPHICS_FUNC_ARGS) + +{ + int lifemod = ((cpart->life>10?10:cpart->life)*19); + *colg += lifemod; + *colb += lifemod; + return 0; +} + + +Element_GPMP::~Element_GPMP() {} \ No newline at end of file diff --git a/src/simulation/elements/GRAV.cpp b/src/simulation/elements/GRAV.cpp new file mode 100644 index 000000000..ea8ff4deb --- /dev/null +++ b/src/simulation/elements/GRAV.cpp @@ -0,0 +1,101 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_GRAV PT_GRAV 102 +Element_GRAV::Element_GRAV() +{ + Identifier = "DEFAULT_PT_GRAV"; + Name = "GRAV"; + Colour = PIXPACK(0xFFE0A0); + MenuVisible = 1; + MenuSection = SC_POWDERS; + Enabled = 1; + + Advection = 0.7f; + AirDrag = 0.00f * CFDS; + AirLoss = 1.00f; + Loss = 1.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 10; + Explosive = 0; + Meltable = 0; + Hardness = 30; + + Weight = 85; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 70; + Description = "Very light dust. Changes colour based on velocity."; + + State = ST_SOLID; + Properties = TYPE_PART; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_GRAV::update; + Graphics = &Element_GRAV::graphics; +} + +//#TPT-Directive ElementHeader Element_GRAV static int update(UPDATE_FUNC_ARGS) +int Element_GRAV::update(UPDATE_FUNC_ARGS) + { + /*int t = parts[i].type; + if (t==PT_LOVE) + ISLOVE=1; + else if (t==PT_LOLZ) + ISLOLZ=1; + else if (t==PT_GRAV) + ISGRAV=1;*/ + return 0; +} + + +//#TPT-Directive ElementHeader Element_GRAV static int graphics(GRAPHICS_FUNC_ARGS) +int Element_GRAV::graphics(GRAPHICS_FUNC_ARGS) + +{ + int GRAV_R, GRAV_B, GRAV_G, GRAV_R2, GRAV_B2, GRAV_G2; + *colr = 20; + *colg = 20; + *colb = 20; + if (cpart->vx>0) + { + *colr += (cpart->vx)*GRAV_R; + *colg += (cpart->vx)*GRAV_G; + *colb += (cpart->vx)*GRAV_B; + } + if (cpart->vy>0) + { + *colr += (cpart->vy)*GRAV_G; + *colg += (cpart->vy)*GRAV_B; + *colb += (cpart->vy)*GRAV_R; + + } + if (cpart->vx<0) + { + *colr -= (cpart->vx)*GRAV_B; + *colg -= (cpart->vx)*GRAV_R; + *colb -= (cpart->vx)*GRAV_G; + + } + if (cpart->vy<0) + { + *colr -= (cpart->vy)*GRAV_R2; + *colg -= (cpart->vy)*GRAV_G2; + *colb -= (cpart->vy)*GRAV_B2; + } + return 0; +} + + +Element_GRAV::~Element_GRAV() {} \ No newline at end of file diff --git a/src/simulation/elements/GUNP.cpp b/src/simulation/elements/GUNP.cpp new file mode 100644 index 000000000..fd5334c7f --- /dev/null +++ b/src/simulation/elements/GUNP.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_GUNP PT_GUNP 7 +Element_GUNP::Element_GUNP() +{ + Identifier = "DEFAULT_PT_GUNP"; + Name = "GUN"; + Colour = PIXPACK(0xC0C0D0); + MenuVisible = 1; + MenuSection = SC_EXPLOSIVE; + Enabled = 1; + + Advection = 0.7f; + AirDrag = 0.02f * CFDS; + AirLoss = 0.94f; + Loss = 0.80f; + Collision = -0.1f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 600; + Explosive = 1; + Meltable = 0; + Hardness = 10; + + Weight = 85; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 97; + Description = "Light dust. Explosive."; + + State = ST_SOLID; + Properties = TYPE_PART; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 673.0f; + HighTemperatureTransition = PT_FIRE; + + Update = NULL; + Graphics = NULL; +} + +Element_GUNP::~Element_GUNP() {} \ No newline at end of file diff --git a/src/elements/h2.cpp b/src/simulation/elements/H2.cpp similarity index 60% rename from src/elements/h2.cpp rename to src/simulation/elements/H2.cpp index fc2e6c894..a75fd13e0 100644 --- a/src/elements/h2.cpp +++ b/src/simulation/elements/H2.cpp @@ -1,6 +1,54 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_H2 PT_H2 148 +Element_H2::Element_H2() +{ + Identifier = "DEFAULT_PT_H2"; + Name = "HYGN"; + Colour = PIXPACK(0x5070FF); + MenuVisible = 1; + MenuSection = SC_GAS; + Enabled = 1; + + Advection = 2.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.99f; + Loss = 0.30f; + Collision = -0.10f; + Gravity = 0.00f; + Diffusion = 3.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 1; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Combines with O2 to make WATR"; + + State = ST_GAS; + Properties = TYPE_GAS; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_H2::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_H2 static int update(UPDATE_FUNC_ARGS) +int Element_H2::update(UPDATE_FUNC_ARGS) -int update_H2(UPDATE_FUNC_ARGS) { int r,rx,ry,rt; if (parts[i].temp > 2273.15 && sim->pv[y/CELL][x/CELL] > 50.0f) @@ -65,3 +113,6 @@ int update_H2(UPDATE_FUNC_ARGS) } return 0; } + + +Element_H2::~Element_H2() {} \ No newline at end of file diff --git a/src/simulation/elements/HFLM.cpp b/src/simulation/elements/HFLM.cpp new file mode 100644 index 000000000..dcd9f9a23 --- /dev/null +++ b/src/simulation/elements/HFLM.cpp @@ -0,0 +1,70 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_HFLM PT_HFLM 68 +Element_HFLM::Element_HFLM() +{ + Identifier = "DEFAULT_PT_HFLM"; + Name = "CFLM"; + Colour = PIXPACK(0x8080FF); + MenuVisible = 1; + MenuSection = SC_EXPLOSIVE; + Enabled = 1; + + Advection = 0.9f; + AirDrag = 0.04f * CFDS; + AirLoss = 0.97f; + Loss = 0.20f; + Collision = 0.0f; + Gravity = -0.1f; + Diffusion = 0.00f; + HotAir = 0.0005f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 2; + + Temperature = 0.0f; + HeatConduct = 88; + Description = "Sub-zero flame."; + + State = ST_LIQUID; + Properties = TYPE_GAS|PROP_LIFE_DEC|PROP_LIFE_KILL; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = NULL; + Graphics = &Element_HFLM::graphics; +} + +//#TPT-Directive ElementHeader Element_HFLM static int graphics(GRAPHICS_FUNC_ARGS) +int Element_HFLM::graphics(GRAPHICS_FUNC_ARGS) + +{ + int caddress = restrict_flt(restrict_flt((float)((int)(cpart->life/2)), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); + *colr = 0;//(unsigned char)hflm_data[caddress]; + *colg = 0;//(unsigned char)hflm_data[caddress+1]; + *colb = 0;//(unsigned char)hflm_data[caddress+2]; + + *firea = 255; + *firer = *colr; + *fireg = *colg; + *fireb = *colb; + + *pixel_mode = PMODE_NONE; //Clear default, don't draw pixel + *pixel_mode |= FIRE_ADD; + //Returning 0 means dynamic, do not cache + return 0; +} + + +Element_HFLM::~Element_HFLM() {} \ No newline at end of file diff --git a/src/simulation/elements/HSWC.cpp b/src/simulation/elements/HSWC.cpp new file mode 100644 index 000000000..1b0091485 --- /dev/null +++ b/src/simulation/elements/HSWC.cpp @@ -0,0 +1,87 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_HSWC PT_HSWC 75 +Element_HSWC::Element_HSWC() +{ + Identifier = "DEFAULT_PT_HSWC"; + Name = "HSWC"; + Colour = PIXPACK(0x3B0A0A); + MenuVisible = 1; + MenuSection = SC_POWERED; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Heat switch. Conducts Heat only when activated"; + + State = ST_NONE; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_HSWC::update; + Graphics = &Element_HSWC::graphics; +} + +//#TPT-Directive ElementHeader Element_HSWC static int update(UPDATE_FUNC_ARGS) +int Element_HSWC::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + if (parts[i].life>0 && parts[i].life!=10) + parts[i].life--; + if (parts[i].life==10) + { + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8].life<10&&parts[r>>8].life>0) + parts[i].life = 9; + else if (parts[r>>8].life==0) + parts[r>>8].life = 10; + } + } + } + return 0; +} + + +//#TPT-Directive ElementHeader Element_HSWC static int graphics(GRAPHICS_FUNC_ARGS) +int Element_HSWC::graphics(GRAPHICS_FUNC_ARGS) + +{ + int lifemod = ((cpart->life>10?10:cpart->life)*19); + *colr += lifemod; + return 0; +} + + +Element_HSWC::~Element_HSWC() {} \ No newline at end of file diff --git a/src/simulation/elements/ICEI.cpp b/src/simulation/elements/ICEI.cpp new file mode 100644 index 000000000..7352d6083 --- /dev/null +++ b/src/simulation/elements/ICEI.cpp @@ -0,0 +1,74 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_ICEI PT_ICEI 13 +Element_ICEI::Element_ICEI() +{ + Identifier = "DEFAULT_PT_ICEI"; + Name = "ICE"; + Colour = PIXPACK(0xA0C0FF); + MenuVisible = 1; + MenuSection = SC_SOLIDS; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = -0.0003f* CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 20; + + Weight = 100; + + Temperature = R_TEMP-50.0f+273.15f; + HeatConduct = 46; + Description = "Solid. Freezes water. Crushes under pressure. Cools down air."; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = 0.8f; + HighPressureTransition = PT_SNOW; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 233.0f; + HighTemperatureTransition = ST; + + Update = &Element_ICEI::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_ICEI static int update(UPDATE_FUNC_ARGS) +int Element_ICEI::update(UPDATE_FUNC_ARGS) + { //currently used for snow as well + int r, rx, ry; + if (parts[i].ctype==PT_FRZW)//get colder if it is from FRZW + { + parts[i].temp = restrict_flt(parts[i].temp-1.0f, MIN_TEMP, MAX_TEMP); + } + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx(rand()%1000)) + { + sim->part_change_type(i,x,y,PT_SLTW); + sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW); + } + } + return 0; +} + + +Element_ICEI::~Element_ICEI() {} \ No newline at end of file diff --git a/src/simulation/elements/IGNT.cpp b/src/simulation/elements/IGNT.cpp new file mode 100644 index 000000000..8e2af19e6 --- /dev/null +++ b/src/simulation/elements/IGNT.cpp @@ -0,0 +1,95 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_IGNT PT_IGNT 140 +Element_IGNT::Element_IGNT() +{ + Identifier = "DEFAULT_PT_IGNT"; + Name = "IGNC"; + Colour = PIXPACK(0xC0B050); + MenuVisible = 1; + MenuSection = SC_EXPLOSIVE; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 88; + Description = "Ignition cord."; + + State = ST_SOLID; + Properties = TYPE_SOLID | PROP_NEUTPENETRATE | PROP_SPARKSETTLE | PROP_LIFE_KILL; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 673.0f; + HighTemperatureTransition = PT_FIRE; + + Update = &Element_IGNT::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_IGNT static int update(UPDATE_FUNC_ARGS) +int Element_IGNT::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + if(parts[i].tmp==0) + { + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8].life==1)) + { + parts[i].tmp = 1; + } + } + } + else if(parts[i].life > 0) + { + if(rand()%3) + { + int nb = sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_BOMB); + if (nb!=-1) { + parts[nb].tmp = 1; + parts[nb].life = 30; + parts[nb].vx = rand()%20-10; + parts[nb].vy = rand()%20-10; + parts[nb].temp = restrict_flt(400.0f+parts[i].temp-273.15, MIN_TEMP, MAX_TEMP); + } + } + else + { + sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_FIRE); + } + parts[i].life--; + } + return 0; +} + + +Element_IGNT::~Element_IGNT() {} \ No newline at end of file diff --git a/src/simulation/elements/INSL.cpp b/src/simulation/elements/INSL.cpp new file mode 100644 index 000000000..a7d1ce110 --- /dev/null +++ b/src/simulation/elements/INSL.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_INSL PT_INSL 38 +Element_INSL::Element_INSL() +{ + Identifier = "DEFAULT_PT_INSL"; + Name = "INSL"; + Colour = PIXPACK(0x9EA3B6); + MenuVisible = 1; + MenuSection = SC_SPECIAL; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.95f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 7; + Explosive = 0; + Meltable = 0; + Hardness = 10; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 0; + Description = "Insulator, does not conduct heat or electricity."; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = NULL; + Graphics = NULL; +} + +Element_INSL::~Element_INSL() {} \ No newline at end of file diff --git a/src/simulation/elements/INST.cpp b/src/simulation/elements/INST.cpp new file mode 100644 index 000000000..78990ef00 --- /dev/null +++ b/src/simulation/elements/INST.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_INST PT_INST 106 +Element_INST::Element_INST() +{ + Identifier = "DEFAULT_PT_INST"; + Name = "INST"; + Colour = PIXPACK(0x404039); + MenuVisible = 1; + MenuSection = SC_ELEC; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Instantly conducts, PSCN to charge, NSCN to take."; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = NULL; + Graphics = NULL; +} + +Element_INST::~Element_INST() {} \ No newline at end of file diff --git a/src/simulation/elements/INVIS.cpp b/src/simulation/elements/INVIS.cpp new file mode 100644 index 000000000..b14f8b6cf --- /dev/null +++ b/src/simulation/elements/INVIS.cpp @@ -0,0 +1,67 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_INVIS PT_INVIS 115 +Element_INVIS::Element_INVIS() +{ + Identifier = "DEFAULT_PT_INVIS"; + Name = "INVS"; + Colour = PIXPACK(0x00CCCC); + MenuVisible = 1; + MenuSection = SC_SOLIDS; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 15; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 164; + Description = "Invisible to everything while under pressure."; + + State = ST_SOLID; + Properties = TYPE_SOLID | PROP_NEUTPASS; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = NULL; + Graphics = &Element_INVIS::graphics; +} + +//#TPT-Directive ElementHeader Element_INVIS static int graphics(GRAPHICS_FUNC_ARGS) +int Element_INVIS::graphics(GRAPHICS_FUNC_ARGS) + +{ + //pv[ny/CELL][nx/CELL]>4.0f || pv[ny/CELL][nx/CELL]<-4.0f + if(cpart->tmp) + { + *cola = 100; + *colr = 15; + *colg = 0; + *colb = 150; + *pixel_mode &= PMODE; + *pixel_mode |= PMODE_BLEND; + } + return 0; +} + + +Element_INVIS::~Element_INVIS() {} \ No newline at end of file diff --git a/src/simulation/elements/INWR.cpp b/src/simulation/elements/INWR.cpp new file mode 100644 index 000000000..0368f06ee --- /dev/null +++ b/src/simulation/elements/INWR.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_INWR PT_INWR 62 +Element_INWR::Element_INWR() +{ + Identifier = "DEFAULT_PT_INWR"; + Name = "INWR"; + Colour = PIXPACK(0x544141); + MenuVisible = 1; + MenuSection = SC_ELEC; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Insulated Wire. Doesn't conduct to metal or semiconductors."; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 1687.0f; + HighTemperatureTransition = PT_LAVA; + + Update = NULL; + Graphics = NULL; +} + +Element_INWR::~Element_INWR() {} \ No newline at end of file diff --git a/src/simulation/elements/IRON.cpp b/src/simulation/elements/IRON.cpp new file mode 100644 index 000000000..a447a299c --- /dev/null +++ b/src/simulation/elements/IRON.cpp @@ -0,0 +1,76 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_IRON PT_IRON 76 +Element_IRON::Element_IRON() +{ + Identifier = "DEFAULT_PT_IRON"; + Name = "IRON"; + Colour = PIXPACK(0x707070); + MenuVisible = 1; + MenuSection = SC_SOLIDS; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 50; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Rusts with salt, can be used for electrolysis of WATR"; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 1687.0f; + HighTemperatureTransition = PT_LAVA; + + Update = &Element_IRON::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_IRON static int update(UPDATE_FUNC_ARGS) +int Element_IRON::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx(rand()/(RAND_MAX/700))) || + ((r&0xFF) == PT_SLTW && 30>(rand()/(RAND_MAX/2000))) || + ((r&0xFF) == PT_WATR && 5 >(rand()/(RAND_MAX/6000))) || + ((r&0xFF) == PT_O2 && 2 >(rand()/(RAND_MAX/500))) || + ((r&0xFF) == PT_LO2))&& + (!(parts[i].life)) + ) + { + sim->part_change_type(i,x,y,PT_BMTL); + parts[i].tmp=(rand()/(RAND_MAX/10))+20; + } + } + return 0; +} + + +Element_IRON::~Element_IRON() {} \ No newline at end of file diff --git a/src/simulation/elements/ISOZ.cpp b/src/simulation/elements/ISOZ.cpp new file mode 100644 index 000000000..f98cb2548 --- /dev/null +++ b/src/simulation/elements/ISOZ.cpp @@ -0,0 +1,65 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_ISOZ PT_ISOZ 107 +Element_ISOZ::Element_ISOZ() +{ + Identifier = "DEFAULT_PT_ISOZ"; + Name = "ISOZ"; + Colour = PIXPACK(0xAA30D0); + MenuVisible = 1; + MenuSection = SC_NUCLEAR; + Enabled = 1; + + Advection = 0.6f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.98f; + Loss = 0.95f; + Collision = 0.0f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 2; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 24; + + Temperature = R_TEMP-2.0f +273.15f; + HeatConduct = 29; + Description = "Radioactive liquid"; + + State = ST_LIQUID; + Properties = TYPE_LIQUID|PROP_NEUTPENETRATE; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = 160.0f; + LowTemperatureTransition = PT_ISZS; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_ISOZ::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_ISOZ static int update(UPDATE_FUNC_ARGS) +int Element_ISOZ::update(UPDATE_FUNC_ARGS) + { // for both ISZS and ISOZ + float rr, rrr; + if (1>rand()%200 && ((int)(-4.0f*(sim->pv[y/CELL][x/CELL])))>(rand()%1000)) + { + sim->create_part(i, x, y, PT_PHOT); + rr = (rand()%228+128)/127.0f; + rrr = (rand()%360)*3.14159f/180.0f; + parts[i].vx = rr*cosf(rrr); + parts[i].vy = rr*sinf(rrr); + } + return 0; +} + + +Element_ISOZ::~Element_ISOZ() {} \ No newline at end of file diff --git a/src/simulation/elements/ISZS.cpp b/src/simulation/elements/ISZS.cpp new file mode 100644 index 000000000..650ef1b82 --- /dev/null +++ b/src/simulation/elements/ISZS.cpp @@ -0,0 +1,65 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_ISZS PT_ISZS 108 +Element_ISZS::Element_ISZS() +{ + Identifier = "DEFAULT_PT_ISZS"; + Name = "ISZS"; + Colour = PIXPACK(0x662089); + MenuVisible = 1; + MenuSection = SC_NUCLEAR; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = -0.0007f* CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 1; + + Weight = 100; + + Temperature = 140.00f; + HeatConduct = 251; + Description = "Solid form of ISOZ, slowly decays."; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 300.0f; + HighTemperatureTransition = PT_ISOZ; + + Update = &Element_ISZS::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_ISZS static int update(UPDATE_FUNC_ARGS) +int Element_ISZS::update(UPDATE_FUNC_ARGS) + { // for both ISZS and ISOZ + float rr, rrr; + if (1>rand()%200 && ((int)(-4.0f*(sim->pv[y/CELL][x/CELL])))>(rand()%1000)) + { + sim->create_part(i, x, y, PT_PHOT); + rr = (rand()%228+128)/127.0f; + rrr = (rand()%360)*3.14159f/180.0f; + parts[i].vx = rr*cosf(rrr); + parts[i].vy = rr*sinf(rrr); + } + return 0; +} + + +Element_ISZS::~Element_ISZS() {} \ No newline at end of file diff --git a/src/simulation/elements/LAVA.cpp b/src/simulation/elements/LAVA.cpp new file mode 100644 index 000000000..35eefecaf --- /dev/null +++ b/src/simulation/elements/LAVA.cpp @@ -0,0 +1,71 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_LAVA PT_LAVA 6 +Element_LAVA::Element_LAVA() +{ + Identifier = "DEFAULT_PT_LAVA"; + Name = "LAVA"; + Colour = PIXPACK(0xE05010); + MenuVisible = 1; + MenuSection = SC_LIQUID; + Enabled = 1; + + Advection = 0.3f; + AirDrag = 0.02f * CFDS; + AirLoss = 0.95f; + Loss = 0.80f; + Collision = 0.0f; + Gravity = 0.15f; + Diffusion = 0.00f; + HotAir = 0.0003f * CFDS; + Falldown = 2; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 2; + + Weight = 45; + + Temperature = R_TEMP+1500.0f+273.15f; + HeatConduct = 60; + Description = "Heavy liquid. Ignites flammable materials. Solidifies when cold."; + + State = ST_LIQUID; + Properties = TYPE_LIQUID|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = 2573.15f; + LowTemperatureTransition = ST; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_FIRE::update; + Graphics = &Element_LAVA::graphics; +} + + +//#TPT-Directive ElementHeader Element_LAVA static int graphics(GRAPHICS_FUNC_ARGS) +int Element_LAVA::graphics(GRAPHICS_FUNC_ARGS) + +{ + *colr = cpart->life * 2 + 0xE0; + *colg = cpart->life * 1 + 0x50; + *colb = cpart->life / 2 + 0x10; + if (*colr>255) *colr = 255; + if (*colg>192) *colg = 192; + if (*colb>128) *colb = 128; + *firea = 40; + *firer = *colr; + *fireg = *colg; + *fireb = *colb; + *pixel_mode |= FIRE_ADD; + *pixel_mode |= PMODE_BLUR; + //Returning 0 means dynamic, do not cache + return 0; +} + + +Element_LAVA::~Element_LAVA() {} \ No newline at end of file diff --git a/src/simulation/elements/LCRY.cpp b/src/simulation/elements/LCRY.cpp new file mode 100644 index 000000000..e06feec46 --- /dev/null +++ b/src/simulation/elements/LCRY.cpp @@ -0,0 +1,154 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_LCRY PT_LCRY 54 +Element_LCRY::Element_LCRY() +{ + Identifier = "DEFAULT_PT_LCRY"; + Name = "LCRY"; + Colour = PIXPACK(0x505050); + MenuVisible = 1; + MenuSection = SC_POWERED; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Liquid Crystal. Changes colour when charged. (PSCN Charges, NSCN Discharges)"; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 1273.0f; + HighTemperatureTransition = PT_BGLA; + + Update = &Element_LCRY::update; + Graphics = &Element_LCRY::graphics; +} + +//#TPT-Directive ElementHeader Element_LCRY static int update(UPDATE_FUNC_ARGS) +int Element_LCRY::update(UPDATE_FUNC_ARGS) + +{ + int r, rx, ry; + if(parts[i].tmp==1 || parts[i].tmp==0) + { + if(parts[i].tmp==1) + { + if(parts[i].life<=0) + parts[i].tmp = 0; + else + { + parts[i].life-=2; + if(parts[i].life < 0) + parts[i].life = 0; + parts[i].tmp2 = parts[i].life; + } + } + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8].tmp == 3) + { + parts[r>>8].tmp = 1; + } + } + } + else if(parts[i].tmp==2 || parts[i].tmp==3) + { + if(parts[i].tmp==2) + { + if(parts[i].life>=10) + parts[i].tmp = 3; + else + { + parts[i].life+=2; + if(parts[i].life > 10) + parts[i].life = 10; + parts[i].tmp2 = parts[i].life; + } + } + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8].tmp == 0) + { + parts[r>>8].tmp = 2; + } + } + } + return 0; +} + + +//#TPT-Directive ElementHeader Element_LCRY static int graphics(GRAPHICS_FUNC_ARGS) +int Element_LCRY::graphics(GRAPHICS_FUNC_ARGS) + +{ + if(ren->decorations_enable && cpart->dcolour && (cpart->dcolour&0xFF000000)) + { + *colr = (cpart->dcolour>>16)&0xFF; + *colg = (cpart->dcolour>>8)&0xFF; + *colb = (cpart->dcolour)&0xFF; + + if(cpart->tmp2<10){ + *colr /= 10-cpart->tmp2; + *colg /= 10-cpart->tmp2; + *colb /= 10-cpart->tmp2; + } + + } + else + { + *colr = *colg = *colb = 0x50+((cpart->tmp2>10?10:cpart->tmp2)*10); + } + *pixel_mode |= NO_DECO; + return 0; + + /*int lifemod = ((cpart->tmp2>10?10:cpart->tmp2)*10); + *colr += lifemod; + *colg += lifemod; + *colb += lifemod; + if(decorations_enable && cpart->dcolour && cpart->dcolour&0xFF000000) + { + lifemod *= 2.5f; + if(lifemod < 40) + lifemod = 40; + *colr = (lifemod*((cpart->dcolour>>16)&0xFF) + (255-lifemod)**colr) >> 8; + *colg = (lifemod*((cpart->dcolour>>8)&0xFF) + (255-lifemod)**colg) >> 8; + *colb = (lifemod*((cpart->dcolour)&0xFF) + (255-lifemod)**colb) >> 8; + } + *pixel_mode |= NO_DECO; + return 0;*/ +} + + +Element_LCRY::~Element_LCRY() {} \ No newline at end of file diff --git a/src/simulation/elements/LIFE.cpp b/src/simulation/elements/LIFE.cpp new file mode 100644 index 000000000..84cec6720 --- /dev/null +++ b/src/simulation/elements/LIFE.cpp @@ -0,0 +1,106 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_LIFE PT_LIFE 78 +Element_LIFE::Element_LIFE() +{ + Identifier = "DEFAULT_PT_LIFE"; + Name = "LIFE"; + Colour = PIXPACK(0x0CAC00); + MenuVisible = 0; + MenuSection = SC_LIFE; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 100; + + Temperature = 9000.0f; + HeatConduct = 40; + Description = "Game Of Life! B3/S23"; + + State = ST_NONE; + Properties = TYPE_SOLID|PROP_LIFE; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = NULL; + Graphics = &Element_LIFE::graphics; +} + +//#TPT-Directive ElementHeader Element_LIFE static int graphics(GRAPHICS_FUNC_ARGS) +int Element_LIFE::graphics(GRAPHICS_FUNC_ARGS) + +{ + pixel pc; + if (cpart->ctype==NGT_LOTE)//colors for life states + { + if (cpart->tmp==2) + pc = PIXRGB(255, 128, 0); + else if (cpart->tmp==1) + pc = PIXRGB(255, 255, 0); + else + pc = PIXRGB(255, 0, 0); + } + else if (cpart->ctype==NGT_FRG2)//colors for life states + { + if (cpart->tmp==2) + pc = PIXRGB(0, 100, 50); + else + pc = PIXRGB(0, 255, 90); + } + else if (cpart->ctype==NGT_STAR)//colors for life states + { + if (cpart->tmp==4) + pc = PIXRGB(0, 0, 128); + else if (cpart->tmp==3) + pc = PIXRGB(0, 0, 150); + else if (cpart->tmp==2) + pc = PIXRGB(0, 0, 190); + else if (cpart->tmp==1) + pc = PIXRGB(0, 0, 230); + else + pc = PIXRGB(0, 0, 70); + } + else if (cpart->ctype==NGT_FROG)//colors for life states + { + if (cpart->tmp==2) + pc = PIXRGB(0, 100, 0); + else + pc = PIXRGB(0, 255, 0); + } + else if (cpart->ctype==NGT_BRAN)//colors for life states + { + if (cpart->tmp==1) + pc = PIXRGB(150, 150, 0); + else + pc = PIXRGB(255, 255, 0); + } else { + pc = PIXRGB(255, 255, 0);//sim->gmenu[cpart->ctype].colour; + } + *colr = PIXR(pc); + *colg = PIXG(pc); + *colb = PIXB(pc); + return 0; +} + + +Element_LIFE::~Element_LIFE() {} \ No newline at end of file diff --git a/src/elements/ligh.cpp b/src/simulation/elements/LIGH.cpp similarity index 73% rename from src/elements/ligh.cpp rename to src/simulation/elements/LIGH.cpp index 586dfc493..27b5c4b48 100644 --- a/src/elements/ligh.cpp +++ b/src/simulation/elements/LIGH.cpp @@ -1,104 +1,57 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" + +//#TPT-Directive ElementClass Element_LIGH PT_LIGH 87 +Element_LIGH::Element_LIGH() +{ + Identifier = "DEFAULT_PT_LIGH"; + Name = "LIGH"; + Colour = PIXPACK(0xFFFFC0); + MenuVisible = 1; + MenuSection = SC_ELEC; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 0; + Description = "More realistic lightning. Set pen size to set the size of the lightning."; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_LIGH::update; + Graphics = &Element_LIGH::graphics; +} #define LIGHTING_POWER 0.65 -int LIGH_nearest_part(Simulation * sim, int ci, int max_d) -{ - int distance = (max_d!=-1)?max_d:MAX_DISTANCE; - int ndistance = 0; - int id = -1; - int i = 0; - int cx = (int)sim->parts[ci].x; - int cy = (int)sim->parts[ci].y; - for (i=0; i<=sim->parts_lastActiveIndex; i++) - { - if (sim->parts[i].type && sim->parts[i].life && i!=ci && sim->parts[i].type!=PT_LIGH && sim->parts[i].type!=PT_THDR && sim->parts[i].type!=PT_NEUT && sim->parts[i].type!=PT_PHOT) - { - ndistance = abs(cx-sim->parts[i].x)+abs(cy-sim->parts[i].y);// Faster but less accurate Older: sqrt(pow(cx-parts[i].x, 2)+pow(cy-parts[i].y, 2)); - if (ndistanceparts[i].x, y=sim->parts[i].y; - int r,rx,ry; - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>=0 && x+rxpmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)==tp) - return r>>8; - } - return -1; -} - -void create_line_par(Simulation * sim, int x1, int y1, int x2, int y2, int c, int temp, int life, int tmp, int tmp2) -{ - int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy; - float e, de; - if (c==WL_EHOLE || c==WL_ALLOWGAS || c==WL_ALLOWALLELEC || c==WL_ALLOWSOLID || c==WL_ALLOWAIR || c==WL_WALL || c==WL_DESTROYALL || c==WL_ALLOWLIQUID || c==WL_FAN || c==WL_STREAM || c==WL_DETECT || c==WL_EWALL || c==WL_WALLELEC) - return; // this function only for particles, no walls - if (cp) - { - y = x1; - x1 = y1; - y1 = y; - y = x2; - x2 = y2; - y2 = y; - } - if (x1 > x2) - { - y = x1; - x1 = x2; - x2 = y; - y = y1; - y1 = y2; - y2 = y; - } - dx = x2 - x1; - dy = abs(y2 - y1); - e = 0.0f; - if (dx) - de = dy/(float)dx; - else - de = 0.0f; - y = y1; - sy = (y1create_part(-1, y, x, c); - else - p = sim->create_part(-1, x, y,c); - if (p!=-1) - { - sim->parts[p].life = life; - sim->parts[p].temp = temp; - sim->parts[p].tmp = tmp; - sim->parts[p].tmp2 = tmp2; - } - e += de; - if (e >= 0.5f) - { - y += sy; - e -= 1.0f; - } - } -} - -int update_LIGH(UPDATE_FUNC_ARGS) { /* * @@ -119,7 +72,7 @@ int update_LIGH(UPDATE_FUNC_ARGS) float angle, angle2=-1; int pNear = 0; powderful = powderful = parts[i].temp*(1+parts[i].life/40)*LIGHTING_POWER; - update_PYRO(UPDATE_FUNC_SUBCALL_ARGS); + Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS); if (sim->aheat_enable) { sim->hv[y/CELL][x/CELL]+=powderful/50; @@ -138,12 +91,12 @@ int update_LIGH(UPDATE_FUNC_ARGS) { if ((r&0xFF)!=PT_CLNE&&(r&0xFF)!=PT_THDR&&(r&0xFF)!=PT_DMND&&(r&0xFF)!=PT_FIRE&&(r&0xFF)!=PT_NEUT&&(r&0xFF)!=PT_PHOT) { - if ((sim->ptypes[r&0xFF].properties&PROP_CONDUCTS) && parts[r>>8].life==0) + if ((sim->elements[r&0xFF].Properties&PROP_CONDUCTS) && parts[r>>8].life==0) { sim->create_part(r>>8,x+rx,y+ry,PT_SPRK); } sim->pv[y/CELL][x/CELL] += powderful/400; - if (sim->ptypes[r&0xFF].hconduct) parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/1.5, MIN_TEMP, MAX_TEMP); + if (sim->elements[r&0xFF].HeatConduct) parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/1.5, MIN_TEMP, MAX_TEMP); } if ((r&0xFF)==PT_DEUT || (r&0xFF)==PT_PLUT) // start nuclear reactions { @@ -163,7 +116,7 @@ int update_LIGH(UPDATE_FUNC_ARGS) parts[r>>8].life = 99; } } - if (sim->ptypes[r&0xFF].hconduct) + if (sim->elements[r&0xFF].HeatConduct) parts[r>>8].temp = restrict_flt(parts[r>>8].temp+powderful/10, MIN_TEMP, MAX_TEMP); if (((r&0xFF)==PT_STKM && sim->player.elem!=PT_LIGH) || ((r&0xFF)==PT_STKM2 && sim->player2.elem!=PT_LIGH)) { @@ -285,7 +238,110 @@ int update_LIGH(UPDATE_FUNC_ARGS) parts[i].tmp2=-1; return 1; } -int graphics_LIGH(GRAPHICS_FUNC_ARGS) + +//#TPT-Directive ElementHeader Element_LIGH static int LIGH_nearest_part(Simulation * sim, int ci, int max_d) +int Element_LIGH::LIGH_nearest_part(Simulation * sim, int ci, int max_d) +{ + int distance = (max_d!=-1)?max_d:MAX_DISTANCE; + int ndistance = 0; + int id = -1; + int i = 0; + int cx = (int)sim->parts[ci].x; + int cy = (int)sim->parts[ci].y; + for (i=0; i<=sim->parts_lastActiveIndex; i++) + { + if (sim->parts[i].type && sim->parts[i].life && i!=ci && sim->parts[i].type!=PT_LIGH && sim->parts[i].type!=PT_THDR && sim->parts[i].type!=PT_NEUT && sim->parts[i].type!=PT_PHOT) + { + ndistance = abs(cx-sim->parts[i].x)+abs(cy-sim->parts[i].y);// Faster but less accurate Older: sqrt(pow(cx-parts[i].x, 2)+pow(cy-parts[i].y, 2)); + if (ndistanceparts[i].x, y=sim->parts[i].y; + int r,rx,ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>=0 && x+rxpmap[y+ry][x+rx]; + if (!r) + continue; + if ((r&0xFF)==tp) + return r>>8; + } + return -1; +} + +//#TPT-Directive ElementHeader Element_LIGH static void create_line_par(Simulation * sim, int x1, int y1, int x2, int y2, int c, int temp, int life, int tmp, int tmp2) +void Element_LIGH::create_line_par(Simulation * sim, int x1, int y1, int x2, int y2, int c, int temp, int life, int tmp, int tmp2) +{ + int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy; + float e, de; + if (c==WL_EHOLE || c==WL_ALLOWGAS || c==WL_ALLOWALLELEC || c==WL_ALLOWSOLID || c==WL_ALLOWAIR || c==WL_WALL || c==WL_DESTROYALL || c==WL_ALLOWLIQUID || c==WL_FAN || c==WL_STREAM || c==WL_DETECT || c==WL_EWALL || c==WL_WALLELEC) + return; // this function only for particles, no walls + if (cp) + { + y = x1; + x1 = y1; + y1 = y; + y = x2; + x2 = y2; + y2 = y; + } + if (x1 > x2) + { + y = x1; + x1 = x2; + x2 = y; + y = y1; + y1 = y2; + y2 = y; + } + dx = x2 - x1; + dy = abs(y2 - y1); + e = 0.0f; + if (dx) + de = dy/(float)dx; + else + de = 0.0f; + y = y1; + sy = (y1create_part(-1, y, x, c); + else + p = sim->create_part(-1, x, y,c); + if (p!=-1) + { + sim->parts[p].life = life; + sim->parts[p].temp = temp; + sim->parts[p].tmp = tmp; + sim->parts[p].tmp2 = tmp2; + } + e += de; + if (e >= 0.5f) + { + y += sy; + e -= 1.0f; + } + } +} + + +//#TPT-Directive ElementHeader Element_LIGH static int graphics(GRAPHICS_FUNC_ARGS) +int Element_LIGH::graphics(GRAPHICS_FUNC_ARGS) + { *firea = 120; *firer = *colr = 235; @@ -294,3 +350,6 @@ int graphics_LIGH(GRAPHICS_FUNC_ARGS) *pixel_mode |= PMODE_GLOW | FIRE_ADD; return 1; } + + +Element_LIGH::~Element_LIGH() {} \ No newline at end of file diff --git a/src/simulation/elements/LNTG.cpp b/src/simulation/elements/LNTG.cpp new file mode 100644 index 000000000..ce776c801 --- /dev/null +++ b/src/simulation/elements/LNTG.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_LNTG PT_LNTG 37 +Element_LNTG::Element_LNTG() +{ + Identifier = "DEFAULT_PT_LNTG"; + Name = "LN2"; + Colour = PIXPACK(0x80A0DF); + MenuVisible = 1; + MenuSection = SC_LIQUID; + Enabled = 1; + + Advection = 0.6f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.98f; + Loss = 0.95f; + Collision = 0.0f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 2; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 30; + + Temperature = 70.15f; + HeatConduct = 70; + Description = "Liquid Nitrogen. Very cold."; + + State = ST_SOLID; + Properties = TYPE_LIQUID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = 63.0f; + LowTemperatureTransition = PT_NICE; + HighTemperature = 77.0f; + HighTemperatureTransition = PT_NONE; + + Update = NULL; + Graphics = NULL; +} + +Element_LNTG::~Element_LNTG() {} \ No newline at end of file diff --git a/src/simulation/elements/LO2.cpp b/src/simulation/elements/LO2.cpp new file mode 100644 index 000000000..cc0c55757 --- /dev/null +++ b/src/simulation/elements/LO2.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_LO2 PT_LO2 60 +Element_LO2::Element_LO2() +{ + Identifier = "DEFAULT_PT_LO2"; + Name = "LOXY"; + Colour = PIXPACK(0x80A0EF); + MenuVisible = 1; + MenuSection = SC_LIQUID; + Enabled = 1; + + Advection = 0.6f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.98f; + Loss = 0.95f; + Collision = 0.0f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 2; + + Flammable = 5000; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 30; + + Temperature = 80.0f; + HeatConduct = 70; + Description = "Liquid Oxygen. Very cold. Reacts with fire"; + + State = ST_LIQUID; + Properties = TYPE_LIQUID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 90.1f; + HighTemperatureTransition = PT_O2; + + Update = NULL; + Graphics = NULL; +} + +Element_LO2::~Element_LO2() {} \ No newline at end of file diff --git a/src/simulation/elements/LOLZ.cpp b/src/simulation/elements/LOLZ.cpp new file mode 100644 index 000000000..14c575771 --- /dev/null +++ b/src/simulation/elements/LOLZ.cpp @@ -0,0 +1,63 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_LOLZ PT_LOLZ 123 +Element_LOLZ::Element_LOLZ() +{ + Identifier = "DEFAULT_PT_LOLZ"; + Name = "LOLZ"; + Colour = PIXPACK(0x569212); + MenuVisible = 1; + MenuSection = SC_CRACKER2; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.00f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.0f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 100; + + Temperature = 373.0f; + HeatConduct = 40; + Description = "Lolz"; + + State = ST_GAS; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_LOLZ::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_LOLZ static int update(UPDATE_FUNC_ARGS) +int Element_LOLZ::update(UPDATE_FUNC_ARGS) + { + /*int t = parts[i].type; + if (t==PT_LOVE) + ISLOVE=1; + else if (t==PT_LOLZ) + ISLOLZ=1; + else if (t==PT_GRAV) + ISGRAV=1;*/ + return 0; +} + + +Element_LOLZ::~Element_LOLZ() {} \ No newline at end of file diff --git a/src/simulation/elements/LOVE.cpp b/src/simulation/elements/LOVE.cpp new file mode 100644 index 000000000..977633603 --- /dev/null +++ b/src/simulation/elements/LOVE.cpp @@ -0,0 +1,63 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_LOVE PT_LOVE 94 +Element_LOVE::Element_LOVE() +{ + Identifier = "DEFAULT_PT_LOVE"; + Name = "LOVE"; + Colour = PIXPACK(0xFF30FF); + MenuVisible = 1; + MenuSection = SC_CRACKER2; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.00f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.0f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 100; + + Temperature = 373.0f; + HeatConduct = 40; + Description = "Love..."; + + State = ST_GAS; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_LOVE::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_LOVE static int update(UPDATE_FUNC_ARGS) +int Element_LOVE::update(UPDATE_FUNC_ARGS) + { + /*int t = parts[i].type; + if (t==PT_LOVE) + ISLOVE=1; + else if (t==PT_LOLZ) + ISLOLZ=1; + else if (t==PT_GRAV) + ISGRAV=1;*/ + return 0; +} + + +Element_LOVE::~Element_LOVE() {} \ No newline at end of file diff --git a/src/simulation/elements/LRBD.cpp b/src/simulation/elements/LRBD.cpp new file mode 100644 index 000000000..445541fe4 --- /dev/null +++ b/src/simulation/elements/LRBD.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_LRBD PT_LRBD 42 +Element_LRBD::Element_LRBD() +{ + Identifier = "DEFAULT_PT_LRBD"; + Name = "LRBD"; + Colour = PIXPACK(0xAAAAAA); + MenuVisible = 1; + MenuSection = SC_EXPLOSIVE; + Enabled = 1; + + Advection = 0.3f; + AirDrag = 0.02f * CFDS; + AirLoss = 0.95f; + Loss = 0.80f; + Collision = 0.0f; + Gravity = 0.15f; + Diffusion = 0.00f; + HotAir = 0.000001f* CFDS; + Falldown = 2; + + Flammable = 1000; + Explosive = 1; + Meltable = 0; + Hardness = 2; + + Weight = 45; + + Temperature = R_TEMP+45.0f+273.15f; + HeatConduct = 170; + Description = "Liquid Rubidium."; + + State = ST_LIQUID; + Properties = TYPE_LIQUID|PROP_CONDUCTS|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = 311.0f; + LowTemperatureTransition = PT_RBDM; + HighTemperature = 961.0f; + HighTemperatureTransition = PT_FIRE; + + Update = NULL; + Graphics = NULL; +} + +Element_LRBD::~Element_LRBD() {} \ No newline at end of file diff --git a/src/elements/merc.cpp b/src/simulation/elements/MERC.cpp similarity index 55% rename from src/elements/merc.cpp rename to src/simulation/elements/MERC.cpp index 58b19a367..9e7ee3856 100644 --- a/src/elements/merc.cpp +++ b/src/simulation/elements/MERC.cpp @@ -1,6 +1,54 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_MERC PT_MERC 152 +Element_MERC::Element_MERC() +{ + Identifier = "DEFAULT_PT_MERC"; + Name = "MERC"; + Colour = PIXPACK(0x736B6D); + MenuVisible = 1; + MenuSection = SC_ELEC; + Enabled = 1; + + Advection = 0.4f; + AirDrag = 0.04f * CFDS; + AirLoss = 0.94f; + Loss = 0.80f; + Collision = 0.0f; + Gravity = 0.3f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 2; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 20; + + Weight = 91; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Mercury. Volume changes with temperature, Conductive."; + + State = ST_LIQUID; + Properties = TYPE_LIQUID|PROP_CONDUCTS|PROP_NEUTABSORB|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_MERC::update; + Graphics = NULL; +} -int update_MERC(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_MERC static int update(UPDATE_FUNC_ARGS) +int Element_MERC::update(UPDATE_FUNC_ARGS) + { int r, rx, ry, trade, np; int maxtmp = ((10000/(parts[i].temp + 1))-1); if ((10000%((int)parts[i].temp+1))>rand()%((int)parts[i].temp+1)) @@ -68,3 +116,6 @@ int update_MERC(UPDATE_FUNC_ARGS) { } return 0; } + + +Element_MERC::~Element_MERC() {} \ No newline at end of file diff --git a/src/simulation/elements/METL.cpp b/src/simulation/elements/METL.cpp new file mode 100644 index 000000000..a0137089e --- /dev/null +++ b/src/simulation/elements/METL.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_METL PT_METL 14 +Element_METL::Element_METL() +{ + Identifier = "DEFAULT_PT_METL"; + Name = "METL"; + Colour = PIXPACK(0x404060); + MenuVisible = 1; + MenuSection = SC_ELEC; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Solid. Conducts electricity. Meltable."; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 1273.0f; + HighTemperatureTransition = PT_LAVA; + + Update = NULL; + Graphics = NULL; +} + +Element_METL::~Element_METL() {} \ No newline at end of file diff --git a/src/simulation/elements/MORT.cpp b/src/simulation/elements/MORT.cpp new file mode 100644 index 000000000..3acaf0ce9 --- /dev/null +++ b/src/simulation/elements/MORT.cpp @@ -0,0 +1,57 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_MORT PT_MORT 77 +Element_MORT::Element_MORT() +{ + Identifier = "DEFAULT_PT_MORT"; + Name = "MORT"; + Colour = PIXPACK(0xE0E0E0); + MenuVisible = 1; + MenuSection = SC_CRACKER2; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 1.00f; + Loss = 1.00f; + Collision = -0.99f; + Gravity = 0.0f; + Diffusion = 0.01f; + HotAir = 0.002f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = -1; + + Temperature = R_TEMP+4.0f +273.15f; + HeatConduct = 60; + Description = "Steam Train."; + + State = ST_NONE; + Properties = TYPE_PART; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_MORT::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_MORT static int update(UPDATE_FUNC_ARGS) +int Element_MORT::update(UPDATE_FUNC_ARGS) + { + sim->create_part(-1, x, y-1, PT_SMKE); + return 0; +} + + +Element_MORT::~Element_MORT() {} \ No newline at end of file diff --git a/src/simulation/elements/MWAX.cpp b/src/simulation/elements/MWAX.cpp new file mode 100644 index 000000000..d9428eba9 --- /dev/null +++ b/src/simulation/elements/MWAX.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_MWAX PT_MWAX 34 +Element_MWAX::Element_MWAX() +{ + Identifier = "DEFAULT_PT_MWAX"; + Name = "MWAX"; + Colour = PIXPACK(0xE0E0AA); + MenuVisible = 1; + MenuSection = SC_LIQUID; + Enabled = 1; + + Advection = 0.3f; + AirDrag = 0.02f * CFDS; + AirLoss = 0.95f; + Loss = 0.80f; + Collision = 0.0f; + Gravity = 0.15f; + Diffusion = 0.00f; + HotAir = 0.000001f* CFDS; + Falldown = 2; + + Flammable = 5; + Explosive = 0; + Meltable = 0; + Hardness = 2; + + Weight = 25; + + Temperature = R_TEMP+28.0f+273.15f; + HeatConduct = 44; + Description = "Liquid Wax."; + + State = ST_LIQUID; + Properties = TYPE_LIQUID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = 318.0f; + LowTemperatureTransition = PT_WAX; + HighTemperature = 673.0f; + HighTemperatureTransition = PT_FIRE; + + Update = NULL; + Graphics = NULL; +} + +Element_MWAX::~Element_MWAX() {} \ No newline at end of file diff --git a/src/simulation/elements/NBHL.cpp b/src/simulation/elements/NBHL.cpp new file mode 100644 index 000000000..88d6ec22c --- /dev/null +++ b/src/simulation/elements/NBHL.cpp @@ -0,0 +1,57 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_NBHL PT_NBHL 150 +Element_NBHL::Element_NBHL() +{ + Identifier = "DEFAULT_PT_NBHL"; + Name = "BHOL"; + Colour = PIXPACK(0x202020); + MenuVisible = 1; + MenuSection = SC_SPECIAL; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 186; + Description = "Black hole (Requires newtonian gravity)"; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_NBHL::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_NBHL static int update(UPDATE_FUNC_ARGS) +int Element_NBHL::update(UPDATE_FUNC_ARGS) + { + sim->gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] += 0.1f; + return 0; +} + + +Element_NBHL::~Element_NBHL() {} \ No newline at end of file diff --git a/src/simulation/elements/NBLE.cpp b/src/simulation/elements/NBLE.cpp new file mode 100644 index 000000000..3cd02591b --- /dev/null +++ b/src/simulation/elements/NBLE.cpp @@ -0,0 +1,78 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_NBLE PT_NBLE 52 +Element_NBLE::Element_NBLE() +{ + Identifier = "DEFAULT_PT_NBLE"; + Name = "NBLE"; + Colour = PIXPACK(0xEB4917); + MenuVisible = 1; + MenuSection = SC_GAS; + Enabled = 1; + + Advection = 1.0f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.99f; + Loss = 0.30f; + Collision = -0.1f; + Gravity = 0.0f; + Diffusion = 0.75f; + HotAir = 0.001f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 1; + + Temperature = R_TEMP+2.0f +273.15f; + HeatConduct = 106; + Description = "Noble Gas. Diffuses. Conductive. Ionizes into plasma when introduced to electricity"; + + State = ST_GAS; + Properties = TYPE_GAS|PROP_CONDUCTS|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_NBLE::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_NBLE static int update(UPDATE_FUNC_ARGS) +int Element_NBLE::update(UPDATE_FUNC_ARGS) + +{ + if (parts[i].temp > 5273.15 && sim->pv[y/CELL][x/CELL] > 100.0f) + { + parts[i].tmp = 1; + if (rand()%5 < 1) + { + int j; + float temp = parts[i].temp; + sim->part_change_type(i,x,y,PT_PLSM); + parts[i].life = rand()%150+50; + j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT); if (j != -1) + j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_ELEC); if (j != -1) + j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_PHOT); + if (j != -1) { parts[j].ctype = 0xFF0000; parts[j].temp = temp; } + + j = sim->create_part(-3,x+rand()%3-1,y+rand()%3-1,PT_CO2); + if (j != -1) parts[j].temp = temp-1000; + + parts[i].temp += 10000; + sim->pv[y/CELL][x/CELL] += 30; + } + } + return 0; +} + + +Element_NBLE::~Element_NBLE() {} \ No newline at end of file diff --git a/src/elements/neut.cpp b/src/simulation/elements/NEUT.cpp similarity index 67% rename from src/elements/neut.cpp rename to src/simulation/elements/NEUT.cpp index c80410661..108ae7223 100644 --- a/src/elements/neut.cpp +++ b/src/simulation/elements/NEUT.cpp @@ -1,48 +1,54 @@ -#include "simulation/Element.h" - - -int create_n_parts(Simulation * sim, int n, int x, int y, float vx, float vy, float temp, int t)//testing a new deut create part +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_NEUT PT_NEUT 18 +Element_NEUT::Element_NEUT() { - int i, c; - n = (n/50); - if (n<1) { - n = 1; - } - if (n>340) { - n = 340; - } - if (x<0 || y<0 || x>=XRES || y>=YRES || t<0 || t>=PT_NUM) - return -1; - - for (c=0; cpfree == -1) - return -1; - i = sim->pfree; - sim->pfree = sim->parts[i].life; - if (i>sim->parts_lastActiveIndex) sim->parts_lastActiveIndex = i; - - sim->parts[i].x = (float)x; - sim->parts[i].y = (float)y; - sim->parts[i].type = t; - sim->parts[i].life = rand()%480+480; - sim->parts[i].vx = r*cosf(a); - sim->parts[i].vy = r*sinf(a); - sim->parts[i].ctype = 0; - sim->parts[i].temp = temp; - sim->parts[i].tmp = 0; - if (t!=PT_STKM&&t!=PT_STKM2 && t!=PT_PHOT && t!=PT_NEUT && !sim->pmap[y][x]) - sim->pmap[y][x] = t|(i<<8); - else if ((t==PT_PHOT||t==PT_NEUT) && !sim->photons[y][x]) - sim->photons[y][x] = t|(i<<8); - - sim->pv[y/CELL][x/CELL] += 6.0f * CFDS; - } - return 0; + Identifier = "DEFAULT_PT_NEUT"; + Name = "NEUT"; + Colour = PIXPACK(0x20E0FF); + MenuVisible = 1; + MenuSection = SC_NUCLEAR; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 1.00f; + Loss = 1.00f; + Collision = -0.99f; + Gravity = 0.0f; + Diffusion = 0.01f; + HotAir = 0.002f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = -1; + + Temperature = R_TEMP+4.0f +273.15f; + HeatConduct = 60; + Description = "Neutrons. Interact with matter in odd ways."; + + State = ST_GAS; + Properties = TYPE_ENERGY|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_NEUT::update; + Graphics = &Element_NEUT::graphics; } -int update_NEUT(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_NEUT static int update(UPDATE_FUNC_ARGS) +int Element_NEUT::update(UPDATE_FUNC_ARGS) + { int r, rx, ry, rt; int pressureFactor = 3 + (int)sim->pv[y/CELL][x/CELL]; for (rx=-1; rx<2; rx++) @@ -75,7 +81,7 @@ int update_NEUT(UPDATE_FUNC_ARGS) { parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy; } sim->pv[y/CELL][x/CELL] += 10.0f * CFDS; //Used to be 2, some people said nukes weren't powerful enough - update_PYRO(UPDATE_FUNC_SUBCALL_ARGS); + Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS); } #ifdef SDEUT else if ((r&0xFF)==PT_DEUT && (pressureFactor+1+(parts[r>>8].life/100))>(rand()%1000)) @@ -124,16 +130,20 @@ int update_NEUT(UPDATE_FUNC_ARGS) { else if ((r&0xFF)==PT_ACID && 5>(rand()%100)) sim->create_part(r>>8, x+rx, y+ry, PT_ISOZ); /*if(parts[r>>8].type>1 && parts[r>>8].type!=PT_NEUT && parts[r>>8].type-1!=PT_NEUT && parts[r>>8].type-1!=PT_STKM && - (ptypes[parts[r>>8].type-1].menusection==SC_LIQUID|| - ptypes[parts[r>>8].type-1].menusection==SC_EXPLOSIVE|| - ptypes[parts[r>>8].type-1].menusection==SC_GAS|| - ptypes[parts[r>>8].type-1].menusection==SC_POWDERS) && 15>(rand()%1000)) + (elements[parts[r>>8].type-1].menusection==SC_LIQUID|| + elements[parts[r>>8].type-1].menusection==SC_EXPLOSIVE|| + elements[parts[r>>8].type-1].menusection==SC_GAS|| + elements[parts[r>>8].type-1].menusection==SC_POWDERS) && 15>(rand()%1000)) parts[r>>8].type--;*/ } return 0; } -int graphics_NEUT(GRAPHICS_FUNC_ARGS) + + +//#TPT-Directive ElementHeader Element_NEUT static int graphics(GRAPHICS_FUNC_ARGS) +int Element_NEUT::graphics(GRAPHICS_FUNC_ARGS) + { *firea = 120; *firer = 10; @@ -143,3 +153,48 @@ int graphics_NEUT(GRAPHICS_FUNC_ARGS) *pixel_mode |= FIRE_ADD; return 1; } + +//#TPT-Directive ElementHeader Element_NEUT static int create_n_parts(Simulation * sim, int n, int x, int y, float vx, float vy, float temp, int t) +int Element_NEUT::create_n_parts(Simulation * sim, int n, int x, int y, float vx, float vy, float temp, int t)//testing a new deut create part +{ + int i, c; + n = (n/50); + if (n<1) { + n = 1; + } + if (n>340) { + n = 340; + } + if (x<0 || y<0 || x>=XRES || y>=YRES || t<0 || t>=PT_NUM) + return -1; + + for (c=0; cpfree == -1) + return -1; + i = sim->pfree; + sim->pfree = sim->parts[i].life; + if (i>sim->parts_lastActiveIndex) sim->parts_lastActiveIndex = i; + + sim->parts[i].x = (float)x; + sim->parts[i].y = (float)y; + sim->parts[i].type = t; + sim->parts[i].life = rand()%480+480; + sim->parts[i].vx = r*cosf(a); + sim->parts[i].vy = r*sinf(a); + sim->parts[i].ctype = 0; + sim->parts[i].temp = temp; + sim->parts[i].tmp = 0; + if (t!=PT_STKM&&t!=PT_STKM2 && t!=PT_PHOT && t!=PT_NEUT && !sim->pmap[y][x]) + sim->pmap[y][x] = t|(i<<8); + else if ((t==PT_PHOT||t==PT_NEUT) && !sim->photons[y][x]) + sim->photons[y][x] = t|(i<<8); + + sim->pv[y/CELL][x/CELL] += 6.0f * CFDS; + } + return 0; +} + + +Element_NEUT::~Element_NEUT() {} \ No newline at end of file diff --git a/src/simulation/elements/NICE.cpp b/src/simulation/elements/NICE.cpp new file mode 100644 index 000000000..8c01ea40c --- /dev/null +++ b/src/simulation/elements/NICE.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_NICE PT_NICE 51 +Element_NICE::Element_NICE() +{ + Identifier = "DEFAULT_PT_NICE"; + Name = "NICE"; + Colour = PIXPACK(0xC0E0FF); + MenuVisible = 1; + MenuSection = SC_SOLIDS; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = -0.0005f* CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 20; + + Weight = 100; + + Temperature = 35.0f; + HeatConduct = 46; + Description = "Nitrogen Ice."; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 63.1f; + HighTemperatureTransition = PT_LNTG; + + Update = NULL; + Graphics = NULL; +} + +Element_NICE::~Element_NICE() {} \ No newline at end of file diff --git a/src/simulation/elements/NITR.cpp b/src/simulation/elements/NITR.cpp new file mode 100644 index 000000000..45877f29b --- /dev/null +++ b/src/simulation/elements/NITR.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_NITR PT_NITR 8 +Element_NITR::Element_NITR() +{ + Identifier = "DEFAULT_PT_NITR"; + Name = "NITR"; + Colour = PIXPACK(0x20E010); + MenuVisible = 1; + MenuSection = SC_EXPLOSIVE; + Enabled = 1; + + Advection = 0.5f; + AirDrag = 0.02f * CFDS; + AirLoss = 0.92f; + Loss = 0.97f; + Collision = 0.0f; + Gravity = 0.2f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 2; + + Flammable = 1000; + Explosive = 2; + Meltable = 0; + Hardness = 3; + + Weight = 23; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 50; + Description = "Liquid. Pressure sensitive explosive."; + + State = ST_LIQUID; + Properties = TYPE_LIQUID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 673.0f; + HighTemperatureTransition = PT_FIRE; + + Update = NULL; + Graphics = NULL; +} + +Element_NITR::~Element_NITR() {} \ No newline at end of file diff --git a/src/simulation/elements/NONE.cpp b/src/simulation/elements/NONE.cpp new file mode 100644 index 000000000..8029bee77 --- /dev/null +++ b/src/simulation/elements/NONE.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_NONE PT_NONE 0 +Element_NONE::Element_NONE() +{ + Identifier = "DEFAULT_PT_NONE"; + Name = ""; + Colour = PIXPACK(0x000000); + MenuVisible = 1; + MenuSection = SC_SPECIAL; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 1.00f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Erases particles."; + + State = ST_NONE; + Properties = 0; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = NULL; + Graphics = NULL; +} + +Element_NONE::~Element_NONE() {} \ No newline at end of file diff --git a/src/simulation/elements/NSCN.cpp b/src/simulation/elements/NSCN.cpp new file mode 100644 index 000000000..3d9364561 --- /dev/null +++ b/src/simulation/elements/NSCN.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_NSCN PT_NSCN 36 +Element_NSCN::Element_NSCN() +{ + Identifier = "DEFAULT_PT_NSCN"; + Name = "NSCN"; + Colour = PIXPACK(0x505080); + MenuVisible = 1; + MenuSection = SC_ELEC; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "N-Type Silicon, Will not transfer current to P-Type Silicon."; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 1687.0f; + HighTemperatureTransition = PT_LAVA; + + Update = NULL; + Graphics = NULL; +} + +Element_NSCN::~Element_NSCN() {} \ No newline at end of file diff --git a/src/simulation/elements/NTCT.cpp b/src/simulation/elements/NTCT.cpp new file mode 100644 index 000000000..0e4d67b38 --- /dev/null +++ b/src/simulation/elements/NTCT.cpp @@ -0,0 +1,58 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_NTCT PT_NTCT 43 +Element_NTCT::Element_NTCT() +{ + Identifier = "DEFAULT_PT_NTCT"; + Name = "NTCT"; + Colour = PIXPACK(0x505040); + MenuVisible = 1; + MenuSection = SC_ELEC; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Semi-conductor. Only conducts electricity when hot (More than 100C)"; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 1687.0f; + HighTemperatureTransition = PT_LAVA; + + Update = &Element_NTCT::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_NTCT static int update(UPDATE_FUNC_ARGS) +int Element_NTCT::update(UPDATE_FUNC_ARGS) + { + if (parts[i].temp>295.0f) + parts[i].temp -= 2.5f; + return 0; +} + + +Element_NTCT::~Element_NTCT() {} \ No newline at end of file diff --git a/src/simulation/elements/NWHL.cpp b/src/simulation/elements/NWHL.cpp new file mode 100644 index 000000000..aadce99aa --- /dev/null +++ b/src/simulation/elements/NWHL.cpp @@ -0,0 +1,57 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_NWHL PT_NWHL 151 +Element_NWHL::Element_NWHL() +{ + Identifier = "DEFAULT_PT_NWHL"; + Name = "WHOL"; + Colour = PIXPACK(0xFFFFFF); + MenuVisible = 1; + MenuSection = SC_SPECIAL; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 186; + Description = "White hole (Requires newtonian gravity)"; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_NWHL::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_NWHL static int update(UPDATE_FUNC_ARGS) +int Element_NWHL::update(UPDATE_FUNC_ARGS) + { + sim->gravmap[(y/CELL)*(XRES/CELL)+(x/CELL)] -= 0.1f; + return 0; +} + + +Element_NWHL::~Element_NWHL() {} \ No newline at end of file diff --git a/src/simulation/elements/O2.cpp b/src/simulation/elements/O2.cpp new file mode 100644 index 000000000..385d1f3f2 --- /dev/null +++ b/src/simulation/elements/O2.cpp @@ -0,0 +1,81 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_O2 PT_O2 61 +Element_O2::Element_O2() +{ + Identifier = "DEFAULT_PT_O2"; + Name = "OXYG"; + Colour = PIXPACK(0x80A0FF); + MenuVisible = 1; + MenuSection = SC_GAS; + Enabled = 1; + + Advection = 2.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.99f; + Loss = 0.30f; + Collision = -0.1f; + Gravity = 0.0f; + Diffusion = 3.0f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 1; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 70; + Description = "Gas. Ignites easily."; + + State = ST_GAS; + Properties = TYPE_GAS; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = 90.0f; + LowTemperatureTransition = PT_LO2; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_O2::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_O2 static int update(UPDATE_FUNC_ARGS) +int Element_O2::update(UPDATE_FUNC_ARGS) + +{ + int r,rx,ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>=0 && x+rx>8].temp+=(rand()/(RAND_MAX/100)); + if(parts[r>>8].tmp&0x01) + parts[r>>8].temp=3473; + parts[r>>8].tmp |= 2; + } + if ((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) + { + sim->create_part(i,x,y,PT_FIRE); + parts[i].temp+=(rand()/(RAND_MAX/100)); + parts[i].tmp |= 2; + } + + } + return 0; +} + + +Element_O2::~Element_O2() {} \ No newline at end of file diff --git a/src/simulation/elements/OIL.cpp b/src/simulation/elements/OIL.cpp new file mode 100644 index 000000000..3504a1f73 --- /dev/null +++ b/src/simulation/elements/OIL.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_OIL PT_OIL 3 +Element_OIL::Element_OIL() +{ + Identifier = "DEFAULT_PT_OIL"; + Name = "OIL"; + Colour = PIXPACK(0x404010); + MenuVisible = 1; + MenuSection = SC_LIQUID; + Enabled = 1; + + Advection = 0.6f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.98f; + Loss = 0.95f; + Collision = 0.0f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 2; + + Flammable = 20; + Explosive = 0; + Meltable = 0; + Hardness = 5; + + Weight = 20; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 42; + Description = "Liquid. Flammable."; + + State = ST_LIQUID; + Properties = TYPE_LIQUID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 333.0f; + HighTemperatureTransition = PT_GAS; + + Update = NULL; + Graphics = NULL; +} + +Element_OIL::~Element_OIL() {} \ No newline at end of file diff --git a/src/elements/pbcn.cpp b/src/simulation/elements/PBCN.cpp similarity index 62% rename from src/elements/pbcn.cpp rename to src/simulation/elements/PBCN.cpp index 3b992d4e1..270bfb5ad 100644 --- a/src/elements/pbcn.cpp +++ b/src/simulation/elements/PBCN.cpp @@ -1,6 +1,54 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_PBCN PT_PBCN 153 +Element_PBCN::Element_PBCN() +{ + Identifier = "DEFAULT_PT_PBCN"; + Name = "PBCN"; + Colour = PIXPACK(0x3B1D0A); + MenuVisible = 1; + MenuSection = SC_POWERED; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.97f; + Loss = 0.50f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 12; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Powered breakable clone"; + + State = ST_NONE; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_PBCN::update; + Graphics = &Element_PBCN::graphics; +} -int update_PBCN(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_PBCN static int update(UPDATE_FUNC_ARGS) +int Element_PBCN::update(UPDATE_FUNC_ARGS) + { int r, rx, ry; if (parts[i].life>0 && parts[i].life!=10) parts[i].life--; @@ -93,3 +141,17 @@ int update_PBCN(UPDATE_FUNC_ARGS) { } return 0; } + + +//#TPT-Directive ElementHeader Element_PBCN static int graphics(GRAPHICS_FUNC_ARGS) +int Element_PBCN::graphics(GRAPHICS_FUNC_ARGS) + +{ + int lifemod = ((cpart->life>10?10:cpart->life)*10); + *colr += lifemod; + *colg += lifemod/2; + return 0; +} + + +Element_PBCN::~Element_PBCN() {} \ No newline at end of file diff --git a/src/elements/pcln.cpp b/src/simulation/elements/PCLN.cpp similarity index 60% rename from src/elements/pcln.cpp rename to src/simulation/elements/PCLN.cpp index ba2c7215c..14991b5ad 100644 --- a/src/elements/pcln.cpp +++ b/src/simulation/elements/PCLN.cpp @@ -1,6 +1,54 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_PCLN PT_PCLN 74 +Element_PCLN::Element_PCLN() +{ + Identifier = "DEFAULT_PT_PCLN"; + Name = "PCLN"; + Colour = PIXPACK(0x3B3B0A); + MenuVisible = 1; + MenuSection = SC_POWERED; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Solid. When activated, duplicates any particles it touches."; + + State = ST_NONE; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_PCLN::update; + Graphics = &Element_PCLN::graphics; +} -int update_PCLN(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_PCLN static int update(UPDATE_FUNC_ARGS) +int Element_PCLN::update(UPDATE_FUNC_ARGS) + { int r, rx, ry; if (parts[i].life>0 && parts[i].life!=10) parts[i].life--; @@ -83,3 +131,17 @@ int update_PCLN(UPDATE_FUNC_ARGS) { } return 0; } + + +//#TPT-Directive ElementHeader Element_PCLN static int graphics(GRAPHICS_FUNC_ARGS) +int Element_PCLN::graphics(GRAPHICS_FUNC_ARGS) + +{ + int lifemod = ((cpart->life>10?10:cpart->life)*10); + *colr += lifemod; + *colg += lifemod; + return 0; +} + + +Element_PCLN::~Element_PCLN() {} \ No newline at end of file diff --git a/src/elements/phot.cpp b/src/simulation/elements/PHOT.cpp similarity index 56% rename from src/elements/phot.cpp rename to src/simulation/elements/PHOT.cpp index 29d534b3b..a32c81f8f 100644 --- a/src/elements/phot.cpp +++ b/src/simulation/elements/PHOT.cpp @@ -1,6 +1,54 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_PHOT PT_PHOT 31 +Element_PHOT::Element_PHOT() +{ + Identifier = "DEFAULT_PT_PHOT"; + Name = "PHOT"; + Colour = PIXPACK(0xFFFFFF); + MenuVisible = 1; + MenuSection = SC_NUCLEAR; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 1.00f; + Loss = 1.00f; + Collision = -0.99f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = -1; + + Temperature = R_TEMP+900.0f+273.15f; + HeatConduct = 251; + Description = "Photons. Travel in straight lines."; + + State = ST_GAS; + Properties = TYPE_ENERGY|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_PHOT::update; + Graphics = &Element_PHOT::graphics; +} -int update_PHOT(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_PHOT static int update(UPDATE_FUNC_ARGS) +int Element_PHOT::update(UPDATE_FUNC_ARGS) + { int r, rt, rx, ry; float rr, rrr; parts[i].pavg[0] = x; @@ -9,7 +57,7 @@ int update_PHOT(UPDATE_FUNC_ARGS) { sim->kill_part(i); return 1; } - if (1>rand()%10) update_PYRO(UPDATE_FUNC_SUBCALL_ARGS); + if (1>rand()%10) Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS); for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) if (x+rx>=0 && y+ry>=0 && x+rxparts[i].ctype)%3)+2); - if ((sim->parts[i].tmp&0xFF) == 0 || count >= 2)//don't push if there is nothing there, max speed of 2 per frame - return; - x = (int)(sim->parts[i].x+0.5f); - y = (int)(sim->parts[i].y+0.5f); - if( !(sim->parts[i].tmp&0x200) ) - { - //normal random push - rndstore = rand(); - // RAND_MAX is at least 32767 on all platforms i.e. pow(8,5)-1 - // so can go 5 cycles without regenerating rndstore - for (q=0; q<3; q++)//try to push twice - { - rnd = rndstore&7; - rndstore = rndstore>>3; - rx = pos_1_rx[rnd]; - ry = pos_1_ry[rnd]; - if (x+rx>=0 && y+ry>=0 && x+rxpmap[y+ry][x+rx]; - if (!r) - continue; - else if ((r&0xFF)==PT_PIPE && sim->parts[r>>8].ctype!=notctype && (sim->parts[r>>8].tmp&0xFF)==0) - { - sim->parts[r>>8].tmp = (sim->parts[r>>8].tmp&~0xFF) | (sim->parts[i].tmp&0xFF); - sim->parts[r>>8].temp = sim->parts[i].temp; - sim->parts[r>>8].tmp2 = sim->parts[i].tmp2; - sim->parts[r>>8].pavg[0] = sim->parts[i].pavg[0]; - sim->parts[r>>8].pavg[1] = sim->parts[i].pavg[1]; - if (r>>8 > original) - sim->parts[r>>8].flags |= PFLAG_NORMALSPEED;//skip particle push, normalizes speed - sim->parts[i].tmp &= ~0xFF; - count++; - pushParticle(sim, r>>8,count,original); - } - } - } - } - else //predefined 1 pixel thick pipe movement - { - int coords = 7 - ((sim->parts[i].tmp>>10)&7); - r = sim->pmap[y+ pos_1_ry[coords]][x+ pos_1_rx[coords]]; - if (!r) - { - } - else if ((r&0xFF)==PT_PIPE && sim->parts[r>>8].ctype!=notctype && (sim->parts[r>>8].tmp&0xFF)==0) - { - sim->parts[r>>8].tmp = (sim->parts[r>>8].tmp&~0xFF) | (sim->parts[i].tmp&0xFF); - sim->parts[r>>8].temp = sim->parts[i].temp; - sim->parts[r>>8].tmp2 = sim->parts[i].tmp2; - sim->parts[r>>8].pavg[0] = sim->parts[i].pavg[0]; - sim->parts[r>>8].pavg[1] = sim->parts[i].pavg[1]; - if (r>>8 > original) - sim->parts[r>>8].flags |= PFLAG_NORMALSPEED;//skip particle push, normalizes speed - sim->parts[i].tmp &= ~0xFF; - count++; - pushParticle(sim, r>>8,count,original); - } - - - } - return; -} - -int update_PIPE(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_PIPE static int update(UPDATE_FUNC_ARGS) +int Element_PIPE::update(UPDATE_FUNC_ARGS) + { int r, rx, ry, np; int rnd, rndstore; if (parts[i].ctype>=2 && parts[i].ctype<=4) @@ -147,7 +129,7 @@ int update_PIPE(UPDATE_FUNC_ARGS) { } } //try eating particle at entrance - else if ((parts[i].tmp&0xFF) == 0 && (sim->ptypes[r&0xFF].falldown!= 0 || sim->ptypes[r&0xFF].state == ST_GAS)) + else if ((parts[i].tmp&0xFF) == 0 && (sim->elements[r&0xFF].Falldown!= 0 || sim->elements[r&0xFF].State == ST_GAS)) { if ((r&0xFF)==PT_SOAP) sim->detach(r>>8); @@ -158,7 +140,7 @@ int update_PIPE(UPDATE_FUNC_ARGS) { parts[i].pavg[1] = parts[r>>8].ctype; sim->kill_part(r>>8); } - else if ((parts[i].tmp&0xFF) == 0 && (r&0xFF)==PT_STOR && parts[r>>8].tmp && (sim->ptypes[parts[r>>8].tmp].falldown!= 0 || sim->ptypes[parts[r>>8].tmp].state == ST_GAS)) + else if ((parts[i].tmp&0xFF) == 0 && (r&0xFF)==PT_STOR && parts[r>>8].tmp && (sim->elements[parts[r>>8].tmp].Falldown!= 0 || sim->elements[parts[r>>8].tmp].State == ST_GAS)) { parts[i].tmp = parts[r>>8].tmp; parts[i].temp = parts[r>>8].temp; @@ -244,7 +226,11 @@ int update_PIPE(UPDATE_FUNC_ARGS) { return 0; } -int graphics_PIPE(GRAPHICS_FUNC_ARGS) + + +//#TPT-Directive ElementHeader Element_PIPE static int graphics(GRAPHICS_FUNC_ARGS) +int Element_PIPE::graphics(GRAPHICS_FUNC_ARGS) + { if ((cpart->tmp&0xFF)>0 && (cpart->tmp&0xFF)sim->ptypes[t].pcolors); - *colg = PIXR(ren->sim->ptypes[t].pcolors); - *colb = PIXR(ren->sim->ptypes[t].pcolors); - if (ren->sim->ptypes[t].graphics_func) + *colr = PIXR(ren->sim->elements[t].Colour); + *colg = PIXR(ren->sim->elements[t].Colour); + *colb = PIXR(ren->sim->elements[t].Colour); + if (ren->sim->elements[t].Graphics) { - (*(ren->sim->ptypes[t].graphics_func))(ren, &tpart, nx, ny, pixel_mode, cola, colr, colg, colb, firea, firer, fireg, fireb); + (*(ren->sim->elements[t].Graphics))(ren, &tpart, nx, ny, pixel_mode, cola, colr, colg, colb, firea, firer, fireg, fireb); } else { - graphics_DEFAULT(ren, &tpart, nx, ny, pixel_mode, cola, colr, colg, colb, firea, firer, fireg, fireb); + Element::defaultGraphics(ren, &tpart, nx, ny, pixel_mode, cola, colr, colg, colb, firea, firer, fireg, fireb); } } - //*colr = PIXR(ptypes[cpart->tmp&0xFF].pcolors); - //*colg = PIXG(ptypes[cpart->tmp&0xFF].pcolors); - //*colb = PIXB(ptypes[cpart->tmp&0xFF].pcolors); + //*colr = PIXR(elements[cpart->tmp&0xFF].pcolors); + //*colg = PIXG(elements[cpart->tmp&0xFF].pcolors); + //*colb = PIXB(elements[cpart->tmp&0xFF].pcolors); } else { @@ -332,3 +318,73 @@ int graphics_PIPE(GRAPHICS_FUNC_ARGS) } return 0; } + +//#TPT-Directive ElementHeader Element_PIPE static void pushParticle(Simulation * sim, int i, int count, int original) +void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original) +{ + int rndstore, rnd, rx, ry, r, x, y, np, q, notctype=(((sim->parts[i].ctype)%3)+2); + if ((sim->parts[i].tmp&0xFF) == 0 || count >= 2)//don't push if there is nothing there, max speed of 2 per frame + return; + x = (int)(sim->parts[i].x+0.5f); + y = (int)(sim->parts[i].y+0.5f); + if( !(sim->parts[i].tmp&0x200) ) + { + //normal random push + rndstore = rand(); + // RAND_MAX is at least 32767 on all platforms i.e. pow(8,5)-1 + // so can go 5 cycles without regenerating rndstore + for (q=0; q<3; q++)//try to push twice + { + rnd = rndstore&7; + rndstore = rndstore>>3; + rx = pos_1_rx[rnd]; + ry = pos_1_ry[rnd]; + if (x+rx>=0 && y+ry>=0 && x+rxpmap[y+ry][x+rx]; + if (!r) + continue; + else if ((r&0xFF)==PT_PIPE && sim->parts[r>>8].ctype!=notctype && (sim->parts[r>>8].tmp&0xFF)==0) + { + sim->parts[r>>8].tmp = (sim->parts[r>>8].tmp&~0xFF) | (sim->parts[i].tmp&0xFF); + sim->parts[r>>8].temp = sim->parts[i].temp; + sim->parts[r>>8].tmp2 = sim->parts[i].tmp2; + sim->parts[r>>8].pavg[0] = sim->parts[i].pavg[0]; + sim->parts[r>>8].pavg[1] = sim->parts[i].pavg[1]; + if (r>>8 > original) + sim->parts[r>>8].flags |= PFLAG_NORMALSPEED;//skip particle push, normalizes speed + sim->parts[i].tmp &= ~0xFF; + count++; + pushParticle(sim, r>>8,count,original); + } + } + } + } + else //predefined 1 pixel thick pipe movement + { + int coords = 7 - ((sim->parts[i].tmp>>10)&7); + r = sim->pmap[y+ pos_1_ry[coords]][x+ pos_1_rx[coords]]; + if (!r) + { + } + else if ((r&0xFF)==PT_PIPE && sim->parts[r>>8].ctype!=notctype && (sim->parts[r>>8].tmp&0xFF)==0) + { + sim->parts[r>>8].tmp = (sim->parts[r>>8].tmp&~0xFF) | (sim->parts[i].tmp&0xFF); + sim->parts[r>>8].temp = sim->parts[i].temp; + sim->parts[r>>8].tmp2 = sim->parts[i].tmp2; + sim->parts[r>>8].pavg[0] = sim->parts[i].pavg[0]; + sim->parts[r>>8].pavg[1] = sim->parts[i].pavg[1]; + if (r>>8 > original) + sim->parts[r>>8].flags |= PFLAG_NORMALSPEED;//skip particle push, normalizes speed + sim->parts[i].tmp &= ~0xFF; + count++; + pushParticle(sim, r>>8,count,original); + } + + + } + return; +} + + +Element_PIPE::~Element_PIPE() {} \ No newline at end of file diff --git a/src/simulation/elements/PLEX.cpp b/src/simulation/elements/PLEX.cpp new file mode 100644 index 000000000..ec5ad1779 --- /dev/null +++ b/src/simulation/elements/PLEX.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_PLEX PT_PLEX 11 +Element_PLEX::Element_PLEX() +{ + Identifier = "DEFAULT_PT_PLEX"; + Name = "C-4"; + Colour = PIXPACK(0xD080E0); + MenuVisible = 1; + MenuSection = SC_EXPLOSIVE; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 1000; + Explosive = 2; + Meltable = 50; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 88; + Description = "Solid. Pressure sensitive explosive."; + + State = ST_SOLID; + Properties = TYPE_SOLID | PROP_NEUTPENETRATE; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 673.0f; + HighTemperatureTransition = PT_FIRE; + + Update = NULL; + Graphics = NULL; +} + +Element_PLEX::~Element_PLEX() {} \ No newline at end of file diff --git a/src/elements/plnt.cpp b/src/simulation/elements/PLNT.cpp similarity index 51% rename from src/elements/plnt.cpp rename to src/simulation/elements/PLNT.cpp index ef7985f8f..17feda798 100644 --- a/src/elements/plnt.cpp +++ b/src/simulation/elements/PLNT.cpp @@ -1,6 +1,54 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_PLNT PT_PLNT 20 +Element_PLNT::Element_PLNT() +{ + Identifier = "DEFAULT_PT_PLNT"; + Name = "PLNT"; + Colour = PIXPACK(0x0CAC00); + MenuVisible = 1; + MenuSection = SC_SOLIDS; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.95f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 20; + Explosive = 0; + Meltable = 0; + Hardness = 10; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 65; + Description = "Plant, drinks water and grows."; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_NEUTPENETRATE|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 573.0f; + HighTemperatureTransition = PT_FIRE; + + Update = &Element_PLNT::update; + Graphics = NULL; +} -int update_PLNT(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_PLNT static int update(UPDATE_FUNC_ARGS) +int Element_PLNT::update(UPDATE_FUNC_ARGS) + { int r, rx, ry, np; for (rx=-2; rx<3; rx++) for (ry=-2; ry<3; ry++) @@ -53,3 +101,6 @@ int update_PLNT(UPDATE_FUNC_ARGS) { } return 0; } + + +Element_PLNT::~Element_PLNT() {} \ No newline at end of file diff --git a/src/simulation/elements/PLSM.cpp b/src/simulation/elements/PLSM.cpp new file mode 100644 index 000000000..4812b844d --- /dev/null +++ b/src/simulation/elements/PLSM.cpp @@ -0,0 +1,70 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_PLSM PT_PLSM 49 +Element_PLSM::Element_PLSM() +{ + Identifier = "DEFAULT_PT_PLSM"; + Name = "PLSM"; + Colour = PIXPACK(0xBB99FF); + MenuVisible = 1; + MenuSection = SC_GAS; + Enabled = 1; + + Advection = 0.9f; + AirDrag = 0.04f * CFDS; + AirLoss = 0.97f; + Loss = 0.20f; + Collision = 0.0f; + Gravity = -0.1f; + Diffusion = 0.30f; + HotAir = 0.001f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 1; + + Temperature = 10000.0f +273.15f; + HeatConduct = 5; + Description = "Plasma, extremely hot."; + + State = ST_NONE; + Properties = TYPE_GAS|PROP_LIFE_DEC|PROP_LIFE_KILL; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_FIRE::update; + Graphics = &Element_PLSM::graphics; +} + +//#TPT-Directive ElementHeader Element_PLSM static int graphics(GRAPHICS_FUNC_ARGS) +int Element_PLSM::graphics(GRAPHICS_FUNC_ARGS) + +{ + int caddress = restrict_flt(restrict_flt((float)cpart->life, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); + *colr = (unsigned char)ren->plasma_data[caddress]; + *colg = (unsigned char)ren->plasma_data[caddress+1]; + *colb = (unsigned char)ren->plasma_data[caddress+2]; + + *firea = 255; + *firer = *colr; + *fireg = *colg; + *fireb = *colb; + + *pixel_mode = PMODE_GLOW | PMODE_ADD; //Clear default, don't draw pixel + *pixel_mode |= FIRE_ADD; + //Returning 0 means dynamic, do not cache + return 0; +} + + +Element_PLSM::~Element_PLSM() {} \ No newline at end of file diff --git a/src/simulation/elements/PLUT.cpp b/src/simulation/elements/PLUT.cpp new file mode 100644 index 000000000..688ea35a3 --- /dev/null +++ b/src/simulation/elements/PLUT.cpp @@ -0,0 +1,60 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_PLUT PT_PLUT 19 +Element_PLUT::Element_PLUT() +{ + Identifier = "DEFAULT_PT_PLUT"; + Name = "PLUT"; + Colour = PIXPACK(0x407020); + MenuVisible = 1; + MenuSection = SC_NUCLEAR; + Enabled = 1; + + Advection = 0.4f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.99f; + Loss = 0.95f; + Collision = 0.0f; + Gravity = 0.4f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 90; + + Temperature = R_TEMP+4.0f +273.15f; + HeatConduct = 251; + Description = "Heavy particles. Fissile. Generates neutrons under pressure."; + + State = ST_SOLID; + Properties = TYPE_PART|PROP_NEUTPENETRATE|PROP_RADIOACTIVE; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_PLUT::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_PLUT static int update(UPDATE_FUNC_ARGS) +int Element_PLUT::update(UPDATE_FUNC_ARGS) + { + if (1>rand()%100 && ((int)(5.0f*sim->pv[y/CELL][x/CELL]))>(rand()%1000)) + { + sim->create_part(i, x, y, PT_NEUT); + } + return 0; +} + + +Element_PLUT::~Element_PLUT() {} \ No newline at end of file diff --git a/src/simulation/elements/PQRT.cpp b/src/simulation/elements/PQRT.cpp new file mode 100644 index 000000000..8c5194744 --- /dev/null +++ b/src/simulation/elements/PQRT.cpp @@ -0,0 +1,168 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_PQRT PT_PQRT 133 +Element_PQRT::Element_PQRT() +{ + Identifier = "DEFAULT_PT_PQRT"; + Name = "PQRT"; + Colour = PIXPACK(0x88BBBB); + MenuVisible = 1; + MenuSection = SC_POWDERS; + Enabled = 1; + + Advection = 0.4f; + AirDrag = 0.04f * CFDS; + AirLoss = 0.94f; + Loss = 0.95f; + Collision = -0.1f; + Gravity = 0.27f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 90; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 3; + Description = "Broken quartz."; + + State = ST_SOLID; + Properties = TYPE_PART| PROP_HOT_GLOW; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 2573.15f; + HighTemperatureTransition = PT_LAVA; + + Update = &Element_PQRT::update; + Graphics = &Element_PQRT::graphics; +} + +//#TPT-Directive ElementHeader Element_PQRT static int update(UPDATE_FUNC_ARGS) +int Element_PQRT::update(UPDATE_FUNC_ARGS) + { + int r, tmp, trade, rx, ry, np, t; + t = parts[i].type; + if (t == PT_QRTZ) + { + parts[i].pavg[0] = parts[i].pavg[1]; + parts[i].pavg[1] = sim->pv[y/CELL][x/CELL]; + if (parts[i].pavg[1]-parts[i].pavg[0] > 0.05*(parts[i].temp/3) || parts[i].pavg[1]-parts[i].pavg[0] < -0.05*(parts[i].temp/3)) + { + sim->part_change_type(i,x,y,PT_PQRT); + } + } + // absorb SLTW + if (parts[i].ctype!=-1) + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rxrand()%2500)) + { + sim->kill_part(r>>8); + parts[i].ctype ++; + } + } + // grow if absorbed SLTW + if (parts[i].ctype>0) + { + for ( trade = 0; trade<5; trade ++) + { + rx = rand()%3-1; + ry = rand()%3-1; + if (x+rx>=0 && y+ry>0 && x+rxcreate_part(-1,x+rx,y+ry,PT_QRTZ); + if (np>-1) + { + parts[np].tmp = parts[i].tmp; + parts[i].ctype--; + if (5>rand()%10) + { + parts[np].ctype=-1;//dead qrtz + } + else if (!parts[i].ctype && 1>rand()%15) + { + parts[i].ctype=-1; + } + + break; + } + } + } + } + } + // diffuse absorbed SLTW + if (parts[i].ctype>0) + { + for ( trade = 0; trade<9; trade ++) + { + rx = rand()%5-2; + ry = rand()%5-2; + if (x+rx>=0 && y+ry>0 && x+rxparts[r>>8].ctype) && parts[r>>8].ctype>=0 )//diffusion + { + tmp = parts[i].ctype - parts[r>>8].ctype; + if (tmp ==1) + { + parts[r>>8].ctype ++; + parts[i].ctype --; + break; + } + if (tmp>0) + { + parts[r>>8].ctype += tmp/2; + parts[i].ctype -= tmp/2; + break; + } + } + } + } + } + return 0; +} + + +//#TPT-Directive ElementHeader Element_PQRT static int graphics(GRAPHICS_FUNC_ARGS) +int Element_PQRT::graphics(GRAPHICS_FUNC_ARGS) + //QRTZ and PQRT +{ + int t = cpart->type, z = cpart->tmp - 5;//speckles! + /*if (cpart->temp>(ptransitions[t].thv-800.0f))//hotglow for quartz + { + float frequency = 3.1415/(2*ptransitions[t].thv-(ptransitions[t].thv-800.0f)); + int q = (cpart->temp>ptransitions[t].thv)?ptransitions[t].thv-(ptransitions[t].thv-800.0f):cpart->temp-(ptransitions[t].thv-800.0f); + *colr += sin(frequency*q) * 226 + (z * 16); + *colg += sin(frequency*q*4.55 +3.14) * 34 + (z * 16); + *colb += sin(frequency*q*2.22 +3.14) * 64 + (z * 16); + } + else*/ + { + *colr += z * 16; + *colg += z * 16; + *colb += z * 16; + } + return 0; +} + + +Element_PQRT::~Element_PQRT() {} \ No newline at end of file diff --git a/src/simulation/elements/PRTI.cpp b/src/simulation/elements/PRTI.cpp new file mode 100644 index 000000000..4d13bd1fd --- /dev/null +++ b/src/simulation/elements/PRTI.cpp @@ -0,0 +1,139 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_PRTI PT_PRTI 109 +Element_PRTI::Element_PRTI() +{ + Identifier = "DEFAULT_PT_PRTI"; + Name = "PRTI"; + Colour = PIXPACK(0xEB5917); + MenuVisible = 1; + MenuSection = SC_SPECIAL; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = -0.005f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 0; + Description = "Portal IN. Things go in here, now with channels (same as WIFI)"; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_PRTI::update; + Graphics = &Element_PRTI::graphics; +} + +//#TPT-Directive ElementHeader Element_PRTI static int update(UPDATE_FUNC_ARGS) +int Element_PRTI::update(UPDATE_FUNC_ARGS) + { + int r, nnx, rx, ry, fe = 0; + int count =0; + parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1); + if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1; + else if (parts[i].tmp<0) parts[i].tmp = 0; + for (count=0; count<8; count++) + { + rx = sim->portal_rx[count]; + ry = sim->portal_ry[count]; + if (x+rx>=0 && y+ry>0 && x+rxelements[r&0xFF].Falldown== 0 && sim->elements[r&0xFF].State != ST_GAS && (r&0xFF)!=PT_SPRK)) + { + r = sim->photons[y+ry][x+rx]; + if (!r || (r&0xFF)==PT_PRTI || (r&0xFF)==PT_PRTO || (sim->elements[r&0xFF].Falldown== 0 && sim->elements[r&0xFF].State != ST_GAS && (r&0xFF)!=PT_SPRK)) + continue; + } + + if ((r&0xFF)==PT_STKM || (r&0xFF)==PT_STKM2 || (r&0xFF)==PT_FIGH) + continue;// Handling these is a bit more complicated, and is done in STKM_interact() + + if ((r&0xFF) == PT_SOAP) + sim->detach(r>>8); + + for ( nnx=0; nnx<80; nnx++) + if (!sim->portalp[parts[i].tmp][count][nnx].type) + { + sim->portalp[parts[i].tmp][count][nnx] = parts[r>>8]; + if ((r&0xFF)==PT_SPRK) + sim->part_change_type(r>>8,x+rx,y+ry,parts[r>>8].ctype); + else + sim->kill_part(r>>8); + fe = 1; + break; + } + } + } + + + if (fe) { + int orbd[4] = {0, 0, 0, 0}; //Orbital distances + int orbl[4] = {0, 0, 0, 0}; //Orbital locations + if (!sim->parts[i].life) parts[i].life = rand()*rand()*rand(); + if (!sim->parts[i].ctype) parts[i].ctype = rand()*rand()*rand(); + sim->orbitalparts_get(parts[i].life, parts[i].ctype, orbd, orbl); + for (r = 0; r < 4; r++) { + if (orbd[r]>1) { + orbd[r] -= 12; + if (orbd[r]<1) { + orbd[r] = (rand()%128)+128; + orbl[r] = rand()%255; + } else { + orbl[r] += 2; + orbl[r] = orbl[r]%255; + } + } else { + orbd[r] = (rand()%128)+128; + orbl[r] = rand()%255; + } + } + sim->orbitalparts_set(&parts[i].life, &parts[i].ctype, orbd, orbl); + } else { + parts[i].life = 0; + parts[i].ctype = 0; + } + return 0; +} + + +//#TPT-Directive ElementHeader Element_PRTI static int graphics(GRAPHICS_FUNC_ARGS) +int Element_PRTI::graphics(GRAPHICS_FUNC_ARGS) + +{ + *firea = 8; + *firer = 255; + *fireg = 0; + *fireb = 0; + *pixel_mode |= EFFECT_GRAVIN; + *pixel_mode &= ~PMODE; + *pixel_mode |= PMODE_ADD; + return 1; +} + + +Element_PRTI::~Element_PRTI() {} \ No newline at end of file diff --git a/src/elements/prto.cpp b/src/simulation/elements/PRTO.cpp similarity index 69% rename from src/elements/prto.cpp rename to src/simulation/elements/PRTO.cpp index 88a292705..788e7d1e6 100644 --- a/src/elements/prto.cpp +++ b/src/simulation/elements/PRTO.cpp @@ -1,12 +1,54 @@ -#include "simulation/Element.h" -/*these are the count values of where the particle gets stored, depending on where it came from - 0 1 2 - 7 . 3 - 6 5 4 - PRTO does (count+4)%8, so that it will come out at the opposite place to where it came in - PRTO does +/-1 to the count, so it doesn't jam as easily -*/ -int update_PRTO(UPDATE_FUNC_ARGS) { +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_PRTO PT_PRTO 110 +Element_PRTO::Element_PRTO() +{ + Identifier = "DEFAULT_PT_PRTO"; + Name = "PRTO"; + Colour = PIXPACK(0x0020EB); + MenuVisible = 1; + MenuSection = SC_SPECIAL; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.005f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 0; + Description = "Portal OUT. Things come out here, now with channels (same as WIFI)"; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_PRTO::update; + Graphics = &Element_PRTO::graphics; +} + +//#TPT-Directive ElementHeader Element_PRTO static int update(UPDATE_FUNC_ARGS) +int Element_PRTO::update(UPDATE_FUNC_ARGS) + { int r, nnx, rx, ry, np, fe = 0; int count = 0; parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1); @@ -114,3 +156,21 @@ int update_PRTO(UPDATE_FUNC_ARGS) { } return 0; } + + +//#TPT-Directive ElementHeader Element_PRTO static int graphics(GRAPHICS_FUNC_ARGS) +int Element_PRTO::graphics(GRAPHICS_FUNC_ARGS) + +{ + *firea = 8; + *firer = 0; + *fireg = 0; + *fireb = 255; + *pixel_mode |= EFFECT_GRAVOUT; + *pixel_mode &= ~PMODE; + *pixel_mode |= PMODE_ADD; + return 1; +} + + +Element_PRTO::~Element_PRTO() {} \ No newline at end of file diff --git a/src/simulation/elements/PSCN.cpp b/src/simulation/elements/PSCN.cpp new file mode 100644 index 000000000..54d64a15c --- /dev/null +++ b/src/simulation/elements/PSCN.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_PSCN PT_PSCN 35 +Element_PSCN::Element_PSCN() +{ + Identifier = "DEFAULT_PT_PSCN"; + Name = "PSCN"; + Colour = PIXPACK(0x805050); + MenuVisible = 1; + MenuSection = SC_ELEC; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "P-Type Silicon, Will transfer current to any conductor."; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 1687.0f; + HighTemperatureTransition = PT_LAVA; + + Update = NULL; + Graphics = NULL; +} + +Element_PSCN::~Element_PSCN() {} \ No newline at end of file diff --git a/src/simulation/elements/PSTE.cpp b/src/simulation/elements/PSTE.cpp new file mode 100644 index 000000000..50ff1d2f0 --- /dev/null +++ b/src/simulation/elements/PSTE.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_PSTE PT_PSTE 111 +Element_PSTE::Element_PSTE() +{ + Identifier = "DEFAULT_PT_PSTE"; + Name = "PSTE"; + Colour = PIXPACK(0xAA99AA); + MenuVisible = 1; + MenuSection = SC_LIQUID; + Enabled = 1; + + Advection = 0.6f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.98f; + Loss = 0.95f; + Collision = 0.0f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 2; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 20; + + Weight = 31; + + Temperature = R_TEMP-2.0f +273.15f; + HeatConduct = 29; + Description = "Colloid, Hardens under pressure"; + + State = ST_LIQUID; + Properties = TYPE_LIQUID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = 0.5f; + HighPressureTransition = PT_PSTS; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 747.0f; + HighTemperatureTransition = PT_BRCK; + + Update = NULL; + Graphics = NULL; +} + +Element_PSTE::~Element_PSTE() {} \ No newline at end of file diff --git a/src/simulation/elements/PSTS.cpp b/src/simulation/elements/PSTS.cpp new file mode 100644 index 000000000..cdd5cad40 --- /dev/null +++ b/src/simulation/elements/PSTS.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_PSTS PT_PSTS 112 +Element_PSTS::Element_PSTS() +{ + Identifier = "DEFAULT_PT_PSTS"; + Name = "PSTS"; + Colour = PIXPACK(0x776677); + MenuVisible = 0; + MenuSection = SC_CRACKER; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.00f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 20; + + Weight = 100; + + Temperature = R_TEMP-2.0f +273.15f; + HeatConduct = 29; + Description = "Solid form of PSTE, temporary"; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = 0.5f; + LowPressureTransition = PT_PSTE; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = NULL; + Graphics = NULL; +} + +Element_PSTS::~Element_PSTS() {} \ No newline at end of file diff --git a/src/simulation/elements/PTCT.cpp b/src/simulation/elements/PTCT.cpp new file mode 100644 index 000000000..9119e1a3c --- /dev/null +++ b/src/simulation/elements/PTCT.cpp @@ -0,0 +1,58 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_PTCT PT_PTCT 46 +Element_PTCT::Element_PTCT() +{ + Identifier = "DEFAULT_PT_PTCT"; + Name = "PTCT"; + Colour = PIXPACK(0x405050); + MenuVisible = 1; + MenuSection = SC_ELEC; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Semi-conductor. Only conducts electricity when cold (Less than 100C)"; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 1414.0f; + HighTemperatureTransition = PT_LAVA; + + Update = &Element_PTCT::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_PTCT static int update(UPDATE_FUNC_ARGS) +int Element_PTCT::update(UPDATE_FUNC_ARGS) + { + if (parts[i].temp>295.0f) + parts[i].temp -= 2.5f; + return 0; +} + + +Element_PTCT::~Element_PTCT() {} \ No newline at end of file diff --git a/src/simulation/elements/PUMP.cpp b/src/simulation/elements/PUMP.cpp new file mode 100644 index 000000000..17b474921 --- /dev/null +++ b/src/simulation/elements/PUMP.cpp @@ -0,0 +1,102 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_PUMP PT_PUMP 97 +Element_PUMP::Element_PUMP() +{ + Identifier = "DEFAULT_PT_PUMP"; + Name = "PUMP"; + Colour = PIXPACK(0x0A0A3B); + MenuVisible = 1; + MenuSection = SC_POWERED; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.95f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 10; + + Weight = 100; + + Temperature = 273.15f; + HeatConduct = 0; + Description = "Changes pressure to its temp when activated. (use HEAT/COOL)."; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_PUMP::update; + Graphics = &Element_PUMP::graphics; +} + +//#TPT-Directive ElementHeader Element_PUMP static int update(UPDATE_FUNC_ARGS) +int Element_PUMP::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + if (parts[i].life>0 && parts[i].life!=10) + parts[i].life--; + if (parts[i].life==10) + { + if (parts[i].temp>=256.0+273.15) + parts[i].temp=256.0+273.15; + if (parts[i].temp<= -256.0+273.15) + parts[i].temp = -256.0+273.15; + + if (sim->pv[y/CELL][x/CELL]<(parts[i].temp-273.15)) + sim->pv[y/CELL][x/CELL] += 0.1f*((parts[i].temp-273.15)-sim->pv[y/CELL][x/CELL]); + if (y+CELLpv[y/CELL+1][x/CELL]<(parts[i].temp-273.15)) + sim->pv[y/CELL+1][x/CELL] += 0.1f*((parts[i].temp-273.15)-sim->pv[y/CELL+1][x/CELL]); + if (x+CELLpv[y/CELL][x/CELL+1] += 0.1f*((parts[i].temp-273.15)-sim->pv[y/CELL][x/CELL+1]); + if (y+CELLpv[y/CELL+1][x/CELL+1] += 0.1f*((parts[i].temp-273.15)-sim->pv[y/CELL+1][x/CELL+1]); + } + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8].life<10&&parts[r>>8].life>0) + parts[i].life = 9; + else if (parts[r>>8].life==0) + parts[r>>8].life = 10; + } + } + } + return 0; +} + + +//#TPT-Directive ElementHeader Element_PUMP static int graphics(GRAPHICS_FUNC_ARGS) +int Element_PUMP::graphics(GRAPHICS_FUNC_ARGS) + +{ + int lifemod = ((cpart->life>10?10:cpart->life)*19); + *colb += lifemod; + return 0; +} + + +Element_PUMP::~Element_PUMP() {} \ No newline at end of file diff --git a/src/simulation/elements/PVOD.cpp b/src/simulation/elements/PVOD.cpp new file mode 100644 index 000000000..267c7bdd6 --- /dev/null +++ b/src/simulation/elements/PVOD.cpp @@ -0,0 +1,91 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_PVOD PT_PVOD 84 +Element_PVOD::Element_PVOD() +{ + Identifier = "DEFAULT_PT_PVOD"; + Name = "PVOD"; + Colour = PIXPACK(0x792020); + MenuVisible = 1; + MenuSection = SC_POWERED; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Solid. When activated, destroys entering particles"; + + State = ST_NONE; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_PVOD::update; + Graphics = &Element_PVOD::graphics; +} + +//#TPT-Directive ElementHeader Element_PVOD static int update(UPDATE_FUNC_ARGS) +int Element_PVOD::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + if (parts[i].life>0 && parts[i].life!=10) + parts[i].life--; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8].life>0 && parts[r>>8].life<4) + { + if (parts[r>>8].ctype==PT_PSCN) + parts[i].life = 10; + else if (parts[r>>8].ctype==PT_NSCN) + parts[i].life = 9; + } + if ((r&0xFF)==PT_PVOD) + { + if (parts[i].life==10&&parts[r>>8].life<10&&parts[r>>8].life>0) + parts[i].life = 9; + else if (parts[i].life==0&&parts[r>>8].life==10) + parts[i].life = 10; + } + } + return 0; +} + + +//#TPT-Directive ElementHeader Element_PVOD static int graphics(GRAPHICS_FUNC_ARGS) +int Element_PVOD::graphics(GRAPHICS_FUNC_ARGS) + +{ + int lifemod = ((cpart->life>10?10:cpart->life)*16); + *colr += lifemod; + return 0; +} + + +Element_PVOD::~Element_PVOD() {} \ No newline at end of file diff --git a/src/simulation/elements/QRTZ.cpp b/src/simulation/elements/QRTZ.cpp new file mode 100644 index 000000000..20aa97dce --- /dev/null +++ b/src/simulation/elements/QRTZ.cpp @@ -0,0 +1,168 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_QRTZ PT_QRTZ 132 +Element_QRTZ::Element_QRTZ() +{ + Identifier = "DEFAULT_PT_QRTZ"; + Name = "QRTZ"; + Colour = PIXPACK(0xAADDDD); + MenuVisible = 1; + MenuSection = SC_SOLIDS; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 3; + Description = "Quartz, breakable mineral. Conducts but becomes brittle at lower temperatures."; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_HOT_GLOW|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 2573.15f; + HighTemperatureTransition = PT_LAVA; + + Update = &Element_QRTZ::update; + Graphics = &Element_QRTZ::graphics; +} + +//#TPT-Directive ElementHeader Element_QRTZ static int update(UPDATE_FUNC_ARGS) +int Element_QRTZ::update(UPDATE_FUNC_ARGS) + { + int r, tmp, trade, rx, ry, np, t; + t = parts[i].type; + if (t == PT_QRTZ) + { + parts[i].pavg[0] = parts[i].pavg[1]; + parts[i].pavg[1] = sim->pv[y/CELL][x/CELL]; + if (parts[i].pavg[1]-parts[i].pavg[0] > 0.05*(parts[i].temp/3) || parts[i].pavg[1]-parts[i].pavg[0] < -0.05*(parts[i].temp/3)) + { + sim->part_change_type(i,x,y,PT_PQRT); + } + } + // absorb SLTW + if (parts[i].ctype!=-1) + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rxrand()%2500)) + { + sim->kill_part(r>>8); + parts[i].ctype ++; + } + } + // grow if absorbed SLTW + if (parts[i].ctype>0) + { + for ( trade = 0; trade<5; trade ++) + { + rx = rand()%3-1; + ry = rand()%3-1; + if (x+rx>=0 && y+ry>0 && x+rxcreate_part(-1,x+rx,y+ry,PT_QRTZ); + if (np>-1) + { + parts[np].tmp = parts[i].tmp; + parts[i].ctype--; + if (5>rand()%10) + { + parts[np].ctype=-1;//dead qrtz + } + else if (!parts[i].ctype && 1>rand()%15) + { + parts[i].ctype=-1; + } + + break; + } + } + } + } + } + // diffuse absorbed SLTW + if (parts[i].ctype>0) + { + for ( trade = 0; trade<9; trade ++) + { + rx = rand()%5-2; + ry = rand()%5-2; + if (x+rx>=0 && y+ry>0 && x+rxparts[r>>8].ctype) && parts[r>>8].ctype>=0 )//diffusion + { + tmp = parts[i].ctype - parts[r>>8].ctype; + if (tmp ==1) + { + parts[r>>8].ctype ++; + parts[i].ctype --; + break; + } + if (tmp>0) + { + parts[r>>8].ctype += tmp/2; + parts[i].ctype -= tmp/2; + break; + } + } + } + } + } + return 0; +} + + +//#TPT-Directive ElementHeader Element_QRTZ static int graphics(GRAPHICS_FUNC_ARGS) +int Element_QRTZ::graphics(GRAPHICS_FUNC_ARGS) + //QRTZ and PQRT +{ + int t = cpart->type, z = cpart->tmp - 5;//speckles! + /*if (cpart->temp>(ptransitions[t].thv-800.0f))//hotglow for quartz + { + float frequency = 3.1415/(2*ptransitions[t].thv-(ptransitions[t].thv-800.0f)); + int q = (cpart->temp>ptransitions[t].thv)?ptransitions[t].thv-(ptransitions[t].thv-800.0f):cpart->temp-(ptransitions[t].thv-800.0f); + *colr += sin(frequency*q) * 226 + (z * 16); + *colg += sin(frequency*q*4.55 +3.14) * 34 + (z * 16); + *colb += sin(frequency*q*2.22 +3.14) * 64 + (z * 16); + } + else*/ + { + *colr += z * 16; + *colg += z * 16; + *colb += z * 16; + } + return 0; +} + + +Element_QRTZ::~Element_QRTZ() {} \ No newline at end of file diff --git a/src/simulation/elements/RBDM.cpp b/src/simulation/elements/RBDM.cpp new file mode 100644 index 000000000..1b85a1526 --- /dev/null +++ b/src/simulation/elements/RBDM.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_RBDM PT_RBDM 41 +Element_RBDM::Element_RBDM() +{ + Identifier = "DEFAULT_PT_RBDM"; + Name = "RBDM"; + Colour = PIXPACK(0xCCCCCC); + MenuVisible = 1; + MenuSection = SC_EXPLOSIVE; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 1000; + Explosive = 1; + Meltable = 50; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 240; + Description = "Rubidium, explosive, especially on contact with water, low melting point"; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 312.0f; + HighTemperatureTransition = PT_LRBD; + + Update = NULL; + Graphics = NULL; +} + +Element_RBDM::~Element_RBDM() {} \ No newline at end of file diff --git a/src/simulation/elements/REPL.cpp b/src/simulation/elements/REPL.cpp new file mode 100644 index 000000000..e7eae1470 --- /dev/null +++ b/src/simulation/elements/REPL.cpp @@ -0,0 +1,73 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_REPL PT_REPL 160 +Element_REPL::Element_REPL() +{ + Identifier = "DEFAULT_PT_REPL"; + Name = "RPEL"; + Colour = PIXPACK(0x99CC00); + MenuVisible = 1; + MenuSection = SC_FORCE; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 100; + + Temperature = 20.0f+0.0f +273.15f; + HeatConduct = 0; + Description = "Repel or attract particles based on temp value."; + + State = ST_NONE; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_REPL::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_REPL static int update(UPDATE_FUNC_ARGS) +int Element_REPL::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry, ri; + for(ri = 0; ri <= 10; ri++) + { + rx = (rand()%20)-10; + ry = (rand()%20)-10; + if (x+rx>=0 && y+ry>0 && x+rxphotons[y+ry][x+rx]; + + if (r && !(sim->elements[r&0xFF].Properties & TYPE_SOLID)){ + parts[r>>8].vx += isign(rx)*((parts[i].temp-273.15)/10.0f); + parts[r>>8].vy += isign(ry)*((parts[i].temp-273.15)/10.0f); + } + } + } + return 0; +} + + +Element_REPL::~Element_REPL() {} \ No newline at end of file diff --git a/src/simulation/elements/RIME.cpp b/src/simulation/elements/RIME.cpp new file mode 100644 index 000000000..e9938628f --- /dev/null +++ b/src/simulation/elements/RIME.cpp @@ -0,0 +1,77 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_RIME PT_RIME 91 +Element_RIME::Element_RIME() +{ + Identifier = "DEFAULT_PT_RIME"; + Name = "RIME"; + Colour = PIXPACK(0xCCCCCC); + MenuVisible = 1; + MenuSection = SC_CRACKER2; + Enabled = 1; + + Advection = 0.00f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.00f; + Loss = 1.00f; + Collision = 0.00f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 30; + + Weight = 100; + + Temperature = 243.15f; + HeatConduct = 100; + Description = "Not quite Ice"; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 273.15f; + HighTemperatureTransition = PT_WATR; + + Update = &Element_RIME::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_RIME static int update(UPDATE_FUNC_ARGS) +int Element_RIME::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + parts[i].vx = 0; + parts[i].vy = 0; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rxpart_change_type(i,x,y,PT_FOG); + parts[i].life = rand()%50 + 60; + } + else if ((r&0xFF)==PT_FOG&&parts[r>>8].life>0) + { + sim->part_change_type(i,x,y,PT_FOG); + parts[i].life = parts[r>>8].life; + } + } + return 0; +} + + +Element_RIME::~Element_RIME() {} \ No newline at end of file diff --git a/src/simulation/elements/SALT.cpp b/src/simulation/elements/SALT.cpp new file mode 100644 index 000000000..5042c6597 --- /dev/null +++ b/src/simulation/elements/SALT.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_SALT PT_SALT 26 +Element_SALT::Element_SALT() +{ + Identifier = "DEFAULT_PT_SALT"; + Name = "SALT"; + Colour = PIXPACK(0xFFFFFF); + MenuVisible = 1; + MenuSection = SC_POWDERS; + Enabled = 1; + + Advection = 0.4f; + AirDrag = 0.04f * CFDS; + AirLoss = 0.94f; + Loss = 0.95f; + Collision = -0.1f; + Gravity = 0.3f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 5; + Hardness = 1; + + Weight = 75; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 110; + Description = "Salt, dissolves in water."; + + State = ST_SOLID; + Properties = TYPE_PART; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 1173.0f; + HighTemperatureTransition = PT_LAVA; + + Update = NULL; + Graphics = NULL; +} + +Element_SALT::~Element_SALT() {} \ No newline at end of file diff --git a/src/simulation/elements/SAND.cpp b/src/simulation/elements/SAND.cpp new file mode 100644 index 000000000..c791a0ada --- /dev/null +++ b/src/simulation/elements/SAND.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_SAND PT_SAND 44 +Element_SAND::Element_SAND() +{ + Identifier = "DEFAULT_PT_SAND"; + Name = "SAND"; + Colour = PIXPACK(0xFFD090); + MenuVisible = 1; + MenuSection = SC_POWDERS; + Enabled = 1; + + Advection = 0.4f; + AirDrag = 0.04f * CFDS; + AirLoss = 0.94f; + Loss = 0.95f; + Collision = -0.1f; + Gravity = 0.3f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 5; + Hardness = 1; + + Weight = 90; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 150; + Description = "Sand, Heavy particles. Meltable."; + + State = ST_SOLID; + Properties = TYPE_PART; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 1973.0f; + HighTemperatureTransition = PT_LAVA; + + Update = NULL; + Graphics = NULL; +} + +Element_SAND::~Element_SAND() {} \ No newline at end of file diff --git a/src/simulation/elements/SHLD1.cpp b/src/simulation/elements/SHLD1.cpp new file mode 100644 index 000000000..2d48f9d09 --- /dev/null +++ b/src/simulation/elements/SHLD1.cpp @@ -0,0 +1,88 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_SHLD1 PT_SHLD1 119 +Element_SHLD1::Element_SHLD1() +{ + Identifier = "DEFAULT_PT_SHLD1"; + Name = "SHLD"; + Colour = PIXPACK(0xAAAAAA); + MenuVisible = 1; + MenuSection = SC_SOLIDS; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 1.00f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 0; + Description = "Shield, spark it to grow"; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = 7.0f; + HighPressureTransition = PT_NONE; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_SHLD1::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_SHLD1 static int update(UPDATE_FUNC_ARGS) +int Element_SHLD1::update(UPDATE_FUNC_ARGS) + { + int r, nnx, nny, rx, ry; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rxrand()%200&&parts[i].life==0) + { + sim->part_change_type(i,x,y,PT_SHLD2); + parts[i].life = 7; + } + for ( nnx=-1; nnx<2; nnx++) + for ( nny=-1; nny<2; nny++) + { + if (!pmap[y+ry+nny][x+rx+nnx]) + { + sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1); + //parts[pmap[y+ny+nny][x+nx+nnx]>>8].life=7; + } + } + } + else if ((r&0xFF)==PT_SHLD3&&4>rand()%10) + { + sim->part_change_type(i,x,y,PT_SHLD2); + parts[i].life = 7; + } + } + return 0; +} + + + +Element_SHLD1::~Element_SHLD1() {} \ No newline at end of file diff --git a/src/simulation/elements/SHLD2.cpp b/src/simulation/elements/SHLD2.cpp new file mode 100644 index 000000000..cdb72e930 --- /dev/null +++ b/src/simulation/elements/SHLD2.cpp @@ -0,0 +1,91 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_SHLD2 PT_SHLD2 120 +Element_SHLD2::Element_SHLD2() +{ + Identifier = "DEFAULT_PT_SHLD2"; + Name = "SHD2"; + Colour = PIXPACK(0x777777); + MenuVisible = 0; + MenuSection = SC_CRACKER2; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 1.00f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 0; + Description = "Shield lvl 2"; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = 15.0f; + HighPressureTransition = PT_NONE; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_SHLD2::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_SHLD2 static int update(UPDATE_FUNC_ARGS) +int Element_SHLD2::update(UPDATE_FUNC_ARGS) + { + int r, nnx, nny, rx, ry, np; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rx0) + sim->create_part(-1,x+rx,y+ry,PT_SHLD1); + if (!r) + continue; + else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) + { + if (25>rand()%200&&parts[i].life==0) + { + sim->part_change_type(i,x,y,PT_SHLD3); + parts[i].life = 7; + } + for ( nnx=-1; nnx<2; nnx++) + for ( nny=-1; nny<2; nny++) + { + if (!pmap[y+ry+nny][x+rx+nnx]) + { + np = sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1); + if (np<0) continue; + parts[np].life=7; + } + } + } + else if ((r&0xFF)==PT_SHLD4&&4>rand()%10) + { + sim->part_change_type(i,x,y,PT_SHLD3); + parts[i].life = 7; + } + } + return 0; +} + + + +Element_SHLD2::~Element_SHLD2() {} \ No newline at end of file diff --git a/src/simulation/elements/SHLD3.cpp b/src/simulation/elements/SHLD3.cpp new file mode 100644 index 000000000..c90a1d8e4 --- /dev/null +++ b/src/simulation/elements/SHLD3.cpp @@ -0,0 +1,101 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_SHLD3 PT_SHLD3 121 +Element_SHLD3::Element_SHLD3() +{ + Identifier = "DEFAULT_PT_SHLD3"; + Name = "SHD3"; + Colour = PIXPACK(0x444444); + MenuVisible = 0; + MenuSection = SC_CRACKER2; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 1.00f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 0; + Description = "Shield lvl 3"; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = 25.0f; + HighPressureTransition = PT_NONE; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_SHLD3::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_SHLD3 static int update(UPDATE_FUNC_ARGS) +int Element_SHLD3::update(UPDATE_FUNC_ARGS) + { + int r, nnx, nny, rx, ry, np; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rxrand()%2500) + { + np = sim->create_part(-1,x+rx,y+ry,PT_SHLD1); + if (np<0) continue; + parts[np].life=7; + sim->part_change_type(i,x,y,PT_SHLD2); + } + else + continue; + + } + if ((r&0xFF)==PT_SHLD1 && parts[i].life>3) + { + sim->part_change_type(r>>8,x+rx,y+ry,PT_SHLD2); + parts[r>>8].life=7; + } + else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) + { + if (18>rand()%3000&&parts[i].life==0) + { + sim->part_change_type(i,x,y,PT_SHLD4); + parts[i].life = 7; + } + for ( nnx=-1; nnx<2; nnx++) + for ( nny=-1; nny<2; nny++) + { + + if (!pmap[y+ry+nny][x+rx+nnx]) + { + np = sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1); + if (np<0) continue; + parts[np].life=7; + } + } + } + } + return 0; +} + + + +Element_SHLD3::~Element_SHLD3() {} \ No newline at end of file diff --git a/src/simulation/elements/SHLD4.cpp b/src/simulation/elements/SHLD4.cpp new file mode 100644 index 000000000..0aa38e852 --- /dev/null +++ b/src/simulation/elements/SHLD4.cpp @@ -0,0 +1,92 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_SHLD4 PT_SHLD4 122 +Element_SHLD4::Element_SHLD4() +{ + Identifier = "DEFAULT_PT_SHLD4"; + Name = "SHD4"; + Colour = PIXPACK(0x212121); + MenuVisible = 0; + MenuSection = SC_CRACKER2; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 1.00f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 0; + Description = "Shield lvl 4"; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = 40.0f; + HighPressureTransition = PT_NONE; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_SHLD4::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_SHLD4 static int update(UPDATE_FUNC_ARGS) +int Element_SHLD4::update(UPDATE_FUNC_ARGS) + { + int r, nnx, nny, rx, ry, np; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rxrand()%5500) + { + np = sim->create_part(-1,x+rx,y+ry,PT_SHLD1); + if (np<0) continue; + parts[np].life=7; + sim->part_change_type(i,x,y,PT_SHLD2); + } + else + continue; + + } + if ((r&0xFF)==PT_SHLD2 && parts[i].life>3) + { + sim->part_change_type(r>>8,x+rx,y+ry,PT_SHLD3); + parts[r>>8].life = 7; + } + else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) + for ( nnx=-1; nnx<2; nnx++) + for ( nny=-1; nny<2; nny++) + { + if (!pmap[y+ry+nny][x+rx+nnx]) + { + np = sim->create_part(-1,x+rx+nnx,y+ry+nny,PT_SHLD1); + if (np<0) continue; + parts[np].life=7; + } + } + } + return 0; +} + + +Element_SHLD4::~Element_SHLD4() {} \ No newline at end of file diff --git a/src/elements/sing.cpp b/src/simulation/elements/SING.cpp similarity index 70% rename from src/elements/sing.cpp rename to src/simulation/elements/SING.cpp index de1e32952..ea0c8c721 100644 --- a/src/elements/sing.cpp +++ b/src/simulation/elements/SING.cpp @@ -1,6 +1,54 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_SING PT_SING 131 +Element_SING::Element_SING() +{ + Identifier = "DEFAULT_PT_SING"; + Name = "SING"; + Colour = PIXPACK(0x242424); + MenuVisible = 1; + MenuSection = SC_NUCLEAR; + Enabled = 1; + + Advection = 0.7f; + AirDrag = 0.36f * CFDS; + AirLoss = 0.96f; + Loss = 0.80f; + Collision = 0.1f; + Gravity = 0.12f; + Diffusion = 0.00f; + HotAir = -0.001f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 86; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 70; + Description = "Singularity"; + + State = ST_SOLID; + Properties = TYPE_PART|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_SING::update; + Graphics = NULL; +} -int update_SING(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_SING static int update(UPDATE_FUNC_ARGS) +int Element_SING::update(UPDATE_FUNC_ARGS) + { int r, rx, ry, cry, crx, rad, nxi, nxj, nb, j, spawncount; int singularity = -parts[i].life; float angle, v; @@ -102,3 +150,6 @@ int update_SING(UPDATE_FUNC_ARGS) { } return 0; } + + +Element_SING::~Element_SING() {} \ No newline at end of file diff --git a/src/simulation/elements/SLTW.cpp b/src/simulation/elements/SLTW.cpp new file mode 100644 index 000000000..039704187 --- /dev/null +++ b/src/simulation/elements/SLTW.cpp @@ -0,0 +1,81 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_SLTW PT_SLTW 27 +Element_SLTW::Element_SLTW() +{ + Identifier = "DEFAULT_PT_SLTW"; + Name = "SLTW"; + Colour = PIXPACK(0x4050F0); + MenuVisible = 1; + MenuSection = SC_LIQUID; + Enabled = 1; + + Advection = 0.6f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.98f; + Loss = 0.95f; + Collision = 0.0f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 2; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 20; + + Weight = 35; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 75; + Description = "Saltwater, conducts electricity, difficult to freeze."; + + State = ST_LIQUID; + Properties = TYPE_LIQUID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_NEUTPENETRATE; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = 233.0f; + LowTemperatureTransition = PT_ICEI; + HighTemperature = 483.0f; + HighTemperatureTransition = ST; + + Update = &Element_SLTW::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_SLTW static int update(UPDATE_FUNC_ARGS) +int Element_SLTW::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx(rand()%10000)) + sim->kill_part(r>>8); + if ((r&0xFF)==PT_PLNT&&5>(rand()%1000)) + sim->kill_part(r>>8); + if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && !sim->legacy_enable && parts[i].temp>(273.15f+12.0f) && 1>(rand()%500)) + { + sim->part_change_type(i,x,y,PT_FIRE); + parts[i].life = 4; + } + if ((r&0xFF)==PT_FIRE){ + sim->kill_part(r>>8); + if(1>(rand()%150)){ + sim->kill_part(i); + return 1; + } + } + } + return 0; +} + + +Element_SLTW::~Element_SLTW() {} \ No newline at end of file diff --git a/src/simulation/elements/SMKE.cpp b/src/simulation/elements/SMKE.cpp new file mode 100644 index 000000000..a00eca24f --- /dev/null +++ b/src/simulation/elements/SMKE.cpp @@ -0,0 +1,68 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_SMKE PT_SMKE 57 +Element_SMKE::Element_SMKE() +{ + Identifier = "DEFAULT_PT_SMKE"; + Name = "SMKE"; + Colour = PIXPACK(0x222222); + MenuVisible = 1; + MenuSection = SC_GAS; + Enabled = 1; + + Advection = 0.9f; + AirDrag = 0.04f * CFDS; + AirLoss = 0.97f; + Loss = 0.20f; + Collision = 0.0f; + Gravity = -0.1f; + Diffusion = 0.00f; + HotAir = 0.001f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 1; + + Temperature = R_TEMP+320.0f+273.15f; + HeatConduct = 88; + Description = "Smoke"; + + State = ST_SOLID; + Properties = TYPE_GAS|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 625.0f; + HighTemperatureTransition = PT_FIRE; + + Update = NULL; + Graphics = &Element_SMKE::graphics; +} + +//#TPT-Directive ElementHeader Element_SMKE static int graphics(GRAPHICS_FUNC_ARGS) +int Element_SMKE::graphics(GRAPHICS_FUNC_ARGS) + +{ + *colr = 55; + *colg = 55; + *colb = 55; + + *firea = 75; + *firer = 55; + *fireg = 55; + *fireb = 55; + + *pixel_mode = PMODE_NONE; //Clear default, don't draw pixel + *pixel_mode |= FIRE_BLEND; + //Returning 1 means static, cache as we please + return 1; +} + +Element_SMKE::~Element_SMKE() {} \ No newline at end of file diff --git a/src/simulation/elements/SNOW.cpp b/src/simulation/elements/SNOW.cpp new file mode 100644 index 000000000..0d09611fa --- /dev/null +++ b/src/simulation/elements/SNOW.cpp @@ -0,0 +1,74 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_SNOW PT_SNOW 16 +Element_SNOW::Element_SNOW() +{ + Identifier = "DEFAULT_PT_SNOW"; + Name = "SNOW"; + Colour = PIXPACK(0xC0E0FF); + MenuVisible = 1; + MenuSection = SC_POWDERS; + Enabled = 1; + + Advection = 0.7f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.96f; + Loss = 0.90f; + Collision = -0.1f; + Gravity = 0.05f; + Diffusion = 0.01f; + HotAir = -0.00005f* CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 20; + + Weight = 50; + + Temperature = R_TEMP-30.0f+273.15f; + HeatConduct = 46; + Description = "Light particles."; + + State = ST_SOLID; + Properties = TYPE_PART|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 273.0f; + HighTemperatureTransition = PT_WATR; + + Update = &Element_SNOW::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_SNOW static int update(UPDATE_FUNC_ARGS) +int Element_SNOW::update(UPDATE_FUNC_ARGS) + { //currently used for snow as well + int r, rx, ry; + if (parts[i].ctype==PT_FRZW)//get colder if it is from FRZW + { + parts[i].temp = restrict_flt(parts[i].temp-1.0f, MIN_TEMP, MAX_TEMP); + } + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx(rand()%1000)) + { + sim->part_change_type(i,x,y,PT_SLTW); + sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW); + } + } + return 0; +} + + +Element_SNOW::~Element_SNOW() {} \ No newline at end of file diff --git a/src/elements/soap.cpp b/src/simulation/elements/SOAP.cpp similarity index 79% rename from src/elements/soap.cpp rename to src/simulation/elements/SOAP.cpp index 0d1054fd1..f122c1f1c 100644 --- a/src/elements/soap.cpp +++ b/src/simulation/elements/SOAP.cpp @@ -1,6 +1,54 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_SOAP PT_SOAP 149 +Element_SOAP::Element_SOAP() +{ + Identifier = "DEFAULT_PT_SOAP"; + Name = "SOAP"; + Colour = PIXPACK(0xF5F5DC); + MenuVisible = 1; + MenuSection = SC_LIQUID; + Enabled = 1; + + Advection = 0.6f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.98f; + Loss = 0.95f; + Collision = 0.0f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 2; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 20; + + Weight = 35; + + Temperature = R_TEMP-2.0f +273.15f; + HeatConduct = 29; + Description = "Soap. Creates bubbles."; + + State = ST_LIQUID; + Properties = TYPE_LIQUID|PROP_NEUTPENETRATE|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITL; + HighTemperatureTransition = NT; + + Update = &Element_SOAP::update; + Graphics = NULL; +} -int update_SOAP(UPDATE_FUNC_ARGS) +//#TPT-Directive ElementHeader Element_SOAP static int update(UPDATE_FUNC_ARGS) +int Element_SOAP::update(UPDATE_FUNC_ARGS) + { int r, rx, ry, nr, ng, nb, na; float tr, tg, tb, ta; @@ -100,7 +148,7 @@ int update_SOAP(UPDATE_FUNC_ARGS) if (parts[i].temp>0) { if (sim->bmap[(y+ry)/CELL][(x+rx)/CELL] - || (r && sim->ptypes[r&0xFF].state != ST_GAS + || (r && sim->elements[r&0xFF].State != ST_GAS && (r&0xFF) != PT_SOAP && (r&0xFF) != PT_GLAS) || (parts[r>>8].ctype == 0 && (r&0xFF) == PT_SOAP && (abs(parts[r>>8].vx)<2 || abs(parts[r>>8].vy)<2))) @@ -232,3 +280,6 @@ int update_SOAP(UPDATE_FUNC_ARGS) return 0; } + + +Element_SOAP::~Element_SOAP() {} \ No newline at end of file diff --git a/src/simulation/elements/SPAWN.cpp b/src/simulation/elements/SPAWN.cpp new file mode 100644 index 000000000..092be1cc4 --- /dev/null +++ b/src/simulation/elements/SPAWN.cpp @@ -0,0 +1,60 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_SPAWN PT_SPAWN 118 +Element_SPAWN::Element_SPAWN() +{ + Identifier = "DEFAULT_PT_SPAWN"; + Name = "SPWN"; + Colour = PIXPACK(0xAAAAAA); + MenuVisible = 0; + MenuSection = SC_SOLIDS; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 1.00f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 0; + Description = "STKM spawn point"; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_SPAWN::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_SPAWN static int update(UPDATE_FUNC_ARGS) +int Element_SPAWN::update(UPDATE_FUNC_ARGS) + { + if (!sim->player.spwn) + sim->create_part(-1, x, y, PT_STKM); + + return 0; +} + + + +Element_SPAWN::~Element_SPAWN() {} \ No newline at end of file diff --git a/src/simulation/elements/SPAWN2.cpp b/src/simulation/elements/SPAWN2.cpp new file mode 100644 index 000000000..be2088369 --- /dev/null +++ b/src/simulation/elements/SPAWN2.cpp @@ -0,0 +1,60 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_SPAWN2 PT_SPAWN2 117 +Element_SPAWN2::Element_SPAWN2() +{ + Identifier = "DEFAULT_PT_SPAWN2"; + Name = "SPWN2"; + Colour = PIXPACK(0xAAAAAA); + MenuVisible = 0; + MenuSection = SC_SOLIDS; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 1.00f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 0; + Description = "STK2 spawn point"; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_SPAWN2::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_SPAWN2 static int update(UPDATE_FUNC_ARGS) +int Element_SPAWN2::update(UPDATE_FUNC_ARGS) + { + if (!sim->player2.spwn) + sim->create_part(-1, x, y, PT_STKM2); + + return 0; +} + + + +Element_SPAWN2::~Element_SPAWN2() {} \ No newline at end of file diff --git a/src/elements/spng.cpp b/src/simulation/elements/SPNG.cpp similarity index 60% rename from src/elements/spng.cpp rename to src/simulation/elements/SPNG.cpp index 868b1e6f9..f522bd6ed 100644 --- a/src/elements/spng.cpp +++ b/src/simulation/elements/SPNG.cpp @@ -1,6 +1,54 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_SPNG PT_SPNG 90 +Element_SPNG::Element_SPNG() +{ + Identifier = "DEFAULT_PT_SPNG"; + Name = "SPNG"; + Colour = PIXPACK(0xFFBE30); + MenuVisible = 1; + MenuSection = SC_SOLIDS; + Enabled = 1; + + Advection = 0.00f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.00f; + Loss = 0.00f; + Collision = 0.00f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 20; + Explosive = 0; + Meltable = 1; + Hardness = 30; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "A sponge, absorbs water."; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 2730.0f; + HighTemperatureTransition = PT_FIRE; + + Update = &Element_SPNG::update; + Graphics = &Element_SPNG::graphics; +} -int update_SPNG(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_SPNG static int update(UPDATE_FUNC_ARGS) +int Element_SPNG::update(UPDATE_FUNC_ARGS) + { int r, trade, rx, ry, tmp, np; if (sim->pv[y/CELL][x/CELL]<=3 && sim->pv[y/CELL][x/CELL]>=-3&&parts[i].temp<=374.0f) { @@ -108,3 +156,23 @@ int update_SPNG(UPDATE_FUNC_ARGS) { } return 0; } + + +//#TPT-Directive ElementHeader Element_SPNG static int graphics(GRAPHICS_FUNC_ARGS) +int Element_SPNG::graphics(GRAPHICS_FUNC_ARGS) + +{ + *colr -= cpart->life*15; + *colg -= cpart->life*15; + *colb -= cpart->life*15; + if (*colr<=50) + *colr = 50; + if (*colg<=50) + *colg = 50; + if (*colb<=20) + *colb = 20; + return 0; +} + + +Element_SPNG::~Element_SPNG() {} \ No newline at end of file diff --git a/src/elements/sprk.cpp b/src/simulation/elements/SPRK.cpp similarity index 82% rename from src/elements/sprk.cpp rename to src/simulation/elements/SPRK.cpp index e01c77401..95f928b5e 100644 --- a/src/elements/sprk.cpp +++ b/src/simulation/elements/SPRK.cpp @@ -1,8 +1,56 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_SPRK PT_SPRK 15 +Element_SPRK::Element_SPRK() +{ + Identifier = "DEFAULT_PT_SPRK"; + Name = "SPRK"; + Colour = PIXPACK(0xFFFF80); + MenuVisible = 1; + MenuSection = SC_ELEC; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.001f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Electricity. Conducted by metal and water."; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_LIFE_DEC; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_SPRK::update; + Graphics = &Element_SPRK::graphics; +} -int update_SPRK(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_SPRK static int update(UPDATE_FUNC_ARGS) +int Element_SPRK::update(UPDATE_FUNC_ARGS) + { int r, rx, ry, rt, conduct_sprk, nearp, pavg, ct = parts[i].ctype; - update_PYRO(UPDATE_FUNC_SUBCALL_ARGS); + Element_FIRE::update(UPDATE_FUNC_SUBCALL_ARGS); if (parts[i].life<=0) { @@ -28,7 +76,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) { } else if (ct==PT_NTCT || ct==PT_PTCT) { - update_NPTCT(UPDATE_FUNC_SUBCALL_ARGS); + Element_NTCT::update(UPDATE_FUNC_SUBCALL_ARGS); } else if (ct==PT_ETRD&&parts[i].life==1) { @@ -145,7 +193,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) { // ct = spark from material, rt = spark to material. Make conduct_sprk = 0 if conduction not allowed if (pavg == PT_INSL) conduct_sprk = 0; - if (!((sim->ptypes[rt].properties&PROP_CONDUCTS)||rt==PT_INST||rt==PT_QRTZ)) conduct_sprk = 0; + if (!((sim->elements[rt].Properties&PROP_CONDUCTS)||rt==PT_INST||rt==PT_QRTZ)) conduct_sprk = 0; if (abs(rx)+abs(ry)>=4 &&ct!=PT_SWCH&&rt!=PT_SWCH) conduct_sprk = 0; @@ -219,7 +267,11 @@ int update_SPRK(UPDATE_FUNC_ARGS) { return 0; } -int graphics_SPRK(GRAPHICS_FUNC_ARGS) + + +//#TPT-Directive ElementHeader Element_SPRK static int graphics(GRAPHICS_FUNC_ARGS) +int Element_SPRK::graphics(GRAPHICS_FUNC_ARGS) + { *firea = 80; @@ -230,3 +282,6 @@ int graphics_SPRK(GRAPHICS_FUNC_ARGS) *pixel_mode |= FIRE_ADD; return 1; } + + +Element_SPRK::~Element_SPRK() {} \ No newline at end of file diff --git a/src/elements/stkm.cpp b/src/simulation/elements/STKM.cpp similarity index 79% rename from src/elements/stkm.cpp rename to src/simulation/elements/STKM.cpp index e7eecf401..e55489220 100644 --- a/src/elements/stkm.cpp +++ b/src/simulation/elements/STKM.cpp @@ -1,26 +1,71 @@ -#include "simulation/Element.h" - -int update_SPAWN(UPDATE_FUNC_ARGS) { - if (!sim->player.spwn) - sim->create_part(-1, x, y, PT_STKM); - - return 0; +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_STKM PT_STKM 55 +Element_STKM::Element_STKM() +{ + Identifier = "DEFAULT_PT_STKM"; + Name = "STKM"; + Colour = PIXPACK(0x000000); + MenuVisible = 1; + MenuSection = SC_SPECIAL; + Enabled = 1; + + Advection = 0.5f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.2f; + Loss = 1.0f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.0f; + HotAir = 0.00f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 50; + + Temperature = R_TEMP+14.6f+273.15f; + HeatConduct = 0; + Description = "Stickman. Don't kill him!"; + + State = ST_NONE; + Properties = 0; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 620.0f; + HighTemperatureTransition = PT_FIRE; + + Update = &Element_STKM::update; + Graphics = &Element_STKM::graphics; } -int update_STKM(UPDATE_FUNC_ARGS) +//#TPT-Directive ElementHeader Element_STKM static int update(UPDATE_FUNC_ARGS) +int Element_STKM::update(UPDATE_FUNC_ARGS) + { run_stickman(&sim->player, UPDATE_FUNC_SUBCALL_ARGS); return 0; } -int graphics_STKM(GRAPHICS_FUNC_ARGS) + + +//#TPT-Directive ElementHeader Element_STKM static int graphics(GRAPHICS_FUNC_ARGS) +int Element_STKM::graphics(GRAPHICS_FUNC_ARGS) + { /**pixel_mode = PSPEC_STICKMAN; if ((int)sim->player.elemplayer.elem].pcolors); - *colg = PIXG(ptypes[sim->player.elem].pcolors); - *colb = PIXB(ptypes[sim->player.elem].pcolors); + *colr = PIXR(elements[sim->player.elem].pcolors); + *colg = PIXG(elements[sim->player.elem].pcolors); + *colb = PIXB(elements[sim->player.elem].pcolors); } else*/ { @@ -29,14 +74,15 @@ int graphics_STKM(GRAPHICS_FUNC_ARGS) return 1; } -int run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_STKM static int run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) +int Element_STKM::run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) { int r, rx, ry; float pp, d; float dt = 0.9;///(FPSB*FPSB); //Delta time in square float gvx, gvy; float gx, gy, dl, dr; - if ((parts[i].ctype>0 && parts[i].ctypeptypes[parts[i].ctype].falldown>0) || parts[i].ctype==SPC_AIR || parts[i].ctype == PT_NEUT || parts[i].ctype == PT_PHOT || parts[i].ctype == PT_LIGH) + if ((parts[i].ctype>0 && parts[i].ctypeelements[parts[i].ctype].Falldown>0) || parts[i].ctype==SPC_AIR || parts[i].ctype == PT_NEUT || parts[i].ctype == PT_PHOT || parts[i].ctype == PT_LIGH) playerp->elem = parts[i].ctype; playerp->frames++; @@ -211,7 +257,7 @@ int run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) { if (!r && !sim->bmap[(y+ry)/CELL][(x+rx)/CELL]) continue; - if (sim->ptypes[r&0xFF].falldown!=0 || sim->ptypes[r&0xFF].state == ST_GAS || (r&0xFF) == PT_NEUT || (r&0xFF) == PT_PHOT) + if (sim->elements[r&0xFF].Falldown!=0 || sim->elements[r&0xFF].State == ST_GAS || (r&0xFF) == PT_NEUT || (r&0xFF) == PT_PHOT) { playerp->elem = r&0xFF; //Current element } @@ -235,7 +281,7 @@ int run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) { if (sim->bmap[(ry+y)/CELL][(rx+x)/CELL]==WL_FAN) playerp->elem = SPC_AIR; if ((r&0xFF)==PT_PRTI) - STKM_interact(sim, playerp, i, rx, ry); + Element_STKM::STKM_interact(sim, playerp, i, rx, ry); if (!parts[i].type)//STKM_interact may kill STKM return 1; } @@ -249,7 +295,7 @@ int run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) { { ry -= 2*(rand()%2)+1; r = pmap[ry][rx]; - if (sim->ptypes[r&0xFF].state == ST_SOLID) + if (sim->elements[r&0xFF].State == ST_SOLID) { sim->create_part(-1, rx, ry, PT_SPRK); playerp->frames = 0; @@ -304,7 +350,7 @@ int run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) { { parts[np].vx -= -gvy*(5*((((int)playerp->pcomm)&0x02) == 0x02) - 5*(((int)(playerp->pcomm)&0x01) == 0x01)); parts[np].vy -= gvx*(5*((((int)playerp->pcomm)&0x02) == 0x02) - 5*(((int)(playerp->pcomm)&0x01) == 0x01)); - parts[i].vx -= (sim->ptypes[(int)playerp->elem].weight*parts[np].vx)/1000; + parts[i].vx -= (sim->elements[(int)playerp->elem].Weight*parts[np].vx)/1000; } playerp->frames = 0; } @@ -398,10 +444,10 @@ int run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) { } //If legs touch something - STKM_interact(sim, playerp, i, (int)(playerp->legs[4]+0.5), (int)(playerp->legs[5]+0.5)); - STKM_interact(sim, playerp, i, (int)(playerp->legs[12]+0.5), (int)(playerp->legs[13]+0.5)); - STKM_interact(sim, playerp, i, (int)(playerp->legs[4]+0.5), (int)playerp->legs[5]); - STKM_interact(sim, playerp, i, (int)(playerp->legs[12]+0.5), (int)playerp->legs[13]); + Element_STKM::STKM_interact(sim, playerp, i, (int)(playerp->legs[4]+0.5), (int)(playerp->legs[5]+0.5)); + Element_STKM::STKM_interact(sim, playerp, i, (int)(playerp->legs[12]+0.5), (int)(playerp->legs[13]+0.5)); + Element_STKM::STKM_interact(sim, playerp, i, (int)(playerp->legs[4]+0.5), (int)playerp->legs[5]); + Element_STKM::STKM_interact(sim, playerp, i, (int)(playerp->legs[12]+0.5), (int)playerp->legs[13]); if (!parts[i].type) return 1; @@ -409,7 +455,8 @@ int run_stickman(playerst* playerp, UPDATE_FUNC_ARGS) { return 0; } -void STKM_interact(Simulation * sim, playerst* playerp, int i, int x, int y) +//#TPT-Directive ElementHeader Element_STKM static void STKM_interact(Simulation * sim, playerst* playerp, int i, int x, int y) +void Element_STKM::STKM_interact(Simulation * sim, playerst* playerp, int i, int x, int y) { int r; if (x<0 || y<0 || x>=XRES || y>=YRES || !sim->parts[i].type) @@ -422,13 +469,13 @@ void STKM_interact(Simulation * sim, playerst* playerp, int i, int x, int y) sim->parts[i].life -= (int)(rand()*20/RAND_MAX)+32; } - if (sim->ptypes[r&0xFF].hconduct && ((playerp->elem!=PT_LIGH && sim->parts[r>>8].temp>=323) || sim->parts[r>>8].temp<=243)) + if (sim->elements[r&0xFF].HeatConduct && ((playerp->elem!=PT_LIGH && sim->parts[r>>8].temp>=323) || sim->parts[r>>8].temp<=243)) { sim->parts[i].life -= 2; playerp->accs[3] -= 1; } - if (sim->ptypes[r&0xFF].properties&PROP_DEADLY) + if (sim->elements[r&0xFF].Properties&PROP_DEADLY) switch (r&0xFF) { case PT_ACID: @@ -439,7 +486,7 @@ void STKM_interact(Simulation * sim, playerst* playerp, int i, int x, int y) break; } - if (sim->ptypes[r&0xFF].properties&PROP_RADIOACTIVE) + if (sim->elements[r&0xFF].Properties&PROP_RADIOACTIVE) sim->parts[i].life -= 1; if ((r&0xFF)==PT_PRTI && sim->parts[i].type) @@ -463,7 +510,8 @@ void STKM_interact(Simulation * sim, playerst* playerp, int i, int x, int y) } } -void STKM_init_legs(Simulation * sim, playerst* playerp, int i) +//#TPT-Directive ElementHeader Element_STKM static void STKM_init_legs(Simulation * sim, playerst* playerp, int i) +void Element_STKM::STKM_init_legs(Simulation * sim, playerst* playerp, int i) { int x, y; @@ -490,3 +538,6 @@ void STKM_init_legs(Simulation * sim, playerst* playerp, int i) playerp->legs[14] = x+3; playerp->legs[15] = y+12; } + + +Element_STKM::~Element_STKM() {} \ No newline at end of file diff --git a/src/simulation/elements/STKM2.cpp b/src/simulation/elements/STKM2.cpp new file mode 100644 index 000000000..ca0d8cfe9 --- /dev/null +++ b/src/simulation/elements/STKM2.cpp @@ -0,0 +1,77 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_STKM2 PT_STKM2 128 +Element_STKM2::Element_STKM2() +{ + Identifier = "DEFAULT_PT_STKM2"; + Name = "STK2"; + Colour = PIXPACK(0x000000); + MenuVisible = 1; + MenuSection = SC_SPECIAL; + Enabled = 1; + + Advection = 0.5f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.2f; + Loss = 1.0f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.0f; + HotAir = 0.00f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 50; + + Temperature = R_TEMP+14.6f+273.15f; + HeatConduct = 0; + Description = "Stickman. Don't kill him!"; + + State = ST_NONE; + Properties = 0; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 620.0f; + HighTemperatureTransition = PT_FIRE; + + Update = &Element_STKM2::update; + Graphics = &Element_STKM2::graphics; +} + +//#TPT-Directive ElementHeader Element_STKM2 static int update(UPDATE_FUNC_ARGS) +int Element_STKM2::update(UPDATE_FUNC_ARGS) + { + Element_STKM::run_stickman(&sim->player2, UPDATE_FUNC_SUBCALL_ARGS); + return 0; +} + + + +//#TPT-Directive ElementHeader Element_STKM2 static int graphics(GRAPHICS_FUNC_ARGS) +int Element_STKM2::graphics(GRAPHICS_FUNC_ARGS) + +{ + /**pixel_mode = PSPEC_STICKMAN; + if ((int)sim->player2.elemplayer2.elem].pcolors); + *colg = PIXG(elements[sim->player2.elem].pcolors); + *colb = PIXB(elements[sim->player2.elem].pcolors); + } + else*/ + { + *colr = *colg = *colb = 255; + } + return 1; +} + + +Element_STKM2::~Element_STKM2() {} \ No newline at end of file diff --git a/src/simulation/elements/STNE.cpp b/src/simulation/elements/STNE.cpp new file mode 100644 index 000000000..2a2a2fdcd --- /dev/null +++ b/src/simulation/elements/STNE.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_STNE PT_STNE 5 +Element_STNE::Element_STNE() +{ + Identifier = "DEFAULT_PT_STNE"; + Name = "STNE"; + Colour = PIXPACK(0xA0A0A0); + MenuVisible = 1; + MenuSection = SC_POWDERS; + Enabled = 1; + + Advection = 0.4f; + AirDrag = 0.04f * CFDS; + AirLoss = 0.94f; + Loss = 0.95f; + Collision = -0.1f; + Gravity = 0.3f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 5; + Hardness = 1; + + Weight = 90; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 150; + Description = "Heavy particles. Meltable."; + + State = ST_SOLID; + Properties = TYPE_PART; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 983.0f; + HighTemperatureTransition = PT_LAVA; + + Update = NULL; + Graphics = NULL; +} + +Element_STNE::~Element_STNE() {} \ No newline at end of file diff --git a/src/simulation/elements/STOR.cpp b/src/simulation/elements/STOR.cpp new file mode 100644 index 000000000..ad119f3bf --- /dev/null +++ b/src/simulation/elements/STOR.cpp @@ -0,0 +1,112 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_STOR PT_STOR 83 +Element_STOR::Element_STOR() +{ + Identifier = "DEFAULT_PT_STOR"; + Name = "STOR"; + Colour = PIXPACK(0x50DFDF); + MenuVisible = 1; + MenuSection = SC_POWERED; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Solid. Stores a single particle, releases when charged with PSCN, also passes to PIPE"; + + State = ST_NONE; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_STOR::update; + Graphics = &Element_STOR::graphics; +} + +//#TPT-Directive ElementHeader Element_STOR static int update(UPDATE_FUNC_ARGS) +int Element_STOR::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry, np, rx1, ry1; + if(parts[i].life && !parts[i].tmp) + parts[i].life--; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + continue; + if (!parts[i].tmp && !parts[i].life && (r&0xFF)!=PT_STOR && !(sim->elements[(r&0xFF)].Properties&TYPE_SOLID) && (!parts[i].ctype || (r&0xFF)==parts[i].ctype)) + { + parts[i].tmp = parts[r>>8].type; + parts[i].temp = parts[r>>8].temp; + parts[i].tmp2 = parts[r>>8].life; + parts[i].pavg[0] = parts[r>>8].tmp; + parts[i].pavg[1] = parts[r>>8].ctype; + sim->kill_part(r>>8); + } + if(parts[i].tmp && (r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_PSCN && parts[r>>8].life>0 && parts[r>>8].life<4) + { + for(ry1 = 1; ry1 >= -1; ry1--){ + for(rx1 = 0; rx1 >= -1 && rx1 <= 1; rx1 = -rx1-rx1+1){ // Oscilate the X starting at 0, 1, -1, 3, -5, etc (Though stop at -1) + np = sim->create_part(-1,x+rx1,y+ry1,parts[i].tmp); + if (np!=-1) + { + parts[np].temp = parts[i].temp; + parts[np].life = parts[i].tmp2; + parts[np].tmp = parts[i].pavg[0]; + parts[np].ctype = parts[i].pavg[1]; + parts[i].tmp = 0; + parts[i].life = 10; + break; + } + } + } + } + } + return 0; +} + + +//#TPT-Directive ElementHeader Element_STOR static int graphics(GRAPHICS_FUNC_ARGS) +int Element_STOR::graphics(GRAPHICS_FUNC_ARGS) + +{ + if(cpart->tmp){ + *pixel_mode |= PMODE_GLOW; + *colr = 0x50; + *colg = 0xDF; + *colb = 0xDF; + } else { + *colr = 0x20; + *colg = 0xAF; + *colb = 0xAF; + } + return 0; +} + + +Element_STOR::~Element_STOR() {} \ No newline at end of file diff --git a/src/elements/swch.cpp b/src/simulation/elements/SWCH.cpp similarity index 51% rename from src/elements/swch.cpp rename to src/simulation/elements/SWCH.cpp index 4adc27077..fa8e49e9f 100644 --- a/src/elements/swch.cpp +++ b/src/simulation/elements/SWCH.cpp @@ -1,6 +1,54 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_SWCH PT_SWCH 56 +Element_SWCH::Element_SWCH() +{ + Identifier = "DEFAULT_PT_SWCH"; + Name = "SWCH"; + Colour = PIXPACK(0x103B11); + MenuVisible = 1; + MenuSection = SC_ELEC; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Solid. Only conducts when switched on. (PSCN switches on, NSCN switches off)"; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_SWCH::update; + Graphics = &Element_SWCH::graphics; +} -int update_SWCH(UPDATE_FUNC_ARGS) { +//#TPT-Directive ElementHeader Element_SWCH static int update(UPDATE_FUNC_ARGS) +int Element_SWCH::update(UPDATE_FUNC_ARGS) + { int r, rt, rx, ry; if (parts[i].life>0 && parts[i].life!=10) parts[i].life--; @@ -42,3 +90,21 @@ int update_SWCH(UPDATE_FUNC_ARGS) { } return 0; } + + +//#TPT-Directive ElementHeader Element_SWCH static int graphics(GRAPHICS_FUNC_ARGS) +int Element_SWCH::graphics(GRAPHICS_FUNC_ARGS) + +{ + if(cpart->life >= 10) + { + *colr = 17; + *colg = 217; + *colb = 24; + *pixel_mode |= PMODE_GLOW; + } + return 0; +} + + +Element_SWCH::~Element_SWCH() {} \ No newline at end of file diff --git a/src/simulation/elements/TESC.cpp b/src/simulation/elements/TESC.cpp new file mode 100644 index 000000000..7c3cce6a3 --- /dev/null +++ b/src/simulation/elements/TESC.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_TESC PT_TESC 88 +Element_TESC::Element_TESC() +{ + Identifier = "DEFAULT_PT_TESC"; + Name = "TESC"; + Colour = PIXPACK(0x707040); + MenuVisible = 1; + MenuSection = SC_ELEC; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Tesla coil!"; + + State = ST_SOLID; + Properties = TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_HOT_GLOW; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = NULL; + Graphics = NULL; +} + +Element_TESC::~Element_TESC() {} \ No newline at end of file diff --git a/src/simulation/elements/THDR.cpp b/src/simulation/elements/THDR.cpp new file mode 100644 index 000000000..df38306f5 --- /dev/null +++ b/src/simulation/elements/THDR.cpp @@ -0,0 +1,102 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_THDR PT_THDR 48 +Element_THDR::Element_THDR() +{ + Identifier = "DEFAULT_PT_THDR"; + Name = "THDR"; + Colour = PIXPACK(0xFFFFA0); + MenuVisible = 1; + MenuSection = SC_EXPLOSIVE; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 1.0f; + Loss = 0.30f; + Collision = -0.99f; + Gravity = 0.6f; + Diffusion = 0.62f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 1; + + Temperature = 9000.0f +273.15f; + HeatConduct = 1; + Description = "Lightning! Very hot, inflicts damage upon most materials, transfers current to metals."; + + State = ST_NONE; + Properties = TYPE_ENERGY; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_THDR::update; + Graphics = &Element_THDR::graphics; +} + +//#TPT-Directive ElementHeader Element_THDR static int update(UPDATE_FUNC_ARGS) +int Element_THDR::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rxelements[r&0xFF].Properties&PROP_CONDUCTS) && parts[r>>8].life==0 && !((r&0xFF)==PT_WATR||(r&0xFF)==PT_SLTW) && parts[r>>8].ctype!=PT_SPRK) + { + parts[i].type = PT_NONE; + parts[r>>8].ctype = parts[r>>8].type; + sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK); + parts[r>>8].life = 4; + } + else if ((r&0xFF)!=PT_CLNE&&(r&0xFF)!=PT_THDR&&(r&0xFF)!=PT_SPRK&&(r&0xFF)!=PT_DMND&&(r&0xFF)!=PT_FIRE&&(r&0xFF)!=PT_NEUT&&(r&0xFF)!=PT_PHOT&&(r&0xFF)) + { + sim->pv[y/CELL][x/CELL] += 100.0f; + if (sim->legacy_enable&&1>(rand()%200)) + { + parts[i].life = rand()%50+120; + sim->part_change_type(i,x,y,PT_FIRE); + } + else + { + parts[i].type = PT_NONE; + } + } + } + if (parts[i].type==PT_NONE) { + sim->kill_part(i); + return 1; + } + return 0; +} + + +//#TPT-Directive ElementHeader Element_THDR static int graphics(GRAPHICS_FUNC_ARGS) +int Element_THDR::graphics(GRAPHICS_FUNC_ARGS) + +{ + *firea = 160; + *fireg = 192; + *fireb = 255; + *firer = 144; + *pixel_mode |= FIRE_ADD; + return 1; +} + + +Element_THDR::~Element_THDR() {} \ No newline at end of file diff --git a/src/simulation/elements/THRM.cpp b/src/simulation/elements/THRM.cpp new file mode 100644 index 000000000..e87a37912 --- /dev/null +++ b/src/simulation/elements/THRM.cpp @@ -0,0 +1,80 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_THRM PT_THRM 65 +Element_THRM::Element_THRM() +{ + Identifier = "DEFAULT_PT_THRM"; + Name = "THRM"; + Colour = PIXPACK(0xA08090); + MenuVisible = 1; + MenuSection = SC_EXPLOSIVE; + Enabled = 1; + + Advection = 0.4f; + AirDrag = 0.04f * CFDS; + AirLoss = 0.94f; + Loss = 0.95f; + Collision = -0.1f; + Gravity = 0.3f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 2; + Hardness = 2; + + Weight = 90; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 211; + Description = "Thermite. Burns at extremely high temperature."; + + State = ST_SOLID; + Properties = TYPE_PART; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_THRM::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_THRM static int update(UPDATE_FUNC_ARGS) +int Element_THRM::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx(rand()%500)) { + sim->part_change_type(i,x,y,PT_LAVA); + parts[i].ctype = PT_BMTL; + parts[i].temp = 3500.0f; + sim->pv[y/CELL][x/CELL] += 50.0f; + } else { + sim->part_change_type(i,x,y,PT_LAVA); + parts[i].life = 400; + parts[i].ctype = PT_THRM; + parts[i].temp = 3500.0f; + parts[i].tmp = 20; + } + } + } + return 0; +} + + +Element_THRM::~Element_THRM() {} \ No newline at end of file diff --git a/src/elements/tron.cpp b/src/simulation/elements/TRON.cpp similarity index 68% rename from src/elements/tron.cpp rename to src/simulation/elements/TRON.cpp index 3e99eb352..a449bc604 100644 --- a/src/elements/tron.cpp +++ b/src/simulation/elements/TRON.cpp @@ -1,22 +1,51 @@ -#include "simulation/Element.h" +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_TRON PT_TRON 143 +Element_TRON::Element_TRON() +{ + Identifier = "DEFAULT_PT_TRON"; + Name = "TRON"; + Colour = PIXPACK(0x000000); + MenuVisible = 1; + MenuSection = SC_SPECIAL; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 100; + + Temperature = 0.0f; + HeatConduct = 40; + Description = "Smart particles, Travels in straight lines and avoids obstacles. Grows with time."; + + State = ST_NONE; + Properties = TYPE_SOLID|PROP_LIFE_DEC|PROP_LIFE_KILL; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_TRON::update; + Graphics = &Element_TRON::graphics; +} -/* TRON element is meant to resemble a tron bike (or worm) moving around and trying to avoid obstacles itself. - * It has four direction each turn to choose from, 0 (left) 1 (up) 2 (right) 3 (down). - * Each turn has a small random chance to randomly turn one way (so it doesn't do the exact same thing in a large room) - * If the place it wants to move isn't a barrier, it will try and 'see' infront of itself to determine its safety. - * For now the tron can only see its own body length in pixels ahead of itself (and around corners) - * - - - - - - - - - - - * - - - - + - - - - - - * - - - + + + - - - - - * - - +<--+-->+ - - - - * - +<----+---->+ - - - * - - - - H - - - - - - * Where H is the head with tail length 4, it checks the + area to see if it can hit any of the edges, then it is called safe, or picks the biggest area if none safe. - * .tmp bit values: 1st head, 2nd no tail growth, 3rd wait flag, 4th Nodie, 5th Dying, 6th & 7th is direction, 8th - 16th hue - * .tmp2 is tail length (gets longer every few hundred frames) - * .life is the timer that kills the end of the tail (the head uses life for how often it grows longer) - * .ctype Contains the colour, lost on save, regenerated using hue tmp (bits 7 - 16) - */ #define TRON_HEAD 1 #define TRON_NOGROW 2 #define TRON_WAIT 4 //it was just created, so WAIT a frame @@ -24,7 +53,120 @@ #define TRON_DEATH 16 //Crashed, now dying int tron_rx[4] = {-1, 0, 1, 0}; int tron_ry[4] = { 0,-1, 0, 1}; -int new_tronhead(Simulation * sim, int x, int y, int i, int direction) + +//#TPT-Directive ElementHeader Element_TRON static int update(UPDATE_FUNC_ARGS) +int Element_TRON::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry, np; + if(!parts[i].ctype) + { + int r, g, b; + int hue = (parts[i].tmp&0xF800)>>7; + HSV_to_RGB(hue,255,255,&r,&g,&b); + parts[i].ctype = r<<16 | g<<8 | b; + //Use photon-like wavelength? + } + if (parts[i].tmp&TRON_WAIT) + { + parts[i].tmp &= ~TRON_WAIT; + return 0; + } + if (parts[i].tmp&TRON_HEAD) + { + int firstdircheck = 0,seconddir,seconddircheck = 0,lastdir,lastdircheck = 0; + int direction = (parts[i].tmp>>5 & 0x3); + int originaldir = direction; + + //random turn + int random = rand()%340; + if (random==1 || random==3) + { + //randomly turn left(3) or right(1) + direction = (direction + random)%4; + } + + //check infront + //do sight check + firstdircheck = Element_TRON::trymovetron(sim,x,y,direction,i,parts[i].tmp2); + if (firstdircheck < parts[i].tmp2) + { + if (originaldir != direction) //if we just tried a random turn, don't pick random again + { + seconddir = originaldir; + lastdir = (direction + 2)%4; + } + else + { + seconddir = (direction + ((rand()%2)*2)+1)% 4; + lastdir = (seconddir + 2)%4; + } + seconddircheck = trymovetron(sim,x,y,seconddir,i,parts[i].tmp2); + lastdircheck = trymovetron(sim,x,y,lastdir,i,parts[i].tmp2); + } + //find the best move + if (seconddircheck > firstdircheck) + direction = seconddir; + if (lastdircheck > seconddircheck && lastdircheck > firstdircheck) + direction = lastdir; + //now try making new head, even if it fails + if (Element_TRON::new_tronhead(sim,x + tron_rx[direction],y + tron_ry[direction],i,direction) == -1) + { + //ohgod crash + parts[i].tmp |= TRON_DEATH; + //trigger tail death for TRON_NODIE, or is that mode even needed? just set a high tail length(but it still won't start dying when it crashes) + } + + //set own life and clear .tmp (it dies if it can't move anyway) + parts[i].life = parts[i].tmp2; + parts[i].tmp &= parts[i].tmp&0xF810; + } + else // fade tail deco, or prevent tail from dieing + { + if (parts[i].tmp&TRON_NODIE) + parts[i].life++; + //parts[i].dcolour = clamp_flt((float)parts[i].life/(float)parts[i].tmp2,0,1.0f) << 24 | parts[i].dcolour&0x00FFFFFF; + } + return 0; +} + + + +//#TPT-Directive ElementHeader Element_TRON static int graphics(GRAPHICS_FUNC_ARGS) +int Element_TRON::graphics(GRAPHICS_FUNC_ARGS) + { + if(cpart->tmp & TRON_HEAD) + *pixel_mode |= PMODE_GLOW; + if(cpart->ctype) + { + *colr = (cpart->ctype & 0xFF0000)>>16; + *colg = (cpart->ctype & 0x00FF00)>>8; + *colb = (cpart->ctype & 0x0000FF); + } + else + { + *colr = 255; + *colg = 255; + *colb = 255; + } + if(cpart->tmp & TRON_DEATH) + { + *pixel_mode |= FIRE_ADD | PMODE_FLARE; + *firer = *colr; + *fireg = *colg; + *fireb = *colb; + *firea = 255; + } + if(cpart->life < cpart->tmp2 && !(cpart->tmp & TRON_HEAD)) + { + *pixel_mode |= PMODE_BLEND; + *pixel_mode &= ~PMODE_FLAT; + *cola = (int)((((float)cpart->life)/((float)cpart->tmp2))*255.0f); + } + return 0; +} + +//#TPT-Directive ElementHeader Element_TRON static int new_tronhead(Simulation * sim, int x, int y, int i, int direction) +int Element_TRON::new_tronhead(Simulation * sim, int x, int y, int i, int direction) { int np = sim->create_part(-1, x , y ,PT_TRON); if (np==-1) @@ -38,13 +180,15 @@ int new_tronhead(Simulation * sim, int x, int y, int i, int direction) sim->parts[np].tmp = 1 | direction<<5 | sim->parts[i].tmp&(TRON_NOGROW|TRON_NODIE) | (sim->parts[i].tmp&0xF800); if (np > i) sim->parts[np].tmp |= TRON_WAIT; - + sim->parts[np].ctype = sim->parts[i].ctype; sim->parts[np].tmp2 = sim->parts[i].tmp2; sim->parts[np].life = sim->parts[i].life + 2; return 1; } -int trymovetron(Simulation * sim, int x, int y, int dir, int i, int len) + +//#TPT-Directive ElementHeader Element_TRON static int trymovetron(Simulation * sim, int x, int y, int dir, int i, int len) +int Element_TRON::trymovetron(Simulation * sim, int x, int y, int dir, int i, int len) { int k,j,r,rx,ry,tx,ty,count; count = 0; @@ -88,107 +232,5 @@ int trymovetron(Simulation * sim, int x, int y, int dir, int i, int len) } return count; } -int update_TRON(UPDATE_FUNC_ARGS) { - int r, rx, ry, np; - if(!parts[i].ctype) - { - int r, g, b; - int hue = (parts[i].tmp&0xF800)>>7; - HSV_to_RGB(hue,255,255,&r,&g,&b); - parts[i].ctype = r<<16 | g<<8 | b; - //Use photon-like wavelength? - } - if (parts[i].tmp&TRON_WAIT) - { - parts[i].tmp &= ~TRON_WAIT; - return 0; - } - if (parts[i].tmp&TRON_HEAD) - { - int firstdircheck = 0,seconddir,seconddircheck = 0,lastdir,lastdircheck = 0; - int direction = (parts[i].tmp>>5 & 0x3); - int originaldir = direction; - //random turn - int random = rand()%340; - if (random==1 || random==3) - { - //randomly turn left(3) or right(1) - direction = (direction + random)%4; - } - - //check infront - //do sight check - firstdircheck = trymovetron(sim,x,y,direction,i,parts[i].tmp2); - if (firstdircheck < parts[i].tmp2) - { - if (originaldir != direction) //if we just tried a random turn, don't pick random again - { - seconddir = originaldir; - lastdir = (direction + 2)%4; - } - else - { - seconddir = (direction + ((rand()%2)*2)+1)% 4; - lastdir = (seconddir + 2)%4; - } - seconddircheck = trymovetron(sim,x,y,seconddir,i,parts[i].tmp2); - lastdircheck = trymovetron(sim,x,y,lastdir,i,parts[i].tmp2); - } - //find the best move - if (seconddircheck > firstdircheck) - direction = seconddir; - if (lastdircheck > seconddircheck && lastdircheck > firstdircheck) - direction = lastdir; - //now try making new head, even if it fails - if (new_tronhead(sim,x + tron_rx[direction],y + tron_ry[direction],i,direction) == -1) - { - //ohgod crash - parts[i].tmp |= TRON_DEATH; - //trigger tail death for TRON_NODIE, or is that mode even needed? just set a high tail length(but it still won't start dying when it crashes) - } - - //set own life and clear .tmp (it dies if it can't move anyway) - parts[i].life = parts[i].tmp2; - parts[i].tmp &= parts[i].tmp&0xF810; - } - else // fade tail deco, or prevent tail from dieing - { - if (parts[i].tmp&TRON_NODIE) - parts[i].life++; - //parts[i].dcolour = clamp_flt((float)parts[i].life/(float)parts[i].tmp2,0,1.0f) << 24 | parts[i].dcolour&0x00FFFFFF; - } - return 0; -} - -int graphics_TRON(GRAPHICS_FUNC_ARGS) { - if(cpart->tmp & TRON_HEAD) - *pixel_mode |= PMODE_GLOW; - if(cpart->ctype) - { - *colr = (cpart->ctype & 0xFF0000)>>16; - *colg = (cpart->ctype & 0x00FF00)>>8; - *colb = (cpart->ctype & 0x0000FF); - } - else - { - *colr = 255; - *colg = 255; - *colb = 255; - } - if(cpart->tmp & TRON_DEATH) - { - *pixel_mode |= FIRE_ADD | PMODE_FLARE; - *firer = *colr; - *fireg = *colg; - *fireb = *colb; - *firea = 255; - } - if(cpart->life < cpart->tmp2 && !(cpart->tmp & TRON_HEAD)) - { - *pixel_mode |= PMODE_BLEND; - *pixel_mode &= ~PMODE_FLAT; - *cola = (int)((((float)cpart->life)/((float)cpart->tmp2))*255.0f); - } - return 0; -} +Element_TRON::~Element_TRON() {} \ No newline at end of file diff --git a/src/simulation/elements/URAN.cpp b/src/simulation/elements/URAN.cpp new file mode 100644 index 000000000..0a5fb798a --- /dev/null +++ b/src/simulation/elements/URAN.cpp @@ -0,0 +1,61 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_URAN PT_URAN 32 +Element_URAN::Element_URAN() +{ + Identifier = "DEFAULT_PT_URAN"; + Name = "URAN"; + Colour = PIXPACK(0x707020); + MenuVisible = 1; + MenuSection = SC_NUCLEAR; + Enabled = 1; + + Advection = 0.4f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.99f; + Loss = 0.95f; + Collision = 0.0f; + Gravity = 0.4f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 90; + + Temperature = R_TEMP+30.0f+273.15f; + HeatConduct = 251; + Description = "Heavy particles. Generates heat under pressure."; + + State = ST_SOLID; + Properties = TYPE_PART | PROP_RADIOACTIVE; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_URAN::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_URAN static int update(UPDATE_FUNC_ARGS) +int Element_URAN::update(UPDATE_FUNC_ARGS) + { + if (!sim->legacy_enable && sim->pv[y/CELL][x/CELL]>0.0f) + { + float atemp = parts[i].temp + (-MIN_TEMP); + parts[i].temp = restrict_flt((atemp*(1+(sim->pv[y/CELL][x/CELL]/2000)))+MIN_TEMP, MIN_TEMP, MAX_TEMP); + } + return 0; +} + + +Element_URAN::~Element_URAN() {} \ No newline at end of file diff --git a/src/simulation/elements/VINE.cpp b/src/simulation/elements/VINE.cpp new file mode 100644 index 000000000..142e235a6 --- /dev/null +++ b/src/simulation/elements/VINE.cpp @@ -0,0 +1,70 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_VINE PT_VINE 114 +Element_VINE::Element_VINE() +{ + Identifier = "DEFAULT_PT_VINE"; + Name = "VINE"; + Colour = PIXPACK(0x079A00); + MenuVisible = 1; + MenuSection = SC_SOLIDS; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.95f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 20; + Explosive = 0; + Meltable = 0; + Hardness = 10; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 65; + Description = "Vine, grows"; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 573.0f; + HighTemperatureTransition = PT_FIRE; + + Update = &Element_VINE::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_VINE static int update(UPDATE_FUNC_ARGS) +int Element_VINE::update(UPDATE_FUNC_ARGS) + { + int r, np, rx =(rand()%3)-1, ry=(rand()%3)-1; + if (x+rx>=0 && y+ry>0 && x+rxrand()%15) + sim->part_change_type(i,x,y,PT_PLNT); + else if (!r) + { + np = sim->create_part(-1,x+rx,y+ry,PT_VINE); + if (np<0) return 0; + parts[np].temp = parts[i].temp; + sim->part_change_type(i,x,y,PT_PLNT); + } + } + return 0; +} + + +Element_VINE::~Element_VINE() {} \ No newline at end of file diff --git a/src/simulation/elements/VOID.cpp b/src/simulation/elements/VOID.cpp new file mode 100644 index 000000000..1627ad266 --- /dev/null +++ b/src/simulation/elements/VOID.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_VOID PT_VOID 22 +Element_VOID::Element_VOID() +{ + Identifier = "DEFAULT_PT_VOID"; + Name = "VOID"; + Colour = PIXPACK(0x790B0B); + MenuVisible = 1; + MenuSection = SC_SPECIAL; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 1.00f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = -0.0003f* CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Hole, will drain away any particles."; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = NULL; + Graphics = NULL; +} + +Element_VOID::~Element_VOID() {} \ No newline at end of file diff --git a/src/simulation/elements/WARP.cpp b/src/simulation/elements/WARP.cpp new file mode 100644 index 000000000..596c1d951 --- /dev/null +++ b/src/simulation/elements/WARP.cpp @@ -0,0 +1,79 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_WARP PT_WARP 96 +Element_WARP::Element_WARP() +{ + Identifier = "DEFAULT_PT_WARP"; + Name = "WARP"; + Colour = PIXPACK(0x000000); + MenuVisible = 1; + MenuSection = SC_NUCLEAR; + Enabled = 1; + + Advection = 0.8f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.9f; + Loss = 0.70f; + Collision = -0.1f; + Gravity = 0.0f; + Diffusion = 3.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 30; + + Weight = 1; + + Temperature = R_TEMP +273.15f; + HeatConduct = 100; + Description = "Displaces other elements."; + + State = ST_GAS; + Properties = TYPE_GAS|PROP_LIFE_DEC|PROP_LIFE_KILL; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_WARP::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_WARP static int update(UPDATE_FUNC_ARGS) +int Element_WARP::update(UPDATE_FUNC_ARGS) + { + int trade, r, rx, ry; + for ( trade = 0; trade<5; trade ++) + { + rx = rand()%3-1; + ry = rand()%3-1; + if (x+rx>=0 && y+ry>0 && x+rx=rand()%200)) + { + parts[i].x = parts[r>>8].x; + parts[i].y = parts[r>>8].y; + parts[r>>8].x = x; + parts[r>>8].y = y; + parts[i].life += 4; + pmap[y][x] = r; + pmap[y+ry][x+rx] = (i<<8)|parts[i].type; + trade = 5; + } + } + } + return 0; +} + + +Element_WARP::~Element_WARP() {} \ No newline at end of file diff --git a/src/simulation/elements/WATR.cpp b/src/simulation/elements/WATR.cpp new file mode 100644 index 000000000..037c8c927 --- /dev/null +++ b/src/simulation/elements/WATR.cpp @@ -0,0 +1,87 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_WATR PT_WATR 2 +Element_WATR::Element_WATR() +{ + Identifier = "DEFAULT_PT_WATR"; + Name = "WATR"; + Colour = PIXPACK(0x2030D0); + MenuVisible = 1; + MenuSection = SC_LIQUID; + Enabled = 1; + + Advection = 0.6f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.98f; + Loss = 0.95f; + Collision = 0.0f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 2; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 20; + + Weight = 30; + + Temperature = R_TEMP-2.0f +273.15f; + HeatConduct = 29; + Description = "Liquid. Conducts electricity. Freezes. Extinguishes fires."; + + State = ST_LIQUID; + Properties = TYPE_LIQUID|PROP_CONDUCTS|PROP_LIFE_DEC|PROP_NEUTPENETRATE; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = 273.15f; + LowTemperatureTransition = PT_ICEI; + HighTemperature = 373.0f; + HighTemperatureTransition = PT_WTRV; + + Update = &Element_WATR::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_WATR static int update(UPDATE_FUNC_ARGS) +int Element_WATR::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx(rand()%250)) + { + sim->part_change_type(i,x,y,PT_SLTW); + sim->part_change_type(r>>8,x+rx,y+ry,PT_SLTW); + } + if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && 1>(rand()%500)) + { + sim->part_change_type(i,x,y,PT_FIRE); + parts[i].life = 4; + parts[i].ctype = PT_WATR; + } + if ((r&0xFF)==PT_FIRE && parts[r>>8].ctype!=PT_WATR){ + sim->kill_part(r>>8); + if(1>(rand()%150)){ + sim->kill_part(i); + return 1; + } + } + /*if ((r&0xFF)==PT_CNCT && 1>(rand()%500)) Concrete+Water to paste, not very popular + { + part_change_type(i,x,y,PT_PSTE); + sim.kill_part(r>>8); + }*/ + } + return 0; +} + +Element_WATR::~Element_WATR() {} \ No newline at end of file diff --git a/src/simulation/elements/WAX.cpp b/src/simulation/elements/WAX.cpp new file mode 100644 index 000000000..2ab705b13 --- /dev/null +++ b/src/simulation/elements/WAX.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_WAX PT_WAX 33 +Element_WAX::Element_WAX() +{ + Identifier = "DEFAULT_PT_WAX"; + Name = "WAX"; + Colour = PIXPACK(0xF0F0BB); + MenuVisible = 1; + MenuSection = SC_SOLIDS; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 10; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 44; + Description = "Wax. Melts at moderately high temperatures."; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 319.0f; + HighTemperatureTransition = PT_MWAX; + + Update = NULL; + Graphics = NULL; +} + +Element_WAX::~Element_WAX() {} \ No newline at end of file diff --git a/src/simulation/elements/WHOL.cpp b/src/simulation/elements/WHOL.cpp new file mode 100644 index 000000000..572fca095 --- /dev/null +++ b/src/simulation/elements/WHOL.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_WHOL PT_WHOL 40 +Element_WHOL::Element_WHOL() +{ + Identifier = "DEFAULT_PT_WHOL"; + Name = "VENT"; + Colour = PIXPACK(0xEFEFEF); + MenuVisible = 1; + MenuSection = SC_SPECIAL; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.95f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.010f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 100; + + Temperature = R_TEMP-16.0f+273.15f; + HeatConduct = 255; + Description = "Air vent, creates pressure and pushes other particles away."; + + State = ST_NONE; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = NULL; + Graphics = NULL; +} + +Element_WHOL::~Element_WHOL() {} \ No newline at end of file diff --git a/src/simulation/elements/WIFI.cpp b/src/simulation/elements/WIFI.cpp new file mode 100644 index 000000000..a108c910e --- /dev/null +++ b/src/simulation/elements/WIFI.cpp @@ -0,0 +1,100 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_WIFI PT_WIFI 124 +Element_WIFI::Element_WIFI() +{ + Identifier = "DEFAULT_PT_WIFI"; + Name = "WIFI"; + Colour = PIXPACK(0x40A060); + MenuVisible = 1; + MenuSection = SC_ELEC; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 1; + Hardness = 2; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 0; + Description = "Wireless transmitter, color coded."; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = 15.0f; + HighPressureTransition = PT_BRMT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_WIFI::update; + Graphics = &Element_WIFI::graphics; +} + +//#TPT-Directive ElementHeader Element_WIFI static int update(UPDATE_FUNC_ARGS) +int Element_WIFI::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + parts[i].tmp = (int)((parts[i].temp-73.15f)/100+1); + if (parts[i].tmp>=CHANNELS) parts[i].tmp = CHANNELS-1; + else if (parts[i].tmp<0) parts[i].tmp = 0; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rxwireless[parts[i].tmp][0]) + { + if (((r&0xFF)==PT_NSCN||(r&0xFF)==PT_PSCN||(r&0xFF)==PT_INWR)&&parts[r>>8].life==0 && sim->wireless[parts[i].tmp][0]) + { + parts[r>>8].ctype = r&0xFF; + sim->part_change_type(r>>8,x+rx,y+ry,PT_SPRK); + parts[r>>8].life = 4; + } + } + else + { + if ((r&0xFF)==PT_SPRK && parts[r>>8].ctype!=PT_NSCN && parts[r>>8].life>=3) + { + sim->wireless[parts[i].tmp][1] = 1; + sim->ISWIRE = 2; + } + } + } + return 0; +} + + +//#TPT-Directive ElementHeader Element_WIFI static int graphics(GRAPHICS_FUNC_ARGS) +int Element_WIFI::graphics(GRAPHICS_FUNC_ARGS) + +{ + float frequency = 0.0628; + int q = cpart->tmp; + *colr = sin(frequency*q + 0) * 127 + 128; + *colg = sin(frequency*q + 2) * 127 + 128; + *colb = sin(frequency*q + 4) * 127 + 128; + return 0; +} + + +Element_WIFI::~Element_WIFI() {} \ No newline at end of file diff --git a/src/simulation/elements/WIRE.cpp b/src/simulation/elements/WIRE.cpp new file mode 100644 index 000000000..4f5906060 --- /dev/null +++ b/src/simulation/elements/WIRE.cpp @@ -0,0 +1,127 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_WIRE PT_WIRE 156 +Element_WIRE::Element_WIRE() +{ + Identifier = "DEFAULT_PT_WIRE"; + Name = "WIRE"; + Colour = PIXPACK(0xFFCC00); + MenuVisible = 1; + MenuSection = SC_ELEC; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.00f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 0; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 250; + Description = "WireWorld wires."; + + State = ST_SOLID; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_WIRE::update; + Graphics = &Element_WIRE::graphics; +} + +//#TPT-Directive ElementHeader Element_WIRE static int update(UPDATE_FUNC_ARGS) +int Element_WIRE::update(UPDATE_FUNC_ARGS) + { + int s,r,rx,ry,count; + /* + 0: wire + 1: spark head + 2: spark tail + + tmp is previous state, ctype is current state + */ + //parts[i].tmp=parts[i].ctype; + parts[i].ctype=0; + if(parts[i].tmp==1) + { + parts[i].ctype=2; + } + if(parts[i].tmp==2) + { + parts[i].ctype=0; + } + + count=0; + for(rx=-1; rx<2; rx++) + for(ry=-1; ry<2; ry++) + { + if(x+rx>=0 && y+ry>0 && x+rx>8].life==3 && parts[r>>8].ctype==PT_PSCN) + { + parts[i].ctype=1; + return 0; + } + else if((r&0xFF)==PT_NSCN && parts[i].tmp==1){sim->create_part(-1, x+rx, y+ry, PT_SPRK);} + else if((r&0xFF)==PT_WIRE && parts[r>>8].tmp==1 && !parts[i].tmp){count++;} + } + } + if(count==1 || count==2) + parts[i].ctype=1; + return 0; +} + + + +//#TPT-Directive ElementHeader Element_WIRE static int graphics(GRAPHICS_FUNC_ARGS) +int Element_WIRE::graphics(GRAPHICS_FUNC_ARGS) + +{ + if (cpart->ctype==0) + { + *colr = 255; + *colg = 204; + *colb = 0; + return 0; + } + if (cpart->ctype==1) + { + *colr = 50; + *colg = 100; + *colb = 255; + //*pixel_mode |= PMODE_GLOW; + return 0; + } + if (cpart->ctype==2) + { + *colr = 255; + *colg = 100; + *colb = 50; + //*pixel_mode |= PMODE_GLOW; + return 0; + } + return 0; +} + + +Element_WIRE::~Element_WIRE() {} \ No newline at end of file diff --git a/src/simulation/elements/WOOD.cpp b/src/simulation/elements/WOOD.cpp new file mode 100644 index 000000000..c53be8e57 --- /dev/null +++ b/src/simulation/elements/WOOD.cpp @@ -0,0 +1,49 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_WOOD PT_WOOD 17 +Element_WOOD::Element_WOOD() +{ + Identifier = "DEFAULT_PT_WOOD"; + Name = "WOOD"; + Colour = PIXPACK(0xC0A040); + MenuVisible = 1; + MenuSection = SC_SOLIDS; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 20; + Explosive = 0; + Meltable = 0; + Hardness = 15; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 164; + Description = "Solid. Flammable."; + + State = ST_SOLID; + Properties = TYPE_SOLID | PROP_NEUTPENETRATE; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 873.0f; + HighTemperatureTransition = PT_FIRE; + + Update = NULL; + Graphics = NULL; +} + +Element_WOOD::~Element_WOOD() {} \ No newline at end of file diff --git a/src/simulation/elements/WTRV.cpp b/src/simulation/elements/WTRV.cpp new file mode 100644 index 000000000..8850cff98 --- /dev/null +++ b/src/simulation/elements/WTRV.cpp @@ -0,0 +1,73 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_WTRV PT_WTRV 23 +Element_WTRV::Element_WTRV() +{ + Identifier = "DEFAULT_PT_WTRV"; + Name = "WTRV"; + Colour = PIXPACK(0xA0A0FF); + MenuVisible = 1; + MenuSection = SC_GAS; + Enabled = 1; + + Advection = 1.0f; + AirDrag = 0.01f * CFDS; + AirLoss = 0.99f; + Loss = 0.30f; + Collision = -0.1f; + Gravity = -0.1f; + Diffusion = 0.75f; + HotAir = 0.0003f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 4; + + Weight = 1; + + Temperature = R_TEMP+100.0f+273.15f; + HeatConduct = 48; + Description = "Steam, heats up air, produced from hot water."; + + State = ST_GAS; + Properties = TYPE_GAS; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = 371.0f; + LowTemperatureTransition = ST; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_WTRV::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_WTRV static int update(UPDATE_FUNC_ARGS) +int Element_WTRV::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rxlegacy_enable && parts[i].temp>(273.15f+12.0f) && 1>(rand()%500)) + { + sim->part_change_type(i,x,y,PT_FIRE); + parts[i].life = 4; + parts[i].ctype = PT_WATR; + } + } + if(parts[i].temp>1273&&parts[i].ctype==PT_FIRE) + parts[i].temp-=parts[i].temp/1000; + return 0; +} + + +Element_WTRV::~Element_WTRV() {} \ No newline at end of file diff --git a/src/simulation/elements/YEST.cpp b/src/simulation/elements/YEST.cpp new file mode 100644 index 000000000..1b1b8fed7 --- /dev/null +++ b/src/simulation/elements/YEST.cpp @@ -0,0 +1,72 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_YEST PT_YEST 63 +Element_YEST::Element_YEST() +{ + Identifier = "DEFAULT_PT_YEST"; + Name = "YEST"; + Colour = PIXPACK(0xEEE0C0); + MenuVisible = 1; + MenuSection = SC_POWDERS; + Enabled = 1; + + Advection = 0.7f; + AirDrag = 0.02f * CFDS; + AirLoss = 0.96f; + Loss = 0.80f; + Collision = 0.0f; + Gravity = 0.1f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 1; + + Flammable = 15; + Explosive = 0; + Meltable = 0; + Hardness = 30; + + Weight = 80; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 70; + Description = "Yeast, grows when warm (~37C)."; + + State = ST_SOLID; + Properties = TYPE_PART; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = 373.0f; + HighTemperatureTransition = PT_DYST; + + Update = &Element_YEST::update; + Graphics = NULL; +} + +//#TPT-Directive ElementHeader Element_YEST static int update(UPDATE_FUNC_ARGS) +int Element_YEST::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx(rand()%30) && !sim->legacy_enable) + { + sim->part_change_type(i,x,y,PT_DYST); + } + } + if (parts[i].temp>303&&parts[i].temp<317) { + sim->create_part(-1, x+rand()%3-1, y+rand()%3-1, PT_YEST); + } + return 0; +} + + +Element_YEST::~Element_YEST() {} \ No newline at end of file diff --git a/src/simulation/elements/dcel.cpp b/src/simulation/elements/dcel.cpp new file mode 100644 index 000000000..07f930b20 --- /dev/null +++ b/src/simulation/elements/dcel.cpp @@ -0,0 +1,85 @@ +#include "simulation/Elements.h" +//#TPT-Directive ElementClass Element_DCEL PT_DCEL 138 +Element_DCEL::Element_DCEL() +{ + Identifier = "DEFAULT_PT_DCEL"; + Name = "DCEL"; + Colour = PIXPACK(0x99CC00); + MenuVisible = 1; + MenuSection = SC_FORCE; + Enabled = 1; + + Advection = 0.0f; + AirDrag = 0.00f * CFDS; + AirLoss = 0.90f; + Loss = 0.00f; + Collision = 0.0f; + Gravity = 0.0f; + Diffusion = 0.00f; + HotAir = 0.000f * CFDS; + Falldown = 0; + + Flammable = 0; + Explosive = 0; + Meltable = 0; + Hardness = 1; + + Weight = 100; + + Temperature = R_TEMP+0.0f +273.15f; + HeatConduct = 251; + Description = "Decelerator"; + + State = ST_NONE; + Properties = TYPE_SOLID; + + LowPressure = IPL; + LowPressureTransition = NT; + HighPressure = IPH; + HighPressureTransition = NT; + LowTemperature = ITL; + LowTemperatureTransition = NT; + HighTemperature = ITH; + HighTemperatureTransition = NT; + + Update = &Element_DCEL::update; + Graphics = &Element_DCEL::graphics; +} + +//#TPT-Directive ElementHeader Element_DCEL static int update(UPDATE_FUNC_ARGS) +int Element_DCEL::update(UPDATE_FUNC_ARGS) + { + int r, rx, ry; + parts[i].tmp = 0; + for (rx=-1; rx<2; rx++) + for (ry=-1; ry<2; ry++) + if (x+rx>=0 && y+ry>0 && x+rxphotons[y+ry][x+rx]; + if ((r>>8)>=NPART || !r) + continue; + if(sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) + { + parts[r>>8].vx *= 0.9f; + parts[r>>8].vy *= 0.9f; + parts[i].tmp = 1; + } + } + return 0; +} + + + +//#TPT-Directive ElementHeader Element_DCEL static int graphics(GRAPHICS_FUNC_ARGS) +int Element_DCEL::graphics(GRAPHICS_FUNC_ARGS) + +{ + if(cpart->tmp) + *pixel_mode |= PMODE_GLOW; + return 0; +} + + +Element_DCEL::~Element_DCEL() {} \ No newline at end of file diff --git a/src/stamps/StampsModel.h b/src/stamps/StampsModel.h index 0356349f8..48d3c38eb 100644 --- a/src/stamps/StampsModel.h +++ b/src/stamps/StampsModel.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include "search/Save.h" class StampsView;