-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a5b841f
commit a39457e
Showing
20 changed files
with
201 additions
and
40 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#ifndef BASE_H | ||
#define BASE_H | ||
|
||
#include "../element.h" | ||
|
||
class Base: public Element { | ||
public: | ||
const double DECAY = 1.0 / 4098; | ||
const double EVAPORATE = 1.0 / 64; | ||
const double EAT = 1.0 / 16; | ||
const double EMIT = 1.0 / 64; | ||
const double DOWN = 1.0 / 1.2; | ||
const double DOWN_BLOCK = 1.0 / 16; | ||
const double MIX = 1.0 / 2; | ||
const double REACT = 1.0 / 2; | ||
|
||
void process(SandSimulation *sim, int row, int col) override { | ||
// Decay | ||
if (sim->randf() < DECAY) { | ||
sim->set_cell(row, col, 22); | ||
return; | ||
} | ||
|
||
sim->liquid_process(row, col, 2); | ||
|
||
bool blocked = !sim->in_bounds(row + 1, col) || sim->get_cell(row + 1, col) == 3; | ||
int new_row = row, new_col = col; | ||
|
||
if (sim->randf() < (blocked ? DOWN_BLOCK : DOWN)) | ||
new_row++; | ||
else | ||
new_col += sim->randf() < 0.5 ? 1 : -1; | ||
|
||
// Ensure that the swallowed cell is in bounds and not base | ||
if (!sim->in_bounds(new_row, new_col) || sim->get_cell(new_row, new_col) == 133) | ||
return; | ||
|
||
// Swap and delete | ||
if (sim->get_cell(new_row, new_col) == 0 || sim->randf() < EAT * (1.0 - sim->elements.at(sim->get_cell(new_row, new_col))->get_acid_resistance())) { | ||
sim->set_cell(new_row, new_col, sim->get_cell(row, col)); | ||
} | ||
|
||
if (sim->randf() < MIX && sim->touch_count(row, col, 21) + sim->touch_count(row, col, 59) > 0) { | ||
sim->set_cell(row, col, 3); | ||
} | ||
|
||
if (sim->randf() < REACT && sim->touch_count(row, col, 17) + sim->touch_count(row, col, 51) + sim->touch_count(row, col, 133) + sim->touch_count(row, col, 135) + sim->touch_count(row, col, 45) + sim->touch_count(row, col, 35) > 0) { | ||
sim->set_cell(row, col, 70); | ||
sim->grow(row - 1, col, -1, 47); | ||
} | ||
} | ||
|
||
double get_density() override { | ||
return 64.0; | ||
} | ||
|
||
double get_explode_resistance() override { | ||
return 0.85; | ||
} | ||
|
||
double get_acid_resistance() override { | ||
return 1.0; | ||
} | ||
|
||
int get_state() override { | ||
return 1; | ||
} | ||
|
||
int get_temperature() override { | ||
return 0; | ||
} | ||
|
||
int get_toxicity() override { | ||
return 1; | ||
} | ||
}; | ||
|
||
#endif // BASE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+27.2 KB
(100%)
extension/sand_simulation.windows.template_debug.x86_64.obj
Binary file not shown.
Binary file modified
BIN
+12.5 KB
(100%)
game/bin/fallingsand/libgdfallingsand.windows.template_debug.x86_64.dll
Binary file not shown.
Binary file modified
BIN
+12.5 KB
(100%)
game/bin/fallingsand/~libgdfallingsand.windows.template_debug.x86_64.dll
Binary file not shown.
Oops, something went wrong.