surfaceinfo.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. typedef int[] SurfaceInfo;
  2. /*!
  3. Unmanaged surface info handle. Provides API to surfaces that are defined as part of 'CfgSurfaces' or exist in an objects .bisurf file.
  4. Lifetime is managed in code so don't store handles of this type yourself.
  5. Any created 'SurfaceInfo' is destroyed during 'Game' ScriptModule destruction.
  6. */
  7. class SurfaceInfo
  8. {
  9. private void SurfaceInfo() {};
  10. private void ~SurfaceInfo() {};
  11. //! Warning: O(n) time complexity where n is the total number of loaded surfaces
  12. //! Note: Will load the surface if not loaded
  13. //! Warning: If the surface name is invalid, it will still create a SurfaceInfo
  14. proto static SurfaceInfo GetByName(string name);
  15. //! Warning: O(n) time complexity where n is the total number of loaded surfaces
  16. //! Note: Will load the surface if not loaded
  17. //! Warning: If the surface name is invalid, it will still create a SurfaceInfo
  18. //! 'CfgSurfaces' can be pathed by having the name prefixed with '#', so 'GetByFile("#cp_grass")' will return same as 'GetByName("cp_grass")'
  19. proto static SurfaceInfo GetByFile(string name);
  20. proto string GetName();
  21. proto string GetEntryName();
  22. proto string GetSurfaceType();
  23. proto float GetRoughness();
  24. proto float GetDustness();
  25. proto float GetBulletPenetrability();
  26. proto float GetThickness();
  27. proto float GetDeflection();
  28. proto float GetTransparency();
  29. proto float GetAudability();
  30. proto bool IsLiquid();
  31. proto bool IsStairs();
  32. proto bool IsPassthrough();
  33. proto bool IsSolid();
  34. proto string GetSoundEnv();
  35. proto string GetImpact();
  36. //! See 'LiquidTypes' in 'constants.c'
  37. proto int GetLiquidType();
  38. //! See 'ParticleList', if config entry not set, value is 'ParticleList.NONE',
  39. //! if config entry is set but doesn't exist, value is 'ParticleList.INVALID'
  40. proto int GetStepParticleId();
  41. proto int GetWheelParticleId();
  42. };
  43. enum UseObjectsMode
  44. {
  45. //! wait for the data to be ready
  46. Wait,
  47. //! do not wait for the data, but refresh caches
  48. NoWait,
  49. //! only return the data we have, do not touch any caches (MT safe mode)
  50. NoLock
  51. };
  52. enum SurfaceDetectionType
  53. {
  54. Scenery,
  55. Roadway
  56. };
  57. /*!
  58. Parameters for detecting the surface
  59. */
  60. /*sealed*/ class SurfaceDetectionParameters
  61. {
  62. //! Type of surface to detect
  63. SurfaceDetectionType type = SurfaceDetectionType.Scenery;
  64. //! 3D position to trace the surface from
  65. vector position;
  66. //! Include water in the surface detection, will return the water if it is higher than the surface
  67. bool includeWater = false;
  68. //! See UseObjectsMode, SurfaceTraceType.Roadway only
  69. UseObjectsMode syncMode = UseObjectsMode.Wait;
  70. //! Object to ignore tracing against, SurfaceTraceType.Roadway only
  71. Object ignore = null;
  72. //! See RoadSurfaceDetection, SurfaceTraceType.Roadway only
  73. RoadSurfaceDetection rsd = RoadSurfaceDetection.ABOVE;
  74. };
  75. /*!
  76. Output of surface detection
  77. */
  78. /*sealed*/ class SurfaceDetectionResult
  79. {
  80. //! Height position
  81. float height = 0;
  82. //! Right normal
  83. float normalX = 0;
  84. //! Up normal - always set to 1, not necessary to expose
  85. //float normalY = 1;
  86. //! Forward normal
  87. float normalZ = 0;
  88. //! Returned SurfaceInfo, plain pointer
  89. SurfaceInfo surface = null;
  90. //! If water was the returned surface
  91. bool aboveWater = false;
  92. //! SurfaceTraceType.Roadway only
  93. Object object = null;
  94. };