open-fpsz/entities/components/projectile_spawner.gd
2024-05-12 17:18:09 -04:00

32 lines
1 KiB
GDScript

# This file is part of open-fpsz.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
class_name ProjectileSpawner extends Node3D
@export_category("Projectile")
@export var PROJECTILE : PackedScene
@export_range(0., 1., .01) var inheritance : float = .5 # ratio
func new_projectile(
projectile_type : Object,
owner_velocity : Vector3,
shooter : MatchParticipant
) -> Node3D:
return projectile_type.new_projectile(
self,
owner_velocity * inheritance,
shooter,
PROJECTILE
)