mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-07-15 16:34:48 +00:00
Merge branch 'feat/flag-grab-and-carry-score' into 'develop'
✨ Add flag grabbing/carrying scoring logic See merge request open-fpsz/open-fpsz!61
This commit is contained in:
commit
d1bebdac0b
8 changed files with 65 additions and 30 deletions
|
|
@ -47,7 +47,7 @@ func _enter_tree() -> void:
|
||||||
toolbar = Toolbar.new()
|
toolbar = Toolbar.new()
|
||||||
toolbar.hide()
|
toolbar.hide()
|
||||||
toolbar.connect("tool_changed", _on_tool_changed)
|
toolbar.connect("tool_changed", _on_tool_changed)
|
||||||
|
|
||||||
toolbar_settings = ToolSettings.new()
|
toolbar_settings = ToolSettings.new()
|
||||||
toolbar_settings.connect("setting_changed", _on_setting_changed)
|
toolbar_settings.connect("setting_changed", _on_setting_changed)
|
||||||
toolbar_settings.connect("picking", _on_picking)
|
toolbar_settings.connect("picking", _on_picking)
|
||||||
|
|
@ -89,7 +89,7 @@ func set_visible(p_visible: bool) -> void:
|
||||||
visible = p_visible
|
visible = p_visible
|
||||||
toolbar.set_visible(p_visible and plugin.terrain)
|
toolbar.set_visible(p_visible and plugin.terrain)
|
||||||
terrain_tools.set_visible(p_visible)
|
terrain_tools.set_visible(p_visible)
|
||||||
|
|
||||||
if p_visible and plugin.terrain:
|
if p_visible and plugin.terrain:
|
||||||
p_visible = plugin.editor.get_tool() != Terrain3DEditor.REGION
|
p_visible = plugin.editor.get_tool() != Terrain3DEditor.REGION
|
||||||
toolbar_settings.set_visible(p_visible and plugin.terrain)
|
toolbar_settings.set_visible(p_visible and plugin.terrain)
|
||||||
|
|
@ -98,19 +98,19 @@ func set_visible(p_visible: bool) -> void:
|
||||||
|
|
||||||
func _on_tool_changed(p_tool: Terrain3DEditor.Tool, p_operation: Terrain3DEditor.Operation) -> void:
|
func _on_tool_changed(p_tool: Terrain3DEditor.Tool, p_operation: Terrain3DEditor.Operation) -> void:
|
||||||
clear_picking()
|
clear_picking()
|
||||||
|
|
||||||
if not visible or not plugin.terrain:
|
if not visible or not plugin.terrain:
|
||||||
return
|
return
|
||||||
|
|
||||||
if plugin.editor:
|
if plugin.editor:
|
||||||
plugin.editor.set_tool(p_tool)
|
plugin.editor.set_tool(p_tool)
|
||||||
plugin.editor.set_operation(p_operation)
|
plugin.editor.set_operation(p_operation)
|
||||||
|
|
||||||
if p_tool != Terrain3DEditor.REGION:
|
if p_tool != Terrain3DEditor.REGION:
|
||||||
# Select which settings to hide. Options:
|
# Select which settings to hide. Options:
|
||||||
# size, opactiy, height, slope, color, roughness, (height|color|roughness) picker
|
# size, opactiy, height, slope, color, roughness, (height|color|roughness) picker
|
||||||
var to_hide: PackedStringArray = []
|
var to_hide: PackedStringArray = []
|
||||||
|
|
||||||
if p_tool == Terrain3DEditor.HEIGHT:
|
if p_tool == Terrain3DEditor.HEIGHT:
|
||||||
to_hide.push_back("color")
|
to_hide.push_back("color")
|
||||||
to_hide.push_back("color picker")
|
to_hide.push_back("color picker")
|
||||||
|
|
@ -158,7 +158,7 @@ func _on_tool_changed(p_tool: Terrain3DEditor.Tool, p_operation: Terrain3DEditor
|
||||||
to_hide.push_back("color picker")
|
to_hide.push_back("color picker")
|
||||||
to_hide.push_back("slope")
|
to_hide.push_back("slope")
|
||||||
to_hide.push_back("enable")
|
to_hide.push_back("enable")
|
||||||
|
|
||||||
elif p_tool in [ Terrain3DEditor.AUTOSHADER, Terrain3DEditor.HOLES, Terrain3DEditor.NAVIGATION ]:
|
elif p_tool in [ Terrain3DEditor.AUTOSHADER, Terrain3DEditor.HOLES, Terrain3DEditor.NAVIGATION ]:
|
||||||
to_hide.push_back("height")
|
to_hide.push_back("height")
|
||||||
to_hide.push_back("height picker")
|
to_hide.push_back("height picker")
|
||||||
|
|
@ -173,16 +173,16 @@ func _on_tool_changed(p_tool: Terrain3DEditor.Tool, p_operation: Terrain3DEditor
|
||||||
|
|
||||||
toolbar_settings.hide_settings(to_hide)
|
toolbar_settings.hide_settings(to_hide)
|
||||||
|
|
||||||
toolbar_settings.set_visible(p_tool != Terrain3DEditor.REGION)
|
toolbar_settings.set_visible(p_tool != Terrain3DEditor.REGION)
|
||||||
|
|
||||||
operation_builder = null
|
operation_builder = null
|
||||||
if p_operation == Terrain3DEditor.GRADIENT:
|
if p_operation == Terrain3DEditor.GRADIENT:
|
||||||
operation_builder = GradientOperationBuilder.new()
|
operation_builder = GradientOperationBuilder.new()
|
||||||
operation_builder.tool_settings = toolbar_settings
|
operation_builder.tool_settings = toolbar_settings
|
||||||
|
|
||||||
_on_setting_changed()
|
_on_setting_changed()
|
||||||
plugin.update_region_grid()
|
plugin.update_region_grid()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _on_setting_changed() -> void:
|
func _on_setting_changed() -> void:
|
||||||
|
|
@ -206,7 +206,7 @@ func _on_setting_changed() -> void:
|
||||||
var brush_imgs: Array = toolbar_settings.get_setting("brush")
|
var brush_imgs: Array = toolbar_settings.get_setting("brush")
|
||||||
brush_data["image"] = brush_imgs[0]
|
brush_data["image"] = brush_imgs[0]
|
||||||
brush_data["texture"] = brush_imgs[1]
|
brush_data["texture"] = brush_imgs[1]
|
||||||
|
|
||||||
update_decal()
|
update_decal()
|
||||||
plugin.editor.set_brush_data(brush_data)
|
plugin.editor.set_brush_data(brush_data)
|
||||||
|
|
||||||
|
|
@ -226,7 +226,7 @@ func update_decal() -> void:
|
||||||
else:
|
else:
|
||||||
# Wait for cursor to recenter after right-click before revealing
|
# Wait for cursor to recenter after right-click before revealing
|
||||||
# See https://github.com/godotengine/godot/issues/70098
|
# See https://github.com/godotengine/godot/issues/70098
|
||||||
await get_tree().create_timer(.05).timeout
|
await get_tree().create_timer(.05).timeout
|
||||||
decal.visible = true
|
decal.visible = true
|
||||||
|
|
||||||
decal.size = Vector3.ONE * brush_data["size"]
|
decal.size = Vector3.ONE * brush_data["size"]
|
||||||
|
|
@ -250,7 +250,7 @@ func update_decal() -> void:
|
||||||
decal.modulate = COLOR_PICK_ROUGH
|
decal.modulate = COLOR_PICK_ROUGH
|
||||||
decal.modulate.a = 1.0
|
decal.modulate.a = 1.0
|
||||||
else:
|
else:
|
||||||
decal.texture_albedo = brush_data["texture"]
|
decal.texture_albedo = brush_data["texture"]
|
||||||
match plugin.editor.get_tool():
|
match plugin.editor.get_tool():
|
||||||
Terrain3DEditor.HEIGHT:
|
Terrain3DEditor.HEIGHT:
|
||||||
match plugin.editor.get_operation():
|
match plugin.editor.get_operation():
|
||||||
|
|
@ -303,10 +303,10 @@ func update_decal() -> void:
|
||||||
decal.albedo_mix = 1.0
|
decal.albedo_mix = 1.0
|
||||||
decal.cull_mask = 1 << ( plugin.terrain.get_mouse_layer() - 1 )
|
decal.cull_mask = 1 << ( plugin.terrain.get_mouse_layer() - 1 )
|
||||||
decal_timer.start()
|
decal_timer.start()
|
||||||
|
|
||||||
for gradient_decal in gradient_decals:
|
for gradient_decal in gradient_decals:
|
||||||
gradient_decal.visible = false
|
gradient_decal.visible = false
|
||||||
|
|
||||||
if plugin.editor.get_operation() == Terrain3DEditor.GRADIENT:
|
if plugin.editor.get_operation() == Terrain3DEditor.GRADIENT:
|
||||||
var index := 0
|
var index := 0
|
||||||
for point in brush_data["gradient_points"]:
|
for point in brush_data["gradient_points"]:
|
||||||
|
|
@ -320,7 +320,7 @@ func update_decal() -> void:
|
||||||
func _get_gradient_decal(index: int) -> Decal:
|
func _get_gradient_decal(index: int) -> Decal:
|
||||||
if gradient_decals.size() > index:
|
if gradient_decals.size() > index:
|
||||||
return gradient_decals[index]
|
return gradient_decals[index]
|
||||||
|
|
||||||
var gradient_decal := Decal.new()
|
var gradient_decal := Decal.new()
|
||||||
gradient_decal = Decal.new()
|
gradient_decal = Decal.new()
|
||||||
gradient_decal.texture_albedo = picker_texture
|
gradient_decal.texture_albedo = picker_texture
|
||||||
|
|
@ -329,7 +329,7 @@ func _get_gradient_decal(index: int) -> Decal:
|
||||||
gradient_decal.size.y = 1000.
|
gradient_decal.size.y = 1000.
|
||||||
gradient_decal.cull_mask = decal.cull_mask
|
gradient_decal.cull_mask = decal.cull_mask
|
||||||
add_child(gradient_decal)
|
add_child(gradient_decal)
|
||||||
|
|
||||||
gradient_decals.push_back(gradient_decal)
|
gradient_decals.push_back(gradient_decal)
|
||||||
return gradient_decal
|
return gradient_decal
|
||||||
|
|
||||||
|
|
@ -351,10 +351,10 @@ func clear_picking() -> void:
|
||||||
func is_picking() -> bool:
|
func is_picking() -> bool:
|
||||||
if picking != Terrain3DEditor.TOOL_MAX:
|
if picking != Terrain3DEditor.TOOL_MAX:
|
||||||
return true
|
return true
|
||||||
|
|
||||||
if operation_builder and operation_builder.is_picking():
|
if operation_builder and operation_builder.is_picking():
|
||||||
return true
|
return true
|
||||||
|
|
||||||
return false
|
return false
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -373,7 +373,7 @@ func pick(p_global_position: Vector3) -> void:
|
||||||
return
|
return
|
||||||
picking_callback.call(picking, color, p_global_position)
|
picking_callback.call(picking, color, p_global_position)
|
||||||
picking = Terrain3DEditor.TOOL_MAX
|
picking = Terrain3DEditor.TOOL_MAX
|
||||||
|
|
||||||
elif operation_builder and operation_builder.is_picking():
|
elif operation_builder and operation_builder.is_picking():
|
||||||
operation_builder.pick(p_global_position, plugin.terrain)
|
operation_builder.pick(p_global_position, plugin.terrain)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ class_name FlagCarryComponent extends Node
|
||||||
@export var max_throw_speed : float = 10.0
|
@export var max_throw_speed : float = 10.0
|
||||||
@export var attachment : Node3D
|
@export var attachment : Node3D
|
||||||
@export var sensor : Area3D
|
@export var sensor : Area3D
|
||||||
|
@export var carrier : Player
|
||||||
|
|
||||||
var _carried_flag : Flag
|
var _carried_flag : Flag
|
||||||
|
|
||||||
|
|
@ -34,7 +35,7 @@ func _process(_delta : float) -> void:
|
||||||
|
|
||||||
func _grab(flag : Flag) -> void:
|
func _grab(flag : Flag) -> void:
|
||||||
if not _is_carrying():
|
if not _is_carrying():
|
||||||
flag.grab()
|
flag.grab(carrier)
|
||||||
_carried_flag = flag
|
_carried_flag = flag
|
||||||
|
|
||||||
func _release(inherited_velocity : Vector3, throw_speed : float) -> void:
|
func _release(inherited_velocity : Vector3, throw_speed : float) -> void:
|
||||||
|
|
|
||||||
|
|
@ -4,14 +4,26 @@ enum FlagState { FLAG_STATE_ON_STAND, FLAG_STATE_DROPPED, FLAG_STATE_TAKEN }
|
||||||
|
|
||||||
@export var flag_state : FlagState = FlagState.FLAG_STATE_ON_STAND
|
@export var flag_state : FlagState = FlagState.FLAG_STATE_ON_STAND
|
||||||
|
|
||||||
|
signal grabbed(grabber : Player)
|
||||||
|
signal regrabbed
|
||||||
|
signal dropped
|
||||||
|
|
||||||
|
var last_carrier : Player = null
|
||||||
|
|
||||||
func can_be_grabbed() -> bool:
|
func can_be_grabbed() -> bool:
|
||||||
return flag_state != FlagState.FLAG_STATE_TAKEN
|
return flag_state != FlagState.FLAG_STATE_TAKEN
|
||||||
|
|
||||||
func grab() -> void:
|
func grab(grabber : Player) -> void:
|
||||||
if flag_state != FlagState.FLAG_STATE_TAKEN:
|
if flag_state != FlagState.FLAG_STATE_TAKEN:
|
||||||
flag_state = FlagState.FLAG_STATE_TAKEN
|
flag_state = FlagState.FLAG_STATE_TAKEN
|
||||||
|
if (last_carrier == null) or (grabber != last_carrier):
|
||||||
|
grabbed.emit(grabber)
|
||||||
|
last_carrier = grabber
|
||||||
|
else:
|
||||||
|
regrabbed.emit()
|
||||||
|
|
||||||
func drop() -> void:
|
func drop() -> void:
|
||||||
if flag_state == FlagState.FLAG_STATE_TAKEN:
|
if flag_state == FlagState.FLAG_STATE_TAKEN:
|
||||||
flag_state = FlagState.FLAG_STATE_DROPPED
|
flag_state = FlagState.FLAG_STATE_DROPPED
|
||||||
|
dropped.emit()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
[gd_scene load_steps=7 format=3 uid="uid://c88l3h0ph00c7"]
|
[gd_scene load_steps=7 format=3 uid="uid://c88l3h0ph00c7"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://entities/flag/flag.gd" id="1_y7d3d"]
|
[ext_resource type="Script" path="res://entities/flag/flag.gd" id="1_y7d3d"]
|
||||||
[ext_resource type="PackedScene" path="res://entities/flag/assets/flag.glb" id="2_i78em"]
|
[ext_resource type="PackedScene" uid="uid://d3l7fvbdg6m5g" path="res://entities/flag/assets/flag.glb" id="2_i78em"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bcgkc5fhhyauv" path="res://entities/flag/waypoint.tscn" id="3_tu6jg"]
|
[ext_resource type="PackedScene" uid="uid://bcgkc5fhhyauv" path="res://entities/flag/waypoint.tscn" id="3_tu6jg"]
|
||||||
|
|
||||||
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_4ymrw"]
|
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_4ymrw"]
|
||||||
|
|
|
||||||
|
|
@ -130,9 +130,10 @@ shape = ExtResource("2_vjqny")
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="HealthComponent"]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="HealthComponent"]
|
||||||
shape = ExtResource("2_vjqny")
|
shape = ExtResource("2_vjqny")
|
||||||
|
|
||||||
[node name="FlagCarryComponent" parent="." node_paths=PackedStringArray("attachment", "sensor") instance=ExtResource("7_e7s1a")]
|
[node name="FlagCarryComponent" parent="." node_paths=PackedStringArray("attachment", "sensor", "carrier") instance=ExtResource("7_e7s1a")]
|
||||||
attachment = NodePath("../Smoothing/SpringArm3D/FlagCarryAttachment")
|
attachment = NodePath("../Smoothing/SpringArm3D/FlagCarryAttachment")
|
||||||
sensor = NodePath("../Sensor")
|
sensor = NodePath("../Sensor")
|
||||||
|
carrier = NodePath("..")
|
||||||
|
|
||||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
libraries = {
|
libraries = {
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.42967, 0)
|
||||||
height = 5.0
|
height = 5.0
|
||||||
|
|
||||||
[node name="FlagStand" type="Marker3D" parent="Terrain3D/FlagPillar/CSGCylinder3D"]
|
[node name="FlagStand" type="Marker3D" parent="Terrain3D/FlagPillar/CSGCylinder3D"]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.42315, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3.53822, 0)
|
||||||
|
|
||||||
[node name="Sunlight" type="DirectionalLight3D" parent="."]
|
[node name="Sunlight" type="DirectionalLight3D" parent="."]
|
||||||
transform = Transform3D(-0.866024, -0.433016, 0.25, 0, 0.499998, 0.866027, -0.500003, 0.75, -0.43301, 0, 100, 0)
|
transform = Transform3D(-0.866024, -0.433016, 0.25, 0, 0.499998, 0.866027, -0.500003, 0.75, -0.43301, 0, 100, 0)
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,17 @@ class_name Multiplayer extends Node
|
||||||
@onready var scoreboard_ui : Node = $ScoreboardUI
|
@onready var scoreboard_ui : Node = $ScoreboardUI
|
||||||
|
|
||||||
var _map_manager : Map
|
var _map_manager : Map
|
||||||
|
var _flag : Flag
|
||||||
|
var _flag_carrier_scoring_timer : Timer = Timer.new()
|
||||||
|
|
||||||
signal connected_to_server
|
signal connected_to_server
|
||||||
signal connection_failed
|
signal connection_failed
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
_flag_carrier_scoring_timer.wait_time = 10.0
|
||||||
|
_flag_carrier_scoring_timer.timeout.connect(_on_flag_carrier_scoring_timer_timeout)
|
||||||
|
add_child(_flag_carrier_scoring_timer)
|
||||||
|
|
||||||
func start_server(port : int, nickname : String) -> void:
|
func start_server(port : int, nickname : String) -> void:
|
||||||
var peer : ENetMultiplayerPeer = ENetMultiplayerPeer.new()
|
var peer : ENetMultiplayerPeer = ENetMultiplayerPeer.new()
|
||||||
peer.create_server(port, MAX_CLIENTS)
|
peer.create_server(port, MAX_CLIENTS)
|
||||||
|
|
@ -101,9 +108,11 @@ func _load_map(scene : PackedScene, nickname : String) -> void:
|
||||||
map.add_child(map_scene)
|
map.add_child(map_scene)
|
||||||
|
|
||||||
func _add_flag() -> void:
|
func _add_flag() -> void:
|
||||||
var flag : Flag = FLAG.instantiate()
|
_flag = FLAG.instantiate()
|
||||||
flag.global_position = _map_manager.get_flagstand().global_position
|
_flag.grabbed.connect(_on_flag_grabbed)
|
||||||
objectives.add_child(flag)
|
_flag.dropped.connect(_on_flag_dropped)
|
||||||
|
_flag.global_position = _map_manager.get_flagstand().global_position
|
||||||
|
objectives.add_child(_flag)
|
||||||
|
|
||||||
func _unhandled_input(event : InputEvent) -> void:
|
func _unhandled_input(event : InputEvent) -> void:
|
||||||
if event.is_action_pressed("scoreboard"):
|
if event.is_action_pressed("scoreboard"):
|
||||||
|
|
@ -123,6 +132,18 @@ func _join_match(nickname : String) -> void:
|
||||||
if is_multiplayer_authority():
|
if is_multiplayer_authority():
|
||||||
add_player(multiplayer.get_remote_sender_id(), nickname)
|
add_player(multiplayer.get_remote_sender_id(), nickname)
|
||||||
|
|
||||||
|
func _on_flag_grabbed(grabber : Player) -> void:
|
||||||
|
scoreboard.add_score_to_player(grabber, 10)
|
||||||
|
scoreboard.broadcast_player_score_update(grabber)
|
||||||
|
_flag_carrier_scoring_timer.start()
|
||||||
|
|
||||||
|
func _on_flag_dropped() -> void:
|
||||||
|
_flag_carrier_scoring_timer.stop()
|
||||||
|
|
||||||
|
func _on_flag_carrier_scoring_timer_timeout() -> void:
|
||||||
|
scoreboard.add_score_to_player(_flag.last_carrier, 10)
|
||||||
|
scoreboard.broadcast_player_score_update(_flag.last_carrier)
|
||||||
|
|
||||||
func _exit_tree() -> void:
|
func _exit_tree() -> void:
|
||||||
if is_multiplayer_authority():
|
if is_multiplayer_authority():
|
||||||
multiplayer.peer_disconnected.disconnect(remove_player)
|
multiplayer.peer_disconnected.disconnect(remove_player)
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
[gd_scene load_steps=6 format=3 uid="uid://bvwxfgygm2xb8"]
|
[gd_scene load_steps=6 format=3 uid="uid://bvwxfgygm2xb8"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://modes/multiplayer.gd" id="1_4t1ad"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://chbno00ugl6te" path="res://maps/genesis/genesis.tscn" id="1_nulvv"]
|
[ext_resource type="PackedScene" uid="uid://chbno00ugl6te" path="res://maps/genesis/genesis.tscn" id="1_nulvv"]
|
||||||
|
[ext_resource type="Script" path="res://modes/multiplayer.gd" id="1_r1kd6"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cbhx1xme0sb7k" path="res://entities/player/player.tscn" id="2_og1vb"]
|
[ext_resource type="PackedScene" uid="uid://cbhx1xme0sb7k" path="res://entities/player/player.tscn" id="2_og1vb"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c88l3h0ph00c7" path="res://entities/flag/flag.tscn" id="3_h0rie"]
|
[ext_resource type="PackedScene" uid="uid://c88l3h0ph00c7" path="res://entities/flag/flag.tscn" id="3_h0rie"]
|
||||||
[ext_resource type="Script" path="res://modes/scoreboard.gd" id="4_n0mhp"]
|
[ext_resource type="Script" path="res://modes/scoreboard.gd" id="4_n0mhp"]
|
||||||
|
|
||||||
[node name="Multiplayer" type="Node"]
|
[node name="Multiplayer" type="Node"]
|
||||||
script = ExtResource("1_4t1ad")
|
script = ExtResource("1_r1kd6")
|
||||||
MAP = ExtResource("1_nulvv")
|
MAP = ExtResource("1_nulvv")
|
||||||
PLAYER = ExtResource("2_og1vb")
|
PLAYER = ExtResource("2_og1vb")
|
||||||
FLAG = ExtResource("3_h0rie")
|
FLAG = ExtResource("3_h0rie")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue