From b699bb176f41012a43c42dbbf1ec82b7e1c27d3d Mon Sep 17 00:00:00 2001 From: jacob1 Date: Mon, 10 Jun 2013 10:51:55 -0400 Subject: [PATCH] Add two new properties for CLNE-like elements the thing CLNE does, drawing upon it will set ctype; and what BCLN does to CLNE - disables #1). Made use of the two new properties --- src/cat/LuaScriptInterface.cpp | 2 ++ src/simulation/Elements.h | 40 ++++++++++++++++--------------- src/simulation/Simulation.cpp | 20 +++++++--------- src/simulation/elements/BCLN.cpp | 2 +- src/simulation/elements/CLNE.cpp | 2 +- src/simulation/elements/CONV.cpp | 2 +- src/simulation/elements/FIGH.cpp | 2 +- src/simulation/elements/PBCN.cpp | 2 +- src/simulation/elements/PCLN.cpp | 2 +- src/simulation/elements/STKM.cpp | 2 +- src/simulation/elements/STKM2.cpp | 2 +- src/simulation/elements/STOR.cpp | 2 +- 12 files changed, 41 insertions(+), 39 deletions(-) diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index d40309cbc..4cb5bd9ef 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -1737,6 +1737,8 @@ void LuaScriptInterface::initElementsAPI() SETCONST(l, PROP_LIFE_KILL_DEC); SETCONST(l, PROP_SPARKSETTLE); SETCONST(l, PROP_NOAMBHEAT); + SETCONST(l, PROP_DRAWONCTYPE); + SETCONST(l, PROP_NOCTYPEDRAW); SETCONST(l, FLAG_STAGNANT); SETCONST(l, FLAG_SKIPMOVE); SETCONST(l, FLAG_MOVABLE); diff --git a/src/simulation/Elements.h b/src/simulation/Elements.h index 67e2c4bce..54f5483aa 100644 --- a/src/simulation/Elements.h +++ b/src/simulation/Elements.h @@ -10,25 +10,27 @@ #define O_MAX_TEMP 3500 #define O_MIN_TEMP -273 -#define TYPE_PART 0x00001 //1 Powders -#define TYPE_LIQUID 0x00002 //2 Liquids -#define TYPE_SOLID 0x00004 //4 Solids -#define TYPE_GAS 0x00008 //8 Gasses (Includes plasma) -#define TYPE_ENERGY 0x00010 //16 Energy (Thunder, Light, Neutrons etc.) -#define PROP_CONDUCTS 0x00020 //32 Conducts electricity -#define PROP_BLACK 0x00040 //64 Absorbs Photons (not currently implemented or used, a photwl attribute might be better) -#define PROP_NEUTPENETRATE 0x00080 //128 Penetrated by neutrons -#define PROP_NEUTABSORB 0x00100 //256 Absorbs neutrons, reflect is default -#define PROP_NEUTPASS 0x00200 //512 Neutrons pass through, such as with glass -#define PROP_DEADLY 0x00400 //1024 Is deadly for stickman -#define PROP_HOT_GLOW 0x00800 //2048 Hot Metal Glow -#define PROP_LIFE 0x01000 //4096 Is a GoL type -#define PROP_RADIOACTIVE 0x02000 //8192 Radioactive -#define PROP_LIFE_DEC 0x04000 //2^14 Life decreases by one every frame if > zero -#define PROP_LIFE_KILL 0x08000 //2^15 Kill when life value is <= zero -#define PROP_LIFE_KILL_DEC 0x10000 //2^16 Kill when life value is decremented to <= zero -#define PROP_SPARKSETTLE 0x20000 //2^17 Allow Sparks/Embers to settle -#define PROP_NOAMBHEAT 0x40000 //2^18 Don't transfer or receive heat from ambient heat. +#define TYPE_PART 0x00001 //1 Powders +#define TYPE_LIQUID 0x00002 //2 Liquids +#define TYPE_SOLID 0x00004 //4 Solids +#define TYPE_GAS 0x00008 //8 Gasses (Includes plasma) +#define TYPE_ENERGY 0x00010 //16 Energy (Thunder, Light, Neutrons etc.) +#define PROP_CONDUCTS 0x00020 //32 Conducts electricity +#define PROP_BLACK 0x00040 //64 Absorbs Photons (not currently implemented or used, a photwl attribute might be better) +#define PROP_NEUTPENETRATE 0x00080 //128 Penetrated by neutrons +#define PROP_NEUTABSORB 0x00100 //256 Absorbs neutrons, reflect is default +#define PROP_NEUTPASS 0x00200 //512 Neutrons pass through, such as with glass +#define PROP_DEADLY 0x00400 //1024 Is deadly for stickman +#define PROP_HOT_GLOW 0x00800 //2048 Hot Metal Glow +#define PROP_LIFE 0x01000 //4096 Is a GoL type +#define PROP_RADIOACTIVE 0x02000 //8192 Radioactive +#define PROP_LIFE_DEC 0x04000 //2^14 Life decreases by one every frame if > zero +#define PROP_LIFE_KILL 0x08000 //2^15 Kill when life value is <= zero +#define PROP_LIFE_KILL_DEC 0x10000 //2^16 Kill when life value is decremented to <= zero +#define PROP_SPARKSETTLE 0x20000 //2^17 Allow Sparks/Embers to settle +#define PROP_NOAMBHEAT 0x40000 //2^18 Don't transfer or receive heat from ambient heat. +#define PROP_DRAWONCTYPE 0x80000 //2^19 Set its ctype to another element if the element is drawn upon it (like what CLNE does) +#define PROP_NOCTYPEDRAW 0x100000 // 2^20 When this element is drawn upon with, do not set ctype (like BCLN for CLNE) #define FLAG_STAGNANT 0x1 #define FLAG_SKIPMOVE 0x2 // skip movement for one frame, only implemented for PHOT diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index c420f3b53..e696581f6 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -2033,6 +2033,7 @@ void Simulation::init_can_move() } } //a list of lots of things PHOT can move through + // TODO: replace with property for (movingType = 0; movingType < PT_NUM; movingType++) { if (movingType == PT_GLAS || movingType == PT_PHOT || movingType == PT_FILT || movingType == PT_INVIS @@ -2721,20 +2722,17 @@ int Simulation::create_part(int p, int x, int y, int tv) { if (pmap[y][x]) { + //If an element has the PROP_DRAWONCTYPE property, and the element being drawn to it does not have PROP_NOCTYPEDRAW (Also some special cases), set the element's ctype int drawOn = pmap[y][x]&0xFF; - if (( - (drawOn == PT_STOR && !(elements[t].Properties&TYPE_SOLID)) || - drawOn==PT_CLNE || - drawOn==PT_BCLN || - drawOn==PT_CONV || - (drawOn==PT_PCLN&&t!=PT_PSCN&&t!=PT_NSCN) || - (drawOn==PT_PBCN&&t!=PT_PSCN&&t!=PT_NSCN) - )&&( - t != PT_CLNE && t != PT_PCLN && t != PT_BCLN && t != PT_STKM && t != PT_STKM2 && t != PT_PBCN && t != PT_STOR && t != PT_FIGH && t != PT_CONV) - ) + if (((elements[drawOn].Properties & PROP_DRAWONCTYPE) || + (drawOn == PT_STOR && !(elements[t].Properties & TYPE_SOLID)) || + (drawOn == PT_PCLN && t != PT_PSCN && t != PT_NSCN) || + (drawOn == PT_PBCN && t != PT_PSCN && t != PT_NSCN)) + && (!(elements[t].Properties & PROP_NOCTYPEDRAW))) { parts[pmap[y][x]>>8].ctype = t; - if (t == PT_LIFE && v < NGOL && drawOn != PT_STOR) parts[pmap[y][x]>>8].tmp = v; + if (t == PT_LIFE && v < NGOL && drawOn != PT_STOR) + parts[pmap[y][x]>>8].tmp = v; } else if ((drawOn == PT_DTEC || (drawOn == PT_PSTN && t != PT_FRME)) && drawOn != t) { diff --git a/src/simulation/elements/BCLN.cpp b/src/simulation/elements/BCLN.cpp index ecec76611..2ffd07848 100644 --- a/src/simulation/elements/BCLN.cpp +++ b/src/simulation/elements/BCLN.cpp @@ -31,7 +31,7 @@ Element_BCLN::Element_BCLN() Description = "Breakable Clone."; State = ST_NONE; - Properties = TYPE_SOLID|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC; + Properties = TYPE_SOLID|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC|PROP_DRAWONCTYPE|PROP_NOCTYPEDRAW; LowPressure = IPL; LowPressureTransition = NT; diff --git a/src/simulation/elements/CLNE.cpp b/src/simulation/elements/CLNE.cpp index f0dffc265..04b0374d8 100644 --- a/src/simulation/elements/CLNE.cpp +++ b/src/simulation/elements/CLNE.cpp @@ -31,7 +31,7 @@ Element_CLNE::Element_CLNE() Description = "Solid. Duplicates any particles it touches."; State = ST_SOLID; - Properties = TYPE_SOLID; + Properties = TYPE_SOLID|PROP_DRAWONCTYPE|PROP_NOCTYPEDRAW; LowPressure = IPL; LowPressureTransition = NT; diff --git a/src/simulation/elements/CONV.cpp b/src/simulation/elements/CONV.cpp index 59c7b1c86..24baa906f 100644 --- a/src/simulation/elements/CONV.cpp +++ b/src/simulation/elements/CONV.cpp @@ -31,7 +31,7 @@ Element_CONV::Element_CONV() Description = "Solid. Converts everything into whatever it first touches."; State = ST_NONE; - Properties = TYPE_SOLID; + Properties = TYPE_SOLID|PROP_DRAWONCTYPE|PROP_NOCTYPEDRAW; LowPressure = IPL; LowPressureTransition = NT; diff --git a/src/simulation/elements/FIGH.cpp b/src/simulation/elements/FIGH.cpp index 6320c2dad..f476671c1 100644 --- a/src/simulation/elements/FIGH.cpp +++ b/src/simulation/elements/FIGH.cpp @@ -31,7 +31,7 @@ Element_FIGH::Element_FIGH() Description = "Fighter. Tries to kill stickmen. You must first give it an element to kill him with."; State = ST_NONE; - Properties = 0; + Properties = PROP_NOCTYPEDRAW; LowPressure = IPL; LowPressureTransition = NT; diff --git a/src/simulation/elements/PBCN.cpp b/src/simulation/elements/PBCN.cpp index ca2478257..5bff0d5e0 100644 --- a/src/simulation/elements/PBCN.cpp +++ b/src/simulation/elements/PBCN.cpp @@ -31,7 +31,7 @@ Element_PBCN::Element_PBCN() Description = "Powered breakable clone."; State = ST_NONE; - Properties = TYPE_SOLID; + Properties = TYPE_SOLID|PROP_NOCTYPEDRAW; LowPressure = IPL; LowPressureTransition = NT; diff --git a/src/simulation/elements/PCLN.cpp b/src/simulation/elements/PCLN.cpp index 441014a80..26b096085 100644 --- a/src/simulation/elements/PCLN.cpp +++ b/src/simulation/elements/PCLN.cpp @@ -31,7 +31,7 @@ Element_PCLN::Element_PCLN() Description = "Powered clone. When activated, duplicates any particles it touches."; State = ST_NONE; - Properties = TYPE_SOLID; + Properties = TYPE_SOLID|PROP_NOCTYPEDRAW; LowPressure = IPL; LowPressureTransition = NT; diff --git a/src/simulation/elements/STKM.cpp b/src/simulation/elements/STKM.cpp index 67d8cdfd4..39b389aa0 100644 --- a/src/simulation/elements/STKM.cpp +++ b/src/simulation/elements/STKM.cpp @@ -31,7 +31,7 @@ Element_STKM::Element_STKM() Description = "Stickman. Don't kill him! Control with the arrow keys."; State = ST_NONE; - Properties = 0; + Properties = PROP_NOCTYPEDRAW; LowPressure = IPL; LowPressureTransition = NT; diff --git a/src/simulation/elements/STKM2.cpp b/src/simulation/elements/STKM2.cpp index ee94adb25..d9c3d9a83 100644 --- a/src/simulation/elements/STKM2.cpp +++ b/src/simulation/elements/STKM2.cpp @@ -31,7 +31,7 @@ Element_STKM2::Element_STKM2() Description = "Second stickman. Don't kill him! Control with wasd."; State = ST_NONE; - Properties = 0; + Properties = PROP_NOCTYPEDRAW; LowPressure = IPL; LowPressureTransition = NT; diff --git a/src/simulation/elements/STOR.cpp b/src/simulation/elements/STOR.cpp index a09096f66..ce26767ec 100644 --- a/src/simulation/elements/STOR.cpp +++ b/src/simulation/elements/STOR.cpp @@ -31,7 +31,7 @@ Element_STOR::Element_STOR() Description = "Captures and stores a single particle. releases when charged with PSCN, also passes to PIPE."; State = ST_NONE; - Properties = TYPE_SOLID; + Properties = TYPE_SOLID|PROP_NOCTYPEDRAW; LowPressure = IPL; LowPressureTransition = NT;