|
27 | 27 |
|
28 | 28 | type Vector = [number, number, number]; |
29 | 29 |
|
30 | | -declare class Unit { |
31 | | - getLevel(): number; |
| 30 | +declare function findUnits(this: void, center: Vector, radius: number): Unit[]; |
| 31 | +declare interface Unit { |
32 | 32 | isEnemy(other: Unit): boolean; |
33 | 33 | kill(): void; |
34 | | - FindUnitsInRadius(radius: number): Unit[]; |
35 | 34 | }</div> |
36 | 35 | <!-- prettier-ignore --> |
37 | 36 | <div class="example-item" id="ts-source"><b>// TS Source</b> |
38 | 37 |
|
39 | | -function onSpellStart(caster: Unit, targetLocation: Vector): void { |
40 | | - const units = FindUnitsInRadius(targetLocation, 500); |
| 38 | +function onAbilityCast(this: void, caster: Unit, targetLocation: Vector) { |
| 39 | + const units = findUnits(targetLocation, 500); |
41 | 40 | const enemies = units.filter(unit => caster.isEnemy(unit)); |
42 | 41 |
|
43 | 42 | for (const enemy of enemies) { |
|
48 | 47 | <!-- prettier-ignore --> |
49 | 48 | <div class="example-item" id="lua"><b>-- Lua Output</b> |
50 | 49 |
|
51 | | -function onSpellStart(caster, targetLocation) |
52 | | - local units = FindUnitsInRadius(targetLocation, 500); |
53 | | - local enemies = __TS__ArrayFilter(units, function(unit) return caster:isEnemy(unit) end); |
54 | | - for _, enemy in ipairs(enemies) do |
55 | | - do |
56 | | - enemy:kill(); |
57 | | - end |
| 50 | +function onAbilityCast(caster, targetLocation) |
| 51 | + local units = findUnits(targetLocation, 500) |
| 52 | + local enemies = __TS__ArrayFilter(units, function(____, unit) return caster:isEnemy(unit) end) |
| 53 | + for ____, enemy in ipairs(enemies) do |
| 54 | + enemy:kill() |
58 | 55 | end |
59 | 56 | end</div> |
60 | 57 | </div> |
|
0 commit comments