|
8 | 8 | "name": "BoidsMovement", |
9 | 9 | "previewIconUrl": "https://resources.gdevelop-app.com/assets/Icons/Glyphster Pack/Master/SVG/Restaurant/Restaurant_restaurant_seafood_animal_fish.svg", |
10 | 10 | "shortDescription": "Simulates flocks movement.", |
11 | | - "version": "0.1.5", |
12 | | - "description": "Simulates swarms or flocks movement following the separation, alignment, cohesion principles. The flock can be attracted to a location or avoid some obstacles.\n\nThe [Fish School example](https://editor.gdevelop.io/?project=example://fish-school) shows how properties impact on the movement.", |
13 | | - |
| 11 | + "version": "0.1.6", |
| 12 | + "description": [ |
| 13 | + "Simulates swarms or flocks movement following the separation, alignment, cohesion principles. The flock can be attracted to a location or avoid some obstacles.", |
| 14 | + "", |
| 15 | + "The [Fish School example](https://editor.gdevelop.io/?project=example://fish-school) shows how properties impact on the movement." |
| 16 | + ], |
14 | 17 | "origin": { |
15 | 18 | "identifier": "BoidsMovement", |
16 | 19 | "name": "gdevelop-extension-store" |
|
211 | 214 | " * @parameter {gdjs.RuntimeBehavior} behavior", |
212 | 215 | " */", |
213 | 216 | " function Boid(behavior) {", |
| 217 | + " /** @type {gdjs.RuntimeBehavior} */", |
214 | 218 | " this.behavior = behavior;", |
215 | 219 | " this.acceleration = new gdjs.__boidsExtension.Vector(0, 0);", |
216 | 220 | " this.velocity = new gdjs.__boidsExtension.Vector(gdjs.randomFloatInRange(-1, 1), gdjs.randomFloatInRange(-1, 1));", |
|
280 | 284 | " */", |
281 | 285 | " Boid.prototype.move = function () {", |
282 | 286 | " const object = this.behavior.owner;", |
283 | | - " const timeDelta = object.getElapsedTime(runtimeScene) / 1000;", |
| 287 | + " const timeDelta = object.getElapsedTime(object.getInstanceContainer()) / 1000;", |
284 | 288 | " this.acceleration.multiply(timeDelta);", |
285 | 289 | "", |
286 | 290 | " const previousVelocityX = this.velocity.x;", |
|
317 | 321 | " * @return {Vector} separation direction", |
318 | 322 | " */", |
319 | 323 | " Boid.prototype.separate = function () {", |
320 | | - " /** @type {BoidsManager} */", |
| 324 | + " const runtimeScene = this.behavior.owner.getInstanceContainer();", |
| 325 | + " /** @type {gdjs.__boidsExtension.BoidsManager} */", |
321 | 326 | " const manager = runtimeScene.__boidsExtension.boidsManager;", |
322 | 327 | " const separationRadius = this.behavior.SeparationRadius();", |
323 | 328 | " this.separationDirection.set(0, 0);", |
|
347 | 352 | " * @return {Vector} alignment direction", |
348 | 353 | " */", |
349 | 354 | " Boid.prototype.align = function () {", |
350 | | - " /** @type {BoidsManager} */", |
| 355 | + " const runtimeScene = this.behavior.owner.getInstanceContainer();", |
| 356 | + " /** @type {gdjs.__boidsExtension.BoidsManager} */", |
351 | 357 | " const manager = runtimeScene.__boidsExtension.boidsManager;", |
352 | 358 | " const alignmentRadius = this.behavior.AlignmentRadius();", |
353 | 359 | " this.alignmentDirection.set(0, 0);", |
|
371 | 377 | " * @return {Vector} cohesion direction", |
372 | 378 | " */", |
373 | 379 | " Boid.prototype.cohesion = function () {", |
374 | | - " /** @type {BoidsManager} */", |
| 380 | + " const runtimeScene = this.behavior.owner.getInstanceContainer();", |
| 381 | + " /** @type {gdjs.__boidsExtension.BoidsManager} */", |
375 | 382 | " const manager = runtimeScene.__boidsExtension.boidsManager;", |
376 | 383 | " const cohesionRadius = this.behavior.CohesionRadius();", |
377 | 384 | " let count = 0;", |
|
412 | 419 | " */", |
413 | 420 | " function BoidsManager() {", |
414 | 421 | " /**", |
415 | | - " * @type {Map<string, Boid>}", |
| 422 | + " * @type {Map<string, gdjs.__boidsExtension.Boid>}", |
416 | 423 | " */", |
417 | 424 | " this.boids = new Map();", |
418 | 425 | " this.boidsRBush = new rbush();", |
|
0 commit comments