Ticket #2055: SharedLOSTechv7.patch

File SharedLOSTechv7.patch, 6.0 KB (added by Niek, 9 years ago)

Move return up in function and add comment to schema

  • binaries/data/mods/public/art/textures/ui/session/portraits/technologies/shared_los.png

    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
  • binaries/data/mods/public/simulation/components/Player.js

    Property changes on: binaries/data/mods/public/art/textures/ui/session/portraits/technologies/shared_los.png
    ___________________________________________________________________
    Added: svn:mime-type
    ## -0,0 +1 ##
    +application/octet-stream
    \ No newline at end of property
     
    11function Player() {}
    22
     3// Technology name that is used for deciding whether a player shares LOS with his allies or not
    34Player.prototype.Schema =
    4     "<a:component type='system'/><empty/>";
     5    "<optional>" +
     6        "<element name='SharedLosTech'>" +
     7            "<text/>" +
     8        "</element>" +
     9    "</optional>";
    510
    611Player.prototype.Init = function()
    712{
     
    114118
    115119Player.prototype.AddPopulation = function(num)
    116120{
    117     this.popUsed += num;
     121    this.popUsed += num;
    118122};
    119123
    120124Player.prototype.SetPopulationBonuses = function(num)
    (this hunk was shorter than expected)  
    445449
    446450Player.prototype.UpdateSharedLos = function()
    447451{
     452    if (!this.template || !this.template.SharedLosTech)
     453        return;
    448454
    449     var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
     455    let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
    450456    if (!cmpRangeManager)
    451457        return;
    452458
    453     var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager);
     459    let cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager);
    454460    if (!cmpPlayerManager)
    455461        return;
    456462
    457     var sharedLos = [];
    458     for (var i = 0; i < cmpPlayerManager.GetNumPlayers(); ++i)
    459         if (this.IsMutualAlly(i))
    460             sharedLos.push(i);
     463    let cmpTechnologyManager = Engine.QueryInterface(this.entity, IID_TechnologyManager);
     464    if (!cmpTechnologyManager)
     465        return;
    461466
    462     cmpRangeManager.SetSharedLos(this.playerID, sharedLos);
     467    if (!cmpTechnologyManager.IsTechnologyResearched(this.template.SharedLosTech))
     468    {
     469        cmpRangeManager.SetSharedLos(this.playerID, [this.playerID]);
     470        return;
     471    }
     472
     473    let sharedLosPlayers = [];
     474    for (let i = 0; i < cmpPlayerManager.GetNumPlayers(); ++i)
     475        if (this.IsMutualAlly(i) && cmpTechnologyManager.IsTechnologyResearched(this.template.SharedLosTech))
     476            sharedLosPlayers.push(i);
     477
     478    cmpRangeManager.SetSharedLos(this.playerID, sharedLosPlayers);
    463479};
    464480
    465481Player.prototype.GetFormations = function()
     
    788806    this.startingTechnologies = techs;
    789807};
    790808
    791 Engine.RegisterComponentType(IID_Player, "Player", Player);
     809Engine.RegisterComponentType(IID_Player, "Player", Player);
     810 No newline at end of file
  • binaries/data/mods/public/simulation/components/TechnologyManager.js

     
    373373    if (cmpPlayerEntityLimits)
    374374        cmpPlayerEntityLimits.UpdateLimitsFromTech(tech);
    375375
     376    // Update Shared LOS
     377    if (tech == cmpPlayer.template.SharedLosTech)
     378        cmpPlayer.UpdateSharedLos();
     379
    376380    // Call the related trigger event
    377381    var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger);
    378382    cmpTrigger.CallEvent("ResearchFinished", {"player": playerID, "tech": tech});
  • binaries/data/mods/public/simulation/data/technologies/unlock_shared_los.json

     
     1{
     2    "genericName": "Cartography",
     3    "description": "By means of trading and travelling people explored beyond the boundaries of their lands and drew maps of it in order to share and memorize their discoveries.",
     4    "cost": {"food": 100, "wood": 0, "stone": 0, "metal": 100},
     5    "requirements": {"tech": "phase_village"},
     6    "icon": "shared_los.png",
     7    "researchTime": 40,
     8    "tooltip": "Player sees what his allies see.",
     9    "soundComplete": "interface/alarm/alarm_upgradearmory.xml"
     10}
     11 No newline at end of file
  • binaries/data/mods/public/simulation/templates/special/player.xml

     
    4848      </CivilCentre>
    4949    </LimitRemovers>
    5050  </EntityLimits>
    51   <Player/>
     51  <Player>
     52    <SharedLosTech>unlock_shared_los</SharedLosTech>
     53  </Player>
    5254  <StatisticsTracker/>
    5355  <TechnologyManager/>
    54 </Entity>
     56</Entity>
     57 No newline at end of file
  • binaries/data/mods/public/simulation/templates/template_structure_economic_market.xml

     
    5151    <BatchTimeModifier>0.7</BatchTimeModifier>
    5252    <Technologies datatype="tokens">
    5353      speed_trader_01
     54      unlock_shared_los
    5455    </Technologies>
    5556    <Entities datatype="tokens">
    5657      units/{civ}_support_trader