item selection
This commit is contained in:
parent
6cda733224
commit
afe7f632e8
14
scenes/interactivity_outline.gdshader
Normal file
14
scenes/interactivity_outline.gdshader
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
shader_type spatial;
|
||||||
|
render_mode blend_mix, cull_front, unshaded;
|
||||||
|
|
||||||
|
uniform vec4 color : source_color = vec4(1,0,0,1);
|
||||||
|
uniform float size : hint_range(1.0, 1.5, 0.01) = 1.05;
|
||||||
|
|
||||||
|
void vertex() {
|
||||||
|
VERTEX *= size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void fragment() {
|
||||||
|
ALBEDO = color.rgb;
|
||||||
|
ALPHA = color.a;
|
||||||
|
}
|
@ -1,6 +1,17 @@
|
|||||||
[gd_scene load_steps=2 format=3 uid="uid://s2a1pry5fw8f"]
|
[gd_scene load_steps=4 format=3 uid="uid://s2a1pry5fw8f"]
|
||||||
|
|
||||||
|
[ext_resource type="Shader" path="res://scenes/interactivity_outline.gdshader" id="1_m18kw"]
|
||||||
|
|
||||||
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_gi5rt"]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
render_priority = 0
|
||||||
|
shader = ExtResource("1_m18kw")
|
||||||
|
shader_parameter/color = Color(1, 1, 1, 0)
|
||||||
|
shader_parameter/size = 1.24
|
||||||
|
|
||||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ptaep"]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ptaep"]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
next_pass = SubResource("ShaderMaterial_gi5rt")
|
||||||
albedo_color = Color(0.0936238, 0.825356, 1, 1)
|
albedo_color = Color(0.0936238, 0.825356, 1, 1)
|
||||||
metallic = 0.8
|
metallic = 0.8
|
||||||
roughness = 0.4
|
roughness = 0.4
|
||||||
|
@ -21,6 +21,8 @@ var _max_speed := 12
|
|||||||
var _mouse_sensitivity := 0.008 # radians/pixel
|
var _mouse_sensitivity := 0.008 # radians/pixel
|
||||||
|
|
||||||
var _projectile_speed := 12.0
|
var _projectile_speed := 12.0
|
||||||
|
## Could be only one thing at a time to consider.
|
||||||
|
var _interaction_selection: Node3D
|
||||||
|
|
||||||
var controls_disabled := false
|
var controls_disabled := false
|
||||||
var held_thing: String
|
var held_thing: String
|
||||||
@ -52,6 +54,18 @@ func _process(_delta: float) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
|
## Process interactivity selection.
|
||||||
|
var collider: Object = null
|
||||||
|
if _line_of_sight.is_colliding():
|
||||||
|
collider = _line_of_sight.get_collider(0)
|
||||||
|
if collider != _interaction_selection:
|
||||||
|
if _interaction_selection != null:
|
||||||
|
_interaction_selection.get_parent().mark_non_interactive()
|
||||||
|
if collider != null:
|
||||||
|
collider.get_parent().mark_interactive()
|
||||||
|
_interaction_selection = collider
|
||||||
|
|
||||||
|
|
||||||
# Add the gravity.
|
# Add the gravity.
|
||||||
if not is_on_floor():
|
if not is_on_floor():
|
||||||
velocity += get_gravity() * delta
|
velocity += get_gravity() * delta
|
||||||
@ -96,12 +110,8 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||||||
return
|
return
|
||||||
|
|
||||||
if event.is_action_pressed("pick") and held_thing == "":
|
if event.is_action_pressed("pick") and held_thing == "":
|
||||||
if _line_of_sight.is_colliding():
|
if _interaction_selection != null:
|
||||||
if id != 1:
|
_interaction_selection.get_parent().get_picked_up.rpc()
|
||||||
print("test")
|
|
||||||
# TODO: bad
|
|
||||||
var picked = _line_of_sight.get_collider(0).get_parent()
|
|
||||||
picked.get_picked_up.rpc()
|
|
||||||
hold_thing.rpc()
|
hold_thing.rpc()
|
||||||
|
|
||||||
if event.is_action_pressed("fire") and held_thing != "":
|
if event.is_action_pressed("fire") and held_thing != "":
|
||||||
|
@ -77,3 +77,11 @@ func set_global_pos(new: Vector3) -> void:
|
|||||||
func get_picked_up() -> void:
|
func get_picked_up() -> void:
|
||||||
if is_multiplayer_authority():
|
if is_multiplayer_authority():
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
|
|
||||||
|
func mark_interactive() -> void:
|
||||||
|
($Model as CSGSphere3D).material_override.next_pass.set("shader_parameter/color", Color.WHITE)
|
||||||
|
|
||||||
|
|
||||||
|
func mark_non_interactive() -> void:
|
||||||
|
($Model as CSGSphere3D).material_override.next_pass.set("shader_parameter/color", Color(1, 1, 1, 0))
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
[gd_scene load_steps=11 format=3 uid="uid://tdsbo3e5ic86"]
|
[gd_scene load_steps=15 format=3 uid="uid://tdsbo3e5ic86"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://src/ingame/water_bomb.gd" id="1_lk5fq"]
|
[ext_resource type="Script" path="res://src/ingame/water_bomb.gd" id="1_lk5fq"]
|
||||||
[ext_resource type="PackedScene" uid="uid://s2a1pry5fw8f" path="res://scenes/water_bomb_model.tscn" id="2_0lxuq"]
|
[ext_resource type="PackedScene" uid="uid://s2a1pry5fw8f" path="res://scenes/water_bomb_model.tscn" id="2_0lxuq"]
|
||||||
[ext_resource type="AudioStream" uid="uid://dtjpv2b74g24m" path="res://assets/sfx/splash-small.wav" id="2_0wk8g"]
|
[ext_resource type="AudioStream" uid="uid://dtjpv2b74g24m" path="res://assets/sfx/splash-small.wav" id="2_0wk8g"]
|
||||||
[ext_resource type="AudioStream" uid="uid://blgrl2wl05feq" path="res://assets/sfx/splash-small-quiet.wav" id="3_hgy7l"]
|
[ext_resource type="AudioStream" uid="uid://blgrl2wl05feq" path="res://assets/sfx/splash-small-quiet.wav" id="3_hgy7l"]
|
||||||
|
[ext_resource type="Shader" path="res://scenes/interactivity_outline.gdshader" id="3_vfl1p"]
|
||||||
|
[ext_resource type="Script" path="res://src/lib/item_component.gd" id="5_rpnf2"]
|
||||||
|
|
||||||
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_0ebrr"]
|
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_0ebrr"]
|
||||||
properties/0/path = NodePath(".:position")
|
properties/0/path = NodePath(".:position")
|
||||||
@ -25,6 +27,20 @@ properties/5/path = NodePath("SplashParticles:emitting")
|
|||||||
properties/5/spawn = true
|
properties/5/spawn = true
|
||||||
properties/5/replication_mode = 2
|
properties/5/replication_mode = 2
|
||||||
|
|
||||||
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_cpgfr"]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
render_priority = 0
|
||||||
|
shader = ExtResource("3_vfl1p")
|
||||||
|
shader_parameter/color = Color(1, 1, 1, 0)
|
||||||
|
shader_parameter/size = 1.24
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_dykfn"]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
next_pass = SubResource("ShaderMaterial_cpgfr")
|
||||||
|
albedo_color = Color(0.0936238, 0.825356, 1, 1)
|
||||||
|
metallic = 0.8
|
||||||
|
roughness = 0.4
|
||||||
|
|
||||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_v7dnr"]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_v7dnr"]
|
||||||
albedo_color = Color(0, 1, 1, 1)
|
albedo_color = Color(0, 1, 1, 1)
|
||||||
roughness = 0.2
|
roughness = 0.2
|
||||||
@ -59,6 +75,7 @@ body = NodePath("RigidBody3D")
|
|||||||
replication_config = SubResource("SceneReplicationConfig_0ebrr")
|
replication_config = SubResource("SceneReplicationConfig_0ebrr")
|
||||||
|
|
||||||
[node name="Model" parent="." instance=ExtResource("2_0lxuq")]
|
[node name="Model" parent="." instance=ExtResource("2_0lxuq")]
|
||||||
|
material_override = SubResource("StandardMaterial3D_dykfn")
|
||||||
|
|
||||||
[node name="SplashParticles" type="GPUParticles3D" parent="."]
|
[node name="SplashParticles" type="GPUParticles3D" parent="."]
|
||||||
material_override = SubResource("StandardMaterial3D_v7dnr")
|
material_override = SubResource("StandardMaterial3D_v7dnr")
|
||||||
@ -107,6 +124,10 @@ monitoring = false
|
|||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="PickingArea"]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="PickingArea"]
|
||||||
shape = SubResource("SphereShape3D_6c830")
|
shape = SubResource("SphereShape3D_6c830")
|
||||||
|
|
||||||
|
[node name="ItemComponent" type="Node" parent="."]
|
||||||
|
script = ExtResource("5_rpnf2")
|
||||||
|
id = "water"
|
||||||
|
|
||||||
[connection signal="body_entered" from="RigidBody3D" to="." method="_on_body_entered"]
|
[connection signal="body_entered" from="RigidBody3D" to="." method="_on_body_entered"]
|
||||||
[connection signal="area_entered" from="RigidBody3D/SplashArea" to="." method="_on_splash_area_entered"]
|
[connection signal="area_entered" from="RigidBody3D/SplashArea" to="." method="_on_splash_area_entered"]
|
||||||
[connection signal="area_exited" from="RigidBody3D/SplashArea" to="." method="_on_splash_area_exited"]
|
[connection signal="area_exited" from="RigidBody3D/SplashArea" to="." method="_on_splash_area_exited"]
|
||||||
|
17
src/lib/item_component.gd
Normal file
17
src/lib/item_component.gd
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
class_name ItemComponent
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
## Base identity, properties are defined in item db.
|
||||||
|
@export var id: String
|
||||||
|
|
||||||
|
|
||||||
|
func mark_interactive() -> void:
|
||||||
|
var parent := get_parent()
|
||||||
|
if parent.has_method("mark_interactive"):
|
||||||
|
parent.mark_interactive()
|
||||||
|
|
||||||
|
|
||||||
|
func mark_non_interactive(delta: float) -> void:
|
||||||
|
var parent := get_parent()
|
||||||
|
if parent.has_method("mark_non_interactive"):
|
||||||
|
parent.mark_non_interactive()
|
Loading…
Reference in New Issue
Block a user