enentity.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870
  1. typedef int[] BaseContainer;
  2. typedef int[] IEntitySource;
  3. typedef int[] WidgetSource;
  4. class BaseContainer
  5. {
  6. proto native owned string GetClassName();
  7. proto native owned string GetName();
  8. proto native int VarIndex(string varName);
  9. proto native bool IsVariableSet(int varIndex);
  10. proto bool IsType(int varIndex, typename type);
  11. proto bool Get(int varIndex, out void val);
  12. };
  13. class IEntitySource: BaseContainer
  14. {
  15. proto native IEntitySource GetChildren();
  16. proto native IEntitySource GetSibling();
  17. proto native IEntitySource GetParent();
  18. };
  19. class WidgetSource: BaseContainer
  20. {
  21. proto native WidgetSource GetChildren();
  22. proto native WidgetSource GetSibling();
  23. proto native WidgetSource GetParent();
  24. };
  25. /**
  26. * \defgroup EntityAPI Entity system
  27. * @{
  28. */
  29. /**
  30. * \defgroup EntityAttributes Entity editor attribute system
  31. * @{
  32. */
  33. //@}
  34. //!Entity events for event-mask, or throwing event from code
  35. enum EntityEvent
  36. {
  37. //! entity was touched by other entity
  38. TOUCH,
  39. /*!
  40. entity is visible, so part of the rendering
  41. other WorldClass
  42. extra frame index
  43. result false should be rendered, true shoudn't be rendered
  44. */
  45. VISIBLE,
  46. /*!
  47. entity is not visible, will not be part of rendering
  48. other WorldClass
  49. extra frame index
  50. */
  51. NOTVISIBLE,
  52. /*!
  53. new frame event, called each frame
  54. other WorldClass
  55. extra frame index
  56. */
  57. FRAME,
  58. /*!
  59. event at the end of each frame or when entity is moved during the frame
  60. other WorldClass
  61. */
  62. POSTFRAME,
  63. /*!
  64. event called after the world is created, including all entities
  65. other WorldClass
  66. */
  67. INIT,
  68. //Only with MeshObject
  69. //ANIMEND - End of AF_ONCE animation, extra = slot number 0...11
  70. //ANIMBLEND - Animation blended from previous one, extra = slot number 0...11
  71. //SOUNDEND - playing of SFL_ONCE sound has ended
  72. // extra = pointer to a sound handle
  73. //USER
  74. JOINTBREAK,
  75. SIMULATE,
  76. POSTSIMULATE,
  77. PHYSICSMOVE,
  78. CONTACT,
  79. EXTRA,
  80. ANIMEVENT,
  81. SOUNDEVENT,
  82. PHYSICSSTEADY,
  83. USER,
  84. //! Object entered Trigger
  85. ENTER,
  86. //! Object left Trigger
  87. LEAVE,
  88. //!Mask of all events
  89. ALL
  90. };
  91. //!Entity flags
  92. enum EntityFlags
  93. {
  94. /*!
  95. Entity is visible. Is rendered if there is some attached object
  96. and event EntityEvent.VISIBLE is invoked, when event mask is set.
  97. */
  98. VISIBLE,
  99. SOLID, ///<Is collidable by various trace methods
  100. TRIGGER, ///<Is not collidable, but invokes touch events.
  101. TOUCHTRIGGERS, ///<Interacts with triggers
  102. SYNCHRONIZATION_DIRTY, ///<Entity wants to synchronize (network)
  103. FEATURE, ///<Scene rendering hint for dominant objects that are not culled by standard way
  104. /*!
  105. Used by tracing methods. When tracing with TraceFlags.PASSTRANSLUCENT,
  106. then this entity is ignored. Used for glass for example.
  107. */
  108. TRANSLUCENT,
  109. //!Used by tracing methods. Traceable only with flag TraceFlags.WATER
  110. WATER,
  111. /*!
  112. Tells that this entity has to be actively updated by engine, its
  113. EntityEvent.FRAME has to be called etc.
  114. */
  115. ACTIVE,
  116. /*!
  117. Tells that this entity will represent mostly static object, so
  118. we can use more precise but slower methods for scene-tree linking.
  119. Also it tells to scene tree that he can count with this entity as
  120. tree-split hint.
  121. */
  122. STATIC,
  123. //!Flags for custom usage and filterings.
  124. USER1,
  125. USER2,
  126. USER3,
  127. USER4,
  128. USER5,
  129. USER6
  130. };
  131. /*!
  132. Internal ancestor of all Entity implementations.
  133. */
  134. class IEntity: Managed
  135. {
  136. //DO NOT INSERT ANYTHING BELOW - order of event methods matters!
  137. /** \name Event methods
  138. Event method stubs. Reimplement these in inherited entities to receive event calls
  139. */
  140. //@{
  141. event protected void EOnTouch(IEntity other, int extra) //!EntityEvent.TOUCH
  142. {
  143. }
  144. event protected void EOnInit(IEntity other, int extra) //!EntityEvent.INIT
  145. {
  146. }
  147. event protected void EOnExtra(IEntity other, int extra) //!EntityEvent.EXTRA
  148. {
  149. }
  150. event protected void EOnNotVisible(IEntity other, int extra) //!EntityEvent.NOTVISIBLE
  151. {
  152. }
  153. event protected void EOnFrame(IEntity other, float timeSlice) //!EntityEvent.FRAME
  154. {
  155. }
  156. event protected int EOnVisible(IEntity other, int extra) //!EntityEvent.VISIBLE
  157. {
  158. }
  159. event protected void EOnPostFrame(IEntity other, int extra) //!EntityEvent.POSTFRAME
  160. {
  161. }
  162. event protected void EOnWorldProcess(IEntity other, int extra) //!EntityEvent.WORLDPROCESS
  163. {
  164. }
  165. event protected void EOnAnimEvent(IEntity other, AnimEvent extra) //!EntityEvent.ANIMEVENT
  166. {
  167. }
  168. event protected void EOnSoundEvent(IEntity other, SoundEvent extra) //!EntityEvent.SOUNDEVENT
  169. {
  170. }
  171. event protected void EOnSimulate(IEntity other, float dt) //!EntityEvent.SIMULATE
  172. {
  173. }
  174. event protected void EOnPostSimulate(IEntity other, float timeSlice) //!EntityEvent.POSTSIMULATE
  175. {
  176. }
  177. event protected void EOnJointBreak(IEntity other, int extra) //!EntityEvent.JOINTBREAK
  178. {
  179. }
  180. event protected void EOnPhysicsMove(IEntity other, int extra) //!EntityEvent.PHYSICSMOVE
  181. {
  182. }
  183. event protected void EOnContact(IEntity other, Contact extra) //!EntityEvent.CONTACT
  184. {
  185. }
  186. protected void EOnUser0(IEntity other, int extra) //!EntityEvent.EV_USER+0
  187. {
  188. }
  189. protected void EOnUser1(IEntity other, int extra) //!EntityEvent.EV_USER+1
  190. {
  191. }
  192. event protected void EOnEnter(IEntity other, int extra) //!EntityEvent.ENTER
  193. {
  194. }
  195. event protected void EOnLeave(IEntity other, int extra) //!EntityEvent.LEAVE
  196. {
  197. }
  198. protected void EOnUser4(IEntity other, int extra) //!EntityEvent.EV_USER+4
  199. {
  200. }
  201. protected void EOnDummy020(IEntity other, int extra) //!Placeholder
  202. {
  203. }
  204. protected void EOnDummy021(IEntity other, int extra) //!Placeholder
  205. {
  206. }
  207. protected void EOnDummy022(IEntity other, int extra) //!Placeholder
  208. {
  209. }
  210. protected void EOnDummy023(IEntity other, int extra) //!Placeholder
  211. {
  212. }
  213. protected void EOnDummy024(IEntity other, int extra) //!Placeholder
  214. {
  215. }
  216. protected void EOnDummy025(IEntity other, int extra) //!Placeholder
  217. {
  218. }
  219. protected void EOnDummy026(IEntity other, int extra) //!Placeholder
  220. {
  221. }
  222. protected void EOnDummy027(IEntity other, int extra) //!Placeholder
  223. {
  224. }
  225. protected void EOnDummy028(IEntity other, int extra) //!Placeholder
  226. {
  227. }
  228. protected void EOnDummy029(IEntity other, int extra) //!Placeholder
  229. {
  230. }
  231. protected void EOnDummy030(IEntity other, int extra) //!Placeholder
  232. {
  233. }
  234. protected void EOnDummy031(IEntity other, int extra) //!Placeholder
  235. {
  236. }
  237. //@}
  238. //DO NOT INSERT ANYTHING ABOVE - order of event methods matters!
  239. /** \name Transformation methods
  240. Setting and getting of entity transformation
  241. */
  242. //@{
  243. /**
  244. \brief Returns transformation of Entity. It returns only so much vectors as array is big
  245. \param mat \p vector[1...4] matrix to be get
  246. @code
  247. Man player = g_Game.GetPlayer();
  248. vector mat[4];
  249. player.GetTransform(mat);
  250. Print( mat );
  251. >> <0.989879,-0,0.141916>,<0,1,0>,<-0.141916,0,0.989879>,<2545.08,15.6754,2867.49>
  252. @endcode
  253. */
  254. proto external void GetTransform(out vector mat[]);
  255. /**
  256. \brief Returns render transformation of Entity. Must pass in vector array size of 4
  257. \param mat \p vector[4] matrix to be get
  258. @code
  259. Man player = g_Game.GetPlayer();
  260. vector mat[4];
  261. player.GetRenderTransform(mat);
  262. Print( mat );
  263. >> <0.989879,-0,0.141916>,<0,1,0>,<-0.141916,0,0.989879>,<2545.08,15.6754,2867.49>
  264. @endcode
  265. */
  266. proto external void GetRenderTransform(out vector mat[]);
  267. /**
  268. \brief Returns local transformation of Entity. It returns only so much vectors as array is big
  269. \param mat \p vector[1...4] matrix to be get
  270. @code
  271. Man player = g_Game.GetPlayer();
  272. vector mat[4];
  273. player.GetTransform(mat);
  274. Print( mat );
  275. >> <0.989879,-0,0.141916>,<0,1,0>,<-0.141916,0,0.989879>,<2545.08,15.6754,2867.49>
  276. @endcode
  277. */
  278. proto external void GetLocalTransform(out vector mat[]);
  279. /**
  280. \brief Returns one row of Entity transformation matrix
  281. \param axis \p int matrix axis. Can be 0..3
  282. \return \p vector axis row of Entity matrix
  283. @code
  284. Man player = g_Game.GetPlayer();
  285. Print( player.GetTransformAxis(0) );
  286. Print( player.GetTransformAxis(1) );
  287. Print( player.GetTransformAxis(2) );
  288. Print( player.GetTransformAxis(3) );
  289. >> <-0.386781,0,0.922171>
  290. >> <0,1,0>
  291. >> <-0.922171,0,-0.386782>
  292. >> <2551.34,15.6439,2856.72>
  293. @endcode
  294. */
  295. proto native external vector GetTransformAxis(int axis);
  296. /**
  297. \brief Sets entity transformation
  298. \param mat \p vector[4] matrix to be set
  299. @code
  300. vector mat[4];
  301. Math3D.MatrixIdentity( mat )
  302. Man player = g_Game.GetPlayer();
  303. player.SetTransform( mat );
  304. vector outmat[4];
  305. player.GetTransform(outmat );
  306. Print( outmat );
  307. >> <1,0,0>,<0,1,0>,<0,0,1>,<0,0,0>
  308. @endcode
  309. */
  310. proto native external void SetTransform(vector mat[4]);
  311. /**
  312. \brief Returns origin of Entity
  313. \return \p vector entity origin
  314. @code
  315. Man player = g_Game.GetPlayer();
  316. Print( player.GetOrigin() );
  317. >> <2577.02,15.6837,2924.27>
  318. @endcode
  319. */
  320. proto native external vector GetOrigin();
  321. /**
  322. \brief Returns local position of Entity
  323. \return \p vector entity local position
  324. @code
  325. Man player = g_Game.GetPlayer();
  326. Print( player.GetOrigin() );
  327. >> <2577.02,15.6837,2924.27>
  328. @endcode
  329. */
  330. proto external vector GetLocalPosition();
  331. /**
  332. \brief Returns orientation of Entity in world space (Yaw, Pitch, Roll)
  333. \return \p vector entity orientation
  334. @code
  335. Man player = g_Game.GetPlayer();
  336. Print( player.GetYawPitchRoll() );
  337. >> <180,-76.5987,180>
  338. @endcode
  339. */
  340. proto native external vector GetYawPitchRoll();
  341. /**
  342. \brief Same as GetYawPitchRoll, but returns rotation vector around X, Y and Z axis.
  343. */
  344. proto native external vector GetAngles();
  345. /**
  346. \brief Returns local orientation when it's in hierarchy (Yaw, Pitch, Roll)
  347. \return \p vector local orientation
  348. @code
  349. Man player = g_Game.GetPlayer();
  350. Print( player.GetLocalYawPitchRoll() );
  351. >> <180,-57.2585,180>
  352. @endcode
  353. */
  354. proto native external vector GetLocalYawPitchRoll();
  355. /**
  356. \brief Same as GetLocalYawPitchRoll, but returns rotation vector around X, Y and Z axis.
  357. */
  358. proto native external vector GetLocalAngles();
  359. /**
  360. \brief Sets angles for entity (Yaw, Pitch, Roll)
  361. \param angles \p vector angles to be set
  362. @code
  363. Man player = g_Game.GetPlayer();
  364. player.SetYawPitchRoll("180 50 180" );
  365. Print( player.GetYawPitchRoll() );
  366. >> <-180,50,-180>
  367. @endcode
  368. */
  369. proto native external void SetYawPitchRoll(vector angles);
  370. /**
  371. \brief Same as SetYawPitchRoll, but sets rotation around X, Y and Z axis.
  372. */
  373. proto native external void SetAngles(vector angles);
  374. /**
  375. \brief Sets origin for entity
  376. \param orig \p vector origin to be set
  377. @code
  378. Man player = g_Game.GetPlayer();
  379. player.SetOrigin("2550 10 2900" );
  380. Print( player.GetOrigin() );
  381. >> <2550,10,2900>
  382. @endcode
  383. */
  384. proto native external void SetOrigin(vector orig);
  385. proto native external float GetScale();
  386. proto native external void SetScale(float scale);
  387. /**
  388. \brief Transforms local vector to world space
  389. \param vec \p vector local space vector to transform
  390. \return \p vector world space vector
  391. @code
  392. Man player = g_Game.GetPlayer();
  393. Print( player.VectorToParent("1 2 3") );
  394. >> <2.89791,2,1.26575>
  395. @endcode
  396. */
  397. proto native external vector VectorToParent(vector vec);
  398. /**
  399. \brief Transforms local position to world space
  400. \param coord \p vector local position to transform
  401. \return \p vector position in world space
  402. @code
  403. Man player = g_Game.GetPlayer();
  404. Print( player.CoordToParent("1 2 3") );
  405. >> <2549,17.6478,2857>
  406. @endcode
  407. */
  408. proto native external vector CoordToParent(vector coord);
  409. /**
  410. \brief Transforms world space vector to local space
  411. \param vec \p vector world space vector to transform
  412. \return \p vector local space vector
  413. @code
  414. Man player = g_Game.GetPlayer();
  415. Print( player.VectorToLocal("2 1 5") );
  416. >> <-0.166849,1,5.38258>
  417. @endcode
  418. */
  419. proto native external vector VectorToLocal(vector vec);
  420. /**
  421. \brief Transforms world space position to local space
  422. \param coord \p vector world space position to transform
  423. \return \p vector position in local space
  424. @code
  425. Man player = g_Game.GetPlayer();
  426. Print( player.CoordToLocal("500 10 155") );
  427. >> <15254,-54.2004,8745.53>
  428. @endcode
  429. */
  430. proto native external vector CoordToLocal(vector coord);
  431. //@}
  432. /** \name Name/ID methods
  433. */
  434. //@{
  435. /**
  436. \brief Return unique entity ID
  437. \return \p int unique entity ID
  438. @code
  439. ItemBase apple = g_Game.CreateObject( "FruitApple", String2Vector("0 10 0"), false );
  440. Print( apple.GetID() );
  441. >> 0
  442. @endcode
  443. */
  444. proto native int GetID();
  445. /**
  446. \brief Set unique entity ID
  447. \param id \p int unique entity ID to be set
  448. @code
  449. ItemBase apple = g_Game.CreateObject( "Fruit_Apple", String2Vector("0 10 0"), false );
  450. apple.SetID(101);
  451. Print( apple.GetID() );
  452. >> 101
  453. @endcode
  454. */
  455. proto native void SetID(int id);
  456. proto native void SetName(string name);
  457. proto native external owned string GetName();
  458. //@}
  459. /** \name Hierarchy methods
  460. Scene hierarchy management
  461. */
  462. //@{
  463. /**
  464. \brief Adds child entity to this entity.
  465. \note Make sure the parent is not ToDelete
  466. \param child \p IEntity Pointer to entity which become our child
  467. \param pivot \p int Pivot is pivot index, or -1 for center of parent.
  468. \param positionOnly \p bool When set to true, the orientation will still be in WS.
  469. \return \p bool True when entity has been attached. False otherwise.
  470. */
  471. proto native external bool AddChild(notnull IEntity child, int pivot, bool positionOnly = false);
  472. /**
  473. \brief Removes child entity from hierarchy.
  474. \note Make sure the child is not ToDelete
  475. \param child \p IEntity Pointer to child entity we want to remove.
  476. \param keepTransform \p bool When set to true, Entity is kept on her world position. Otherwise it's local transform is used as world-space one.
  477. \return \p bool True if it was removed, false when this entity is not our child.
  478. */
  479. proto native external bool RemoveChild(notnull IEntity child, bool keepTransform = false);
  480. //! Returns if the hierarchy component was created with positionOnly
  481. proto native bool IsHierarchyPositionOnly();
  482. //! Returns the hierarchy component pivot
  483. proto native int GetHierarchyPivot();
  484. //! Returns pointer to parent Entity in hierarchy
  485. proto native IEntity GetParent();
  486. //! Returns pointer to first child Entity in hierarchy
  487. proto native IEntity GetChildren();
  488. //! Returns pointer to next child Entity on the same hierarchy
  489. proto native IEntity GetSibling();
  490. //@}
  491. /**
  492. \brief Returns local bounding box of model on Entity
  493. \param[out] mins \p vector minimum point of bounding box
  494. \param[out] maxs \p vector maximum point of bounding box
  495. @code
  496. Man player = g_Game.GetPlayer();
  497. vector mins, maxs;
  498. player.GetBounds(mins, maxs );
  499. Print( mins );
  500. Print( maxs );
  501. >> <0,0,0>
  502. >> <0,0,0>
  503. @endcode
  504. */
  505. proto external void GetBounds(out vector mins, out vector maxs);
  506. /**
  507. \brief Returns quantized world-bound-box of Entity
  508. \param[out] mins \p vector minimum point of bounding box
  509. \param[out] maxs \p vector maximum point of bounding box
  510. @code
  511. Man player = g_Game.GetPlayer();
  512. vector mins, maxs;
  513. player.GetWorldBounds( mins, maxs );
  514. Print( mins );
  515. Print( maxs );
  516. >> <2547.2,15.5478,2852.85>
  517. >> <2548.8,17.5478,2855.05>
  518. @endcode
  519. */
  520. proto external void GetWorldBounds(out vector mins, out vector maxs);
  521. /** \name Simulation/handling properties
  522. Flags that affects simulation and entity handling behavior
  523. */
  524. //@{
  525. /**
  526. \brief Returns Entity flags
  527. \return \p EntityFlags entity flags
  528. @code
  529. Man player = g_Game.GetPlayer();
  530. Print( player.GetFlags() );
  531. >> 1610612745
  532. @endcode
  533. */
  534. proto native external EntityFlags GetFlags();
  535. /**
  536. \brief Test if one or more of specified flags are set
  537. \return \p bool True if is set, false otherwise.
  538. @code
  539. Man player = g_Game.GetPlayer();
  540. player.SetFlags(EntityFlags.VISIBLE);
  541. Print( player.IsFlagSet(EntityFlags.VISIBLE) );
  542. >> true
  543. @endcode
  544. */
  545. proto native external bool IsFlagSet(EntityFlags flags);
  546. /**
  547. \brief Sets Entity flags. It's OR operation, not rewrite. Returns previous flags
  548. \param flags \p int flags to be set
  549. \param recursively flags will be recursively applied to children of hierarchy too
  550. \return \p int previous flags
  551. @code
  552. Man player = g_Game.GetPlayer();
  553. player.SetFlags(EntityFlags.VISIBLE|EntityFlags.SOLID );
  554. Print( player.GetFlags() );
  555. >> 1610612747
  556. @endcode
  557. */
  558. proto native external EntityFlags SetFlags(EntityFlags flags, bool recursively);
  559. /**
  560. \brief Clear Entity flags. Returns cleared flags
  561. \param flags \p int flags to be set
  562. \param recursively flags will be recursively applied to children of hierarchy too
  563. \return \p int cleared flags
  564. @code
  565. Man player = g_Game.GetPlayer();
  566. player.ClearFlags(EntityFlags.VISIBLE|EntityFlags.SOLID );
  567. Print( player.GetFlags() );
  568. >> 1610612744
  569. @endcode
  570. */
  571. proto native external EntityFlags ClearFlags(EntityFlags flags, bool recursively);
  572. /**
  573. \brief Returns current event mask
  574. \return \p int current event mask
  575. @code
  576. Man player = g_Game.GetPlayer();
  577. Print( player.GetEventMask() );
  578. >> 0
  579. @endcode
  580. */
  581. proto native external EntityEvent GetEventMask();
  582. /**
  583. \brief Sets event mask
  584. \param e combined mask of one or more members of EntityEvent enum
  585. @code
  586. Man player = g_Game.GetPlayer();
  587. Print( player.GetEventMask() );
  588. player.SetEventMask( EntityEvent.VISIBLE );
  589. Print( player.GetEventMask() );
  590. >> 0
  591. >> 128
  592. @endcode
  593. */
  594. proto native external EntityEvent SetEventMask(EntityEvent e );
  595. /**
  596. \brief Clears event mask
  597. \param e \p int event mask
  598. \return \p int event mask
  599. @code
  600. Man player = g_Game.GetPlayer();
  601. player.SetEventMask(EntityEvent.VISIBLE );
  602. Print( player.GetEventMask() );
  603. player.ClearEventMask(EntityEvent.ALL );
  604. Print( player.GetEventMask() );
  605. >> 128
  606. >> 0
  607. @endcode
  608. */
  609. proto native external EntityEvent ClearEventMask(EntityEvent e);
  610. //!Dynamic event invokation. Parameters are the same as in IEntity::EOnXXXX() methods
  611. proto external volatile void SendEvent(notnull IEntity actor, EntityEvent e, void extra);
  612. //@}
  613. /** \name Visual component methods
  614. Manipulation with visual component - model, particle effect etc
  615. */
  616. //@{
  617. /**
  618. \brief Sets the visual object to this entity. Reference is added and released upon entity destruction
  619. \param object handle to object got by GetObject()
  620. \param options String, dependant on object type.
  621. //Only supported one for XOB objects:
  622. //$remap 'original material name' 'new material'; [$remap 'another original material name' 'anothernew material']
  623. */
  624. proto native external void SetObject(vobject object, string options);
  625. /**
  626. \brief Returns visual object set to this Entity. No reference is added
  627. */
  628. proto native vobject GetVObject();
  629. //!Updates animation (either xob, or particle, whatever)
  630. proto native external int Animate(float speed, int loop);
  631. //!Updates animation (either xob, or particle, whatever)
  632. proto native external int AnimateEx(float speed, int loop, out vector lin, out vector ang);
  633. //!Sets visibility mask for cameras, where Entity will be rendered
  634. proto native external int SetCameraMask(int mask);
  635. //@}
  636. /**
  637. \brief When called, the Entity is excluded from consequent TraceMove/TraceLine
  638. */
  639. proto native external void FilterNextTrace();
  640. /*!
  641. Updates entity state/position. Should be called when you want to manually commit position changes etc
  642. before trace methods etc. Entity is updated automatically at the end and the beginning of simulation step,
  643. when it has EntityFlags.TFL_ACTIVE flag set.
  644. \returns mask with flags
  645. // EntityFlags.UPDATE - hierarchy has been updated
  646. // EntityFlags.UPDATE_MDL - model hierarchy has been updated
  647. */
  648. proto native external int Update();
  649. #ifdef COMPONENT_SYSTEM
  650. //! Constructor
  651. protected void IEntity(IEntitySource src, IEntity parent);
  652. #endif
  653. };
  654. #ifdef ENF_DONE
  655. // Set fixed LOD. -1 for non-fixed LOD
  656. proto native void SetFixedLOD(IEntity ent, int lod);
  657. //Sets the texture that can be referenced from material as $renderview
  658. //and connects it with camera cam_index. Size iz recommended size of
  659. //rendertarget (0 is default)
  660. proto native void SetRenderView(IEntity ent, int cam_index, int width, int height);
  661. proto void GetRenderView(IEntity ent, out int cam_index, out int width, out int height);
  662. #endif
  663. /**
  664. * \defgroup EntityAttributes Entity editor attribute system
  665. * @{
  666. */
  667. class ParamEnum: Managed
  668. {
  669. string m_Key;
  670. string m_Value;
  671. string m_Desc;
  672. void ParamEnum(string key, string value, string desc = "")
  673. {
  674. m_Key = key;
  675. m_Value = value;
  676. m_Desc = desc;
  677. }
  678. }
  679. class ParamEnumArray: array<ref ParamEnum>
  680. {
  681. static ParamEnumArray FromEnum(typename e)
  682. {
  683. ParamEnumArray params = new ParamEnumArray();
  684. int cnt = e.GetVariableCount();
  685. int val;
  686. for (int i = 0; i < cnt; i++)
  687. {
  688. if (e.GetVariableType(i) == int && e.GetVariableValue(NULL, i, val))
  689. {
  690. params.Insert(new ParamEnum(e.GetVariableName(i), val.ToString()));
  691. }
  692. }
  693. return params;
  694. }
  695. }
  696. // -------------------------------------------------------------------------
  697. class Attribute
  698. {
  699. string m_DefValue;
  700. string m_UiWidget; ///< can be "editbox", "combobox", "spinbox", "slider", "font", "fileeditbox", "colorPicker", "flags", "resourceNamePicker"
  701. string m_RangeScale; ///< defined as "MIN_VALUE MAX_VALUE STEP" eg. "1 100 0.5"
  702. string m_Desc;
  703. ref ParamEnumArray m_Enums; ///< Only ints and floats are currently supported. Array can be defined this way: { ParamEnum("Choice 1", "1"), ParamEnum("Choicen 2", "2") }
  704. void Attribute(string defvalue, string uiwidget, string desc = "", string rangescale = "", ParamEnumArray enums = NULL)
  705. {
  706. m_DefValue = defvalue;
  707. m_UiWidget = uiwidget;
  708. m_RangeScale = rangescale;
  709. m_Desc = desc;
  710. m_Enums = enums;
  711. }
  712. }
  713. class EditorAttribute
  714. {
  715. string m_Style; ///< can be "box", "sphere", "cylinder", "pyramid", "diamond" or custom style name
  716. string m_Category; ///< folder structure eg. StaticEntities/Walls
  717. string m_Description; ///< class purpose description
  718. vector m_SizeMin; ///< min vector of a bounding box
  719. vector m_SizeMax; ///< max vector of a bounding box
  720. string m_Color;
  721. string m_Color2;
  722. bool m_Visible;
  723. bool m_Insertable;
  724. bool m_DynamicBox;
  725. void EditorAttribute(string style, string category, string description, vector sizeMin, vector sizeMax, string color, string color2 = "0 0 0 0", bool visible = true, bool insertable = true, bool dynamicBox = false)
  726. {
  727. m_Style = style;
  728. m_Category = category;
  729. m_Description = description;
  730. m_SizeMin = sizeMin;
  731. m_SizeMax = sizeMax;
  732. m_Color = color;
  733. m_Color2 = color2;
  734. m_Visible = visible;
  735. m_Insertable = insertable;
  736. m_DynamicBox = dynamicBox;
  737. }
  738. }
  739. //@}
  740. //@}