review save method
[carveJwlIkooP6JGAAIwe30JlM.git] / entity.h
index 143ad0da8428d3e49d9525ef2a30bcf8db613ae7..ae9d63bd45f7aa442b41779d7d1d6d919792c648 100644 (file)
--- a/entity.h
+++ b/entity.h
@@ -16,27 +16,55 @@ typedef struct volume_particles volume_particles;
 typedef struct volume_trigger volume_trigger;
 typedef struct ent_volume ent_volume;
 typedef struct ent_audio ent_audio;
-typedef struct ent_index ent_index;
 typedef struct ent_marker ent_marker;
+typedef struct ent_traffic ent_traffic;
 typedef struct ent_font ent_font;
 typedef struct ent_font_variant ent_font_variant;
 typedef struct ent_glyph ent_glyph;
+typedef struct ent_skateshop ent_skateshop;
+typedef struct ent_camera ent_camera;
+typedef struct ent_swspreview ent_swspreview;
+typedef struct ent_worldinfo ent_worldinfo;
+typedef struct ent_ccmd ent_ccmd;
+typedef struct ent_challenge ent_challenge;
+typedef struct ent_unlock ent_unlock;
+typedef struct ent_relay ent_relay;
 
 enum entity_alias{
-   k_ent_gate = 1,
-   k_ent_spawn = 2,
-   k_ent_route_node = 3,
-   k_ent_route = 4,
-   k_ent_water = 5,
-   k_ent_volume = 6,
-   k_ent_audio = 7,
-   k_ent_marker = 8
+   k_ent_none        = 0,
+   k_ent_gate        = 1,
+   k_ent_spawn       = 2,
+   k_ent_route_node  = 3,
+   k_ent_route       = 4,
+   k_ent_water       = 5,
+   k_ent_volume      = 6,
+   k_ent_audio       = 7,
+   k_ent_marker      = 8,
+   k_ent_font        = 9,
+   k_ent_font_variant= 10,
+   k_ent_traffic     = 11,
+   k_ent_skateshop   = 12,
+   k_ent_camera      = 13,
+   k_ent_swspreview  = 14,
+   k_ent_menuitem    = 15,
+   k_ent_worldinfo   = 16,
+   k_ent_ccmd        = 17,
+   k_ent_challenge   = 18,
+   k_ent_unlock      = 19,
+   k_ent_relay       = 20
 };
 
