Skip to content

Commit

Permalink
Guess what mfers, this isn't fully dead yet
Browse files Browse the repository at this point in the history
  • Loading branch information
IonutParau committed Aug 18, 2023
1 parent 5833fb2 commit b061395
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
Empty file modified TODO.md
100644 → 100755
Empty file.
15 changes: 10 additions & 5 deletions lib/layout/tools/saving.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1718,11 +1718,7 @@ class VX {
}

static String encodeID(String id) {
if (stdIDs.containsKey(id) && stdIDs[id] != id) {
return '@$id';
}

return inverseIds[id] ?? id;
return inverseIds[id] ?? '@$id';
}

static int decodeRot(String id, num rot) {
Expand Down Expand Up @@ -1866,6 +1862,15 @@ class VX {
"onedir": "onedir",
"ghost": "ghost",
"ungeneratable": "ungeneratable",
"mobile_trash": "mobile_trash",
"mobile_enemy": "mobile_enemy",
"strong_enemy": "strong_enemy",
"weak_enemy": "weak_enemy",
"driller": "driller",
"balanced_enemy": "balanced_enemy",
"rotational_player": "puzzle",
"controllable_mover": "mover_puzzle",
"rot_180": "rotator_180",
};

static final inverseIds = stdIDs.map((key, value) => MapEntry(value, key));
Expand Down
16 changes: 12 additions & 4 deletions lib/logic/move.dart
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,13 @@ int addedForce(Cell cell, int dir, int force, MoveType mt) {
return scriptingManager.addedForce(cell, dir, force, mt);
}

if(cell.id == "anvil") {
final d = (cell.rot-1)%4;
if(dir == d) {
return -cell.data["velocity"].toInt();
}
}

if (cell.id == "weight") {
return -1;
}
Expand Down Expand Up @@ -1095,21 +1102,22 @@ bool nudge(int x, int y, int rot, {MoveType mt = MoveType.unknown_move}) {
return false;
}

void doSpeedMover(int x, int y, int dir, int force, int speed) {
bool doSpeedMover(int x, int y, int dir, int force, int speed) {
final o = grid.at(x, y).copy;
for (var i = 0; i < speed; i++) {
if (!grid.inside(x, y)) {
return;
return false;
}
if (grid.at(x, y).id != o.id) {
return;
return false;
}
if (!push(x, y, dir, force)) {
return;
return false;
}
x = frontX(x, dir);
y = frontY(y, dir);
}
return true;
}

void doSpeedPuller(int x, int y, int dir, int force, int speed) {
Expand Down
22 changes: 20 additions & 2 deletions lib/logic/update/anvil.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,29 @@ part of logic;

void anvil() {
grid.updateCell((cell, x, y) {
final dir = cell.rot;
final dir = (cell.rot+1)%4;
final double gravity = cell.data["gravity"].toDouble();
final double velocity = cell.data["velocity"].toDouble();
double velocity = cell.data["velocity"].toDouble();
final double breakingVelocity = cell.data["breaking_velocity"].toDouble();
final double lossUponLethalImpact = cell.data["impact_loss"].toDouble();
final double terminalVelocity = cell.data["speed_limit"].toDouble();

cell.data["velocity"] += gravity;
velocity += gravity;
if(velocity > terminalVelocity) {
velocity = terminalVelocity;
cell.data["velocity"] = terminalVelocity;
}

if(doSpeedMover(x, y, dir, velocity.toInt(), velocity.toInt())) {
if(velocity >= breakingVelocity) {
final dx = frontX(x, dir);
final dy = frontY(y, dir);
if(grid.inside(dx, dy) && breakable(grid.at(dx, dy), dx, dy, dir, BreakType.gravity)) {
grid.set(dx, dy, Cell(dx, dy));
}
}
cell.data["velocity"] = velocity * (1 - lossUponLethalImpact / 100);
}
}, null, "anvil");
}

2 comments on commit b061395

@uku1928
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you did it, you madman

@kTheLemon
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kill it with fire

Please sign in to comment.