26 lines
733 B
GDScript
26 lines
733 B
GDScript
extends Node
|
|
|
|
@export var CursorBullet: PackedScene
|
|
@export var max_ammo = 10
|
|
var ammo = 10
|
|
|
|
func activate(world, activator):
|
|
var target: Vector2 = activator.get_target_pos()
|
|
var bullet = CursorBullet.instantiate()
|
|
world.add_child(bullet)
|
|
bullet.position = activator.position
|
|
bullet.look_at(target)
|
|
if activator.get_collision_layer_bit(1): # player object
|
|
bullet.set_collision_layer_bit(1, false)
|
|
bullet.set_collision_layer_bit(2, true)
|
|
elif activator.get_collision_layer_bit(2): # enemy object
|
|
bullet.set_collision_layer_bit(1, true)
|
|
bullet.set_collision_layer_bit(2, false)
|
|
else:
|
|
assert(false, "who are you, activator?")
|
|
ammo -= 1
|
|
# TODO: handle ammo for player and virus
|
|
|
|
func discard(world, activator):
|
|
pass
|