LCOV - code coverage report
Current view: top level - simulation/components - RangeOverlayManager.js (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 42 0.0 %
Date: 2023-04-02 12:52:40 Functions: 0 9 0.0 %

          Line data    Source code
       1             : function RangeOverlayManager() {}
       2             : 
       3           0 : RangeOverlayManager.prototype.Schema = "<empty/>";
       4             : 
       5           0 : RangeOverlayManager.prototype.Init = function()
       6             : {
       7           0 :         this.enabled = false;
       8           0 :         this.enabledRangeTypes = {
       9             :                 "Attack": false,
      10             :                 "Auras": false,
      11             :                 "Heal": false
      12             :         };
      13             : 
      14           0 :         this.rangeVisualizations = new Map();
      15             : };
      16             : 
      17             : // The GUI enables visualizations
      18           0 : RangeOverlayManager.prototype.Serialize = null;
      19             : 
      20           0 : RangeOverlayManager.prototype.Deserialize = function(data)
      21             : {
      22           0 :         this.Init();
      23             : };
      24             : 
      25           0 : RangeOverlayManager.prototype.UpdateRangeOverlays = function(componentName)
      26             : {
      27           0 :         let cmp = Engine.QueryInterface(this.entity, global["IID_" + componentName]);
      28           0 :         if (cmp)
      29           0 :                 this.rangeVisualizations.set(componentName, cmp.GetRangeOverlays());
      30             : };
      31             : 
      32           0 : RangeOverlayManager.prototype.SetEnabled = function(enabled, enabledRangeTypes, forceUpdate)
      33             : {
      34           0 :         this.enabled = enabled;
      35           0 :         this.enabledRangeTypes = enabledRangeTypes;
      36             : 
      37           0 :         this.RegenerateRangeOverlays(forceUpdate);
      38             : };
      39             : 
      40           0 : RangeOverlayManager.prototype.RegenerateRangeOverlays = function(forceUpdate)
      41             : {
      42           0 :         let cmpRangeOverlayRenderer = Engine.QueryInterface(this.entity, IID_RangeOverlayRenderer);
      43           0 :         if (!cmpRangeOverlayRenderer)
      44           0 :                 return;
      45             : 
      46           0 :         cmpRangeOverlayRenderer.ResetRangeOverlays();
      47             : 
      48           0 :         if (!this.enabled && !forceUpdate)
      49           0 :                 return;
      50             : 
      51             :         // Only render individual range types that have been enabled
      52           0 :         for (let rangeOverlayType of this.rangeVisualizations.keys())
      53           0 :                 if (this.enabledRangeTypes[rangeOverlayType])
      54           0 :                         for (let rangeOverlay of this.rangeVisualizations.get(rangeOverlayType))
      55           0 :                                 cmpRangeOverlayRenderer.AddRangeOverlay(
      56             :                                         rangeOverlay.radius,
      57             :                                         rangeOverlay.texture,
      58             :                                         rangeOverlay.textureMask,
      59             :                                         rangeOverlay.thickness);
      60             : };
      61             : 
      62           0 : RangeOverlayManager.prototype.OnOwnershipChanged = function(msg)
      63             : {
      64           0 :         if (msg.to == INVALID_PLAYER)
      65           0 :                 return;
      66           0 :         for (let type in this.enabledRangeTypes)
      67           0 :                 this.UpdateRangeOverlays(type);
      68             : 
      69           0 :         this.RegenerateRangeOverlays(false);
      70             : };
      71             : 
      72           0 : RangeOverlayManager.prototype.OnValueModification = function(msg)
      73             : {
      74           0 :         if (msg.valueNames.indexOf("Heal/Range") == -1 &&
      75             :             msg.valueNames.indexOf("Attack/Ranged/MinRange") == -1 &&
      76             :             msg.valueNames.indexOf("Attack/Ranged/MaxRange") == -1)
      77           0 :                 return;
      78             : 
      79           0 :         this.UpdateRangeOverlays(msg.component);
      80           0 :         this.RegenerateRangeOverlays(false);
      81             : };
      82             : 
      83             : /**
      84             :  * RangeOverlayManager component is deserialized before the TechnologyManager, so need to update the ranges here
      85             :  */
      86           0 : RangeOverlayManager.prototype.OnDeserialized = function(msg)
      87             : {
      88           0 :         for (let type in this.enabledRangeTypes)
      89           0 :                 this.UpdateRangeOverlays(type);
      90             : };
      91             : 
      92           0 : Engine.RegisterComponentType(IID_RangeOverlayManager, "RangeOverlayManager", RangeOverlayManager);

Generated by: LCOV version 1.14