summaryrefslogtreecommitdiff
path: root/src/simulation/elements
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-08-29 21:04:07 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-08-29 21:04:07 (GMT)
commit58dc2559aad5abb3ae23f89155a4cdf37e0de885 (patch)
treea7a452483b8875f3a95145578d7d45c36d53b52d /src/simulation/elements
parent3e78f64da8265816e973c6047fc9985193311e31 (diff)
downloadpowder-58dc2559aad5abb3ae23f89155a4cdf37e0de885.zip
powder-58dc2559aad5abb3ae23f89155a4cdf37e0de885.tar.gz
Implement retrieval of element properties
Diffstat (limited to 'src/simulation/elements')
-rw-r--r--src/simulation/elements/Element.cpp38
-rw-r--r--src/simulation/elements/Element.h5
2 files changed, 43 insertions, 0 deletions
diff --git a/src/simulation/elements/Element.cpp b/src/simulation/elements/Element.cpp
index 8d4b997..9c1002a 100644
--- a/src/simulation/elements/Element.cpp
+++ b/src/simulation/elements/Element.cpp
@@ -1,4 +1,5 @@
#include "simulation/Elements.h"
+#include "simulation/StructProperty.h"
Element::Element():
Identifier("DEFAULT_INVALID"),
@@ -47,6 +48,43 @@ Element::Element():
{
}
+std::vector<StructProperty> Element::GetProperties()
+{
+ std::vector<StructProperty> properties;
+ properties.push_back(StructProperty("Name", StructProperty::String, offsetof(Element, Name)));
+ properties.push_back(StructProperty("Colour", StructProperty::Colour, offsetof(Element, Colour)));
+ properties.push_back(StructProperty("MenuVisible", StructProperty::Integer, offsetof(Element, MenuVisible)));
+ properties.push_back(StructProperty("MenuSection", StructProperty::Integer, offsetof(Element, MenuSection)));
+ properties.push_back(StructProperty("Advection", StructProperty::Float, offsetof(Element, Advection)));
+ properties.push_back(StructProperty("AirDrag", StructProperty::Float, offsetof(Element, AirDrag)));
+ properties.push_back(StructProperty("AirLoss", StructProperty::Float, offsetof(Element, AirLoss)));
+ properties.push_back(StructProperty("Loss", StructProperty::Float, offsetof(Element, Loss)));
+ properties.push_back(StructProperty("Collision", StructProperty::Float, offsetof(Element, Collision)));
+ properties.push_back(StructProperty("Gravity", StructProperty::Float, offsetof(Element, Gravity)));
+ properties.push_back(StructProperty("Diffusion", StructProperty::Float, offsetof(Element, Diffusion)));
+ properties.push_back(StructProperty("HotAir", StructProperty::Float, offsetof(Element, HotAir)));
+ properties.push_back(StructProperty("Falldown", StructProperty::Integer, offsetof(Element, Falldown)));
+ properties.push_back(StructProperty("Flammable", StructProperty::Integer, offsetof(Element, Flammable)));
+ properties.push_back(StructProperty("Explosive", StructProperty::Integer, offsetof(Element, Explosive)));
+ properties.push_back(StructProperty("Meltable", StructProperty::Integer, offsetof(Element, Meltable)));
+ properties.push_back(StructProperty("Hardness", StructProperty::Integer, offsetof(Element, Hardness)));
+ properties.push_back(StructProperty("Weight", StructProperty::Integer, offsetof(Element, Weight)));
+ properties.push_back(StructProperty("Temperature", StructProperty::Float, offsetof(Element, Temperature)));
+ properties.push_back(StructProperty("HeatConduct", StructProperty::UChar, offsetof(Element, HeatConduct)));
+ properties.push_back(StructProperty("Description", StructProperty::String, offsetof(Element, Description)));
+ properties.push_back(StructProperty("State", StructProperty::Char, offsetof(Element, State)));
+ properties.push_back(StructProperty("Properties", StructProperty::Integer, offsetof(Element, Properties)));
+ properties.push_back(StructProperty("LowPressure", StructProperty::Float, offsetof(Element, LowPressure)));
+ properties.push_back(StructProperty("LowPressureTransition", StructProperty::Integer, offsetof(Element, LowPressureTransition)));
+ properties.push_back(StructProperty("HighPressure", StructProperty::Float, offsetof(Element, HighPressure)));
+ properties.push_back(StructProperty("HighPressureTransition", StructProperty::Integer, offsetof(Element, HighPressureTransition)));
+ properties.push_back(StructProperty("LowTemperature", StructProperty::Float, offsetof(Element, LowTemperature)));
+ properties.push_back(StructProperty("LowTemperatureTransition", StructProperty::Integer, offsetof(Element, LowTemperatureTransition)));
+ properties.push_back(StructProperty("HighTemperature", StructProperty::Float, offsetof(Element, HighTemperature)));
+ properties.push_back(StructProperty("HighTemperatureTransition", StructProperty::Integer, offsetof(Element, HighTemperatureTransition)));
+ return properties;
+}
+
int Element::legacyUpdate(UPDATE_FUNC_ARGS) {
int r, rx, ry, rt;
int t = parts[i].type;
diff --git a/src/simulation/elements/Element.h b/src/simulation/elements/Element.h
index 9df38d7..b51bddc 100644
--- a/src/simulation/elements/Element.h
+++ b/src/simulation/elements/Element.h
@@ -4,6 +4,7 @@
#include "simulation/Simulation.h"
#include "graphics/Renderer.h"
#include "simulation/Elements.h"
+#include "simulation/StructProperty.h"
class Simulation;
class Renderer;
@@ -53,6 +54,10 @@ public:
virtual ~Element() {}
static int defaultGraphics(GRAPHICS_FUNC_ARGS);
static int legacyUpdate(UPDATE_FUNC_ARGS);
+
+ /** Returns a list of properties, their type and offset within the structure that can be changed
+ by higher-level processes refering to them by name such as Lua or the property tool **/
+ static std::vector<StructProperty> GetProperties();
};
#endif