X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_gen.h;h=31722e563bf40f8a662929b000cdb5747fefe559;hb=bceb3a28f8127fa27a17f480bd21fa20a340e848;hp=030af6b8ac11628a1b9e26b3d66985ddc7eb2f59;hpb=b9dedb4dd2a1e94ae76a3986716ee3c57e568213;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_gen.h b/world_gen.h index 030af6b..31722e5 100644 --- a/world_gen.h +++ b/world_gen.h @@ -1,3 +1,7 @@ +/* + * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved + */ + #ifndef WORLD_GEN_H #define WORLD_GEN_H @@ -204,7 +208,97 @@ static void world_load(void) } } } + 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; + } + else if( pnode->classtype == k_classtype_audio ) + { + world.audio_things = + buffer_reserve( world.audio_things, + world.audio_things_count, + &world.audio_things_cap, 1, + sizeof(struct world_audio_thing) ); + + struct world_audio_thing *thing = &world.audio_things[ + world.audio_things_count ]; + memset( thing, 0, sizeof(struct world_audio_thing) ); + struct classtype_audio *aud = mdl_get_entdata(mworld,pnode); + + v3_copy( pnode->co, thing->pos ); + + if( aud->flags & AUDIO_FLAG_SPACIAL_3D ) + thing->volume = aud->volume * pnode->s[0]; + else + thing->volume = aud->volume; + + thing->flags = aud->flags; + const char *fp = mdl_pstr( mworld, aud->pstr_file ); + char *path2 = vg_alloc( strlen(fp)+1 ); + strcpy( path2, fp ); + thing->temp_embedded_clip.path = path2; + thing->temp_embedded_clip.source_mode = k_audio_source_compressed; + audio_clip_load( &thing->temp_embedded_clip ); + thing->player.name = "[temp]"; + thing->player.enqued = 0; + + pnode->sub_uid = world.audio_things_count; + world.audio_things_count ++; + } + } + + /* 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; + } + + /* initialize audio if need be */ + audio_lock(); + for( int i=0; iplayer ); + audio_player_set_flags( &thingy->player, thingy->flags ); + audio_player_set_vol( &thingy->player, thingy->volume ); + audio_player_set_pan( &thingy->player, 0.0f ); + + if( thingy->flags & AUDIO_FLAG_SPACIAL_3D ) + audio_player_set_position( &thingy->player, thingy->pos ); + + if( thingy->flags & AUDIO_FLAG_AUTO_START ) + audio_player_playclip( &thingy->player, &thingy->temp_embedded_clip ); } + audio_unlock(); world.instance_cache = buffer_fix( world.instance_cache, world.instance_cache_count,