-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a double laser projectile effect.
This effect adds an identical lazer ouput offset from the original laser. It also makes some modifications to how the firing mechanism and effects dispatch is handled, to make it easier to offload effect mechanism management to each effect.
- Loading branch information
Showing
5 changed files
with
58 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
class_name EffectDoubleLaser | ||
extends ProjectileEffect | ||
|
||
var Projectile : PackedScene = preload("res://units/projectile.tscn") | ||
@export var laser_offset = Vector2(0, -50) | ||
const is_double_laser = true | ||
|
||
func check_not_double_laser(effect: ProjectileEffect) -> bool: | ||
# TODO:: Filter on type? This implementation is Bad | ||
if "is_double_laser" in effect: | ||
return not effect.is_double_laser | ||
return true | ||
|
||
func modify_creation(owner: Node, projectile_effects: Array[ProjectileEffect], transform: Transform2D): | ||
var p = Projectile.instantiate() | ||
# TODO:: Stacking double-lasers? would mean we only want to filter 1 out of this list. | ||
var non_recursive_effects = projectile_effects.filter(check_not_double_laser) | ||
var doubled_transform = transform | ||
# TODO:: Do we want to offset the laser, or do we want to angle out of the same point of origin? | ||
doubled_transform.origin += laser_offset | ||
p.spawn(owner, non_recursive_effects, doubled_transform) | ||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready(): | ||
Projectile = load("res://units/projectile.tscn") | ||
# Called when the node enters the scene tree for the first time. | ||
|
||
# Called every frame. 'delta' is the elapsed time since the previous frame. | ||
func _process(delta): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[gd_scene load_steps=2 format=3 uid="uid://dgp68vbl25onx"] | ||
|
||
[ext_resource type="Script" path="res://projectiles/double_laser.gd" id="1_wqupk"] | ||
|
||
[node name="DoubleLaser" type="Node"] | ||
script = ExtResource("1_wqupk") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters