basic npc
[carveJwlIkooP6JGAAIwe30JlM.git] / entity.h
index ae9d63bd45f7aa442b41779d7d1d6d919792c648..105f4496c78b2469d95e2b10c5959f52e6fe5e18 100644 (file)
--- a/entity.h
+++ b/entity.h
@@ -1,6 +1,7 @@
-#ifndef ENTITY_H
-#define ENTITY_H
+#pragma once
 
+#include "vg/vg_audio.h"
+#include "vg/vg_imgui.h"
 #include "model.h"
 
 typedef struct ent_spawn ent_spawn;
@@ -26,9 +27,16 @@ 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_objective ent_objective;
 typedef struct ent_challenge ent_challenge;
-typedef struct ent_unlock ent_unlock;
 typedef struct ent_relay ent_relay;
+typedef struct ent_cubemap ent_cubemap;
+typedef struct ent_miniworld ent_miniworld;
+typedef struct ent_prop ent_prop;
+typedef struct ent_region ent_region;
+typedef struct ent_list ent_list;
+typedef struct ent_glider ent_glider;
+typedef struct ent_npc ent_npc;
 
 enum entity_alias{
    k_ent_none        = 0,
@@ -49,26 +57,38 @@ enum entity_alias{
    k_ent_menuitem    = 15,
    k_ent_worldinfo   = 16,
    k_ent_ccmd        = 17,
-   k_ent_challenge   = 18,
-   k_ent_unlock      = 19,
-   k_ent_relay       = 20
-};
-
-static u32 mdl_entity_id_type( u32 entity_id ){
-   return (entity_id & 0xffff0000) >> 16;
+   k_ent_objective   = 18,
+   k_ent_challenge   = 19,
+   k_ent_relay       = 20,
+   k_ent_cubemap     = 21,
+   k_ent_miniworld   = 22,
+   k_ent_prop        = 23,
+   k_ent_list        = 24,
+   k_ent_region      = 25,
+   k_ent_glider      = 26,
+   k_ent_npc         = 27
+};
+
+static inline u32 mdl_entity_id_type( u32 entity_id )
+{
+   return (entity_id & 0x0fff0000) >> 16;
 }
 
-static u32 mdl_entity_id_id( u32 entity_id ){
+static inline u32 mdl_entity_id_id( u32 entity_id )
+{
    return entity_id & 0x0000ffff;
 }
 
-static u32 mdl_entity_id( u32 type, u32 index ){
+static inline u32 mdl_entity_id( u32 type, u32 index )
+{
    return (type & 0xfffff)<<16 | (index & 0xfffff);
 }
 
-enum entity_function{
+enum entity_function
+{
    k_ent_function_trigger,
-   k_ent_function_particle_spawn
+   k_ent_function_particle_spawn,
+   k_ent_function_trigger_leave
 };
 
 struct ent_spawn{
@@ -112,6 +132,8 @@ enum ent_gate_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 */
+
+   k_ent_gate_clean_pass  = 0x20,/* player didn't rewind while getting here */
 };
 
 struct ent_gate{
@@ -156,14 +178,25 @@ struct ent_checkpoint{
    u16 gate_index,
        path_start,
        path_count;
+
+   /* EXTENSION */
+   f32 best_time;
 };
 
-struct ent_route{
+enum ent_route_flag {
+   k_ent_route_flag_achieve_silver = 0x1,
+   k_ent_route_flag_achieve_gold   = 0x2,
+
+   k_ent_route_flag_out_of_zone    = 0x10,
+   k_ent_region_flag_hasname       = 0x20
+};
 
+struct ent_route{
    union{
       mdl_transform transform;
-      u32 official_track_id;
-   };
+      u32 official_track_id;   /* TODO: remove this */
+   }
+   anon;
 
    u32 pstr_name;
    u16 checkpoints_start,
@@ -175,10 +208,19 @@ struct ent_route{
    u16 active_checkpoint, 
        valid_checkpoints;
 
-   float factive;
+   f32 factive;
    m4x3f board_transform;
    mdl_submesh sm;
-   double timing_base;
+   f64 timing_base;
+
+   u32 id_camera; /* v103+ */
+
+   /* v104+, but always accessible */
+   u32 flags;
+   f64 best_laptime;
+   f32 ui_stopper, ui_residual;
+
+   ui_px ui_first_block_width, ui_residual_block_w;
 };
 
 struct ent_water{
@@ -201,7 +243,7 @@ struct volume_particles{
 };
 
 struct volume_trigger{
-   u32 event, blank;
+   u32 event, event_leave;
 };
 
 enum ent_volume_flag {
@@ -239,9 +281,11 @@ struct ent_marker{
 };
 
 enum skateshop_type{
-   k_skateshop_type_boardshop,
-   k_skateshop_type_charshop,
-   k_skateshop_type_worldshop
+   k_skateshop_type_boardshop = 0,
+   k_skateshop_type_charshop = 1,
+   k_skateshop_type_worldshop = 2,
+   k_skateshop_type_DELETED = 3,
+   k_skateshop_type_server = 4
 };
 
 struct ent_skateshop{
@@ -267,6 +311,11 @@ struct ent_skateshop{
              id_info;
       }
       worlds;
+
+      struct{
+         u32 id_lever;
+      }
+      server;
    };
 };
 
@@ -296,7 +345,15 @@ enum ent_menuitem_type{
    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
+   k_ent_menuitem_type_page         = 5,
+   k_ent_menuitem_type_binding      = 6,
+   k_ent_menuitem_type_visual_nocol = 7,
+   k_ent_menuitem_type_disabled     = 90
+};
+
+enum ent_menuitem_stack_behaviour{
+   k_ent_menuitem_stack_append  = 0,
+   k_ent_menuitem_stack_replace = 1
 };
 
 typedef struct ent_menuitem ent_menuitem;
@@ -315,6 +372,11 @@ struct ent_menuitem{
    };
 
    union{
+      struct{
+         u32 pstr_name;
+      }
+      visual;
+
       struct{
          u32 id_min,    /* ent_marker */
              id_max,    /* . */
@@ -324,7 +386,8 @@ struct ent_menuitem{
       slider;
 
       struct{
-         u32 pstr;
+         u32 pstr,
+             stack_behaviour;
       }
       button;
 
@@ -341,27 +404,24 @@ struct ent_menuitem{
              id_viewpoint;   /* ent_camera */
       }
       page;
+
+      struct{
+         u32 pstr_bind,
+             font_variant;
+      }
+      binding;
    };
 };
 
 struct ent_worldinfo{
    u32 pstr_name, pstr_author, pstr_desc;
    f32 timezone;
+   u32 pstr_skybox;
+   u32 flags;
 };
 
-VG_STATIC ent_marker *ent_find_marker( mdl_context *mdl,
-                                       mdl_array_ptr *arr, const char *alias )
-{
-   for( u32 i=0; i<mdl_arrcount(arr); i++ ){
-      ent_marker *marker = mdl_arritm( arr, i );
-
-      if( !strcmp( mdl_pstr( mdl, marker->pstr_alias ), alias ) ){
-         return marker;
-      }
-   }
-
-   return NULL;
-}
+ent_marker *ent_find_marker( mdl_context *mdl, mdl_array_ptr *arr, 
+                             const char *alias );
 
 enum channel_behaviour{
    k_channel_behaviour_unlimited = 0,
@@ -399,26 +459,72 @@ struct ent_ccmd{
    u32 pstr_command;
 };
 
-struct ent_challenge{
+enum ent_objective_filter{
+   k_ent_objective_filter_none            = 0x00000000,
+   k_ent_objective_filter_trick_shuvit    = 0x00000001,
+   k_ent_objective_filter_trick_kickflip  = 0x00000002,
+   k_ent_objective_filter_trick_treflip   = 0x00000004,
+   k_ent_objective_filter_trick_any       = 
+      k_ent_objective_filter_trick_shuvit|
+      k_ent_objective_filter_trick_treflip|
+      k_ent_objective_filter_trick_kickflip,
+   k_ent_objective_filter_flip_back       = 0x00000008,
+   k_ent_objective_filter_flip_front      = 0x00000010,
+   k_ent_objective_filter_flip_any        =
+      k_ent_objective_filter_flip_back|
+      k_ent_objective_filter_flip_front,
+   k_ent_objective_filter_grind_truck_any = 0x00000020,
+   k_ent_objective_filter_grind_board_any = 0x00000040,
+   k_ent_objective_filter_grind_any       =
+      k_ent_objective_filter_grind_truck_any|
+      k_ent_objective_filter_grind_board_any,
+   k_ent_objective_filter_footplant       = 0x00000080,
+   k_ent_objective_filter_passthrough     = 0x00000100
+};
+
+enum ent_objective_flag {
+   k_ent_objective_hidden = 0x1,
+   k_ent_objective_passed = 0x2
+};
+
+struct ent_objective{
    mdl_transform transform;
    u32 submesh_start,
        submesh_count,
+       flags,
        id_next,
-       filter,
+       filter,filter2,
        id_win,
        win_event;
    f32 time_limit;
 };
 
-struct ent_unlock{
+enum ent_challenge_flag {
+   k_ent_challenge_timelimit = 0x1
+};
+
+struct ent_challenge{
+   mdl_transform transform;
    u32 pstr_alias,
+       flags,
        target,
        target_event,
+       reset,
+       reset_event,
+       first,
+       camera,
        status;
 };
 
 struct ent_relay {
    u32 targets[4][2];
+   u32 targets_events[4];
+};
+
+struct ent_cubemap {
+   v3f co;
+   u32 resolution, live, texture_id, 
+       framebuffer_id, renderbuffer_id, placeholder[2];
 };
 
 typedef struct ent_call ent_call;
@@ -427,7 +533,37 @@ struct ent_call{
    void *data;
 };
 
-#include "world.h"
-VG_STATIC void entity_call( world_instance *world, ent_call *call );
+struct ent_miniworld {
+   mdl_transform transform;
+   u32 pstr_world;
+   u32 camera;
+   u32 proxy;
+};
 
-#endif /* ENTITY_H */
+struct ent_prop {
+   mdl_transform transform;
+   u32 submesh_start, submesh_count, flags, pstr_alias;
+};
+
+struct ent_region {
+   mdl_transform transform;
+   u32 submesh_start, submesh_count, pstr_title, flags, zone_volume,
+
+       /* 105+ */
+       target0[2];
+};
+
+struct ent_glider {
+   mdl_transform transform;
+   u32 flags;
+   f32 cooldown;
+};
+
+struct ent_npc 
+{
+   mdl_transform transform;
+   u32 id, context;
+};
+
+#include "world.h"
+void entity_call( world_instance *world, ent_call *call );