Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: binaries/data/mods/public/simulation/components/AuraManager.js
- ===================================================================
- --- binaries/data/mods/public/simulation/components/AuraManager.js (revision 18503)
- +++ binaries/data/mods/public/simulation/components/AuraManager.js (working copy)
- @@ -9,8 +9,25 @@
- this.modifications = new Map();
- this.templateModificationsCache = new Map();
- this.templateModifications = new Map();
- +
- + this.globalAuraGivers = [];
- };
- +
- +AuraManager.prototype.RegisterGlobalAuraGiver = function(ent)
- +{
- + let idx = this.globalAuraGivers.indexOf(ent);
- + if (idx == -1)
- + this.globalAuraGivers.push(ent);
- +};
- +
- +AuraManager.prototype.UnregisterGlobalAuraGiver = function(ent)
- +{
- + let idx = this.globalAuraGivers.indexOf(ent);
- + if (idx != -1)
- + this.globalAuraGivers.splice(idx, 1);
- +};
- +
- AuraManager.prototype.ensureExists = function(name, value, id, key, defaultData)
- {
- var cacheName = name + "Cache";
- @@ -230,4 +247,14 @@
- return value * multiply + add;
- };
- +AuraManager.prototype.OnGlobalOwnershipChanged = function(msg)
- +{
- + for (let ent in this.globalAuraGivers)
- + {
- + let cmpAuras = Engine.QueryInterface(ent, IID_Auras);
- + if (cmpAuras)
- + cmpAuras.RegisterGlobalOwnershipChanged = function(msg);
- + }
- +};
- +
- Engine.RegisterSystemComponentType(IID_AuraManager, "AuraManager", AuraManager);
- Index: binaries/data/mods/public/simulation/components/Auras.js
- ===================================================================
- --- binaries/data/mods/public/simulation/components/Auras.js (revision 18503)
- +++ binaries/data/mods/public/simulation/components/Auras.js (working copy)
- @@ -60,11 +60,9 @@
- Auras.prototype.GetRange = function(name)
- {
- - if (!this.IsRangeAura(name))
- - return undefined;
- - if (this.IsGlobalAura(name))
- - return -1; // -1 is infinite range
- - return +this.auras[name].radius;
- + if (this.IsRangeAura(name))
- + return +this.auras[name].radius;
- + return undefined;
- };
- Auras.prototype.GetClasses = function(name)
- @@ -154,8 +152,7 @@
- Auras.prototype.IsRangeAura = function(name)
- {
- - // A global aura is also treated as a range aura with infinite range.
- - return ["range", "global"].indexOf(this.GetType(name)) != -1;
- + return this.GetType(name) == "range";
- };
- Auras.prototype.IsGlobalAura = function(name)
- @@ -204,6 +201,13 @@
- if (!affectedPlayers.length)
- continue;
- + if (this.IsGlobalAura(name))
- + {
- + for (let player of affectedPlayers)
- + this.ApplyBonus(name, cmpRangeManager.GetEntitiesByPlayer(player));
- + continue;
- + }
- +
- if (!this.IsRangeAura(name))
- {
- this.ApplyBonus(name, targetUnitsClone[name]);
- @@ -219,18 +223,6 @@
- cmpRangeManager.GetEntityFlagMask("normal")
- );
- cmpRangeManager.EnableActiveQuery(this[name].rangeQuery);
- -
- - if (this.IsGlobalAura(name))
- - {
- - this.ApplyTemplateBonus(name, affectedPlayers);
- -
- - // Add self to your own query for consistency with templates.
- - this.OnRangeUpdate({
- - "tag": this[name].rangeQuery,
- - "added": [this.entity],
- - "removed": []
- - });
- - }
- }
- };
- @@ -263,6 +255,21 @@
- }
- };
- +Auras.prototype.RegisterGlobalOwnershipChanged = function(msg)
- +{
- + let auraNames = this.GetAuraNames().filter(n => this.IsGlobalAura(n));
- + for (let name of auraNames)
- + {
- + let affectedPlayers = this.GetAffectedPlayers();
- + let wasApplied = affectedPlayers.indexOf(msg.from) != -1;
- + let willBeApplied = affectedPlayers.indexOf(msg.to) != -1;
- + if (wasApplied && !willBeApplied)
- + this.RemoveBonus(name, msg.entity);
- + if (willBeApplied && !wasApplied)
- + this.ApplyBonus(name, msg.entity);
- + }
- +};
- +
- Auras.prototype.ApplyFormationBonus = function(memberList)
- {
- var auraNames = this.GetAuraNames().filter(n => this.IsFormationAura(n));
- @@ -288,6 +295,8 @@
- var cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager);
- var classes = this.GetClasses(name);
- + cmpAuraManager.RegisterGlobalAuraGiver(this.entity);
- +
- for (let mod of modifications)
- for (let player of players)
- cmpAuraManager.ApplyTemplateBonus(mod.value, player, classes, mod, this.GetModifierIdentifier(name));
- @@ -314,6 +323,8 @@
- if (!this.IsGlobalAura(name))
- return;
- + cmpAuraManager.UnregisterGlobalAuraGiver(this.entity);
- +
- var modifications = this.GetModifications(name);
- var cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager);
- var classes = this.GetClasses(name);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement