summaryrefslogtreecommitdiff
path: root/src/simulation/tools/SolidTool.cpp
blob: f8fdf2a152fd5b91e54bddd160ab56204b828221 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "ToolClasses.h"
//#TPT-Directive ToolClass Tool_Solid TOOL_SOLID 6
//#TPT-Directive ToolHeader Tool_Solid int LastSolid
//#TPT-Directive ToolHeader Tool_Solid virtual int Start(Simulation * sim, Particle * cpart, int x, int y)
Tool_Solid::Tool_Solid()
{
    Identifier = "DEFAULT_TOOL_SOLID";
    Name = "SLD";
    Colour = PIXPACK(0xA0A080);
    Description = "Makes affected particles into a solid.";
    LastSolid = -1;
}

int Tool_Solid::Start(Simulation * sim, Particle * cpart, int x, int y) {
    if(cpart && cpart->sld)
        LastSolid = cpart->sld - 1;
    else
        LastSolid = -1;
    return 1;
}

int Tool_Solid::Perform(Simulation * sim, Particle * cpart, int x, int y, float strength)
{
    int solid_index = LastSolid, i;

    if(!cpart || cpart->sld ||
       !(sim->elements[cpart->type].Properties & TYPE_SOLID))
        return 0;

    if(solid_index == -1)
        for(i=0; i<NSOLID; i++)
            if(sim->solids[i].first == -1) {
                solid_index = i;
                break;
            }
    if(solid_index == -1)
        return 0;
    LastSolid = solid_index;

    return sim->link_solid(cpart - sim->parts, solid_index);
}

Tool_Solid::~Tool_Solid() {}