Advertisement
Guest User

Untitled

a guest
Jul 14th, 2016
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.44 KB | None | 0 0
  1. Index: binaries/data/mods/public/simulation/components/AuraManager.js
  2. ===================================================================
  3. --- binaries/data/mods/public/simulation/components/AuraManager.js  (revision 18503)
  4. +++ binaries/data/mods/public/simulation/components/AuraManager.js  (working copy)
  5. @@ -9,8 +9,25 @@
  6.     this.modifications = new Map();
  7.     this.templateModificationsCache = new Map();
  8.     this.templateModifications = new Map();
  9. +
  10. +   this.globalAuraGivers = [];
  11.  };
  12.  
  13. +
  14. +AuraManager.prototype.RegisterGlobalAuraGiver = function(ent)
  15. +{
  16. +   let idx = this.globalAuraGivers.indexOf(ent);
  17. +   if (idx == -1)
  18. +       this.globalAuraGivers.push(ent);
  19. +};
  20. +
  21. +AuraManager.prototype.UnregisterGlobalAuraGiver = function(ent)
  22. +{
  23. +   let idx = this.globalAuraGivers.indexOf(ent);
  24. +   if (idx != -1)
  25. +       this.globalAuraGivers.splice(idx, 1);
  26. +};
  27. +
  28.  AuraManager.prototype.ensureExists = function(name, value, id, key, defaultData)
  29.  {
  30.     var cacheName = name + "Cache";
  31. @@ -230,4 +247,14 @@
  32.     return value * multiply + add;
  33.  };
  34.  
  35. +AuraManager.prototype.OnGlobalOwnershipChanged = function(msg)
  36. +{
  37. +   for (let ent in this.globalAuraGivers)
  38. +   {
  39. +       let cmpAuras = Engine.QueryInterface(ent, IID_Auras);
  40. +       if (cmpAuras)
  41. +           cmpAuras.RegisterGlobalOwnershipChanged = function(msg);
  42. +   }
  43. +};
  44. +
  45.  Engine.RegisterSystemComponentType(IID_AuraManager, "AuraManager", AuraManager);
  46. Index: binaries/data/mods/public/simulation/components/Auras.js
  47. ===================================================================
  48. --- binaries/data/mods/public/simulation/components/Auras.js    (revision 18503)
  49. +++ binaries/data/mods/public/simulation/components/Auras.js    (working copy)
  50. @@ -60,11 +60,9 @@
  51.  
  52.  Auras.prototype.GetRange = function(name)
  53.  {
  54. -   if (!this.IsRangeAura(name))
  55. -       return undefined;
  56. -   if (this.IsGlobalAura(name))
  57. -       return -1; // -1 is infinite range
  58. -   return +this.auras[name].radius;
  59. +   if (this.IsRangeAura(name))
  60. +       return +this.auras[name].radius;
  61. +   return undefined;
  62.  };
  63.  
  64.  Auras.prototype.GetClasses = function(name)
  65. @@ -154,8 +152,7 @@
  66.  
  67.  Auras.prototype.IsRangeAura = function(name)
  68.  {
  69. -   // A global aura is also treated as a range aura with infinite range.
  70. -   return ["range", "global"].indexOf(this.GetType(name)) != -1;
  71. +   return this.GetType(name) == "range";
  72.  };
  73.  
  74.  Auras.prototype.IsGlobalAura = function(name)
  75. @@ -204,6 +201,13 @@
  76.         if (!affectedPlayers.length)
  77.             continue;
  78.  
  79. +       if (this.IsGlobalAura(name))
  80. +       {
  81. +           for (let player of affectedPlayers)
  82. +               this.ApplyBonus(name, cmpRangeManager.GetEntitiesByPlayer(player));
  83. +           continue;
  84. +       }
  85. +
  86.         if (!this.IsRangeAura(name))
  87.         {
  88.             this.ApplyBonus(name, targetUnitsClone[name]);
  89. @@ -219,18 +223,6 @@
  90.             cmpRangeManager.GetEntityFlagMask("normal")
  91.         );
  92.         cmpRangeManager.EnableActiveQuery(this[name].rangeQuery);
  93. -
  94. -       if (this.IsGlobalAura(name))
  95. -       {
  96. -           this.ApplyTemplateBonus(name, affectedPlayers);
  97. -
  98. -           // Add self to your own query for consistency with templates.
  99. -           this.OnRangeUpdate({
  100. -               "tag": this[name].rangeQuery,
  101. -               "added": [this.entity],
  102. -               "removed": []
  103. -           });
  104. -       }
  105.     }
  106.  };
  107.  
  108. @@ -263,6 +255,21 @@
  109.     }
  110.  };
  111.  
  112. +Auras.prototype.RegisterGlobalOwnershipChanged = function(msg)
  113. +{
  114. +   let auraNames = this.GetAuraNames().filter(n => this.IsGlobalAura(n));
  115. +   for (let name of auraNames)
  116. +   {
  117. +       let affectedPlayers = this.GetAffectedPlayers();
  118. +       let wasApplied = affectedPlayers.indexOf(msg.from) != -1;
  119. +       let willBeApplied = affectedPlayers.indexOf(msg.to) != -1;
  120. +       if (wasApplied && !willBeApplied)
  121. +           this.RemoveBonus(name, msg.entity);
  122. +       if (willBeApplied && !wasApplied)
  123. +           this.ApplyBonus(name, msg.entity);
  124. +   }
  125. +};
  126. +
  127.  Auras.prototype.ApplyFormationBonus = function(memberList)
  128.  {
  129.     var auraNames = this.GetAuraNames().filter(n => this.IsFormationAura(n));
  130. @@ -288,6 +295,8 @@
  131.     var cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager);
  132.     var classes = this.GetClasses(name);
  133.  
  134. +   cmpAuraManager.RegisterGlobalAuraGiver(this.entity);
  135. +
  136.     for (let mod of modifications)
  137.         for (let player of players)
  138.             cmpAuraManager.ApplyTemplateBonus(mod.value, player, classes, mod, this.GetModifierIdentifier(name));
  139. @@ -314,6 +323,8 @@
  140.     if (!this.IsGlobalAura(name))
  141.         return;
  142.  
  143. +   cmpAuraManager.UnregisterGlobalAuraGiver(this.entity);
  144. +
  145.     var modifications = this.GetModifications(name);
  146.     var cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager);
  147.     var classes = this.GetClasses(name);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement