Ticket #2913: visibility-performance+958.patch

File visibility-performance+958.patch, 24.8 KB (added by Itms, 9 years ago)
  • binaries/data/mods/public/simulation/components/BuildingAI.js

     
    340340    if (cmpFogging && cmpFogging.IsMiraged(cmpOwnership.GetOwner()))
    341341        return true;
    342342
    343     if (cmpRangeManager.GetLosVisibility(target, cmpOwnership.GetOwner(), false) == "hidden")
     343    if (cmpRangeManager.GetLosVisibility(target, cmpOwnership.GetOwner()) == "hidden")
    344344        return false;
    345345
    346346    // Either visible directly, or visible in fog
  • binaries/data/mods/public/simulation/components/BuildRestrictions.js

     
    9595    if (!cmpPlayer.IsAI())
    9696    {
    9797        // Check whether it's in a visible or fogged region
    98         // tell GetLosVisibility to force RetainInFog because preview entities set this to false,
    99         // which would show them as hidden instead of fogged
    10098        var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
    10199        var cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership);
    102100        if (!cmpRangeManager || !cmpOwnership)
    103101            return result; // Fail
    104102
    105         var explored = (cmpRangeManager.GetLosVisibility(this.entity, cmpOwnership.GetOwner(), true) != "hidden");
     103        var explored = (cmpRangeManager.GetLosVisibility(this.entity, cmpOwnership.GetOwner()) != "hidden");
    106104        if (!explored)
    107105        {
    108106            result.message = markForTranslation("%(name)s cannot be built in unexplored area");
  • binaries/data/mods/public/simulation/components/Fogging.js

     
    160160    for (var player = 0; player < this.mirages.length; ++player)
    161161    {
    162162        var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
    163         if (cmpRangeManager.GetLosVisibility(this.mirages[player], player, false) == "hidden")
     163        if (cmpRangeManager.GetLosVisibility(this.mirages[player], player) == "hidden")
    164164        {
    165165            Engine.DestroyEntity(this.mirages[player]);
    166166            continue;
  • binaries/data/mods/public/simulation/components/GuiInterface.js

     
    381381    }
    382382
    383383    var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
    384     ret.visibility = cmpRangeManager.GetLosVisibility(ent, player, false);
     384    ret.visibility = cmpRangeManager.GetLosVisibility(ent, player);
    385385
    386386    return ret;
    387387};
     
    14331433        cmpOwnership.SetOwner(player);
    14341434       
    14351435        // Check whether it's in a visible or fogged region
    1436         //  tell GetLosVisibility to force RetainInFog because preview entities set this to false,
    1437         //  which would show them as hidden instead of fogged
    14381436        // TODO: should definitely reuse SetBuildingPlacementPreview, this is just straight up copy/pasta
    1439         var visible = (cmpRangeManager.GetLosVisibility(ent, player, true) != "hidden");
     1437        var visible = (cmpRangeManager.GetLosVisibility(ent, player) != "hidden");
    14401438        if (visible)
    14411439        {
    14421440            var cmpBuildRestrictions = Engine.QueryInterface(ent, IID_BuildRestrictions);
  • binaries/data/mods/public/simulation/components/UnitAI.js

     
    43974397    if (cmpFogging && cmpFogging.IsMiraged(cmpOwnership.GetOwner()))
    43984398        return true;
    43994399
    4400     if (cmpRangeManager.GetLosVisibility(target, cmpOwnership.GetOwner(), false) == "hidden")
     4400    if (cmpRangeManager.GetLosVisibility(target, cmpOwnership.GetOwner()) == "hidden")
    44014401        return false;
    44024402
    44034403    // Either visible directly, or visible in fog
  • binaries/data/mods/public/simulation/components/Visibility.js

     
    1010    "</element>" +
    1111    "<element name='AlwaysVisible'>" +
    1212        "<data type='boolean'/>" +
     13    "</element>" +
     14    "<element name='Preview'>" +
     15        "<data type='boolean'/>" +
    1316    "</element>";
    1417
    1518Visibility.prototype.Init = function()
    1619{
     20    this.retainInFog = this.template.RetainInFog == "true";
     21    this.alwaysVisible = this.template.AlwaysVisible == "true";
     22    this.preview = this.template.Preview == "true";
    1723
     24    this.activated = false;
     25
     26    if (this.preview)
     27        this.activated = true;
    1828};
    1929
    2030/**
    21  * This function is called for entities in explored territory.
    22  * isOutsideFog: true if we're in the vision range of a unit, false otherwise
    23  * forceRetainInFog: useful for previewed entities, see the RangeManager system component documentation
     31 * If this function returns true, the range manager will call the GetVisibility function
     32 * instead of computing the visibility.
    2433 */
    25 Visibility.prototype.GetLosVisibility = function(player, isOutsideFog, forceRetainInFog)
     34Visibility.prototype.IsActivated = function()
    2635{
    27     if (isOutsideFog)
    28     {
    29         var cmpMirage = Engine.QueryInterface(this.entity, IID_Mirage);
    30         if (cmpMirage)
    31             return VIS_HIDDEN;
     36    return this.activated;
     37};
    3238
    33         return VIS_VISIBLE;
    34     }
     39/**
     40 * This function is called if IsActivated returns true.
     41 * If so, the return value supersedes the visibility computed by the range manager.
     42 * isVisible: true if the entity is in the vision range of a unit, false otherwise
     43 * isExplored: true if the entity is in explored territory, false otherwise
     44 */
     45Visibility.prototype.GetVisibility = function(player, isVisible, isExplored)
     46{
     47    if (!this.activated)
     48        warn("The Visibility component was asked to provide a superseding visibility while not activated, this should not happen");
    3549
    36     // Fogged if the 'retain in fog' flag is set, and in a non-visible explored region
    37     if (!forceRetainInFog && !this.GetRetainInFog())
    38         return VIS_HIDDEN;
    39 
    40     var cmpMirage = Engine.QueryInterface(this.entity, IID_Mirage);
    41     if (cmpMirage && cmpMirage.GetPlayer() == player)
    42         return VIS_FOGGED;
    43 
    44     var cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership);
    45     if (!cmpOwnership)
    46         return VIS_FOGGED;
    47 
    48     if (cmpOwnership.GetOwner() == player)
     50    if (this.preview)
    4951    {
    50         var cmpFogging = Engine.QueryInterface(this.entity, IID_Fogging);
    51         if (!cmpFogging)
    52             return VIS_FOGGED;
     52        // For the owner only, mock the "RetainInFog" behaviour
    5353
    54         // Fogged entities must not disappear while the mirage is not ready
    55         if (!cmpFogging.IsMiraged(player))
    56             return VIS_FOGGED;
     54        let cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership);
     55        if (cmpOwnership && cmpOwnership.GetOwner() == player && isExplored)
     56            return isVisible ? VIS_VISIBLE : VIS_FOGGED;
    5757
    5858        return VIS_HIDDEN;
    5959    }
    6060
    61     // Fogged entities must not disappear while the mirage is not ready
    62     var cmpFogging = Engine.QueryInterface(this.entity, IID_Fogging);
    63     if (cmpFogging && cmpFogging.WasSeen(player) && !cmpFogging.IsMiraged(player))
    64         return VIS_FOGGED;
    65 
    66     return VIS_HIDDEN;
     61    return VIS_VISIBLE;
    6762};
    6863
    6964Visibility.prototype.GetRetainInFog = function()
    7065{
    71     return this.template.RetainInFog == "true";
     66    return this.retainInFog;
    7267};
    7368
    7469Visibility.prototype.GetAlwaysVisible = function()
    7570{
    76     return this.template.AlwaysVisible == "true";
     71    return this.alwaysVisible;
    7772};
    7873
    7974Engine.RegisterComponentType(IID_Visibility, "Visibility", Visibility);
  • binaries/data/mods/public/simulation/templates/special/actor.xml

     
    99  <Visibility>
    1010    <RetainInFog>true</RetainInFog>
    1111    <AlwaysVisible>false</AlwaysVisible>
     12    <Preview>false</Preview>
    1213  </Visibility>
    1314  <Vision>
    1415    <Range>0</Range>
  • binaries/data/mods/public/simulation/templates/template_gaia.xml

     
    2323  <Visibility>
    2424    <RetainInFog>true</RetainInFog>
    2525    <AlwaysVisible>false</AlwaysVisible>
     26    <Preview>false</Preview>
    2627  </Visibility>
    2728  <Vision>
    2829    <Range>0</Range>
  • binaries/data/mods/public/simulation/templates/template_rubble.xml

     
    1717  <Visibility>
    1818    <RetainInFog>true</RetainInFog>
    1919    <AlwaysVisible>false</AlwaysVisible>
     20    <Preview>false</Preview>
    2021  </Visibility>
    2122  <Vision>
    2223    <Range>0</Range>
  • binaries/data/mods/public/simulation/templates/template_structure.xml

     
    105105  <Visibility>
    106106    <RetainInFog>true</RetainInFog>
    107107    <AlwaysVisible>false</AlwaysVisible>
     108    <Preview>false</Preview>
    108109  </Visibility>
    109110  <Vision>
    110111    <Range>40</Range>
  • binaries/data/mods/public/simulation/templates/template_structure_gaia_settlement.xml

     
    2929  <Visibility>
    3030    <RetainInFog>true</RetainInFog>
    3131    <AlwaysVisible>false</AlwaysVisible>
     32    <Preview>false</Preview>
    3233  </Visibility>
    3334  <Vision>
    3435    <Range>0</Range>
  • binaries/data/mods/public/simulation/templates/template_unit.xml

     
    118118  <Visibility>
    119119    <RetainInFog>false</RetainInFog>
    120120    <AlwaysVisible>false</AlwaysVisible>
     121    <Preview>false</Preview>
    121122  </Visibility>
    122123  <Vision>
    123124    <Range>10</Range>
  • binaries/data/mods/public/simulation/templates/template_unit_fauna_decorative.xml

     
    4141    <Visibility>
    4242        <RetainInFog>true</RetainInFog>
    4343        <AlwaysVisible>false</AlwaysVisible>
     44        <Preview>false</Preview>
    4445    </Visibility>
    4546    <Vision>
    4647        <Range>0</Range>
  • source/graphics/GameView.cpp

     
    1 /* Copyright (C) 2014 Wildfire Games.
     1/* Copyright (C) 2015 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
    44 * 0 A.D. is free software: you can redistribute it and/or modify
     
    717717        CmpPtr<ICmpPosition> cmpPosition(*(m->Game->GetSimulation2()), m->FollowEntity);
    718718        CmpPtr<ICmpRangeManager> cmpRangeManager(*(m->Game->GetSimulation2()), SYSTEM_ENTITY);
    719719        if (cmpPosition && cmpPosition->IsInWorld() &&
    720             cmpRangeManager && cmpRangeManager->GetLosVisibility(m->FollowEntity, m->Game->GetPlayerID(), false) == ICmpRangeManager::VIS_VISIBLE)
     720            cmpRangeManager && cmpRangeManager->GetLosVisibility(m->FollowEntity, m->Game->GetPlayerID()) == ICmpRangeManager::VIS_VISIBLE)
    721721        {
    722722            // Get the most recent interpolated position
    723723            float frameOffset = m->Game->GetSimulation2()->GetLastFrameOffset();
  • source/ps/TemplateLoader.cpp

     
    388388            CParamNode::LoadXMLString(out, "<Entity><VisualActor><DisableShadows/></VisualActor></Entity>");
    389389
    390390        // Previews should always be visible in fog-of-war/etc
    391         CParamNode::LoadXMLString(out, "<Entity><Visibility><RetainInFog>false</RetainInFog><AlwaysVisible>true</AlwaysVisible></Visibility></Entity>");
     391        CParamNode::LoadXMLString(out, "<Entity><Visibility><RetainInFog>false</RetainInFog><AlwaysVisible>true</AlwaysVisible><Preview>true</Preview></Visibility></Entity>");
    392392    }
    393393
    394394    if (corpse)
     
    402402            CParamNode::LoadXMLString(out, "<Entity><VisualActor><SilhouetteDisplay>false</SilhouetteDisplay></VisualActor></Entity>");
    403403
    404404        // Corpses should remain visible in fog-of-war
    405         CParamNode::LoadXMLString(out, "<Entity><Visibility><RetainInFog>true</RetainInFog><AlwaysVisible>false</AlwaysVisible></Visibility></Entity>");
     405        CParamNode::LoadXMLString(out, "<Entity><Visibility><RetainInFog>true</RetainInFog><AlwaysVisible>false</AlwaysVisible><Preview>false</Preview></Visibility></Entity>");
    406406    }
    407407}
    408408
     
    437437
    438438    // Set the entity as mirage entity
    439439    CParamNode::LoadXMLString(out, "<Entity><Mirage/></Entity>");
    440     CParamNode::LoadXMLString(out, "<Entity><Visibility><RetainInFog>true</RetainInFog><AlwaysVisible>false</AlwaysVisible></Visibility></Entity>");
     440    CParamNode::LoadXMLString(out, "<Entity><Visibility><RetainInFog>true</RetainInFog><AlwaysVisible>false</AlwaysVisible><Preview>false</Preview></Visibility></Entity>");
    441441}
    442442
    443443void CTemplateLoader::CopyFoundationSubset(CParamNode& out, const CParamNode& in)
  • source/simulation2/components/CCmpRangeManager.cpp

     
    13861386            return CLosQuerier(GetSharedLosMask(player), m_LosState, m_TerrainVerticesPerSide);
    13871387    }
    13881388
    1389     ELosVisibility ComputeLosVisibility(CEntityHandle ent, player_id_t player, bool forceRetainInFog)
     1389    ELosVisibility ComputeLosVisibility(CEntityHandle ent, player_id_t player)
    13901390    {
    13911391        // Entities not with positions in the world are never visible
    13921392        if (ent.GetId() == INVALID_ENTITY)
     
    14131413                return VIS_VISIBLE;
    14141414        }
    14151415
    1416         // Visible if within a visible region
     1416        // Get visible regions
    14171417        CLosQuerier los(GetSharedLosMask(player), m_LosState, m_TerrainVerticesPerSide);
    14181418
     1419        // Ask the Visibility component about special situations
     1420        CmpPtr<ICmpVisibility> cmpVisibility(ent);
     1421        if (cmpVisibility && cmpVisibility->IsActivated())
     1422            return cmpVisibility->GetVisibility(player, los.IsVisible(i, j), los.IsExplored(i, j));
     1423
     1424        // Else, default behavior
     1425
     1426        if (los.IsVisible(i, j))
     1427            return VIS_VISIBLE;
     1428
    14191429        if (!los.IsExplored(i, j))
    14201430            return VIS_HIDDEN;
    14211431
    1422         // Try to ask the Visibility component of the entity, if any
    1423         CmpPtr<ICmpVisibility> cmpVisibility(ent);
    1424         if (cmpVisibility)
    1425             return cmpVisibility->GetLosVisibility(player, los.IsVisible(i, j), forceRetainInFog);
     1432        // Invisible if the 'retain in fog' flag is not set, and in a non-visible explored region
     1433        if (!(cmpVisibility && cmpVisibility->GetRetainInFog()))
     1434            return VIS_HIDDEN;
    14261435
    1427         // Default behaviour
    1428         if (los.IsVisible(i, j))
     1436        if (cmpMirage && cmpMirage->GetPlayer() == player)
     1437            return VIS_FOGGED;
     1438
     1439        CmpPtr<ICmpOwnership> cmpOwnership(ent);
     1440        if (!cmpOwnership)
    14291441            return VIS_VISIBLE;
    1430        
    1431         if (forceRetainInFog)
     1442
     1443        if (cmpOwnership->GetOwner() == player)
     1444        {
     1445            CmpPtr<ICmpFogging> cmpFogging(ent);
     1446            if (!cmpFogging)
     1447                return VIS_VISIBLE;
     1448
     1449            // Fogged entities must not disappear while the mirage is not ready
     1450            if (!cmpFogging->IsMiraged(player))
     1451                return VIS_FOGGED;
     1452
     1453            return VIS_HIDDEN;
     1454        }
     1455   
     1456        // Fogged entities must not disappear while the mirage is not ready
     1457        CmpPtr<ICmpFogging> cmpFogging(ent);
     1458        if (cmpFogging && cmpFogging->WasSeen(player) && !cmpFogging->IsMiraged(player))
    14321459            return VIS_FOGGED;
    1433        
     1460
    14341461        return VIS_HIDDEN;
    14351462    }
    14361463
    1437     ELosVisibility ComputeLosVisibility(entity_id_t ent, player_id_t player, bool forceRetainInFog)
     1464    ELosVisibility ComputeLosVisibility(entity_id_t ent, player_id_t player)
    14381465    {
    14391466        CEntityHandle handle = GetSimContext().GetComponentManager().LookupEntityHandle(ent);
    1440         return ComputeLosVisibility(handle, player, forceRetainInFog);
     1467        return ComputeLosVisibility(handle, player);
    14411468    }
    14421469
    1443     virtual ELosVisibility GetLosVisibility(CEntityHandle ent, player_id_t player, bool forceRetainInFog)
     1470    virtual ELosVisibility GetLosVisibility(CEntityHandle ent, player_id_t player)
    14441471    {
    14451472        entity_id_t entId = ent.GetId();
    14461473       
     
    14551482        i32 n = PosToLosTilesHelper(pos.X, pos.Y);
    14561483
    14571484        if (m_DirtyVisibility[n])
    1458             return ComputeLosVisibility(ent, player, forceRetainInFog);
     1485            return ComputeLosVisibility(ent, player);
    14591486
    14601487        if (std::find(m_ModifiedEntities.begin(), m_ModifiedEntities.end(), entId) != m_ModifiedEntities.end())
    1461             return ComputeLosVisibility(ent, player, forceRetainInFog);
     1488            return ComputeLosVisibility(ent, player);
    14621489
    14631490        EntityMap<EntityData>::iterator it = m_EntityData.find(entId);
    14641491        if (it == m_EntityData.end())
    1465             return ComputeLosVisibility(ent, player, forceRetainInFog);
     1492            return ComputeLosVisibility(ent, player);
    14661493
    14671494        return static_cast<ELosVisibility>(GetPlayerVisibility(it->second.visibilities, player));
    14681495    }
    14691496
    1470     virtual ELosVisibility GetLosVisibility(entity_id_t ent, player_id_t player, bool forceRetainInFog)
     1497    virtual ELosVisibility GetLosVisibility(entity_id_t ent, player_id_t player)
    14711498    {
    14721499        CEntityHandle handle = GetSimContext().GetComponentManager().LookupEntityHandle(ent);
    1473         return GetLosVisibility(handle, player, forceRetainInFog);
     1500        return GetLosVisibility(handle, player);
    14741501    }
    14751502
    14761503    i32 PosToLosTilesHelper(entity_pos_t x, entity_pos_t z)
     
    15491576        for (player_id_t player = 1; player < MAX_LOS_PLAYER_ID+1; ++player)
    15501577        {
    15511578            u8 oldVis = GetPlayerVisibility(itEnts->second.visibilities, player);
    1552             u8 newVis = ComputeLosVisibility(itEnts->first, player, false);
     1579            u8 newVis = ComputeLosVisibility(itEnts->first, player);
    15531580           
    15541581            oldVisibilities.push_back(oldVis);
    15551582            newVisibilities.push_back(newVis);
  • source/simulation2/components/ICmpRangeManager.cpp

     
    1 /* Copyright (C) 2014 Wildfire Games.
     1/* Copyright (C) 2015 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
    44 * 0 A.D. is free software: you can redistribute it and/or modify
     
    2121
    2222#include "simulation2/system/InterfaceScripted.h"
    2323
    24 std::string ICmpRangeManager::GetLosVisibility_wrapper(entity_id_t ent, int player, bool forceRetainInFog)
     24std::string ICmpRangeManager::GetLosVisibility_wrapper(entity_id_t ent, int player)
    2525{
    26     ELosVisibility visibility = GetLosVisibility(ent, player, forceRetainInFog);
     26    ELosVisibility visibility = GetLosVisibility(ent, player);
    2727    switch (visibility)
    2828    {
    2929    case VIS_HIDDEN: return "hidden";
     
    5151DEFINE_INTERFACE_METHOD_2("SetLosRevealAll", void, ICmpRangeManager, SetLosRevealAll, player_id_t, bool)
    5252DEFINE_INTERFACE_METHOD_1("GetLosRevealAll", bool, ICmpRangeManager, GetLosRevealAll, player_id_t)
    5353DEFINE_INTERFACE_METHOD_5("GetElevationAdaptedRange", entity_pos_t, ICmpRangeManager, GetElevationAdaptedRange, CFixedVector3D, CFixedVector3D, entity_pos_t, entity_pos_t, entity_pos_t)
    54 DEFINE_INTERFACE_METHOD_3("GetLosVisibility", std::string, ICmpRangeManager, GetLosVisibility_wrapper, entity_id_t, player_id_t, bool)
     54DEFINE_INTERFACE_METHOD_2("GetLosVisibility", std::string, ICmpRangeManager, GetLosVisibility_wrapper, entity_id_t, player_id_t)
    5555DEFINE_INTERFACE_METHOD_1("SetLosCircular", void, ICmpRangeManager, SetLosCircular, bool)
    5656DEFINE_INTERFACE_METHOD_0("GetLosCircular", bool, ICmpRangeManager, GetLosCircular)
    5757DEFINE_INTERFACE_METHOD_2("SetSharedLos", void, ICmpRangeManager, SetSharedLos, player_id_t, std::vector<player_id_t>)
  • source/simulation2/components/ICmpRangeManager.h

     
    1 /* Copyright (C) 2014 Wildfire Games.
     1/* Copyright (C) 2015 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
    44 * 0 A.D. is free software: you can redistribute it and/or modify
     
    319319     * Returns the visibility status of the given entity, with respect to the given player.
    320320     * Returns VIS_HIDDEN if the entity doesn't exist or is not in the world.
    321321     * This respects the GetLosRevealAll flag.
    322      * If forceRetainInFog is true, the visibility acts as if CCmpVision's RetainInFog flag were set.
    323      * TODO: This is a hack to allow preview entities in FoW to return fogged instead of hidden,
    324      *  see http://trac.wildfiregames.com/ticket/958
    325322     */
    326     virtual ELosVisibility GetLosVisibility(CEntityHandle ent, player_id_t player, bool forceRetainInFog = false) = 0;
    327     virtual ELosVisibility GetLosVisibility(entity_id_t ent, player_id_t player, bool forceRetainInFog = false) = 0;
     323    virtual ELosVisibility GetLosVisibility(CEntityHandle ent, player_id_t player) = 0;
     324    virtual ELosVisibility GetLosVisibility(entity_id_t ent, player_id_t player) = 0;
    328325
    329326
    330327    /**
     
    331328     * GetLosVisibility wrapped for script calls.
    332329     * Returns "hidden", "fogged" or "visible".
    333330     */
    334     std::string GetLosVisibility_wrapper(entity_id_t ent, player_id_t player, bool forceRetainInFog);
     331    std::string GetLosVisibility_wrapper(entity_id_t ent, player_id_t player);
    335332
    336333    /**
    337334     * Explore all tiles (but leave them in the FoW) for player p
  • source/simulation2/components/ICmpVisibility.cpp

     
    1 /* Copyright (C) 2014 Wildfire Games.
     1/* Copyright (C) 2015 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
    44 * 0 A.D. is free software: you can redistribute it and/or modify
     
    3030public:
    3131    DEFAULT_SCRIPT_WRAPPER(VisibilityScripted)
    3232
    33     virtual ICmpRangeManager::ELosVisibility GetLosVisibility(player_id_t player, bool isOutsideFog, bool forceRetainInFog)
     33    virtual bool IsActivated()
    3434    {
    35         int visibility = m_Script.Call<int, player_id_t, bool, bool>("GetLosVisibility", player, isOutsideFog, forceRetainInFog);
     35        return m_Script.Call<bool>("IsActivated");
     36    }
    3637
     38    virtual ICmpRangeManager::ELosVisibility GetVisibility(player_id_t player, bool isVisible, bool isExplored)
     39    {
     40        int visibility = m_Script.Call<int, player_id_t, bool, bool>("GetVisibility", player, isVisible, isExplored);
     41
    3742        switch (visibility)
    3843        {
    3944        case ICmpRangeManager::VIS_HIDDEN:
  • source/simulation2/components/ICmpVisibility.h

     
    1 /* Copyright (C) 2014 Wildfire Games.
     1/* Copyright (C) 2015 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
    44 * 0 A.D. is free software: you can redistribute it and/or modify
     
    2222
    2323#include "simulation2/components/ICmpRangeManager.h"
    2424
     25/**
     26 * The Visibility component is a scripted component that allows any part of the simulation to
     27 * influence the visibility of an entity.
     28 *
     29 * This component:
     30 * - Holds the template values RetainInFog and AlwaysVisible, used by the range manager to compute
     31 * the visibility of the entity;
     32 * - Can supersede the range manager if it is "activated". This is to avoid useless calls to the scripts.
     33 */
     34
    2535class ICmpVisibility : public IComponent
    2636{
    2737public:
    28     virtual ICmpRangeManager::ELosVisibility GetLosVisibility(player_id_t player, bool isOutsideFog, bool forceRetainInFog) = 0;
     38    virtual bool IsActivated() = 0;
    2939
     40    virtual ICmpRangeManager::ELosVisibility GetVisibility(player_id_t player, bool isVisible, bool isExplored) = 0;
     41
    3042    virtual bool GetRetainInFog() = 0;
    3143
    3244    virtual bool GetAlwaysVisible() = 0;