-struct ent_index{
-   u32 type,
-       index;
-};
+static u32 mdl_entity_id_type( u32 entity_id ){
+   return (entity_id & 0xffff0000) >> 16;
+}
+
+static u32 mdl_entity_id_id( u32 entity_id ){
+   return entity_id & 0x0000ffff;
+}
+
+static u32 mdl_entity_id( u32 type, u32 index ){
+   return (type & 0xfffff)<<16 | (index & 0xfffff);
+}
 
 enum entity_function{
    k_ent_function_trigger,
@@ -66,17 +94,30 @@ struct ent_light{
    v2f angle_sin_cos;
 };
 
+/* v101 */
+#if 0
 enum gate_type{
    k_gate_type_unlinked = 0,
    k_gate_type_teleport = 1,
-   k_gate_type_nonlocal = 2
+   k_gate_type_nonlocal_unlinked = 2,
+   k_gate_type_nonlocel = 3
+};
+#endif
+
+/* v102+ */
+enum ent_gate_flag{
+   k_ent_gate_linked      = 0x1, /* this is a working portal */
+   k_ent_gate_nonlocal    = 0x2, /* use the key string to link this portal.
+                                       NOTE: if set, it adds the flip flag. */
+   k_ent_gate_flip        = 0x4, /* flip direction 180* for exiting portal */
+   k_ent_gate_custom_mesh = 0x8, /* use a custom submesh instead of default */
+   k_ent_gate_locked      = 0x10,/* has to be unlocked to be useful */
 };
 
 struct ent_gate{
-   u32 type,
-       target;
-
-   /* TODO: World index */
+   u32 flags,
+       target, 
+       key;
 
    v3f dimensions,
        co[2];
@@ -97,6 +138,9 @@ struct ent_gate{
    double timing_time;
    u16 routes[4];       /* routes that pass through this gate */
    u8 route_count;
+
+   /* v102+ */
+   u32 submesh_start, submesh_count;
 };
 
 struct ent_route_node{
@@ -147,7 +191,7 @@ struct ent_audio_clip{
    union{
       mdl_file file;
       audio_clip clip;
-   };
+   }_;
 
    float probability;
 };
@@ -160,18 +204,17 @@ struct volume_trigger{
    u32 event, blank;
 };
 
-enum volume_subtype{
-   k_volume_subtype_trigger,
-   k_volume_subtype_particle
+enum ent_volume_flag {
+   k_ent_volume_flag_particles = 0x1,
+   k_ent_volume_flag_disabled  = 0x2
 };
 
 struct ent_volume{
    mdl_transform transform;
    m4x3f to_world, to_local;
-   u32 type;
-
-   ent_index target;
+   u32 flags;
 
+   u32 target;
    union{
       volume_trigger trigger;
       volume_particles particles;
@@ -195,6 +238,117 @@ struct ent_marker{
    u32 pstr_alias;
 };
 
+enum skateshop_type{
+   k_skateshop_type_boardshop,
+   k_skateshop_type_charshop,
+   k_skateshop_type_worldshop
+};
+
+struct ent_skateshop{
+   mdl_transform transform;
+   u32 type, id_camera;
+
+   union{
+      struct{
+         u32 id_display,
+             id_info,
+             id_rack;
+      }
+      boards;
+
+      struct{
+         u32 id_display,
+             id_info;
+      }
+      character;
+
+      struct{
+         u32 id_display,
+             id_info;
+      }
+      worlds;
+   };
+};
+
+struct ent_swspreview{
+   u32 id_camera, id_display, id_display1;
+};
+
+struct ent_traffic{
+   mdl_transform transform;
+   u32 submesh_start,
+       submesh_count,
+       start_node,
+       node_count;
+   float speed,
+         t;
+   u32 index;     /* into the path */
+};
+
+struct ent_camera{
+   mdl_transform transform;
+   float fov;
+};
+
+enum ent_menuitem_type{
+   k_ent_menuitem_type_visual       = 0,
+   k_ent_menuitem_type_event_button = 1,
+   k_ent_menuitem_type_page_button  = 2,
+   k_ent_menuitem_type_toggle       = 3,
+   k_ent_menuitem_type_slider       = 4,
+   k_ent_menuitem_type_page         = 5
+};
+
+typedef struct ent_menuitem ent_menuitem;
+struct ent_menuitem{
+   u32 type, groups, 
+       id_links[4];  /* ent_menuitem */
+   f32 factive, fvisible;
+
+   mdl_transform transform;
+   u32 submesh_start, submesh_count;
+
+   union{ u64 _u64;  /* force storage for 64bit pointers */
+          i32 *pi32;
+          f32 *pf32;
+          void *pvoid;
+   };
+
+   union{
+      struct{
+         u32 id_min,    /* ent_marker */
+             id_max,    /* . */
+             id_handle, /* ent_menuitem */
+             pstr_data;
+      }
+      slider;
+
+      struct{
+         u32 pstr;
+      }
+      button;
+
+      struct{
+         u32 id_check, /* ent_menuitem */
+             pstr_data;
+         v3f offset; /* relative to parent */
+      }
+      checkmark;
+
+      struct{
+         u32 pstr_name, 
+             id_entrypoint,  /* ent_menuitem */
+             id_viewpoint;   /* ent_camera */
+      }
+      page;
+   };
+};
+
+struct ent_worldinfo{
+   u32 pstr_name, pstr_author, pstr_desc;
+   f32 timezone;
+};
+
 VG_STATIC ent_marker *ent_find_marker( mdl_context *mdl,
                                        mdl_array_ptr *arr, const char *alias )
 {
@@ -241,4 +395,39 @@ struct ent_glyph{
        indice_count;
 };
 
+struct ent_ccmd{
+   u32 pstr_command;
+};
+
+struct ent_challenge{
+   mdl_transform transform;
+   u32 submesh_start,
+       submesh_count,
+       id_next,
+       filter,
+       id_win,
+       win_event;
+   f32 time_limit;
+};
+
+struct ent_unlock{
+   u32 pstr_alias,
+       target,
+       target_event,
+       status;
+};
+
+struct ent_relay {
+   u32 targets[4][2];
+};
+
+typedef struct ent_call ent_call;
+struct ent_call{
+   u32 id, function;
+   void *data;
+};
+
+#include "world.h"
+VG_STATIC void entity_call( world_instance *world, ent_call *call );
+
 #endif /* ENTITY_H */