Ticket #2055: SharedLOSTechv2.patch

File SharedLOSTechv2.patch, 3.9 KB (added by Niek, 9 years ago)

Patch with style fixes

  • 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"),
     
    114115
    115116Player.prototype.AddPopulation = function(num)
    116117{
    117     this.popUsed += num;
     118    this.popUsed += num;
    118119};
    119120
    120121Player.prototype.SetPopulationBonuses = function(num)
     
    445446
    446447Player.prototype.UpdateSharedLos = function()
    447448{
    448     var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
     449    let cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
    449450    if (!cmpRangeManager)
    450451        return;
    451452
    452     var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager);
     453    let cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager);
    453454    if (!cmpPlayerManager)
    454455        return;
    455456
    456     var sharedLos = [];
    457     for (var i = 0; i < cmpPlayerManager.GetNumPlayers(); ++i)
    458         if (this.IsMutualAlly(i))
    459             sharedLos.push(i);
     457    let cmpTechnologyManager = Engine.QueryInterface(this.entity, IID_TechnologyManager);
     458    if (!cmpTechnologyManager)
     459        return;
    460460
    461     cmpRangeManager.SetSharedLos(this.playerID, sharedLos);
     461    if(!this.sharedLos) {
     462        cmpRangeManager.SetSharedLos(this.playerID, [this.playerID]);
     463        return;
     464    }
     465
     466    let sharedLosPlayers = [];
     467    for (let i = 0; i < cmpPlayerManager.GetNumPlayers(); ++i)
     468        if (this.IsMutualAlly(i) && this.sharedLos)
     469            sharedLosPlayers.push(i);
     470
     471    cmpRangeManager.SetSharedLos(this.playerID, sharedLosPlayers);
    462472};
    463473
    464474Player.prototype.GetFormations = function()
     
    788798    this.startingTechnologies = techs;
    789799};
    790800
    791 Engine.RegisterComponentType(IID_Player, "Player", Player);
     801Player.prototype.OnValueModification = function(msg)
     802{
     803    if (msg.component != "Player")
     804        return;
     805
     806    let oldSharedLos = this.sharedLos;
     807    this.sharedLos = ApplyValueModificationsToPlayer("Player/sharedLos", this.sharedLos, this.entity);
     808
     809    if (oldSharedLos != this.sharedLos)
     810        this.UpdateSharedLos();
     811};
     812
     813Engine.RegisterComponentType(IID_Player, "Player", Player);
     814 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