X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_gen.h;h=16d64fdefdf8a53af2a1cbb98b28eed71d43702a;hb=be6707a307bfeec1b45cca8b3fb647e81262be87;hp=4605adf662a6107c0a02b0b12c037a39f48f205d;hpb=bdac014448b6ec968fe645f1581f321144f07dba;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_gen.h b/world_gen.h index 4605adf..16d64fd 100644 --- a/world_gen.h +++ b/world_gen.h @@ -115,6 +115,16 @@ VG_STATIC void world_ents_allocate(void) k_classtype_trigger, (void*)&world.triggers, sizeof(struct trigger_zone) + }, + { + k_classtype_logic_relay, + (void*)&world.logic_relays, + sizeof(struct logic_relay) + }, + { + k_classtype_logic_achievement, + (void*)&world.logic_achievements, + sizeof(struct logic_achievement) } }; @@ -129,6 +139,7 @@ VG_STATIC void world_ents_allocate(void) { if( pnode->classtype == entity_counts[j].ct ) { + pnode->sub_uid = entity_counts[j].count; entity_counts[j].count ++; break; } @@ -199,7 +210,7 @@ VG_STATIC void world_pct_audio( mdl_node *pnode ) thing->temp_embedded_clip.path = mdl_pstr( world.meta, aud->pstr_file ); thing->temp_embedded_clip.source_mode = k_audio_source_mono; - audio_clip_load( &thing->temp_embedded_clip ); + audio_clip_load( &thing->temp_embedded_clip, world.audio_vgl ); thing->player.name = mdl_pstr( world.meta, pnode->pstr_name ); thing->player.enqued = 0; @@ -207,6 +218,71 @@ VG_STATIC void world_pct_audio( mdl_node *pnode ) world.audio_things_count ++; } + +VG_STATIC void world_pct_trigger( mdl_node *pnode ) +{ + struct trigger_zone *trigger = &world.triggers[ world.trigger_count ]; + struct classtype_trigger *inf = mdl_get_entdata( world.meta, pnode ); + + if( inf->target ) + { + mdl_node *target_node = mdl_node_from_id( world.meta, inf->target ); + + trigger->target.sub_id = target_node->sub_uid; + trigger->target.classtype = target_node->classtype; + } + else + { + vg_warn( "Trigger with no target...\n" ); + return; + } + + mdl_node_transform( pnode, trigger->transform ); + m4x3_invert_full( trigger->transform, trigger->inv_transform ); + + world.trigger_count ++; +} + + +VG_STATIC void world_pct_relay( mdl_node *pnode ) +{ + struct logic_relay *relay = &world.logic_relays[ world.relay_count ]; + struct classtype_logic_relay *inf = mdl_get_entdata( world.meta, pnode ); + + relay->target_count = 0; + + for( int i=0; itargets); i++ ) + { + if( inf->targets[i] ) + { + struct relay_target *target = &relay->targets[relay->target_count ++]; + mdl_node *other = mdl_node_from_id( world.meta, inf->targets[i] ); + + target->classtype = other->classtype; + target->sub_id = other->sub_uid; + } + } + + v3_copy( pnode->co, relay->pos ); + world.relay_count ++; +} + + +VG_STATIC void world_pct_achievement( mdl_node *pnode ) +{ + struct logic_achievement *ach = + &world.logic_achievements[ world.achievement_count ]; + struct classtype_logic_achievement *inf = + mdl_get_entdata( world.meta, pnode ); + + v3_copy( pnode->co, ach->pos ); + ach->achievement_id = mdl_pstr( world.meta, inf->pstr_name ); + ach->achieved = 0; + + world.achievement_count ++; +} + + VG_STATIC void world_entities_process(void) { struct entity_instruction @@ -219,6 +295,9 @@ VG_STATIC void world_entities_process(void) { k_classtype_spawn, world_pct_spawn }, { k_classtype_water, world_pct_water }, { k_classtype_audio, world_pct_audio }, + { k_classtype_trigger, world_pct_trigger }, + { k_classtype_logic_relay, world_pct_relay }, + { k_classtype_logic_achievement, world_pct_achievement } }; for( int i=0; iinfo.node_count; i++ ) @@ -235,50 +314,7 @@ VG_STATIC void world_entities_process(void) break; } } - -#if 0 - else if( pnode->classtype == k_classtype_achievement_box ) - { - world.achievement_zones = - buffer_reserve( world.achievement_zones, - world.achievement_zones_count, - &world.achievement_zones_cap, 1, - sizeof(struct achievement_zone) ); - - struct achievement_zone *zone = &world.achievement_zones[ - world.achievement_zones_count ++ ]; - - - struct classtype_achievement_box *box = mdl_get_entdata(mworld,pnode); - - mdl_node_transform( pnode, zone->transform ); - m4x3_invert_full( zone->transform, zone->inv_transform ); - vg_strncpy( mdl_pstr(mworld, box->pstr_name), zone->name, 31 ); - zone->name[31] = 0x00; - zone->triggered = 0; - - if( box->trigger ) - zone->ptarget_delegated = mdl_node_from_id( mworld, box->trigger ); - else - zone->ptarget_delegated = NULL; - } -#endif } - -#if 0 - /* fixup links */ - for( int i=0; iptarget_delegated ) - { - u32 id = ach->ptarget_delegated->sub_uid; - ach->ptarget = &world.audio_things[ id ]; - } - else - ach->ptarget = NULL; - } -#endif } VG_STATIC void world_generate(void) @@ -413,6 +449,7 @@ VG_STATIC void world_generate(void) world.scene_no_collide = NULL; } +VG_STATIC int reset_player( int argc, char const *argv[] ); VG_STATIC void world_post_process(void) { /* initialize audio if need be */ @@ -505,6 +542,8 @@ VG_STATIC void world_post_process(void) /* * Setup scene collider */ + + reset_player( 1, (const char *[]){"start"} ); } @@ -538,6 +577,7 @@ VG_STATIC void world_unload(void) /* delete the entire block of memory */ vg_linear_clear( world.dynamic_vgl ); + vg_linear_clear( world.audio_vgl ); /* clean dangling pointers */ world.meta = NULL; @@ -556,15 +596,15 @@ VG_STATIC void world_unload(void) world.audio_things = NULL; world.audio_things_count = 0; - world.logic_entities = NULL; - world.logic_entity_count = 0; - - world.logic_actions = NULL; - world.logic_action_count = 0; - world.triggers = NULL; world.trigger_count = 0; + world.logic_relays = NULL; + world.relay_count = 0; + + world.logic_achievements = NULL; + world.achievement_count = 0; + world.nodes = NULL; world.node_count = 0;