switch to entity list
[carveJwlIkooP6JGAAIwe30JlM.git] / blender_export.py
index 3f1b04f1dd00e7a91ee3afa2651ac069e5151994..820c49ac05e6f721af4ca38ab7f02e200bb5e616 100644 (file)
@@ -450,7 +450,11 @@ class ent_challenge(Structure):#{
    _fields_ = [("transform",mdl_transform),
                ("submesh_start",c_uint32), ("submesh_count",c_uint32),
                ("id_next",c_uint32),
-               ("filter",c_uint32)]
+               ("filter",c_uint32),
+               ("time_limit",c_float)]
+
+   sr_functions = { 0: 'trigger',
+                    1: 'start_challenge' }
 #}
 
 def obj_ent_type( obj ):
@@ -1723,6 +1727,7 @@ def sr_compile( collection ):
 
             if obj_data.target:#{
                volume.target = sr_entity_id( obj_data.target )
+               volume._anon.trigger.event = obj_data.event
             #}
 
             sr_ent_push(volume)
@@ -1784,6 +1789,8 @@ def sr_compile( collection ):
             challenge = ent_challenge()
             obj_data = obj.SR_data.ent_challenge[0]
             challenge.id_next = sr_entity_id( obj_data.proxima )
+            challenge.filter = 0
+            challenge.time_limit = obj_data.time_limit
 
             compile_obj_transform( obj, challenge.transform )
             challenge.submesh_start, challenge.submesh_count, _ = \
@@ -2730,8 +2737,7 @@ class SR_OBJECT_ENT_ROUTE(bpy.types.PropertyGroup):
    #}
 #}
 
-class SR_OBJECT_ENT_VOLUME(bpy.types.PropertyGroup):
-#{
+class SR_OBJECT_ENT_VOLUME(bpy.types.PropertyGroup):#{
    subtype: bpy.props.EnumProperty(
       name="Subtype",
       items=[('0','Trigger',''),
@@ -2741,14 +2747,33 @@ class SR_OBJECT_ENT_VOLUME(bpy.types.PropertyGroup):
    target: bpy.props.PointerProperty( \
            type=bpy.types.Object, name="Target", \
            poll=lambda self,obj: sr_filter_ent_type(obj,\
-                                    ['ent_audio','ent_skateshop','ent_ccmd']))
+                                    ['ent_audio','ent_skateshop','ent_ccmd',\
+                                     'ent_challenge']))
+
+   event: bpy.props.IntProperty( name="Event/Method" )
 
    @staticmethod
-   def sr_inspector( layout, data ):
-   #{
-      data = data[0]
-      layout.prop( data, 'subtype' )
-      layout.prop( data, 'target' )
+   def sr_inspector( layout, data ):#{
+      layout.prop( data[0], 'subtype' )
+      layout.prop( data[0], 'target' )
+
+      row = layout.row()
+      row.prop( data[0], 'event' )
+
+      if data[0].target:#{
+         tipo = data[0].target.SR_data.ent_type
+         cls = globals()[ tipo ]
+
+         table = getattr( cls, 'sr_functions', None )
+         if table:#{
+            if data[0].event in table:#{
+               row.label( text=table[data[0].event] )
+            #}
+            else:#{
+               row.label( text="undefined function" )
+            #}
+         #}
+      #}
    #}
 #}
 
@@ -3038,6 +3063,8 @@ class SR_OBJECT_ENT_CHALLENGE(bpy.types.PropertyGroup):#{
            type=bpy.types.Object, name="Target", \
            poll=lambda self,obj: sr_filter_ent_type(obj,\
                                     ['ent_audio','ent_ccmd']))
+   event: bpy.props.IntProperty( name="Event/Method" )
+   time_limit: bpy.props.FloatProperty( name="Time Limit", default=1.0 )
 #}
 
 class SR_OBJECT_PROPERTIES(bpy.types.PropertyGroup):
@@ -3703,14 +3730,14 @@ def cv_ent_volume( obj ):
       cv_draw_ucube( obj.matrix_world, (0,1,0) )
 
       if data.target:#{
-         cv_draw_line( obj.location, data.target.location, (0,1,0) )
+         cv_draw_arrow( obj.location, data.target.location, (0,1,0) )
       #}
    #}
    elif data.subtype == '1':#{
       cv_draw_ucube( obj.matrix_world, (1,1,0) )
 
       if data.target:#{
-         cv_draw_line( obj.location, data.target.location, (1,1,0) )
+         cv_draw_arrow( obj.location, data.target.location, (1,1,0) )
       #}
    #}
 #}
@@ -3989,6 +4016,12 @@ def cv_draw():
          elif ent_type == 'ent_volume':#{
             cv_ent_volume( obj )
          #}
+         elif ent_type == 'ent_challenge':#{
+            data = obj.SR_data.ent_challenge[0]
+            if data.proxima:#{
+               cv_draw_arrow( obj.location, data.proxima.location, (0,0.2,1.0) )
+            #}
+         #}
          elif ent_type == 'ent_audio':#{
             if obj.SR_data.ent_audio[0].flag_3d:
                cv_draw_sphere( obj.location, obj.scale[0], (1,1,0) )