generated from krampus/template-godot4
Stickers can be removed with spray tools
This commit is contained in:
parent
ff379484ca
commit
3d1e5dda38
@ -20,5 +20,5 @@ func _spray() -> void:
|
|||||||
(collider as GunkBody).paint_continuous(
|
(collider as GunkBody).paint_continuous(
|
||||||
point, laser.get_collision_normal(), point_scale
|
point, laser.get_collision_normal(), point_scale
|
||||||
)
|
)
|
||||||
if collider is GunkNode:
|
if collider is Sprayable:
|
||||||
(collider as GunkNode).hit(damage)
|
(collider as Sprayable).hit(damage)
|
||||||
|
12
src/equipment/sprayable.gd
Normal file
12
src/equipment/sprayable.gd
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
class_name Sprayable extends StaticBody3D
|
||||||
|
|
||||||
|
|
||||||
|
## Called each frame this node takes a hit.
|
||||||
|
##
|
||||||
|
## Derived types should override `_hit()` as a lifecycle method.
|
||||||
|
func hit(damage: float) -> void:
|
||||||
|
_hit()
|
||||||
|
|
||||||
|
|
||||||
|
func _hit() -> void:
|
||||||
|
pass # Implemented in derived type
|
1
src/equipment/sprayable.gd.uid
Normal file
1
src/equipment/sprayable.gd.uid
Normal file
@ -0,0 +1 @@
|
|||||||
|
uid://ddpgqjf71eqm5
|
@ -47,21 +47,18 @@ func fire() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func place_sticker() -> void:
|
func place_sticker() -> void:
|
||||||
var instance: Decal = sticker_scene.instantiate()
|
var instance: WorldSticker = sticker_scene.instantiate()
|
||||||
var target: Node = raycast.get_collider() as Node
|
var target: Node = raycast.get_collider() as Node
|
||||||
if not target:
|
if not target:
|
||||||
push_warning("Tried to apply decal to non-node target ", raycast.get_collider())
|
push_warning("Tried to apply decal to non-node target ", raycast.get_collider())
|
||||||
return
|
return
|
||||||
target.add_sibling(instance)
|
target.add_sibling(instance)
|
||||||
|
instance.place(
|
||||||
instance.texture_albedo = get_selected_sticker()
|
get_selected_sticker(),
|
||||||
instance.global_position = raycast.get_collision_point()
|
raycast.get_collision_point(),
|
||||||
|
raycast.get_collision_normal(),
|
||||||
# Build basis
|
global_basis.y
|
||||||
var up := raycast.get_collision_normal()
|
)
|
||||||
var right := up.cross(global_basis.y).normalized()
|
|
||||||
var forward := -right.cross(up).normalized()
|
|
||||||
instance.global_basis = Basis(right, up, forward)
|
|
||||||
print_debug("Sticker placed")
|
print_debug("Sticker placed")
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ sticker_scene = ExtResource("2_yigow")
|
|||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
transform = Transform3D(1, 0, 0, 0, 0.997564, -0.0697565, 0, 0.0697565, 0.997564, 0, 0, -0.15)
|
transform = Transform3D(1, 0, 0, 0, 0.997564, -0.0697565, 0, 0.0697565, 0.997564, 0, 0, -0.15)
|
||||||
target_position = Vector3(0, 0, -1)
|
target_position = Vector3(0, 0, -1)
|
||||||
collision_mask = 4
|
|
||||||
hit_from_inside = true
|
hit_from_inside = true
|
||||||
|
|
||||||
[node name="RestingPosition" type="Marker3D" parent="."]
|
[node name="RestingPosition" type="Marker3D" parent="."]
|
||||||
|
22
src/equipment/sticker_pack/world_sticker.gd
Normal file
22
src/equipment/sticker_pack/world_sticker.gd
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
class_name WorldSticker extends Sprayable
|
||||||
|
|
||||||
|
@onready var decal: Decal = %Decal
|
||||||
|
|
||||||
|
|
||||||
|
func _hit() -> void:
|
||||||
|
# Remove on hit
|
||||||
|
queue_free()
|
||||||
|
|
||||||
|
|
||||||
|
## Place this sticker at a given point, aligned to the given normal, with the given texture.
|
||||||
|
func place(texture: Texture2D, point: Vector3, normal: Vector3, src_up: Vector3) -> void:
|
||||||
|
decal.texture_albedo = texture
|
||||||
|
global_position = point
|
||||||
|
|
||||||
|
# Build basis
|
||||||
|
var up := normal
|
||||||
|
var right := up.cross(src_up).normalized()
|
||||||
|
var forward := -right.cross(up).normalized()
|
||||||
|
global_basis = Basis(right, up, forward)
|
||||||
|
|
||||||
|
# TODO handle serialization & deserialization
|
1
src/equipment/sticker_pack/world_sticker.gd.uid
Normal file
1
src/equipment/sticker_pack/world_sticker.gd.uid
Normal file
@ -0,0 +1 @@
|
|||||||
|
uid://giosvggx808p
|
@ -1,6 +1,10 @@
|
|||||||
[gd_scene load_steps=4 format=3 uid="uid://dqc1a8xaqac8h"]
|
[gd_scene load_steps=6 format=3 uid="uid://dqc1a8xaqac8h"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://cl8ui8nnoaa1i" path="res://assets/stickers/heart_suit_3d.png" id="1_e4i3l"]
|
[ext_resource type="Texture2D" uid="uid://cl8ui8nnoaa1i" path="res://assets/stickers/heart_suit_3d.png" id="1_e4i3l"]
|
||||||
|
[ext_resource type="Script" uid="uid://giosvggx808p" path="res://src/equipment/sticker_pack/world_sticker.gd" id="1_q766c"]
|
||||||
|
|
||||||
|
[sub_resource type="SphereShape3D" id="SphereShape3D_e4i3l"]
|
||||||
|
radius = 0.09
|
||||||
|
|
||||||
[sub_resource type="PlaneMesh" id="PlaneMesh_e4i3l"]
|
[sub_resource type="PlaneMesh" id="PlaneMesh_e4i3l"]
|
||||||
|
|
||||||
@ -9,18 +13,29 @@ top_radius = 0.01
|
|||||||
bottom_radius = 0.01
|
bottom_radius = 0.01
|
||||||
height = 0.2
|
height = 0.2
|
||||||
|
|
||||||
[node name="WorldSticker" type="Decal"]
|
[node name="WorldSticker" type="StaticBody3D"]
|
||||||
|
collision_layer = 4
|
||||||
|
collision_mask = 0
|
||||||
|
script = ExtResource("1_q766c")
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
|
shape = SubResource("SphereShape3D_e4i3l")
|
||||||
|
|
||||||
|
[node name="Decal" type="Decal" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
size = Vector3(0.25, 0.1, 0.25)
|
size = Vector3(0.25, 0.1, 0.25)
|
||||||
texture_albedo = ExtResource("1_e4i3l")
|
texture_albedo = ExtResource("1_e4i3l")
|
||||||
upper_fade = 0.01
|
upper_fade = 0.01
|
||||||
lower_fade = 0.01
|
lower_fade = 0.01
|
||||||
|
|
||||||
[node name="DebugPlane" type="MeshInstance3D" parent="."]
|
[node name="DebugPlane" type="MeshInstance3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 0.848002, -0.529993, 0, 0.529993, 0.848002, 0, 0, 0)
|
transform = Transform3D(1, 0, 0, 0, 0.729219, -0.68428, 0, 0.68428, 0.729219, 0, 0, 0)
|
||||||
visible = false
|
visible = false
|
||||||
mesh = SubResource("PlaneMesh_e4i3l")
|
mesh = SubResource("PlaneMesh_e4i3l")
|
||||||
|
skeleton = NodePath("../Decal")
|
||||||
|
|
||||||
[node name="DebugNormal" type="MeshInstance3D" parent="."]
|
[node name="DebugNormal" type="MeshInstance3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.15, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.15, 0)
|
||||||
visible = false
|
visible = false
|
||||||
mesh = SubResource("CylinderMesh_e4i3l")
|
mesh = SubResource("CylinderMesh_e4i3l")
|
||||||
|
skeleton = NodePath("../Decal")
|
||||||
|
@ -61,8 +61,8 @@ func _spray() -> void:
|
|||||||
prev_target = target
|
prev_target = target
|
||||||
prev_point = point
|
prev_point = point
|
||||||
prev_normal = normal
|
prev_normal = normal
|
||||||
elif collider is GunkNode:
|
elif collider is Sprayable:
|
||||||
(collider as GunkNode).hit(damage)
|
(collider as Sprayable).hit(damage)
|
||||||
|
|
||||||
|
|
||||||
func _on_animation_finished(anim_name: StringName) -> void:
|
func _on_animation_finished(anim_name: StringName) -> void:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
class_name GunkNode extends StaticBody3D
|
class_name GunkNode extends Sprayable
|
||||||
## A static body which can be destroyed and collected by the player.
|
## A static body which can be destroyed and collected by the player.
|
||||||
|
|
||||||
## Emitted immediately after this node has been destroyed by the player,
|
## Emitted immediately after this node has been destroyed by the player,
|
||||||
@ -30,7 +30,7 @@ func _enter_tree() -> void:
|
|||||||
func hit(damage: float = 0.05) -> void:
|
func hit(damage: float = 0.05) -> void:
|
||||||
_sustained_damage += damage
|
_sustained_damage += damage
|
||||||
_hit_this_frame = true
|
_hit_this_frame = true
|
||||||
_hit()
|
super.hit(damage)
|
||||||
|
|
||||||
|
|
||||||
## Return this node's current damage as a proportion of it's total durability.
|
## Return this node's current damage as a proportion of it's total durability.
|
||||||
|
@ -301,7 +301,7 @@ vault_milestones = Dictionary[int, ExtResource("2_c37ff")]({
|
|||||||
})
|
})
|
||||||
mp3_player_unlocked = false
|
mp3_player_unlocked = false
|
||||||
toothbrush_unlocked = false
|
toothbrush_unlocked = false
|
||||||
stickers_unlocked = true
|
stickers_unlocked = false
|
||||||
mp3_collection = Array[ExtResource("3_yiuq5")]([])
|
mp3_collection = Array[ExtResource("3_yiuq5")]([])
|
||||||
grunk_tank = 0.0
|
grunk_tank = 0.0
|
||||||
grunk_vault = 0.0
|
grunk_vault = 0.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user