generated from MechanicalFlower/godot-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: allowing to define multiple powers
- Loading branch information
1 parent
b5fc686
commit ef304bd
Showing
15 changed files
with
112 additions
and
87 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
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
const PROPS := 0 | ||
const CONNECTION_AREAS := 1 | ||
const MARBLES := 2 | ||
const BOOSTS := 3 | ||
const POWERS := 3 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
@tool | ||
extends Node3D | ||
|
||
enum PowerType { BOOST } | ||
|
||
const Group := preload("res://scripts/constants/groups.gd") | ||
const CollisionLayers := preload("res://scripts/constants/collision_layers.gd") | ||
|
||
@export var active: bool: | ||
set = toggle | ||
|
||
@export var type: PowerType: | ||
set = set_type | ||
|
||
@onready var area: Area3D = get_node(^"Area3D") | ||
@onready var audio: AudioStreamPlayer3D = get_node(^"AudioStreamPlayer3D") | ||
@onready var mesh: MeshInstance3D = get_node(^"MeshInstance3D") | ||
|
||
|
||
func _ready(): | ||
toggle(false) | ||
|
||
area.collision_layer = 1 << CollisionLayers.POWERS | ||
area.collision_mask = 1 << CollisionLayers.MARBLES | ||
|
||
set_type(type) | ||
|
||
|
||
func toggle(val) -> void: | ||
active = val | ||
set_visible(val) | ||
area.set_monitoring(val) | ||
|
||
|
||
func set_type(val) -> void: | ||
type = val | ||
|
||
if mesh: | ||
# Change the color accordingly to the type of the power | ||
match type: | ||
PowerType.BOOST: | ||
var material: ShaderMaterial = mesh.get_surface_override_material(0) | ||
material.set_shader_parameter("_shield_color", Color.BLUE) | ||
|
||
|
||
func _on_area_3d_body_entered(body): | ||
if body.is_in_group(Group.MARBLES): | ||
match type: | ||
PowerType.BOOST: | ||
body.linear_velocity *= 2 | ||
audio.play() |
Oops, something went wrong.