staticflagpole.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. For use in events/by modders, not part of standard gameplay
  3. Example object spawner json use:
  4. {
  5. "Objects": [
  6. {
  7. "name": "StaticFlagPole",
  8. "pos": [
  9. 3000,
  10. 57,
  11. 3000
  12. ],
  13. "ypr": [
  14. 0.0,
  15. 0.0,
  16. 0.0
  17. ],
  18. "scale": 1,
  19. "customString": "Flag_Bohemia"
  20. }
  21. ]
  22. }
  23. */
  24. class StaticFlagPole extends TerritoryFlag
  25. {
  26. override void OnPartDismantledServer( notnull Man player, string part_name, int action_id )
  27. {
  28. }
  29. override void OnPartDestroyedServer( Man player, string part_name, int action_id, bool destroyed_by_connected_part = false )
  30. {
  31. }
  32. override void OnSpawnByObjectSpawner(ITEM_SpawnerObject item)
  33. {
  34. FullyBuild();
  35. if (item.customString != string.Empty)
  36. {
  37. EntityAI flag = GetInventory().CreateInInventory(item.customString);
  38. if (flag)
  39. {
  40. AnimateFlagEx(0);
  41. AddRefresherTime01(1);
  42. }
  43. }
  44. }
  45. // version of FullyBuild which does not require a player
  46. override void FullyBuild()
  47. {
  48. array<ConstructionPart> parts = GetConstruction().GetConstructionParts().GetValueArray();
  49. foreach (ConstructionPart part : parts)
  50. {
  51. ConstructionPart construtionPart = GetConstruction().GetConstructionPart(part.GetPartName());
  52. if (construtionPart.IsBase())
  53. {
  54. SetBaseState(true);
  55. CreateConstructionKit();
  56. }
  57. RegisterPartForSync(construtionPart.GetId());
  58. RegisterActionForSync(construtionPart.GetId(), AT_BUILD_PART);
  59. SynchronizeBaseState();
  60. SetPartFromSyncData(construtionPart); // server part of sync, client will be synced from SetPartsFromSyncData
  61. UpdateNavmesh();
  62. UpdateVisuals();
  63. GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(ResetActionSyncData, 100, false, this);
  64. }
  65. GetConstruction().UpdateVisuals();
  66. }
  67. }