first commit 🎉

This commit is contained in:
anyreso 2026-02-17 23:36:57 -05:00
commit 6e724f67fe
805 changed files with 62098 additions and 0 deletions

View file

@ -0,0 +1,35 @@
# 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 DeathmatchScoringComponent extends Node
@export var ON_KILL_SCORE := Vector3i(1,0,0)
signal add_score(peer_id:int, score:Vector3i)
## This method returns a new bound deathmatch scoring component to be added in tree.
func _init(scoreboard:Scoreboard, players: Node) -> void:
add_score.connect(scoreboard.add_score)
players.child_entered_tree.connect(register)
players.child_exiting_tree.connect(unregister)
func register(player: Player) -> void:
player.killed.connect(_on_player_killed)
func unregister(player: Player) -> void:
player.killed.disconnect(_on_player_killed)
func _on_player_killed(victim: Player, killer:int) -> void:
if victim.peer_id != killer:
add_score.emit(killer, ON_KILL_SCORE)

View file

@ -0,0 +1 @@
uid://jm5sw8brqh3k

View file

@ -0,0 +1,57 @@
# 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 defines a rabbit scoring component.
class_name RabbitScoringComponent extends Node
const ON_GRAB_SCORE := Vector3i(1,0,0)
const ON_HOLD_SCORE := Vector3i(1,0,0)
const HOLD_SCORING_TIMER:float = 10.0 # seconds
var timer:= Timer.new()
signal add_score(peer_id:int, score:Vector3i)
# @TODO: remove this variable by passing flag to signals `grabbed` and `dropped`
# this if fine for rabbit but will be required for CTF
var flag: Flag
# This method initializes a new rabbit scoring component.
func _init(scoreboard:Scoreboard, _flag:Flag) -> void:
timer.timeout.connect(_on_timer_timeout.bind(_flag))
add_score.connect(scoreboard.add_score)
flag = _flag
flag.grabbed.connect(_on_flag_grabbed)
flag.dropped.connect(_on_flag_dropped)
func _ready() -> void:
add_child(timer)
func _on_flag_grabbed(carry:FlagHolder) -> void:
assert(flag)
# prevent chained grab scoring abuse
if flag and (not flag.last_carrier or flag.last_carrier != carry.owner.peer_id):
# set new carrier for `_on_timer_timeout`
flag.last_carrier = carry.owner.peer_id
add_score.emit(carry.owner.peer_id, ON_GRAB_SCORE)
timer.start(HOLD_SCORING_TIMER)
func _on_flag_dropped(_carry: FlagHolder) -> void:
assert(flag)
timer.stop()
func _on_timer_timeout(_flag:Flag) -> void:
assert(flag)
if _flag.last_carrier:
add_score.emit(_flag.last_carrier, ON_HOLD_SCORE)

View file

@ -0,0 +1 @@
uid://boflqfufg3fte