aiworld.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. enum PGPolyFlags
  2. {
  3. NONE,
  4. WALK, // Ability to walk (ground, grass, road)
  5. DISABLED, // Disabled polygon
  6. DOOR, // Ability to move through doors
  7. INSIDE, // Ability to move inside buildings
  8. SWIM, // Ability to swim (water)
  9. SWIM_SEA, // Ability to swim (sea water)
  10. LADDER, // Ability to climb on ladders
  11. JUMP_OVER, // Ability to do jumps overs
  12. JUMP_DOWN, // Ability to jump down
  13. CLIMB, // Ability to climb up
  14. CRAWL, // Ability to crawl
  15. CROUCH, // Ability to crouch
  16. UNREACHABLE,
  17. ALL,
  18. JUMP, // JUMP_OVER | JUMP_DOWN
  19. SPECIAL // JUMP | CLIMB | CRAWL | CROUCH
  20. }
  21. enum PGAreaType
  22. {
  23. NONE,
  24. TERRAIN,
  25. WATER,
  26. WATER_DEEP,
  27. WATER_SEA,
  28. WATER_SEA_DEEP,
  29. OBJECTS_NOFFCON,
  30. OBJECTS,
  31. BUILDING,
  32. ROADWAY,
  33. TREE,
  34. ROADWAY_BUILDING,
  35. DOOR_OPENED,
  36. DOOR_CLOSED,
  37. LADDER,
  38. CRAWL,
  39. CROUCH,
  40. FENCE_WALL,
  41. JUMP
  42. }
  43. /*!
  44. Filter for FindPath, RaycastNavMesh, SampleNavmeshPosition
  45. */
  46. class PGFilter : Managed
  47. {
  48. // Uses PGPolyFlags bitmasks
  49. proto native int GetIncludeFlags();
  50. proto native int GetExcludeFlags();
  51. proto native int GetExlusiveFlags();
  52. proto native void SetFlags(int includeFlags, int excludeFlags, int exclusiveFlags);
  53. proto native void SetCost(PGAreaType areaType, float cost);
  54. }
  55. class AIWorld : Managed
  56. {
  57. private void AIWorld();
  58. private void ~AIWorld();
  59. /*!
  60. Creates group with group behaviour specified by templateName param.
  61. AIGroups lifetime is managed by AIWorld, e.g. empty groups are deleted automatically.
  62. */
  63. proto native AIGroup CreateGroup(string templateName);
  64. /*!
  65. Creates group with no group behaviour
  66. */
  67. proto native AIGroup CreateDefaultGroup();
  68. /*!
  69. Destroys group and all AIAgents attached
  70. */
  71. proto native void DeleteGroup(notnull AIGroup group);
  72. /*!
  73. Finds path on navmesh using path graph filter.
  74. /param [in] from starting position
  75. /param [in] to ending position
  76. /param [in] pgFilter filter used for searching
  77. /param [out] waypoints waypoints array including starting and ending position
  78. /returns true - if path has been found
  79. */
  80. proto native bool FindPath(vector from, vector to, PGFilter pgFilter, out TVectorArray waypoints);
  81. /*!
  82. Raytest in navmesh
  83. /param [in] from starting position
  84. /param [in] to ending position
  85. /param [in] pgFilter filter used for searching
  86. /param [out] hitPos hit position
  87. /param [out] hitNormal hit normal
  88. /returns true - if ray hits navmesh edge
  89. */
  90. proto native bool RaycastNavMesh(vector from, vector to, PGFilter pgFilter, out vector hitPos, out vector hitNormal);
  91. /*!
  92. Finds closest point on navmesh within maxDistance radius using path graph filter.
  93. /param [in] position position wanted
  94. /param [in] maxDistance search radius
  95. /param [in] pgFilter filter used for searching
  96. /param [out] sampledPosition closest position on navmesh to position
  97. /returns true - function succeedes and found position is written to output paramter "sampledPosition"
  98. /returns false - function failed to find position on navmesh within given radius, output paramter is left intact
  99. */
  100. proto native bool SampleNavmeshPosition(vector position, float maxDistance, PGFilter pgFilter, out vector sampledPosition);
  101. }