Add activeness to ctransform
Changelog: - Activeness determines whether to start moving or not - Tile collision will skip inactive objects - Crates are inactive on spawnscene_man
parent
bb6da04e74
commit
b70dcc1e98
|
@ -49,6 +49,7 @@ typedef struct _CTransform_t {
|
|||
int8_t grav_delay;
|
||||
int8_t grav_timer;
|
||||
MovementMode_t movement_mode;
|
||||
bool active;
|
||||
} CTransform_t;
|
||||
|
||||
typedef struct _CMovementState_t {
|
||||
|
|
|
@ -862,6 +862,7 @@ void tile_collision_system(Scene_t* scene)
|
|||
{
|
||||
Entity_t* p_ent = get_entity(&scene->ent_manager, ent_idx);
|
||||
CTransform_t* p_ctransform = get_component(p_ent, CTRANSFORM_COMP_T);
|
||||
if (!p_ctransform->active) continue;
|
||||
// Get the occupied tiles
|
||||
// For each tile, loop through the entities, check collision and move
|
||||
// exclude self
|
||||
|
@ -1313,6 +1314,12 @@ void movement_update_system(Scene_t* scene)
|
|||
unsigned long ent_idx;
|
||||
sc_map_foreach(&scene->ent_manager.component_map[CTRANSFORM_COMP_T], ent_idx, p_ctransform)
|
||||
{
|
||||
if (!p_ctransform->active)
|
||||
{
|
||||
memset(&p_ctransform->velocity, 0, sizeof(Vector2));
|
||||
memset(&p_ctransform->accel, 0, sizeof(Vector2));
|
||||
continue;
|
||||
}
|
||||
p_ctransform->prev_velocity = p_ctransform->velocity;
|
||||
|
||||
if (p_ctransform->movement_mode == REGULAR_MOVEMENT)
|
||||
|
@ -1462,6 +1469,11 @@ void state_transition_update_system(Scene_t* scene)
|
|||
p_mstate->water_state <<= 1;
|
||||
p_mstate->water_state |= in_water? 1:0;
|
||||
p_mstate->water_state &= 3;
|
||||
|
||||
if (p_mstate->ground_state == 0b10)
|
||||
{
|
||||
p_ctransform->active = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ Entity_t* create_boulder(EntityManager_t* ent_manager, Assets_t* assets)
|
|||
|
||||
CTransform_t* p_ctransform = add_component(p_boulder, CTRANSFORM_COMP_T);
|
||||
p_ctransform->grav_delay = 5;
|
||||
p_ctransform->active = true;
|
||||
add_component(p_boulder, CMOVEMENTSTATE_T);
|
||||
add_component(p_boulder, CTILECOORD_COMP_T);
|
||||
CMoveable_t* p_cmove = add_component(p_boulder, CMOVEABLE_T);
|
||||
|
|
|
@ -59,7 +59,8 @@ Entity_t* create_player(EntityManager_t* ent_manager, Assets_t* assets)
|
|||
CBBox_t* p_bbox = add_component(p_ent, CBBOX_COMP_T);
|
||||
|
||||
set_bbox(p_bbox, PLAYER_WIDTH, PLAYER_HEIGHT);
|
||||
add_component(p_ent, CTRANSFORM_COMP_T);
|
||||
CTransform_t* p_ct = add_component(p_ent, CTRANSFORM_COMP_T);
|
||||
p_ct->active = true;
|
||||
|
||||
CJump_t* p_cjump = add_component(p_ent, CJUMP_COMP_T);
|
||||
p_cjump->jump_speed = 680;
|
||||
|
|
Loading…
Reference in New Issue