entity lists
authorhgn <hgodden00@gmail.com>
Wed, 5 Mar 2025 16:07:13 +0000 (16:07 +0000)
committerhgn <hgodden00@gmail.com>
Wed, 5 Mar 2025 16:07:13 +0000 (16:07 +0000)
content_skaterift/maps/dev_heaven/main.mdl
skaterift_blender/sr_main.py
skaterift_blender/sr_mdl.py
src/ent_challenge.c
src/ent_prop.c [new file with mode: 0644]
src/ent_prop.h [new file with mode: 0644]
src/entity.c
src/entity.h
src/skaterift.c
src/world.c

index 182ccd9bb13b8eec49654e64212d5402cd57494a..ce8e00731034cf98ccfbe0129ce7bbd6f9338fbc 100644 (file)
Binary files a/content_skaterift/maps/dev_heaven/main.mdl and b/content_skaterift/maps/dev_heaven/main.mdl differ
index d03246c8e6a1323d96ce11c5ede51ce7a7d4138b..cabbc9661224215e6005e982706a23022af55dc6 100644 (file)
@@ -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" )
    #}
 #}
 
index 9942acf782b1eb0a523c006678eef285b72aedc2..c8ad71e63020f07ef0faf528fe6cf6e5f5022106 100644 (file)
@@ -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 )
index 265acfc4608eb02c8e6959449bf6535588fca7c7..902ea256d274d2222207596adb793ca3a3fd5adf 100644 (file)
@@ -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; i<list->entity_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; i<af_arrcount( &world->ent_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 (file)
index 0000000..3aab17a
--- /dev/null
@@ -0,0 +1,13 @@
+#include "ent_prop.h"
+
+void ent_prop_update( world_instance *world )
+{
+   for( u32 i=0; i<af_arrcount( &world->ent_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 (file)
index 0000000..8e294eb
--- /dev/null
@@ -0,0 +1,3 @@
+#pragma once
+#include "world.h"
+void ent_prop_update( world_instance *world );
index ea4c3885e6ce1c0a2a1f3047adea033b9a359282..14d5665a2e177e11f15aa055d723f2490a26cc5b 100644 (file)
@@ -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 <string.h>
index 8c71974a070b0f3562f5345a51ad838caab40c0e..1031df0ad437f158f749c7b6ae5a6a0a5184001e 100644 (file)
@@ -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 {
index b6a8dbcad69b93f5c87bda65c6c57c6c042f88fa..6c16d86d752c675f94186721f0eee864586f1cf7 100644 (file)
@@ -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"
index cb485dbc5a97405119afa8ea52f0894e4ee728a2..bb907d6fb560c1546b4c0f2538d9bb3bc8764e80 100644 (file)
@@ -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 )