This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Changeset 10015 for ps


Ignore:
Timestamp:
08/16/11 06:44:15 (13 years ago)
Author:
ben
Message:

Moves build limits counter to BuildLimits component, to avoid some weirdness with BuildRestrictions for preview entities (caused some warnings in Atlas).

Location:
ps/trunk/binaries/data/mods/public/simulation/components
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/binaries/data/mods/public/simulation/components/BuildLimits.js

    r9970 r10015  
    7777        if (this.count[category] >= this.count["CivilCentre"] * this.limit[category].LimitPerCivCentre)
    7878        {
    79             var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager);
    8079            var cmpPlayer = Engine.QueryInterface(this.entity, IID_Player);
    8180            var notification = {"player": cmpPlayer.GetPlayerID(), "message": category+" build limit of "+this.limit[category].LimitPerCivCentre+" per civil centre reached"};
     
    8887    else if (this.count[category] >= this.limit[category])
    8988    {
    90         var cmpPlayerManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager);
    91         var cmpPlayer = Engine.QueryInterface(this.entity, IID_Player);
     89        var cmpPlayer = Engine.QueryInterface(this.entity, IID_Player);
    9290        var notification = {"player": cmpPlayer.GetPlayerID(), "message": category+" build limit of "+this.limit[category]+ " reached"};
    9391        var cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface);
     
    10098};
    10199
     100BuildLimits.prototype.OnGlobalOwnershipChanged = function(msg)
     101{
     102    // This automatically updates build counts
     103    var cmpBuildRestrictions = Engine.QueryInterface(msg.entity, IID_BuildRestrictions);
     104    if (cmpBuildRestrictions)
     105    {
     106        var playerID = (Engine.QueryInterface(this.entity, IID_Player)).GetPlayerID();
     107        if (msg.from == playerID)
     108        {
     109            this.DecrementCount(cmpBuildRestrictions.GetCategory());
     110        }
     111        if (msg.to == playerID)
     112        {
     113            this.IncrementCount(cmpBuildRestrictions.GetCategory());
     114        }
     115    }
     116};
     117
    102118Engine.RegisterComponentType(IID_BuildLimits, "BuildLimits", BuildLimits);
  • ps/trunk/binaries/data/mods/public/simulation/components/BuildRestrictions.js

    r9991 r10015  
    7272};
    7373
    74 BuildRestrictions.prototype.OnOwnershipChanged = function(msg)
    75 {
    76     // This automatically updates building counts
    77     if (this.template.Category)
    78     {
    79         if (msg.from != -1)
    80         {
    81             var fromPlayerBuildLimits = QueryPlayerIDInterface(msg.from, IID_BuildLimits);
    82             fromPlayerBuildLimits.DecrementCount(this.template.Category);
    83         }
    84         if (msg.to != -1)
    85         {
    86             var toPlayerBuildLimits = QueryPlayerIDInterface(msg.to, IID_BuildLimits);
    87             toPlayerBuildLimits.IncrementCount(this.template.Category);
    88         }
    89     }
    90 };
    91 
    9274BuildRestrictions.prototype.CheckPlacement = function(player)
    9375{
Note: See TracChangeset for help on using the changeset viewer.