51 lines
1.1 KiB
GDScript
51 lines
1.1 KiB
GDScript
extends Entity
|
|
class_name GenericProjectile
|
|
|
|
export var BULLET_SPEED: float = 1
|
|
export var BULLET_DAMAGE: float = 15
|
|
|
|
export var LIFETIME: float = 0
|
|
var _timer = 0
|
|
|
|
func _init():
|
|
gravity_scale = 0
|
|
|
|
enum WeaponProperties {
|
|
HOMING = 0x00000001,
|
|
BOUNCE = 0x00000002,
|
|
PROXIMITY = 0x00000004,
|
|
AREA_HURT = 0x00000008,
|
|
TRIGGER_OBJECT = 0x00000010,
|
|
TRIGGER_GROUND = 0x00000020,
|
|
TRIGGER_TIMEOUT = 0x00000040,
|
|
EXPLODE = 0x00000080,
|
|
DO_ORIENTATION = 0x00000100,
|
|
COLLIDE_GROUND = 0x00000200,
|
|
GROUND_RIPPLE = 0x00000400,
|
|
DEFLECTABLE = 0x00000800,
|
|
SHOOTABLE = 0x00001000,
|
|
FIRST_FIRE_DELAY = 0x00002000,
|
|
FLARE = 0x00004000,
|
|
INCENDIARY = 0x00008000,
|
|
EMP = 0x00010000,
|
|
}
|
|
|
|
var from: Transform
|
|
var to: Vector3 = Vector3.ZERO
|
|
export(int, FLAGS) var properties
|
|
|
|
func _physics_process(delta):
|
|
if LIFETIME != 0:
|
|
_timer += delta
|
|
if _timer >= LIFETIME:
|
|
queue_free()
|
|
|
|
func create(_from: Transform, _to: Vector3, exclude_collisions: Array):
|
|
from = _from
|
|
to = _to
|
|
global_transform = from
|
|
|
|
for object in exclude_collisions:
|
|
add_collision_exception_with(object)
|
|
add_central_force((to - from.origin).normalized() * BULLET_SPEED)
|