|
|
@ -809,6 +809,7 @@ void ser_entity(SerState* ser, GameState* gs, Entity* e)
|
|
|
|
ser_entityid(ser, &e->next_box);
|
|
|
|
ser_entityid(ser, &e->next_box);
|
|
|
|
ser_entityid(ser, &e->prev_box);
|
|
|
|
ser_entityid(ser, &e->prev_box);
|
|
|
|
SER_VAR(&e->compass_rotation);
|
|
|
|
SER_VAR(&e->compass_rotation);
|
|
|
|
|
|
|
|
SER_VAR(&e->indestructible);
|
|
|
|
SER_VAR(&e->thrust);
|
|
|
|
SER_VAR(&e->thrust);
|
|
|
|
SER_VAR(&e->wanted_thrust);
|
|
|
|
SER_VAR(&e->wanted_thrust);
|
|
|
|
SER_VAR(&e->energy_used);
|
|
|
|
SER_VAR(&e->energy_used);
|
|
|
@ -1054,6 +1055,45 @@ void entity_ensure_in_orbit(Entity* e)
|
|
|
|
cpBodySetVelocity(e->body, cpvmult(cpvperp(pos), v));
|
|
|
|
cpBodySetVelocity(e->body, cpvmult(cpvperp(pos), v));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EntityID create_spacestation(GameState* gs)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
#define BOX_AT_TYPE(grid, pos, type) { Entity* box = new_entity(gs); box_create(gs, box, grid, pos); box->box_type = type; box->indestructible = indestructible; }
|
|
|
|
|
|
|
|
#define BOX_AT(grid, pos) BOX_AT_TYPE(grid, pos, BoxHullpiece)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool indestructible = false;
|
|
|
|
|
|
|
|
Entity* grid = new_entity(gs);
|
|
|
|
|
|
|
|
grid_create(gs, grid);
|
|
|
|
|
|
|
|
entity_set_pos(grid, (V2) { -150.0f, 0.0f });
|
|
|
|
|
|
|
|
entity_ensure_in_orbit(grid);
|
|
|
|
|
|
|
|
Entity* explosion_box = new_entity(gs);
|
|
|
|
|
|
|
|
box_create(gs, explosion_box, grid, (V2) { 0 });
|
|
|
|
|
|
|
|
explosion_box->is_explosion_unlock = true;
|
|
|
|
|
|
|
|
BOX_AT_TYPE(grid, ((V2) { BOX_SIZE, 0 }), BoxExplosive);
|
|
|
|
|
|
|
|
BOX_AT_TYPE(grid, ((V2) { BOX_SIZE*2, 0 }), BoxHullpiece);
|
|
|
|
|
|
|
|
BOX_AT_TYPE(grid, ((V2) { BOX_SIZE*3, 0 }), BoxHullpiece);
|
|
|
|
|
|
|
|
BOX_AT_TYPE(grid, ((V2) { BOX_SIZE*4, 0 }), BoxHullpiece);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
indestructible = true;
|
|
|
|
|
|
|
|
for (float y = -BOX_SIZE * 5.0; y <= BOX_SIZE * 5.0; y += BOX_SIZE)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
BOX_AT_TYPE(grid, ((V2) { BOX_SIZE*5.0, y }), BoxHullpiece);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (float x = -BOX_SIZE * 5.0; x <= BOX_SIZE * 5.0; x += BOX_SIZE)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
BOX_AT_TYPE(grid, ((V2) { x, BOX_SIZE*5.0 }), BoxHullpiece);
|
|
|
|
|
|
|
|
BOX_AT_TYPE(grid, ((V2) { x, -BOX_SIZE*5.0 }), BoxHullpiece);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
indestructible = false;
|
|
|
|
|
|
|
|
BOX_AT_TYPE(grid, ((V2) { -BOX_SIZE*6.0, BOX_SIZE*5.0 }), BoxExplosive);
|
|
|
|
|
|
|
|
BOX_AT_TYPE(grid, ((V2) { -BOX_SIZE*6.0, BOX_SIZE*3.0 }), BoxExplosive);
|
|
|
|
|
|
|
|
BOX_AT_TYPE(grid, ((V2) { -BOX_SIZE*6.0, BOX_SIZE*1.0 }), BoxExplosive);
|
|
|
|
|
|
|
|
BOX_AT_TYPE(grid, ((V2) { -BOX_SIZE*6.0, -BOX_SIZE*2.0 }), BoxExplosive);
|
|
|
|
|
|
|
|
BOX_AT_TYPE(grid, ((V2) { -BOX_SIZE*6.0, -BOX_SIZE*3.0 }), BoxExplosive);
|
|
|
|
|
|
|
|
BOX_AT_TYPE(grid, ((V2) { -BOX_SIZE*6.0, -BOX_SIZE*5.0 }), BoxExplosive);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return get_id(gs, grid);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void process(GameState* gs, float dt)
|
|
|
|
void process(GameState* gs, float dt)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
assert(gs->space != NULL);
|
|
|
|
assert(gs->space != NULL);
|
|
|
@ -1178,10 +1218,13 @@ void process(GameState* gs, float dt)
|
|
|
|
if (nearest != NULL)
|
|
|
|
if (nearest != NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Entity* cur_box = cp_shape_entity(nearest);
|
|
|
|
Entity* cur_box = cp_shape_entity(nearest);
|
|
|
|
|
|
|
|
if (!cur_box->indestructible)
|
|
|
|
|
|
|
|
{
|
|
|
|
Entity* cur_grid = cp_body_entity(cpShapeGetBody(nearest));
|
|
|
|
Entity* cur_grid = cp_body_entity(cpShapeGetBody(nearest));
|
|
|
|
p->damage -= DAMAGE_TO_PLAYER_PER_BLOCK * ((BATTERY_CAPACITY - cur_box->energy_used) / BATTERY_CAPACITY);
|
|
|
|
p->damage -= DAMAGE_TO_PLAYER_PER_BLOCK * ((BATTERY_CAPACITY - cur_box->energy_used) / BATTERY_CAPACITY);
|
|
|
|
grid_remove_box(gs, cur_grid, cur_box);
|
|
|
|
grid_remove_box(gs, cur_grid, cur_box);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (target_grid == NULL)
|
|
|
|
else if (target_grid == NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Entity* new_grid = new_entity(gs);
|
|
|
|
Entity* new_grid = new_entity(gs);
|
|
|
@ -1215,6 +1258,11 @@ void process(GameState* gs, float dt)
|
|
|
|
p->damage = clamp01(p->damage);
|
|
|
|
p->damage = clamp01(p->damage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(get_entity(gs, gs->cur_spacestation) == NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
gs->cur_spacestation = create_spacestation(gs);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// process entities
|
|
|
|
// process entities
|
|
|
|
for (size_t i = 0; i < gs->cur_next_entity; i++) {
|
|
|
|
for (size_t i = 0; i < gs->cur_next_entity; i++) {
|
|
|
|
Entity* e = &gs->entities[i];
|
|
|
|
Entity* e = &gs->entities[i];
|
|
|
|