diff --git a/assets/entities/door.symtres b/assets/entities/door.symtres index e21db70..8f5383c 100644 --- a/assets/entities/door.symtres +++ b/assets/entities/door.symtres @@ -62,9 +62,54 @@ Entity active : true diffuse_texture : default.tga diffuse : 1.0000 - position : 0.000 4.500 0.000 + position : 0.006 4.500 0.000 specular_strength : 62.0000 name : Door_Mesh uv_scale : 0.300 0.200 } +Entity +{ + type : 6 + scale : 1.000 1.000 1.000 + material : 1 + rotation : 0.000 0.000 0.000 1.000 + diffuse_color : 0.100 0.100 0.100 + geometry : cube.symbres + active : true + diffuse_texture : white.tga + position : -2.000 9.500 0.000 + name : Door_Key_Indicator_Red + uv_scale : 0.300 0.200 +} + +Entity +{ + type : 6 + scale : 1.000 1.000 1.000 + material : 1 + rotation : 0.000 0.000 0.000 1.000 + diffuse_color : 0.100 0.100 0.100 + geometry : cube.symbres + active : true + diffuse_texture : white.tga + position : -0.250 9.500 0.000 + name : Door_Key_Indicator_Green + uv_scale : 0.300 0.200 +} + +Entity +{ + type : 6 + scale : 1.000 1.000 1.000 + material : 1 + rotation : 0.000 0.000 0.000 1.000 + diffuse_color : 0.100 0.100 0.100 + geometry : cube.symbres + active : true + diffuse_texture : white.tga + position : 1.500 9.500 0.000 + name : Door_Key_Indicator_Blue + uv_scale : 0.300 0.200 +} + diff --git a/src/common/version.h b/src/common/version.h index a22f902..3c95f2c 100755 --- a/src/common/version.h +++ b/src/common/version.h @@ -4,7 +4,7 @@ /* Auto generated version file. DO NOT MODIFY */ #define SYMMETRY_VERSION_MAJOR 0 #define SYMMETRY_VERSION_MINOR 1 -#define SYMMETRY_VERSION_REVISION 346 +#define SYMMETRY_VERSION_REVISION 348 #define SYMMETRY_VERSION_BRANCH "dev" #endif \ No newline at end of file diff --git a/src/game/door.c b/src/game/door.c index 60cf5de..38a1d5b 100644 --- a/src/game/door.c +++ b/src/game/door.c @@ -13,6 +13,11 @@ static void door_on_scene_loaded(struct Event* event, void* door_ptr); static void door_on_trigger(struct Event* event, void* door_ptr); +static const vec4 KEY_INDICATOR_COLOR_RED = { 0.87, 0.32, 0.40, 1.0f }; +static const vec4 KEY_INDICATOR_COLOR_GREEN = { 0.53, 0.67, 0.28, 1.0f }; +static const vec4 KEY_INDICATOR_COLOR_BLUE = { 0.47, 0.67, 0.89, 1.0f }; +static const vec4 KEY_INDICATOR_COLOR_DISABLED = { 0.1, 0.1, 0.1, 1.0f }; + void door_init(struct Door* door, int mask) { struct Game_State* game_state = game_state_get(); @@ -104,17 +109,43 @@ void door_update(struct Door* door, struct Scene* scene, float dt) } } +void door_update_key_indicator_materials(struct Door* door) +{ + if((door->mask & DOOR_KEY_MASK_RED)) + vec4_assign(&door->key_indicator_red->model.material_params[MMP_DIFFUSE_COL].val_vec4, &KEY_INDICATOR_COLOR_RED); + else + vec4_assign(&door->key_indicator_red->model.material_params[MMP_DIFFUSE_COL].val_vec4, &KEY_INDICATOR_COLOR_DISABLED); + + if((door->mask & DOOR_KEY_MASK_GREEN)) + vec4_assign(&door->key_indicator_green->model.material_params[MMP_DIFFUSE_COL].val_vec4, &KEY_INDICATOR_COLOR_GREEN); + else + vec4_assign(&door->key_indicator_green->model.material_params[MMP_DIFFUSE_COL].val_vec4, &KEY_INDICATOR_COLOR_DISABLED); + + if((door->mask & DOOR_KEY_MASK_BLUE)) + vec4_assign(&door->key_indicator_blue->model.material_params[MMP_DIFFUSE_COL].val_vec4, &KEY_INDICATOR_COLOR_BLUE); + else + vec4_assign(&door->key_indicator_blue->model.material_params[MMP_DIFFUSE_COL].val_vec4, &KEY_INDICATOR_COLOR_DISABLED); +} + void door_on_scene_loaded(struct Event* event, void* door_ptr) { - struct Door* door = (struct Door*)door_ptr; - struct Entity* door_mesh[1] = { NULL }; + struct Door* door = (struct Door*)door_ptr; + struct Entity* door_meshes[4] = { NULL }; struct Entity* door_sound[1] = { NULL }; struct Entity* door_trigger[1] = { NULL }; - if(entity_get_num_children_of_type(door, ET_STATIC_MESH, &door_mesh, 1) == 1) - door->mesh = door_mesh[0]; + if(entity_get_num_children_of_type(door, ET_STATIC_MESH, &door_meshes, 4) >= 4) + { + door->mesh = door_meshes[0]; + door->key_indicator_red = door_meshes[1]; + door->key_indicator_green = door_meshes[2]; + door->key_indicator_blue = door_meshes[3]; + door_update_key_indicator_materials(door); + } else + { log_error("door:on_scene_load", "Could not find mesh entity for door %s", door->base.name); + } if(entity_get_num_children_of_type(door, ET_SOUND_SOURCE, &door_sound, 1) == 1) door->sound = door_sound[0]; diff --git a/src/game/door.h b/src/game/door.h index 3a42ac9..5d47a41 100644 --- a/src/game/door.h +++ b/src/game/door.h @@ -21,5 +21,6 @@ void door_reset(struct Door* door); void door_update(struct Door* door, struct Scene* scene, float dt); struct Door* door_read(struct Parser_Object* object, const char* name, struct Entity* parent_entity); void door_write(struct Door* door, struct Hashmap* entity_data); +void door_update_key_indicator_materials(struct Door* door); #endif \ No newline at end of file diff --git a/src/game/editor.c b/src/game/editor.c index 346c9de..9489971 100755 --- a/src/game/editor.c +++ b/src/game/editor.c @@ -2415,9 +2415,9 @@ void editor_window_property_inspector(struct nk_context* context, struct Editor* nk_layout_row_dynamic(context, row_height, 1); nk_label(context, "Key Mask", NK_TEXT_ALIGN_MIDDLE | NK_TEXT_ALIGN_CENTERED); nk_layout_row_dynamic(context, row_height, 3); - nk_checkbox_flags_label(context, "Red", &door->mask, DOOR_KEY_MASK_RED); - nk_checkbox_flags_label(context, "Green", &door->mask, DOOR_KEY_MASK_GREEN); - nk_checkbox_flags_label(context, "Blue", &door->mask, DOOR_KEY_MASK_BLUE); + if(nk_checkbox_flags_label(context, "Red", &door->mask, DOOR_KEY_MASK_RED)) door_update_key_indicator_materials(door); + if(nk_checkbox_flags_label(context, "Green", &door->mask, DOOR_KEY_MASK_GREEN)) door_update_key_indicator_materials(door); + if(nk_checkbox_flags_label(context, "Blue", &door->mask, DOOR_KEY_MASK_BLUE)) door_update_key_indicator_materials(door); nk_layout_row_dynamic(context, row_height, 1); nk_property_float(context, "Speed", -FLT_MAX, &door->speed, FLT_MAX, 0.1f, 0.1f); diff --git a/src/game/entity.h b/src/game/entity.h index 7ccb543..d035545 100755 --- a/src/game/entity.h +++ b/src/game/entity.h @@ -266,6 +266,9 @@ struct Door float open_position; float close_position; struct Static_Mesh* mesh; + struct Static_Mesh* key_indicator_red; + struct Static_Mesh* key_indicator_green; + struct Static_Mesh* key_indicator_blue; struct Sound_Source* sound; struct Trigger* trigger; };