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