mirror of
https://codeberg.org/sunder/sunder.git
synced 2026-07-15 14:04:35 +00:00
first commit 🎉
This commit is contained in:
commit
6e724f67fe
805 changed files with 62098 additions and 0 deletions
44
scenes/entities/player/scripts/energy.gd
Normal file
44
scenes/entities/player/scripts/energy.gd
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
# This file is part of sunder.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
## This class defines an Energy component for entities.
|
||||
@icon("res://assets/icons/energy.svg")
|
||||
class_name Energy extends Node
|
||||
|
||||
## Emitted when [param value] is changed ([param value] > [param 0])
|
||||
signal changed(new_value:int)
|
||||
## Emitted when [param value] is exhausted ([param value] == [param 0])
|
||||
signal exhausted
|
||||
|
||||
## The maximum energy value
|
||||
@export var max_value:float = 100.
|
||||
|
||||
## The amount of energy left to consume
|
||||
@export var value:float = 100.:
|
||||
set(new_value):
|
||||
value = clampf(new_value, 0, max_value)
|
||||
if value > 0:
|
||||
changed.emit(value)
|
||||
else:
|
||||
exhausted.emit()
|
||||
|
||||
## Wether the energy [param value] should recharge over time based on [param charge_rate]
|
||||
@export var charging:bool = true
|
||||
|
||||
## The energy charge rate per second, expressed as a percentage of [param max_value]
|
||||
@export_range(0,100, 1., "suffix:%") var charge_rate:float = 10
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if charging:
|
||||
value += charge_rate / 100 * max_value * delta
|
||||
1
scenes/entities/player/scripts/energy.gd.uid
Normal file
1
scenes/entities/player/scripts/energy.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c0v6nfmjxp045
|
||||
38
scenes/entities/player/scripts/info.gd
Normal file
38
scenes/entities/player/scripts/info.gd
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
@tool
|
||||
class_name Profile extends Resource
|
||||
|
||||
@export var name: String
|
||||
|
||||
var _loadouts:Array[Loadout] = []:
|
||||
set(value):
|
||||
_loadouts = value
|
||||
_loadouts.resize(3)
|
||||
notify_property_list_changed()
|
||||
|
||||
func _init() -> void:
|
||||
_loadouts.resize(3)
|
||||
notify_property_list_changed()
|
||||
|
||||
func _get_property_list() -> Array:
|
||||
var properties := []
|
||||
for i in range(_loadouts.size()):
|
||||
properties.append({
|
||||
"name": "loadout_%d" % (i + 1),
|
||||
"type": TYPE_OBJECT,
|
||||
"hint": PROPERTY_HINT_RESOURCE_TYPE,
|
||||
"hint_string": "Loadout",
|
||||
})
|
||||
return properties
|
||||
|
||||
func _get(prop:StringName) -> Variant:
|
||||
if prop.begins_with("loadout_"):
|
||||
var index := prop.get_slice("_", 1).to_int() - 1
|
||||
return _loadouts[index]
|
||||
return null
|
||||
|
||||
func _set(prop:StringName, value:Variant) -> bool:
|
||||
if prop.begins_with("loadout_"):
|
||||
var index := prop.get_slice("_", 1).to_int() - 1
|
||||
_loadouts[index] = value
|
||||
return true
|
||||
return false
|
||||
1
scenes/entities/player/scripts/info.gd.uid
Normal file
1
scenes/entities/player/scripts/info.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cnvbn183o3bgc
|
||||
62
scenes/entities/player/scripts/jetpack.gd
Normal file
62
scenes/entities/player/scripts/jetpack.gd
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
# This file is part of sunder.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
class_name Jetpack extends Node3D
|
||||
|
||||
@export var input:InputSynchronizer
|
||||
@export var energy:Energy
|
||||
|
||||
## The [param energy.value] drain rate per second, as a percentage of [param energy.max_value]
|
||||
@export_range(0,100, 1., "suffix:%") var drain_rate:float = 30
|
||||
## The stutter threshold of [param energy.value] at which the jetpack needs to charge to be used again,
|
||||
## as a percentage of [param energy.max_value]
|
||||
@export_range(0,100, 1., "suffix:%") var stutter_treshold:float = 15
|
||||
## This property indicates wether the [Jetpack] is stuttering
|
||||
@export var stuttering:bool = false
|
||||
|
||||
@export_category("Thrust")
|
||||
# @NOTE: If a body want to accelerate upward on a high-gravity planet, say by 10 m/s²:
|
||||
# F = 80 * (19.6 + 10) = 80 * 29.6 = 2,368 N
|
||||
## The thrust vertical acceleration component, expressed in m/s²
|
||||
@export_range(0, 100, .01, "suffix:m/s²") var vertical_acceleration:float = 10
|
||||
# @NOTE: If a body want to accelerate horizontally, say by 15 m/s²:
|
||||
# F = 80 * 15 = 1200 N
|
||||
## The thrust horizontal acceleration component, expressed in m/s²
|
||||
@export_range(0, 100, .01, "suffix:m/s²") var horizontal_acceleration:float = 15
|
||||
|
||||
@export_category("Effects")
|
||||
## An array of [GPUParticles3D] children
|
||||
@onready var emitters:Array = find_children("*", "GPUParticles3D")
|
||||
## Wether all [GPUParticles3D] children have their [member GPUParticles3D.emitting] property set
|
||||
@export var emitting:bool:
|
||||
get: return emitters.map(func(child:Node) -> bool: return child.emitting).max()
|
||||
set(value): emitters.map(func(child:Node) -> void: child.emitting = value)
|
||||
## Wether all [GPUParticles3D] children have their [member GPUParticles3D.one_shot] property set
|
||||
@export var one_shot:bool:
|
||||
get: return emitters.map(func(child:Node) -> bool: return child.one_shot).max()
|
||||
set(value): emitters.map(func(child:Node) -> void: child.one_shot = value)
|
||||
|
||||
func _ready() -> void:
|
||||
assert(input and energy, "Jetpack requires 'input' and 'energy' properties to be assigned")
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if stuttering:
|
||||
stuttering = energy.value <= stutter_treshold / 100. * energy.max_value
|
||||
elif input.jetting and energy.value <= 0:
|
||||
stuttering = true
|
||||
energy.charging = !input.jetting or stuttering
|
||||
if !energy.charging:
|
||||
energy.value -= drain_rate / 100. * energy.max_value * delta
|
||||
if input.jetting and energy.value > 0 and not stuttering:
|
||||
emitting = true
|
||||
1
scenes/entities/player/scripts/jetpack.gd.uid
Normal file
1
scenes/entities/player/scripts/jetpack.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://chwntu0dwwtwq
|
||||
Loading…
Add table
Add a link
Reference in a new issue