challange entitites
[carveJwlIkooP6JGAAIwe30JlM.git] / blender_export.py
index 2b059d9730b125ccba52973a9c1cb8145ce80bec..ae8b641b3db7963004c5f706cc425e1dd1b0ac08 100644 (file)
@@ -35,7 +35,8 @@ sr_entity_list = [
    ('ent_swspreview', 'Workshop Preview', '', 14 ),
    ('ent_menuitem',     'Menu Item',      '', 15 ),
    ('ent_worldinfo',    'World Info',     '', 16 ),
-   ('ent_ccmd',         'CCmd',           '', 17 )
+   ('ent_ccmd',         'CCmd',           '', 17 ),
+   ('ent_challenge',    'Challenge',      '', 18 )
 ]
 
 def get_entity_enum_id( alias ):
@@ -445,6 +446,13 @@ class ent_ccmd(Structure):
    _fields_ = [("pstr_command",c_uint32)]
 #}
 
+class ent_challenge(Structure):#{
+   _fields_ = [("transform",mdl_transform),
+               ("submesh_start",c_uint32), ("submesh_count",c_uint32),
+               ("id_next",c_uint32),
+               ("filter",c_uint32)]
+#}
+
 def obj_ent_type( obj ):
 #{
    if obj.type == 'ARMATURE': return 'mdl_armature'
@@ -793,8 +801,9 @@ def sr_armature_bones( armature ):
          yield from _recurse_bone( b )
 #}
 
-def sr_entity_id( obj ):
-#{
+def sr_entity_id( obj ):#{
+   if not obj: return 0
+   
    tipo = get_entity_enum_id( obj_ent_type(obj) )
    index = sr_compile.entity_ids[ obj.name ]
 
@@ -1531,6 +1540,7 @@ def sr_compile( collection ):
          if ent_type == 'ent_font': continue
          if ent_type == 'ent_font_variant': continue
          if ent_type == 'ent_menuitem': continue
+         if ent_type == 'ent_challenge': continue
          #--------------------------
 
          print( F'[SR] {i: 3}/{mesh_count} {obj.name:<40}', end='\r' )
@@ -1743,6 +1753,17 @@ def sr_compile( collection ):
             ccmd.pstr_command = sr_compile_string( obj_data.command )
             sr_ent_push( ccmd )
          #}
+         elif ent_type == 'ent_challenge':#{
+            challenge = ent_challenge()
+            obj_data = obj.SR_data.ent_challenge[0]
+            challenge.id_next = sr_entity_id( obj_data.proxima )
+
+            compile_obj_transform( obj, challenge.transform )
+            challenge.submesh_start, challenge.submesh_count, _ = \
+                  sr_compile_mesh_internal( obj )
+
+            sr_ent_push( challenge )
+         #}
       #}
    #}
 
@@ -2982,6 +3003,16 @@ class SR_OBJECT_ENT_CCMD(bpy.types.PropertyGroup):
    command: bpy.props.StringProperty(name="Command Line")
 #}
 
+class SR_OBJECT_ENT_CHALLENGE(bpy.types.PropertyGroup):#{
+   proxima: bpy.props.PointerProperty( \
+            type=bpy.types.Object, name="Next", \
+            poll=lambda self,obj: sr_filter_ent_type(obj,['ent_challenge']))
+   target: bpy.props.PointerProperty( \
+           type=bpy.types.Object, name="Target", \
+           poll=lambda self,obj: sr_filter_ent_type(obj,\
+                                    ['ent_audio','ent_ccmd']))
+#}
+
 class SR_OBJECT_PROPERTIES(bpy.types.PropertyGroup):
 #{
    ent_gate: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_GATE)
@@ -2999,6 +3030,7 @@ class SR_OBJECT_PROPERTIES(bpy.types.PropertyGroup):
    ent_menuitem: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_MENU_ITEM)
    ent_worldinfo: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_WORLD_INFO)
    ent_ccmd: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_CCMD)
+   ent_challenge: bpy.props.CollectionProperty(type=SR_OBJECT_ENT_CHALLENGE)
 
    ent_type: bpy.props.EnumProperty(
       name="Type",
@@ -4121,6 +4153,7 @@ classes = [ SR_INTERFACE, SR_MATERIAL_PANEL,\
             SR_OBJECT_ENT_FONT,SR_OBJECT_ENT_TRAFFIC,SR_OBJECT_ENT_SKATESHOP,\
             SR_OBJECT_ENT_WORKSHOP_PREVIEW,SR_OBJECT_ENT_MENU_ITEM,\
             SR_OBJECT_ENT_WORLD_INFO,SR_OBJECT_ENT_CCMD,\
+            SR_OBJECT_ENT_CHALLENGE,\
             \
             SR_OBJECT_PROPERTIES, SR_LIGHT_PROPERTIES, SR_BONE_PROPERTIES, 
             SR_MESH_PROPERTIES, SR_MATERIAL_PROPERTIES \