some changes to LIGH creation (mostly from lua)
This commit is contained in:
parent
fef767335f
commit
8e7e8e0670
@ -114,11 +114,7 @@ WindTool::WindTool(int id, string name, string description, int r, int g, int b,
|
|||||||
Tool(id, name, description, r, g, b, identifier, textureGen)
|
Tool(id, name, description, r, g, b, identifier, textureGen)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
WindTool::~WindTool() {}
|
|
||||||
void WindTool::Draw(Simulation * sim, Brush * brush, ui::Point position)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
void WindTool::DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging)
|
void WindTool::DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging)
|
||||||
{
|
{
|
||||||
int radiusX, radiusY, sizeX, sizeY;
|
int radiusX, radiusY, sizeX, sizeY;
|
||||||
@ -146,39 +142,15 @@ void WindTool::DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void WindTool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {}
|
|
||||||
void WindTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {}
|
|
||||||
|
|
||||||
|
|
||||||
void Element_LIGH_Tool::Draw(Simulation * sim, Brush * brush, ui::Point position)
|
void Element_LIGH_Tool::DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging)
|
||||||
{
|
{
|
||||||
if(sim->currentTick >= nextUse)
|
if (dragging)
|
||||||
{
|
sim->CreateParts(position1.X, position1.Y, brush->GetRadius().X, brush->GetRadius().Y, PT_LIGH);
|
||||||
int p = sim->create_part(-2, position.X, position.Y, toolID);
|
|
||||||
if (p != -1)
|
|
||||||
{
|
|
||||||
sim->parts[p].life = brush->GetRadius().X+brush->GetRadius().Y;
|
|
||||||
if (sim->parts[p].life > 55)
|
|
||||||
sim->parts[p].life = 55;
|
|
||||||
sim->parts[p].temp = sim->parts[p].life*150; // temperature of the lighting shows the power of the lighting
|
|
||||||
nextUse = sim->currentTick+sim->parts[p].life/4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Element_TESC_Tool::Element_TESC_Tool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int)):
|
|
||||||
ElementTool(id, name, description, r, g, b, identifier, textureGen)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
void Element_TESC_Tool::Draw(Simulation * sim, Brush * brush, ui::Point position){
|
|
||||||
int radiusInfo = brush->GetRadius().X*4+brush->GetRadius().Y*4+7;
|
|
||||||
sim->CreateParts(position.X, position.Y, toolID | (radiusInfo << 8), brush);
|
|
||||||
}
|
|
||||||
void Element_TESC_Tool::DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging) {
|
|
||||||
int radiusInfo = brush->GetRadius().X*4+brush->GetRadius().Y*4+7;
|
|
||||||
sim->CreateLine(position1.X, position1.Y, position2.X, position2.Y, toolID | (radiusInfo << 8), brush);
|
|
||||||
}
|
|
||||||
void Element_TESC_Tool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {
|
void Element_TESC_Tool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {
|
||||||
int radiusInfo = brush->GetRadius().X*4+brush->GetRadius().Y*4+7;
|
int radiusInfo = brush->GetRadius().X*4+brush->GetRadius().Y*4+7;
|
||||||
sim->CreateBox(position1.X, position1.Y, position2.X, position2.Y, toolID | (radiusInfo << 8));
|
sim->CreateBox(position1.X, position1.Y, position2.X, position2.Y, toolID | (radiusInfo << 8));
|
||||||
|
@ -104,17 +104,13 @@ public:
|
|||||||
|
|
||||||
class Element_LIGH_Tool: public Tool
|
class Element_LIGH_Tool: public Tool
|
||||||
{
|
{
|
||||||
int nextUse;
|
|
||||||
public:
|
public:
|
||||||
Element_LIGH_Tool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL):
|
Element_LIGH_Tool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL):
|
||||||
Tool(id, name, description, r, g, b, identifier, textureGen),
|
Tool(id, name, description, r, g, b, identifier, textureGen)
|
||||||
nextUse(0)
|
{ }
|
||||||
{
|
virtual ~Element_LIGH_Tool() { }
|
||||||
}
|
|
||||||
virtual ~Element_LIGH_Tool() {}
|
|
||||||
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
|
|
||||||
virtual void Click(Simulation * sim, Brush * brush, ui::Point position) { }
|
virtual void Click(Simulation * sim, Brush * brush, ui::Point position) { }
|
||||||
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging = false) { }
|
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging = false);
|
||||||
virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) { }
|
virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) { }
|
||||||
virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position) { }
|
virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position) { }
|
||||||
};
|
};
|
||||||
@ -134,10 +130,10 @@ public:
|
|||||||
class Element_TESC_Tool: public ElementTool
|
class Element_TESC_Tool: public ElementTool
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Element_TESC_Tool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL);
|
Element_TESC_Tool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL):
|
||||||
|
ElementTool(id, name, description, r, g, b, identifier, textureGen)
|
||||||
|
{ }
|
||||||
virtual ~Element_TESC_Tool() {}
|
virtual ~Element_TESC_Tool() {}
|
||||||
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
|
|
||||||
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging = false);
|
|
||||||
virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2);
|
virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2);
|
||||||
virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position);
|
virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position);
|
||||||
};
|
};
|
||||||
@ -146,11 +142,10 @@ class PlopTool: public ElementTool
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PlopTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL):
|
PlopTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL):
|
||||||
ElementTool(id, name, description, r, g, b, identifier, textureGen)
|
ElementTool(id, name, description, r, g, b, identifier, textureGen)
|
||||||
{
|
{ }
|
||||||
}
|
virtual ~PlopTool() { }
|
||||||
virtual ~PlopTool() {}
|
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position) { }
|
||||||
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position) {}
|
|
||||||
virtual void Click(Simulation * sim, Brush * brush, ui::Point position);
|
virtual void Click(Simulation * sim, Brush * brush, ui::Point position);
|
||||||
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging = false) { }
|
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging = false) { }
|
||||||
virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) { }
|
virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) { }
|
||||||
@ -172,11 +167,11 @@ class WindTool: public Tool
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WindTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL);
|
WindTool(int id, string name, string description, int r, int g, int b, std::string identifier, VideoBuffer * (*textureGen)(int, int, int) = NULL);
|
||||||
virtual ~WindTool();
|
virtual ~WindTool() { }
|
||||||
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
|
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position) { }
|
||||||
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging = false);
|
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging = false);
|
||||||
virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2);
|
virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) { }
|
||||||
virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position);
|
virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* TOOL_H_ */
|
#endif /* TOOL_H_ */
|
||||||
|
@ -1256,16 +1256,36 @@ int Simulation::CreateParts(int positionX, int positionY, int c, Brush * cBrush,
|
|||||||
{
|
{
|
||||||
if (flags == -1)
|
if (flags == -1)
|
||||||
flags = replaceModeFlags;
|
flags = replaceModeFlags;
|
||||||
if(cBrush)
|
if (cBrush)
|
||||||
{
|
{
|
||||||
int radiusX = cBrush->GetRadius().X, radiusY = cBrush->GetRadius().Y, sizeX = cBrush->GetSize().X, sizeY = cBrush->GetSize().Y;
|
int radiusX = cBrush->GetRadius().X, radiusY = cBrush->GetRadius().Y, sizeX = cBrush->GetSize().X, sizeY = cBrush->GetSize().Y;
|
||||||
unsigned char *bitmap = cBrush->GetBitmap();
|
unsigned char *bitmap = cBrush->GetBitmap();
|
||||||
|
|
||||||
for(int y = sizeY-1; y >=0; y--)
|
// special case for LIGH
|
||||||
|
if (c == PT_LIGH)
|
||||||
{
|
{
|
||||||
for(int x = 0; x < sizeX; x++)
|
if (currentTick < lightningRecreate)
|
||||||
|
return 1;
|
||||||
|
int newlife = radiusX + radiusY;
|
||||||
|
if (newlife > 55)
|
||||||
|
newlife = 55;
|
||||||
|
c = c|newlife<<8;
|
||||||
|
lightningRecreate = currentTick+newlife/4;
|
||||||
|
return CreatePartFlags(positionX, positionY, c, flags);
|
||||||
|
}
|
||||||
|
else if (c == PT_TESC)
|
||||||
|
{
|
||||||
|
int newtmp = (radiusX*4+radiusY*4+7);
|
||||||
|
if (newtmp > 300)
|
||||||
|
newtmp = 300;
|
||||||
|
c = c|newtmp<<8;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int y = sizeY-1; y >=0; y--)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < sizeX; x++)
|
||||||
{
|
{
|
||||||
if(bitmap[(y*sizeX)+x] && (positionX+(x-radiusX) >= 0 && positionY+(y-radiusY) >= 0 && positionX+(x-radiusX) < XRES && positionY+(y-radiusY) < YRES))
|
if (bitmap[(y*sizeX)+x] && (positionX+(x-radiusX) >= 0 && positionY+(y-radiusY) >= 0 && positionX+(x-radiusX) < XRES && positionY+(y-radiusY) < YRES))
|
||||||
{
|
{
|
||||||
CreatePartFlags(positionX+(x-radiusX), positionY+(y-radiusY), c, flags);
|
CreatePartFlags(positionX+(x-radiusX), positionY+(y-radiusY), c, flags);
|
||||||
}
|
}
|
||||||
@ -1277,16 +1297,36 @@ int Simulation::CreateParts(int positionX, int positionY, int c, Brush * cBrush,
|
|||||||
|
|
||||||
int Simulation::CreateParts(int x, int y, int rx, int ry, int c, int flags)
|
int Simulation::CreateParts(int x, int y, int rx, int ry, int c, int flags)
|
||||||
{
|
{
|
||||||
int i, j, f = 0;
|
bool created = false;
|
||||||
|
|
||||||
if (flags == -1)
|
if (flags == -1)
|
||||||
flags = replaceModeFlags;
|
flags = replaceModeFlags;
|
||||||
|
|
||||||
for (j=-ry; j<=ry; j++)
|
// special case for LIGH
|
||||||
for (i=-rx; i<=rx; i++)
|
if (c == PT_LIGH)
|
||||||
|
{
|
||||||
|
if (currentTick < lightningRecreate)
|
||||||
|
return 1;
|
||||||
|
int newlife = rx + ry;
|
||||||
|
if (newlife > 55)
|
||||||
|
newlife = 55;
|
||||||
|
c = c|newlife<<8;
|
||||||
|
lightningRecreate = currentTick+newlife/4;
|
||||||
|
rx = ry = 0;
|
||||||
|
}
|
||||||
|
else if (c == PT_TESC)
|
||||||
|
{
|
||||||
|
int newtmp = (rx*4+ry*4+7);
|
||||||
|
if (newtmp > 300)
|
||||||
|
newtmp = 300;
|
||||||
|
c = c|newtmp<<8;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = -ry; j <= ry; j++)
|
||||||
|
for (int i = -rx; i <= rx; i++)
|
||||||
if (CreatePartFlags(x+i, y+j, c, flags))
|
if (CreatePartFlags(x+i, y+j, c, flags))
|
||||||
f = 1;
|
created = true;
|
||||||
return !f;
|
return !created;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Simulation::CreatePartFlags(int x, int y, int c, int flags)
|
int Simulation::CreatePartFlags(int x, int y, int c, int flags)
|
||||||
@ -3041,11 +3081,16 @@ int Simulation::create_part(int p, int x, int y, int tv)
|
|||||||
case PT_LIGH:
|
case PT_LIGH:
|
||||||
{
|
{
|
||||||
float gx, gy, gsize;
|
float gx, gy, gsize;
|
||||||
if (p!=-2)
|
|
||||||
|
if (v >= 0)
|
||||||
{
|
{
|
||||||
parts[i].life=30;
|
if (v > 55)
|
||||||
parts[i].temp=parts[i].life*150.0f; // temperature of the lighting shows the power of the lighting
|
v = 55;
|
||||||
|
parts[i].life = v;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
parts[i].life = 30;
|
||||||
|
parts[i].temp = parts[i].life*150.0f; // temperature of the lightning shows the power of the lightning
|
||||||
GetGravityField(x, y, 1.0f, 1.0f, gx, gy);
|
GetGravityField(x, y, 1.0f, 1.0f, gx, gy);
|
||||||
gsize = gx*gx+gy*gy;
|
gsize = gx*gx+gy*gy;
|
||||||
if (gsize<0.0016f)
|
if (gsize<0.0016f)
|
||||||
@ -4896,6 +4941,7 @@ Simulation::Simulation():
|
|||||||
ISWIRE(0),
|
ISWIRE(0),
|
||||||
force_stacking_check(0),
|
force_stacking_check(0),
|
||||||
emp_decor(0),
|
emp_decor(0),
|
||||||
|
lightningRecreate(0),
|
||||||
gravWallChanged(false),
|
gravWallChanged(false),
|
||||||
edgeMode(0),
|
edgeMode(0),
|
||||||
gravityMode(0),
|
gravityMode(0),
|
||||||
|
@ -62,6 +62,7 @@ public:
|
|||||||
int ISWIRE;
|
int ISWIRE;
|
||||||
int force_stacking_check;
|
int force_stacking_check;
|
||||||
int emp_decor;
|
int emp_decor;
|
||||||
|
int lightningRecreate;
|
||||||
//Stickman
|
//Stickman
|
||||||
playerst player;
|
playerst player;
|
||||||
playerst player2;
|
playerst player2;
|
||||||
|
Loading…
Reference in New Issue
Block a user