From 04a6a17232d1d85917aecbf97d47e89a476cd423 Mon Sep 17 00:00:00 2001 From: hgn Date: Wed, 5 Mar 2025 16:07:13 +0000 Subject: [PATCH] entity lists --- content_skaterift/maps/dev_heaven/main.mdl | Bin 973024 -> 973024 bytes skaterift_blender/sr_main.py | 25 +++++------ skaterift_blender/sr_mdl.py | 18 ++++---- src/ent_challenge.c | 46 +++++++++++---------- src/ent_prop.c | 13 ++++++ src/ent_prop.h | 3 ++ src/entity.c | 1 + src/entity.h | 20 +++------ src/skaterift.c | 1 + src/world.c | 1 + 10 files changed, 68 insertions(+), 60 deletions(-) create mode 100644 src/ent_prop.c create mode 100644 src/ent_prop.h diff --git a/content_skaterift/maps/dev_heaven/main.mdl b/content_skaterift/maps/dev_heaven/main.mdl index 182ccd9bb13b8eec49654e64212d5402cd57494a..ce8e00731034cf98ccfbe0129ce7bbd6f9338fbc 100644 GIT binary patch delta 90 zcmaE`(fYwg>kSbGJX&XT_tn@lI&X-bV!t`XK#qx#xw+Y>z1fHnh?#(x8Hibcm=%cG cfS4VKIe?fGh`E568;E&;n0I@#5nt>w0N4Z{Bme*a delta 90 zcmaE`(fYwg>kSbGJV&Ho?$bNY=)B^usKe$I134x}hUR9Y_GTkSAZ7w$W*}w(Vpbq# c17da{<^W<&Am##MZXo6XV&3h|Mtrf$03v-L8UO$Q diff --git a/skaterift_blender/sr_main.py b/skaterift_blender/sr_main.py index d03246c..cabbc96 100644 --- a/skaterift_blender/sr_main.py +++ b/skaterift_blender/sr_main.py @@ -256,14 +256,13 @@ class ent_audio_clip(Structure): class ent_list(Structure): #{ - _fields_ = [("entity_ref_start",c_uint32), - ("entity_ref_count",c_uint32)] + _fields_ = [("entity_ref_start",c_uint16),("entity_ref_count",c_uint16)] #} # used in ent_list class file_entity_ref(Structure): #{ - _fields_ = [("index",c_uint32)] + _fields_ = [("entity_id",c_uint32)] #} class ent_checkpoint(Structure): @@ -291,10 +290,6 @@ class ent_route(Structure): sr_functions = { 0: 'view' } #} -class ent_list(Structure):#{ - _fields_ = [("start",c_uint16),("count",c_uint16)] -#} - class ent_glider(Structure):#{ _fields_ = [("transform",mdl_transform), ("flags",c_uint32), @@ -490,14 +485,14 @@ class ent_challenge(Structure):#{ _fields_ = [("transform",mdl_transform), ("pstr_alias",c_uint32), ("flags",c_uint32), - ("target",c_uint32), - ("target_event",c_int32), + ("on_activate_id",c_uint32), + ("on_activate_event",c_int32), ("reset",c_uint32), ("reset_event",c_int32), - ("first",c_uint32), - ("camera",c_uint32), + ("first_objective_id",c_uint32), + ("camera_id",c_uint32), ("status",c_uint32), - ("visible_when_unlocked_id",c_uint32)] #runtime + ("visible_when_unlocked_id",c_uint32)] sr_functions = { 0: 'unlock', 1: 'view', -1: 'unview' } @@ -1965,11 +1960,11 @@ class SR_OBJECT_ENT_CHALLENGE(bpy.types.PropertyGroup):#{ camera: bpy.props.PointerProperty( \ type=bpy.types.Object, name="Camera", \ - poll=lambda self,obj: sr_filter_ent_type(obj,['ent_camera','ent_objective'])) + poll=lambda self,obj: sr_filter_ent_type(obj,['ent_camera'])) visible_when_unlocked: bpy.props.PointerProperty( \ type=bpy.types.Object, name="Visibile when unlocked", \ - poll=lambda self,obj: sr_filter_ent_type(obj,['ent_objective','ent_prop','ent_list'])) + poll=lambda self,obj: sr_filter_ent_type(obj,['ent_list'])) @staticmethod def sr_inspector( layout, data ): @@ -1981,7 +1976,7 @@ class SR_OBJECT_ENT_CHALLENGE(bpy.types.PropertyGroup):#{ layout.prop( data[0], 'time_limit' ) layout.prop( data[0], 'is_story' ) SR_OBJECT_ENT_VOLUME.inspect_target( layout, data, 'target', text=("On Activate" if data[0].is_story else "On Complete") ) - SR_OBJECT_ENT_VOLUME.inspect_target( layout, data, 'reset', text=("On Finish" if data[0].is_story else "On Reset") ) + SR_OBJECT_ENT_VOLUME.inspect_target( layout, data, 'reset', text="On Reset" ) #} #} diff --git a/skaterift_blender/sr_mdl.py b/skaterift_blender/sr_mdl.py index 9942acf..c8ad71e 100644 --- a/skaterift_blender/sr_mdl.py +++ b/skaterift_blender/sr_mdl.py @@ -849,17 +849,17 @@ def _mdl_compiler_compile_entities(): obj_data = obj.SR_data.ent_challenge[0] compile_obj_transform( obj, challenge.transform ) challenge.pstr_alias = _af_pack_string( obj_data.alias ) - challenge.target = sr_entity_id( obj_data.target ) - challenge.target_event = obj_data.target_event - challenge.reset = sr_entity_id( obj_data.reset ) - challenge.reset_event = obj_data.reset_event - challenge.first = sr_entity_id( obj_data.first ) - challenge.visible_when_unlocked_id = sr_entity_id( obj_data.visible_when_unlocked ) challenge.flags = 0x00 - challenge.camera = sr_entity_id( obj_data.camera ) if obj_data.time_limit: challenge.flags |= 0x01 if obj_data.is_story: challenge.flags |= 0x02 + challenge.on_activate_id = sr_entity_id( obj_data.target ) + challenge.on_activate_event = obj_data.target_event + challenge.reset = sr_entity_id( obj_data.reset ) + challenge.reset_event = obj_data.reset_event + challenge.first_objective_id = sr_entity_id( obj_data.first ) + challenge.camera_id = sr_entity_id( obj_data.camera ) challenge.status = 0 + challenge.visible_when_unlocked_id = sr_entity_id( obj_data.visible_when_unlocked ) sr_ent_push( challenge ) #} elif ent_type == 'ent_list': @@ -873,9 +873,9 @@ def _mdl_compiler_compile_entities(): if obj_data.entities[k]: #{ list_entry = file_entity_ref() - list_entry.index = sr_entity_id( obj_data.entities[k].target ) + list_entry.entity_id = sr_entity_id( obj_data.entities[k].target ) sr_ent_push( list_entry ) - list.entity_ref_count += 1 + lista.entity_ref_count += 1 #} #} sr_ent_push( lista ) diff --git a/src/ent_challenge.c b/src/ent_challenge.c index 265acfc..902ea25 100644 --- a/src/ent_challenge.c +++ b/src/ent_challenge.c @@ -82,38 +82,40 @@ entity_call_result ent_challenge_call( world_instance *world, ent_call *call ) void ent_challenge_visibility( ent_challenge *challenge, bool visible ) { world_instance *world = &_world.main; - if( challenge->indicator_prop_id ) + if( challenge->visible_when_unlocked_id ) { - ent_prop *prop = af_arritm( &world->ent_prop, mdl_entity_id_id( challenge->indicator_prop_id ) ); + ent_list *list = af_arritm( &world->ent_list, mdl_entity_id_id( challenge->visible_when_unlocked_id ) ); - if( visible ) prop->flags &= ~((u32)k_prop_flag_hidden); - else prop->flags |= k_prop_flag_hidden; - } + for( u32 i=0; ientity_ref_count; i ++ ) + { + u32 ref_index = list->entity_ref_start + i; + + file_entity_ref *ref = af_arritm( &world->file_entity_ref, ref_index ); - if( challenge->objective_id ) - { - ent_objective *objective = af_arritm( &world->ent_objective, mdl_entity_id_id( challenge->objective_id ) ); + u32 type = mdl_entity_id_type( ref->entity_id ), + index = mdl_entity_id_id( ref->entity_id ); + + if( type == k_ent_objective ) + { + ent_objective *objective = af_arritm( &world->ent_objective, index ); - if( visible ) objective->flags &= ~((u32)k_ent_objective_hidden); - else objective->flags |= k_ent_objective_hidden; + if( visible ) objective->flags &= ~((u32)k_ent_objective_hidden); + else objective->flags |= k_ent_objective_hidden; + } + else if( type == k_ent_prop ) + { + ent_prop *prop = af_arritm( &world->ent_prop, index ); + + if( visible ) prop->flags &= ~((u32)k_prop_flag_hidden); + else prop->flags |= k_prop_flag_hidden; + } + } } } void ent_challenge_update(void) { world_instance *world = &_world.main; - for( u32 i=0; ient_challenge); i ++ ) - { - ent_challenge *challenge = af_arritm( &world->ent_challenge, i ); - if( challenge->flags & k_ent_challenge_is_story ) - { - if( challenge->indicator_prop_id ) - { - ent_prop *prop = af_arritm( &world->ent_prop, mdl_entity_id_id( challenge->indicator_prop_id ) ); - q_axis_angle( prop->transform.q, (v3f){0,1,0}, vg.time ); - } - } - } if( _world.event != k_world_event_challenge ) return; diff --git a/src/ent_prop.c b/src/ent_prop.c new file mode 100644 index 0000000..3aab17a --- /dev/null +++ b/src/ent_prop.c @@ -0,0 +1,13 @@ +#include "ent_prop.h" + +void ent_prop_update( world_instance *world ) +{ + for( u32 i=0; ient_prop ); i ++ ) + { + ent_prop *prop = af_arritm( &world->ent_prop, i ); + if( prop->flags & k_prop_flag_hidden ) continue; + + if( prop->flags & k_prop_flag_spinning ) + q_axis_angle( prop->transform.q, (v3f){0,1,0}, vg.time ); + } +} diff --git a/src/ent_prop.h b/src/ent_prop.h new file mode 100644 index 0000000..8e294eb --- /dev/null +++ b/src/ent_prop.h @@ -0,0 +1,3 @@ +#pragma once +#include "world.h" +void ent_prop_update( world_instance *world ); diff --git a/src/entity.c b/src/entity.c index ea4c388..14d5665 100644 --- a/src/entity.c +++ b/src/entity.c @@ -10,6 +10,7 @@ #include "ent_miniworld.h" #include "ent_region.h" #include "ent_glider.h" +#include "ent_prop.h" #include "world_water.h" #include diff --git a/src/entity.h b/src/entity.h index 8c71974..1031df0 100644 --- a/src/entity.h +++ b/src/entity.h @@ -64,7 +64,7 @@ enum entity_alias{ k_ent_cubemap = 21, k_ent_miniworld = 22, k_ent_prop = 23, - k_ent_UNUSED0 = 24, + k_ent_list = 24, k_ent_region = 25, k_ent_glider = 26, k_ent_npc = 27, @@ -170,12 +170,12 @@ enum gate_type{ struct ent_list { - u32 entity_ref_start, entity_ref_count; + u16 entity_ref_start, entity_ref_count; }; struct file_entity_ref { - u32 index; + u32 entity_id; }; /* v102+ */ @@ -618,19 +618,11 @@ struct ent_challenge{ u32 reset; i32 reset_event; - union - { - u32 first_objective_id, - indicator_prop_id; - }; - - union - { - u32 camera_id, - objective_id; - }; + u32 first_objective_id; + u32 camera_id; u32 status; + u32 visible_when_unlocked_id; }; struct ent_relay { diff --git a/src/skaterift.c b/src/skaterift.c index b6a8dbc..6c16d86 100644 --- a/src/skaterift.c +++ b/src/skaterift.c @@ -561,6 +561,7 @@ void vg_framebuffer_resize( int w, int h ) #include "ent_skateshop.c" #include "ent_tornado.c" #include "ent_traffic.c" +#include "ent_prop.c" #include "freecam.c" #include "menu.c" #include "network.c" diff --git a/src/world.c b/src/world.c index cb485db..bb907d6 100644 --- a/src/world.c +++ b/src/world.c @@ -45,6 +45,7 @@ void world_update( world_instance *world, v3f pos ) world_volumes_update( world, pos ); ent_skateshop_update(); ent_challenge_update(); + ent_prop_update( world ); } void world_gui( ui_context *ctx, world_instance *world ) -- 2.25.1