Ticket #2055: SharedLOSTech.patch

File SharedLOSTech.patch, 4.0 KB (added by Niek, 9 years ago)

Implements the Shared LOS technology

  • 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
     
    3535    this.cheatsEnabled = false;
    3636    this.cheatTimeMultiplier = 1;
    3737    this.heroes = [];
     38    this.sharedLos = false;
    3839    this.resourceNames = {
    3940        "food": markForTranslation("Food"),
    4041        "wood": markForTranslation("Wood"),
     
    453454    if (!cmpPlayerManager)
    454455        return;
    455456
    456     var sharedLos = [];
     457    var cmpTechnologyManager = Engine.QueryInterface(this.entity, IID_TechnologyManager);
     458    if (!cmpTechnologyManager)
     459        return;
     460
     461    var sharedLosArr = [];
    457462    for (var i = 0; i < cmpPlayerManager.GetNumPlayers(); ++i)
    458         if (this.IsMutualAlly(i))
    459             sharedLos.push(i);
     463        if ( (this.IsMutualAlly(i) && this.sharedLos) || (i == this.GetPlayerID()) )
     464            sharedLosArr.push(i);
    460465
    461     cmpRangeManager.SetSharedLos(this.playerID, sharedLos);
     466    cmpRangeManager.SetSharedLos(this.playerID, sharedLosArr);
    462467};
    463468
    464469Player.prototype.GetFormations = function()
     
    788793    this.startingTechnologies = techs;
    789794};
    790795
    791 Engine.RegisterComponentType(IID_Player, "Player", Player);
     796Player.prototype.OnValueModification = function(msg)
     797{
     798    if (msg.component != "Player")
     799        return;
     800
     801    var oldSharedLos = this.sharedLos;
     802    this.sharedLos = ApplyValueModificationsToPlayer("Player/sharedLos", this.sharedLos, this.entity);
     803
     804    if (oldSharedLos != this.sharedLos)
     805        this.UpdateSharedLos();
     806};
     807
     808Engine.RegisterComponentType(IID_Player, "Player", Player);
     809 No newline at end of file
  • binaries/data/mods/public/simulation/data/technologies/unlock_shared_los.json

     
     1{
     2    "genericName": "Carthography",
     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    "modifications": [{"value": "Player/sharedLos", "replace": true}],
     10    "soundComplete": "interface/alarm/alarm_upgradearmory.xml"
     11}
  • 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