Timestamp:
Apr 16, 2021, 9:02:58 AM (3 years ago)
Author:
Freagarach
Message:

Use a map for the weighted list.

Less object creations at addition time, more intuitive handling.

Differential revision: https://code.wildfiregames.com/D3854
Comments by: @Stan, @wraitii

File:
1 edited

Legend:

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

    r25123 r25276  
    342342    while (firedArrows < arrowsToFire && targets.length())
    343343    {
    344         let selectedIndex = targets.randomIndex();
    345         let selectedTarget = targets.itemAt(selectedIndex);
     344        let selectedTarget = targets.randomItem();
    346345
    347346        let targetCmpPosition = Engine.QueryInterface(selectedTarget, IID_Position);
     
    365364
    366365        // Could not attack target, try a different target.
    367         targets.removeAt(selectedIndex);
     366        targets.remove);
    368367    }
    369368
Note: See TracChangeset for help on using the changeset viewer.