Fix ability to build ship with holes

main
Cameron Murphy Reikes 2 years ago
parent bb063cf372
commit e10eed315e

@ -301,12 +301,8 @@ void box_create(GameState* gs, Entity* new_box, Entity* grid, V2 pos)
// removes boxes from grid, then ensures that the rule that grids must not have // removes boxes from grid, then ensures that the rule that grids must not have
// holes in them is applied. // holes in them is applied.
static void grid_remove_box(GameState* gs, struct Entity* grid, struct Entity* box) static void grid_correct_for_holes(GameState* gs, struct Entity* grid)
{ {
assert(grid->is_grid);
assert(box->is_box);
entity_destroy(gs, box);
int num_boxes = grid_num_boxes(gs, grid); int num_boxes = grid_num_boxes(gs, grid);
if (num_boxes == 0) if (num_boxes == 0)
{ {
@ -453,6 +449,14 @@ static void grid_remove_box(GameState* gs, struct Entity* grid, struct Entity* b
} }
} }
static void grid_remove_box(GameState* gs, struct Entity* grid, struct Entity* box)
{
assert(grid->is_grid);
assert(box->is_box);
entity_destroy(gs, box);
grid_correct_for_holes(gs, grid);
}
static cpBool on_damage(cpArbiter* arb, cpSpace* space, cpDataPointer userData) static cpBool on_damage(cpArbiter* arb, cpSpace* space, cpDataPointer userData)
{ {
cpShape* a, * b; cpShape* a, * b;
@ -1124,6 +1128,7 @@ void process(GameState* gs, float dt)
{ {
Entity* new_box = new_entity(gs); Entity* new_box = new_entity(gs);
box_create(gs, new_box, target_grid, grid_world_to_local(target_grid, world_build)); box_create(gs, new_box, target_grid, grid_world_to_local(target_grid, world_build));
grid_correct_for_holes(gs, target_grid); // no holey ship for you!
new_box->box_type = player->input.build_type; new_box->box_type = player->input.build_type;
new_box->compass_rotation = player->input.build_rotation; new_box->compass_rotation = player->input.build_rotation;
p->spice_taken_away += 0.1f; p->spice_taken_away += 0.1f;

Loading…
Cancel
Save