mirror of
https://github.com/klmp200/sarl-fireworks.git
synced 2024-11-25 02:24:28 +00:00
Modifying variable naiming and extracting hardcoded variables
This commit is contained in:
parent
822144a89b
commit
c23aa15d24
14
src/main/sarl/io/sarl/demos/fireworks/Configuration.sarl
Normal file
14
src/main/sarl/io/sarl/demos/fireworks/Configuration.sarl
Normal file
@ -0,0 +1,14 @@
|
||||
package io.sarl.demos.fireworks
|
||||
|
||||
|
||||
public class Configuration {
|
||||
|
||||
/**
|
||||
* Delay in miillisecond
|
||||
*/
|
||||
public static val RocketLifeCycleSchedulingRate : long = 30
|
||||
|
||||
public static val FireLifeCycleSchedulingRate : long = 30
|
||||
|
||||
|
||||
}
|
@ -7,6 +7,7 @@ import io.sarl.core.Initialize
|
||||
import io.sarl.core.Lifecycle
|
||||
import io.sarl.core.Logging
|
||||
import io.sarl.core.Schedules
|
||||
import io.sarl.demos.fireworks.Configuration
|
||||
import io.sarl.demos.fireworks.Positions
|
||||
import io.sarl.demos.fireworks.events.Exit
|
||||
import io.sarl.demos.fireworks.events.FireReady
|
||||
@ -62,7 +63,7 @@ agent Fire {
|
||||
}
|
||||
|
||||
on FireReady {
|
||||
move = atFixedDelay(30) [
|
||||
move = atFixedDelay(Configuration.FireLifeCycleSchedulingRate) [
|
||||
try {
|
||||
wake(new UpdateFirePosition);
|
||||
} catch (e : Exception) {
|
||||
|
@ -55,13 +55,13 @@ agent LaunchingArea {
|
||||
|
||||
on Initialize [!occurrence.parameters.empty] {
|
||||
var ctrl = occurrence.parameters.get(0) as FXMLViewerController
|
||||
var ^space = defaultContext.createSpace(OpenEventSpaceSpecification, UUID.randomUUID)
|
||||
ctrl.setGUISpace(^space)
|
||||
^space.register(asEventListener)
|
||||
var ispace = defaultContext.createSpace(OpenEventSpaceSpecification, UUID.randomUUID)
|
||||
ctrl.setGUISpace(ispace)
|
||||
ispace.register(asEventListener)
|
||||
|
||||
ctrl.listenAndDraw(grid)
|
||||
|
||||
info("Setup Area")
|
||||
info("Finishing initialization of Launching Area")
|
||||
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ agent LaunchingArea {
|
||||
}
|
||||
|
||||
on MemberJoined [occurrence.inInnerDefaultSpace && memberAgentCount == rocketsQuantity] {
|
||||
info("Area Ready")
|
||||
info("Area is Ready: All rockets are here")
|
||||
innerContext.defaultSpace.emit(new Launch)
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import io.sarl.core.Logging
|
||||
import io.sarl.core.MemberJoined
|
||||
import io.sarl.core.MemberLeft
|
||||
import io.sarl.core.Schedules
|
||||
import io.sarl.demos.fireworks.Configuration
|
||||
import io.sarl.demos.fireworks.Positions
|
||||
import io.sarl.demos.fireworks.events.Exit
|
||||
import io.sarl.demos.fireworks.events.Explode
|
||||
@ -77,7 +78,7 @@ agent Rocket {
|
||||
lifetime = rnd.nextInt(5) * 300 + 300
|
||||
id = UUID.randomUUID
|
||||
|
||||
move = atFixedDelay(30) [
|
||||
move = atFixedDelay(Configuration.RocketLifeCycleSchedulingRate) [
|
||||
try {
|
||||
wake(new UpdateRocketPosition);
|
||||
} catch (e : Exception) {
|
||||
|
Loading…
Reference in New Issue
Block a user