Ticket #1907: corral-v4.diff

File corral-v4.diff, 25.1 KB (added by mimo, 11 years ago)
  • binaries/data/mods/public/gui/session/session.xml

     
    997997                <object size="90 -2 126 34" name="attackAndArmorStats" type="image" sprite="stretched:session/icons/stances/defensive.png" tooltip="Attack and Armor" tooltip_style="sessionToolTip"/>
    998998
    999999                <!-- Resource carrying icon/counter -->
    1000                 <!-- Used also for number of gatherers/builders -->
     1000                <!-- Used also for number of gatherers/builders/corraled -->
    10011001                <object size="100%-98 -2 100%-28 34" type="text" name="resourceCarryingText" style="CarryingTextRight"/>
    10021002                <object size="100%-36 -2 100% 34" type="image" name="resourceCarryingIcon" tooltip_style="sessionToolTip"/>
    10031003            </object>
  • binaries/data/mods/public/gui/session/selection_details.js

     
    166166        getGUIObjectByName("resourceCarryingText").caption = entState.resourceSupply.gatherers.length + " / " + entState.resourceSupply.maxGatherers + "    ";
    167167        getGUIObjectByName("resourceCarryingIcon").tooltip = "Current/max gatherers";
    168168    }
     169    // And for number of corraled animals
     170    else if (entState.corral)
     171    {
     172        getGUIObjectByName("resourceCarryingIcon").hidden = false;
     173        getGUIObjectByName("resourceCarryingText").hidden = false;
     174        getGUIObjectByName("resourceCarryingIcon").sprite = "stretched:session/icons/corral.png";
     175        getGUIObjectByName("resourceCarryingText").caption = entState.corral.entities.length + " / " + entState.corral.capacity + "    ";
     176        getGUIObjectByName("resourceCarryingIcon").tooltip = "Current/max corraled animals";
     177        if (entState.corral.type)
     178        {
     179            getGUIObjectByName("resourceCarryingIcon").tooltip += "\n(income: " + entState.corral.rate + " " + entState.corral.type + "/s";
     180            if (entState.corral.bonusClass)
     181                getGUIObjectByName("resourceCarryingIcon").tooltip += " and reduced build time for " + entState.corral.bonusClass + " units)";
     182            else
     183                getGUIObjectByName("resourceCarryingIcon").tooltip += ")";
     184        }
     185    }
    169186    else
    170187    {
    171188        getGUIObjectByName("resourceCarryingIcon").hidden = true;
  • binaries/data/mods/public/gui/session/input.js

     
    248248            if (targetState.garrisonHolder.entities.length >= targetState.garrisonHolder.capacity)
    249249                tooltip = "[color=\"orange\"]" + tooltip + "[/color]";
    250250        }
     251        else if (targetState.corral)
     252        {
     253            data.command = "corral";
     254            data.target = target;
     255            cursor = "action-gather-milk";
     256            tooltip = "Current corraled: " + targetState.corral.entities.length
     257                + "/" + targetState.corral.capacity;
     258            if (targetState.corral.entities.length >= targetState.corral.capacity)
     259                tooltip = "[color=\"orange\"]" + tooltip + "[/color]";
     260        }
    251261        else if (targetState.resourceSupply)
    252262        {
    253263            var resourceType = targetState.resourceSupply.type;
     
    349359                }
    350360            }
    351361            break;
     362        case "corral":
     363            if (hasClass(entState, "Unit") && targetState.corral)
     364            {
     365                var tooltip = "Current corraled: " + targetState.corral.entities.length
     366                    + "/" + targetState.corral.capacity;
     367                if (targetState.corral.entities.length >= targetState.corral.capacity)
     368                    tooltip = "[color=\"orange\"]" + tooltip + "[/color]";
     369                return {"possible": Engine.GuiInterfaceCall("CanBeCorraled", {"entity": entState.id, "corral": target}), "tooltip": tooltip};
     370            }
     371            break;
    352372        case "setup-trade-route":
    353373            // If ground or sea trade possible
    354374            if (!targetState.foundation && ((entState.trader && hasClass(entState, "Organic") && (playerOwned || allyOwned) && hasClass(targetState, "Market")) ||
     
    539559            return {"type": "attack", "cursor": "action-attack", "target": target};
    540560        else if (getActionInfo("unset-rallypoint", target).possible)
    541561            return {"type": "unset-rallypoint"};
     562        else if ((actionInfo = getActionInfo("corral", target)).possible)
     563            return {"type": "corral", "cursor": "action-gather-milk", "tooltip": actionInfo.tooltip, "target": target};
    542564        else if (getActionInfo("move", target).possible)
    543565            return {"type": "move"};
    544566    }
     
    13971419        Engine.GuiInterfaceCall("PlaySound", { "name": "order_garrison", "entity": selection[0] });
    13981420        return true;
    13991421
     1422    case "corral":
     1423        Engine.PostNetworkCommand({"type": "corral", "entities": selection, "target": action.target, "queued": queued});
     1424        Engine.GuiInterfaceCall("PlaySound", { "name": "order_corral", "entity": selection[0] });
     1425        return true;
     1426
    14001427    case "set-rallypoint":
    14011428        var pos = undefined;
    14021429        // if there is a position set in the action then use this so that when setting a
  • binaries/data/mods/public/simulation/templates/gaia/fauna_goat.xml

     
    1717  <ResourceSupply>
    1818    <Amount>120</Amount>
    1919    <Type>food.meat</Type>
    20     <MaxGatherers>6</MaxGatherers>
     20    <MaxGatherers>6</MaxGatherers>
    2121  </ResourceSupply>
     22  <CorralSupply>
     23    <Type>food</Type>
     24    <Rate>0.4</Rate>
     25  </CorralSupply>
    2226  <VisualActor>
    2327    <Actor>fauna/goat.xml</Actor>
    2428  </VisualActor>
  • binaries/data/mods/public/simulation/templates/gaia/fauna_pig.xml

     
    55    <SpecificName>Pig</SpecificName>
    66    <Icon>gaia/fauna_pig.png</Icon>
    77  </Identity>
     8  <CorralSupply>
     9    <Type>food</Type>
     10    <Rate>0.4</Rate>
     11  </CorralSupply>
    812  <Position>
    913    <Anchor>pitch</Anchor>
    1014  </Position>
  • binaries/data/mods/public/simulation/templates/gaia/fauna_sheep.xml

     
    1212    <Classes datatype="tokens">Domestic</Classes>
    1313    <Icon>gaia/fauna_sheep.png</Icon>
    1414  </Identity>
     15  <CorralSupply>
     16    <Type>food</Type>
     17    <Rate>0.4</Rate>
     18  </CorralSupply>
    1519  <Position>
    1620    <Anchor>pitch</Anchor>
    1721  </Position>
  • binaries/data/mods/public/simulation/templates/gaia/fauna_horse.xml

     
    1818  <ResourceSupply>
    1919    <Amount>200</Amount>
    2020  </ResourceSupply>
     21  <CorralSupply>
     22    <Type>metal</Type>
     23    <Rate>0.1</Rate>
     24    <BonusClass>Cavalry</BonusClass>
     25  </CorralSupply>
    2126  <Sound>
    2227    <SoundGroups>
    2328      <select>actor/fauna/animal/horse_select.xml</select>
  • binaries/data/mods/public/simulation/templates/template_structure_resource_corral.xml

     
    1010    <Square width="12.0" depth="22.0"/>
    1111    <Height>5.0</Height>
    1212  </Footprint>
    13   <GarrisonHolder>
    14     <Max>10</Max>
    15     <EjectHealth>0.1</EjectHealth>
    16     <EjectEntitiesOnDestroy>true</EjectEntitiesOnDestroy>
    17     <List datatype="tokens">Animal</List>
    18     <BuffHeal>1</BuffHeal>
    19     <LoadingRange>2</LoadingRange>
    20   </GarrisonHolder>
     13  <Corral>
     14    <MaxCapacity>10</MaxCapacity>
     15    <Range>4</Range>
     16  </Corral>
    2117  <Health>
    2218    <Max>500</Max>
    2319    <SpawnEntityOnDeath>rubble/rubble_2x4</SpawnEntityOnDeath>
  • binaries/data/mods/public/simulation/helpers/Commands.js

     
    319319        }
    320320        break;
    321321
     322    case "corral":
     323        GetFormationUnitAIs(entities, player).forEach(function(cmpUnitAI) {
     324            cmpUnitAI.SetCorraled(cmd.target, cmd.queued);
     325        });
     326        break;
     327
    322328    case "stop":
    323329        GetFormationUnitAIs(entities, player).forEach(function(cmpUnitAI) {
    324330            cmpUnitAI.Stop(cmd.queued);
  • binaries/data/mods/public/simulation/helpers/RallyPointCommands.js

     
    6060                "queued": true
    6161            });
    6262            break;
     63        case "corral":
     64            ret.push( {
     65                "type": "corral",
     66                "entities": spawnedEnts,
     67                "target": data[i].target,
     68                "queued": true
     69            });
     70            break;
    6371        case "trade":
    6472            ret.push( {
    6573                "type": "setup-trade-route",
  • binaries/data/mods/public/simulation/components/UnitAI.js

     
    620620        }
    621621    },
    622622
     623    "Order.Corral": function(msg) {
     624        var cmpCorral = Engine.QueryInterface(msg.data.target, IID_Corral);
     625        if (!cmpCorral)
     626        {
     627            this.FinishOrder();
     628            return;
     629        }
     630
     631        var range = cmpCorral.GetRange();
     632        if (this.MoveToTargetRangeExplicit(this.order.data.target, 0, range))
     633        {
     634            this.SetNextState("ANIMAL.CORRAL.APPROACHING");
     635        }
     636        else
     637        {
     638            this.StopMoving();
     639            this.SetNextState("ANIMAL.CORRAL.CORRALED");
     640        }
     641    },
     642
    623643    "Order.Cheering": function(msg) {
    624644        this.SetNextState("INDIVIDUAL.CHEERING");
    625645    },
     
    905925            this.SetNextStateAlwaysEntering("MEMBER");
    906926        },
    907927
     928        "Order.Corral": function(msg) {
     929            var cmpFormation = Engine.QueryInterface(this.entity, IID_Formation);
     930            cmpFormation.SetRearrange(false);
     931            cmpFormation.CallMemberFunction("SetCorraled", [msg.data.target, false]);
     932
     933            this.SetNextStateAlwaysEntering("MEMBER");
     934        },
     935
    908936        "IDLE": {
    909937        },
    910938
     
    23822410            this.SetNextState("FLEEING");
    23832411        },
    23842412
     2413
     2414        "Order.Corral": function(msg) {
     2415            var cmpCorral = Engine.QueryInterface(msg.data.target, IID_Corral);
     2416            if (!cmpCorral)
     2417            {
     2418                this.FinishOrder();
     2419                return;
     2420            }
     2421
     2422            var range = cmpCorral.GetRange();
     2423            if (this.MoveToTargetRangeExplicit(this.order.data.target, 0, range))
     2424            {
     2425                this.SetNextState("ANIMAL.CORRAL.APPROACHING");
     2426            }
     2427            else
     2428            {
     2429                this.StopMoving();
     2430                this.SetNextState("ANIMAL.CORRAL.CORRALED");
     2431            }
     2432        },
     2433
    23852434        "IDLE": {
    23862435            // (We need an IDLE state so that FinishOrder works)
    23872436
     
    23922441            },
    23932442        },
    23942443
     2444        'CORRAL': {
     2445            'APPROACHING': {
     2446                "MoveCompleted": function() {
     2447                    var cmpCorral = Engine.QueryInterface(this.order.data.target, IID_Corral);
     2448                    if (cmpCorral)
     2449                    {
     2450                        var range = cmpCorral.GetRange();
     2451                        var cmpUnitMotion = Engine.QueryInterface(this.entity, IID_UnitMotion);
     2452                        if (cmpUnitMotion.IsInTargetRange(this.order.data.target, 0, range))
     2453                        {
     2454                            this.SetNextState("ANIMAL.CORRAL.CORRALED");
     2455                            return;
     2456                        }                       
     2457                    }
     2458                    this.FinishOrder();
     2459                },
     2460            },
     2461
     2462            'CORRALED': {
     2463                "enter": function() {
     2464                    this.corral = this.order.data.target;
     2465                    var cmpCorral = Engine.QueryInterface(this.corral, IID_Corral);
     2466                    if (!cmpCorral || !cmpCorral.AddCorraled(this.entity))
     2467                    {
     2468                        this.SetNextState("ROAMING");
     2469                        return true;
     2470                    }
     2471                    this.SelectAnimation("feeding");
     2472                    return false;
     2473                },
     2474
     2475                "Order.UnsetCorraled": function() {
     2476                    this.FinishOrder();
     2477                },
     2478
     2479                "leave": function() {
     2480                    if (this.corral)
     2481                    {
     2482                        var cmpCorral = Engine.QueryInterface(this.corral, IID_Corral);
     2483                        if (cmpCorral)
     2484                            cmpCorral.RemoveCorraled(this.entity);
     2485                        delete this.corral;
     2486                    }
     2487                },
     2488            },
     2489        },
     2490
    23952491        "ROAMING": {
    23962492            "enter": function() {
    23972493                // Walk in a random direction
     
    37813877        case "ReturnResource":
    37823878        case "Repair":
    37833879        case "Garrison":
     3880        case "Corral":
    37843881            // Find the target unit's position
    37853882            var cmpTargetPosition = Engine.QueryInterface(order.data.target, IID_Position);
    37863883            if (!cmpTargetPosition || !cmpTargetPosition.IsInWorld())
     
    45214618
    45224619//// Animal specific functions ////
    45234620
     4621/**
     4622 * Adds setcorraled order to the queue, forced by the player.
     4623 */
     4624UnitAI.prototype.SetCorraled = function(target, queued)
     4625{
     4626    var cmpCorral = Engine.QueryInterface(target, IID_Corral);
     4627    if (!cmpCorral || !cmpCorral.CanBeCorraled(this.entity))
     4628    {
     4629        this.WalkToTarget(target, queued);
     4630        return;
     4631    }
     4632    this.AddOrder("Corral", { "target": target, "force": true }, queued);
     4633};
     4634
     4635/**
     4636 * Adds unsetcorraled order to the queue.
     4637 */
     4638UnitAI.prototype.UnsetCorraled = function()
     4639{
     4640    if (this.corral)
     4641        this.AddOrder("UnsetCorraled", null, false);
     4642};
     4643
    45244644UnitAI.prototype.MoveRandomly = function(distance)
    45254645{
    45264646    // We want to walk in a random direction, but avoid getting stuck
  • binaries/data/mods/public/simulation/components/Player.js

     
    3434    this.cheatsEnabled = false;
    3535    this.cheatTimeMultiplier = 1;
    3636    this.heroes = [];
     37    this.corralBonuses = []; // list of Bonuses given by the corraled animals
    3738};
    3839
    3940Player.prototype.SetPlayerID = function(id)
     
    602603        cmpGUIInterface.PushNotification(notification);
    603604};
    604605
     606Player.prototype.UpdateCorralBonus = function(bonusClass, increment)
     607{
     608    for (var i=0; i<this.corralBonuses.length; ++i)
     609    {
     610        if (this.corralBonuses[i].bonusClass != bonusClass)
     611            continue;
     612        this.corralBonuses[i].count += increment;
     613        if (this.corralBonuses[i].count <= 0)
     614            this.corralBonuses.splice(i, 1);
     615        return;
     616    }
     617    // new bonusClass
     618    this.corralBonuses.push({"bonusClass": bonusClass, "count": 1});
     619};
     620
    605621Engine.RegisterComponentType(IID_Player, "Player", Player);
  • binaries/data/mods/public/simulation/components/GuiInterface.js

     
    291291    }
    292292
    293293    var cmpResourceSupply = Engine.QueryInterface(ent, IID_ResourceSupply);
    294     if (cmpResourceSupply)
     294    if (cmpResourceSupply)
     295    {
     296        ret.resourceSupply = {
     297            "isInfinite": cmpResourceSupply.IsInfinite(),
     298            "max": cmpResourceSupply.GetMaxAmount(),
     299            "amount": cmpResourceSupply.GetCurrentAmount(),
     300            "type": cmpResourceSupply.GetType(),
     301            "killBeforeGather": cmpResourceSupply.GetKillBeforeGather(),
     302            "maxGatherers": cmpResourceSupply.GetMaxGatherers(),
     303            "gatherers": cmpResourceSupply.GetGatherers()
     304        };
     305    }
     306
     307    var cmpCorral = Engine.QueryInterface(ent, IID_Corral);
     308    if (cmpCorral)
    295309    {
    296         ret.resourceSupply = {
    297             "isInfinite": cmpResourceSupply.IsInfinite(),
    298             "max": cmpResourceSupply.GetMaxAmount(),
    299             "amount": cmpResourceSupply.GetCurrentAmount(),
    300             "type": cmpResourceSupply.GetType(),
    301             "killBeforeGather": cmpResourceSupply.GetKillBeforeGather(),
    302             "maxGatherers": cmpResourceSupply.GetMaxGatherers(),
    303             "gatherers": cmpResourceSupply.GetGatherers()
    304         };
    305     }
     310        ret.corral = {
     311            "entities": cmpCorral.GetEntities(),
     312            "capacity": cmpCorral.GetCapacity(),
     313            "rate": cmpCorral.GetRate().toFixed(2),
     314            "type": cmpCorral.GetType(),
     315            "bonusClass": cmpCorral.GetBonusClass()
     316        };
     317    }
    306318
    307319    var cmpResourceGatherer = Engine.QueryInterface(ent, IID_ResourceGatherer);
    308320    if (cmpResourceGatherer)
     
    17161728    return cmpAttack.CanAttack(data.target);
    17171729};
    17181730
     1731GuiInterface.prototype.CanBeCorraled = function(player, data)
     1732{
     1733    var cmpCorral = Engine.QueryInterface(data.corral, IID_Corral);
     1734    if (!cmpCorral)
     1735        return false;
     1736
     1737    return cmpCorral.CanBeCorraled(data.entity);
     1738};
     1739
    17191740/*
    17201741 * Returns batch build time.
    17211742 */
     
    18011822    "GetTradingRouteGain": 1,
    18021823    "GetTradingDetails": 1,
    18031824    "CanAttack": 1,
     1825    "CanBeCorraled": 1,
    18041826    "GetBatchTime": 1,
    18051827
    18061828    "SetPathfinderDebugOverlay": 1,
  • binaries/data/mods/public/simulation/components/interfaces/Corral.js

     
     1Engine.RegisterInterface("Corral");
     2
     3// Message of the form { "increment": 1, "bonusClass": bonusClass },
     4// sent to the current entity whenever the corraled units change.
     5Engine.RegisterMessageType("CorraledUnitsChanged");
  • binaries/data/mods/public/simulation/components/interfaces/CorralSupply.js

     
     1Engine.RegisterInterface("CorralSupply");
  • binaries/data/mods/public/simulation/components/Corral.js

     
     1function Corral() {}
     2
     3Corral.prototype.Schema =
     4    "<element name='MaxCapacity' a:help='Maximum number of corraled units'>" +
     5        "<ref name='nonNegativeDecimal'/>" +
     6    "</element>" +
     7    "<element name='Range' a:help='Range distance of corraled units'>" +
     8        "<ref name='nonNegativeDecimal'/>" +
     9    "</element>";
     10
     11Corral.prototype.Init = function()
     12{
     13    this.entities = [];
     14    this.increment = 1;
     15    this.timer = undefined;
     16};
     17
     18Corral.prototype.GetCapacity = function()
     19{
     20    return +this.template.MaxCapacity;
     21};
     22
     23Corral.prototype.GetEntities = function()
     24{
     25    return this.entities;
     26};
     27
     28Corral.prototype.GetRange = function()
     29{
     30    return +this.template.Range;
     31};
     32
     33Corral.prototype.GetRate = function()
     34{
     35    var rate = 0;
     36    for each (var ent in this.entities)
     37    {
     38        var cmpCorralSupply = Engine.QueryInterface(ent, IID_CorralSupply);
     39        rate += cmpCorralSupply.GetRate();
     40    }
     41    rate = ApplyTechModificationsToEntity("Corral/Rate", rate, this.entity);
     42    return rate;
     43};
     44
     45Corral.prototype.GetType = function()
     46{
     47    var type = null;
     48    if (this.entities.length > 0)
     49    {
     50        var cmpCorralSupply = Engine.QueryInterface(this.entities[0], IID_CorralSupply);
     51        type = cmpCorralSupply.GetType();
     52    }
     53    return type;
     54};
     55
     56Corral.prototype.GetBonusClass = function()
     57{
     58    var bonus = null;
     59    if (this.entities.length > 0)
     60    {
     61        var cmpCorralSupply = Engine.QueryInterface(this.entities[0], IID_CorralSupply);
     62        bonus = cmpCorralSupply.GetBonusClass();
     63    }
     64    return bonus;
     65};
     66
     67/**
     68 * Returns true if the entity ent can be corraled inside,
     69 */
     70Corral.prototype.CanBeCorraled = function(ent)
     71{
     72    // Formation controllers should always respond to commands
     73    var cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI);
     74    if (cmpUnitAI && cmpUnitAI.IsFormationController())
     75        return true;
     76
     77    var cmpCorralSupply = Engine.QueryInterface(ent, IID_CorralSupply);
     78    if (!cmpCorralSupply)
     79        return false;
     80
     81    if (this.entities.length > 0)
     82    {
     83        // if there is already a corraled unit, it must have the same type
     84        if (cmpCorralSupply.GetType() != this.GetType())
     85            return false;
     86        // and the same bonusClass if any
     87        if (cmpCorralSupply.GetBonusClass() != this.GetBonusClass())
     88            return false;
     89    }
     90
     91    return true;
     92};
     93
     94Corral.prototype.AddCorraled = function(ent)
     95{
     96    if (!this.CanBeCorraled(ent))
     97        return false;
     98    if (this.entities.indexOf(ent) != -1 || this.entities.length >= this.GetCapacity())
     99        return false;
     100    this.entities.push(ent);
     101    var bonusClass = Engine.QueryInterface(ent, IID_CorralSupply).GetBonusClass();
     102    Engine.PostMessage(this.entity, MT_CorraledUnitsChanged, { "increment": 1, "bonusClass": bonusClass });
     103    return true;
     104};
     105
     106Corral.prototype.RemoveCorraled = function(ent)
     107{
     108    if (this.entities.indexOf(ent) == -1)
     109        return;
     110    this.entities.splice(this.entities.indexOf(ent), 1);
     111    var bonusClass = Engine.QueryInterface(ent, IID_CorralSupply).GetBonusClass();
     112    Engine.PostMessage(this.entity, MT_CorraledUnitsChanged, { "increment": -1, "bonusClass": bonusClass });
     113};
     114
     115Corral.prototype.Timeout = function(data)
     116{
     117    var type = this.GetType();
     118    var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
     119    if (type != null)
     120    {
     121        var cmpPlayer = QueryOwnerInterface(this.entity, IID_Player);
     122        cmpPlayer.AddResource(type, this.increment);
     123        var cmpStatisticsTracker = QueryOwnerInterface(this.entity, IID_StatisticsTracker);
     124        if (cmpStatisticsTracker)
     125            cmpStatisticsTracker.IncreaseResourceGatheredCounter(type, this.increment);
     126
     127        var rate = this.GetRate();
     128        this.increment = this.entities.length;
     129        this.timer = cmpTimer.SetTimeout(this.entity, IID_Corral, "Timeout", this.increment*1000/rate, {});
     130    }
     131    else
     132    {
     133        cmpTimer.CancelTimer(this.timer);
     134        this.timer = undefined;
     135    }
     136};
     137
     138Corral.prototype.OnCorraledUnitsChanged = function(msg)
     139{
     140    // first clear the cache for technology modifications (the total rate has changed)
     141    var cmpTechMan = QueryOwnerInterface(this.entity, IID_TechnologyManager);
     142    if (cmpTechMan)
     143        cmpTechMan.clearModificationCache(this.entity);
     144
     145    // update the timer state
     146    if (this.entities.length > 0 && !this.timer)
     147    {
     148        var rate = this.GetRate();
     149        this.increment = this.entities.length;
     150        var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
     151        this.timer = cmpTimer.SetTimeout(this.entity, IID_Corral, "Timeout", this.increment*1000/rate, {});
     152    }
     153    else if (this.entities.length == 0 && this.timer)
     154    {
     155        var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
     156        cmpTimer.CancelTimer(this.timer);
     157        this.timer = undefined;
     158    }
     159
     160    // update the list of bonuses
     161    if (msg.bonusClass)
     162    {
     163        var cmpPlayer = QueryOwnerInterface(this.entity, IID_Player);
     164        cmpPlayer.UpdateCorralBonus(msg.bonusClass, msg.increment);
     165    }
     166};
     167
     168Corral.prototype.OnDestroy = function()
     169{
     170    if (this.timer)
     171    {
     172        var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer);
     173        cmpTimer.CancelTimer(this.timer);
     174    }
     175
     176    for (var i = this.entities.length; i > 0; --i)
     177    {
     178        var cmpUnitAI = Engine.QueryInterface(this.entities[i-1], IID_UnitAI);
     179        if (cmpUnitAI)
     180            cmpUnitAI.UnsetCorraled();
     181    }
     182};
     183
     184Engine.RegisterComponentType(IID_Corral, "Corral", Corral);
  • binaries/data/mods/public/simulation/components/CorralSupply.js

     
     1function CorralSupply() {}
     2
     3CorralSupply.prototype.Schema =
     4    "<element name='Type' a:help='Production type when corraled'>" +
     5        "<choice>" +
     6            "<value>food</value>" +
     7            "<value>metal</value>" +
     8        "</choice>" +
     9    "</element>" +
     10    "<element name='Rate' a:help='Production rate per sec when corraled'>" +
     11        "<ref name='positiveDecimal'/>" +
     12    "</element>" +
     13    "<optional>" +
     14        "<element name='BonusClass' a:help='If an entity has this class, its time cost will be reduced'>" +
     15            "<text/>" +
     16        "</element>" +
     17    "</optional>";
     18
     19CorralSupply.prototype.Init = function()
     20{
     21};
     22
     23CorralSupply.prototype.GetRate = function()
     24{
     25    return +(this.template.Rate);
     26};
     27
     28CorralSupply.prototype.GetType = function()
     29{
     30    return this.template.Type;
     31};
     32
     33CorralSupply.prototype.GetBonusClass = function()
     34{
     35    return (this.template.BonusClass || "");
     36};
     37
     38Engine.RegisterComponentType(IID_CorralSupply, "CorralSupply", CorralSupply);
  • binaries/data/mods/public/art/textures/ui/session/icons/corral.png

    Impossible d'afficher : fichier considéré comme binaire.
    svn:mime-type = application/octet-stream