Compare commits
	
		
			1 Commits
		
	
	
		
			main
			...
			VS-3/basic
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 992994670c | 
							
								
								
									
										39
									
								
								modules/weapons/Weapon.gd
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								modules/weapons/Weapon.gd
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,39 @@
 | 
				
			|||||||
 | 
					class_name Weapon extends Node
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					enum Type {
 | 
				
			||||||
 | 
					  MELEE,
 | 
				
			||||||
 | 
					  PROJECTILE,
 | 
				
			||||||
 | 
					  AOF, # area of effect
 | 
				
			||||||
 | 
					  RAY,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var effects : Callable
 | 
				
			||||||
 | 
					var durationInMilliseconds : int
 | 
				
			||||||
 | 
					var area: Area2D
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func onBodyEntered ():
 | 
				
			||||||
 | 
						print('onBodyEntered')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func onTimeEnd ():
 | 
				
			||||||
 | 
						print('onTimeEnd')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func _ready() -> void:
 | 
				
			||||||
 | 
						var children = self.get_children()
 | 
				
			||||||
 | 
						for i in children.size():
 | 
				
			||||||
 | 
							if (children[i] is Area2D):
 | 
				
			||||||
 | 
								area = children[i]
 | 
				
			||||||
 | 
						area.connect('body_entered',  onBodyEntered)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func _process(delta: float) -> void:
 | 
				
			||||||
 | 
						set_process(true)
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func _physics_process(delta: float) -> void:
 | 
				
			||||||
 | 
						if (durationInMilliseconds > 0):
 | 
				
			||||||
 | 
							durationInMilliseconds -= delta * 1000
 | 
				
			||||||
 | 
						if durationInMilliseconds <= 0:
 | 
				
			||||||
 | 
							durationInMilliseconds = 0  # Ensure duration doesn't go negative
 | 
				
			||||||
 | 
							set_process(false)
 | 
				
			||||||
 | 
						
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user