Custom appearance for sticky hearts

main
copygirl 2 weeks ago
parent 6998da4fdd
commit 5ee2543a42
  1. 33
      Resources/heart.gd
  2. BIN
      Resources/heart.glb
  3. 16
      Resources/heart.tscn
  4. BIN
      Resources/heart_inner.glb
  5. 37
      Resources/heart_inner.glb.import
  6. 64
      copyThrower.gd

@ -22,9 +22,11 @@ var sticky := false
# heart sticks to a character, it can return here once it unsticks.
@onready var original_parent: Node = get_parent()
static var stream_normal: AudioStream = load("res://Mods/copyThrower/Resources/normal_randomizer.tres")
static var stream_sticky: AudioStream = load("res://Mods/copyThrower/Resources/sticky_randomizer.tres")
# A cache of StandardMaterial3D materials created from colors and textures, with transparent variants.
static var material_cache: Dictionary[Variant, Dictionary]
func _ready() -> void:
body_entered.connect(on_body_entered)
@ -42,11 +44,34 @@ func set_size(value: float) -> void:
func set_sticky(value: bool) -> void:
sticky = value
$Model/Inner.visible = value
if value: $AudioStreamPlayer3D.stream = stream_sticky
else: $AudioStreamPlayer3D.stream = stream_normal
func set_material(material: StandardMaterial3D) -> void:
$Model/Heart.material_override = material
func set_material(value: Variant) -> void:
if not material_cache.has(value):
var material_normal: StandardMaterial3D
if value is Material:
material_normal = value
elif value is Color:
material_normal = StandardMaterial3D.new()
material_normal.albedo_color = value
elif value is Texture2D:
material_normal = StandardMaterial3D.new()
material_normal.albedo_texture = value
else: printerr("unsupported value type");
# Create an additional material that's semi-transparent.
var material_sticky := material_normal.duplicate()
material_sticky.transparency = BaseMaterial3D.TRANSPARENCY_ALPHA
material_sticky.albedo_color.a = 0.5
material_cache[value] = { normal = material_normal, sticky = material_sticky }
var material := material_cache[value]
# NOTE: Assuming this function is called after set_sticky.
var sticky_str := "sticky" if sticky else "normal"
$Model/Outer/Heart.material_override = material[sticky_str]
$Model/Inner/Heart.material_override = material["normal"]
func _process(delta: float) -> void:

Binary file not shown.

@ -1,8 +1,9 @@
[gd_scene load_steps=5 format=3 uid="uid://m7kmum7ygiw2"]
[gd_scene load_steps=6 format=3 uid="uid://m7kmum7ygiw2"]
[ext_resource type="Script" uid="uid://ba4w1hier1kps" path="res://Mods/copyThrower/Resources/heart.gd" id="1_h4gh1"]
[ext_resource type="PackedScene" uid="uid://bryal7hhfonuv" path="res://Mods/copyThrower/Resources/heart.glb" id="1_liglp"]
[ext_resource type="AudioStream" uid="uid://jmgp1vmm5mdf" path="res://Mods/copyThrower/Resources/sticky_randomizer.tres" id="3_4n8sw"]
[ext_resource type="AudioStream" uid="uid://by5roe3uixyln" path="res://Mods/copyThrower/Resources/normal_randomizer.tres" id="3_4n8sw"]
[ext_resource type="PackedScene" uid="uid://ci53c7a5h2ew4" path="res://Mods/copyThrower/Resources/heart_inner.glb" id="4_2dw4y"]
[sub_resource type="CylinderShape3D" id="CylinderShape3D_rfhqb"]
height = 0.04
@ -13,9 +14,6 @@ contact_monitor = true
max_contacts_reported = 1
script = ExtResource("1_h4gh1")
[node name="Model" parent="." instance=ExtResource("1_liglp")]
transform = Transform3D(0.6, 0, 0, 0, 0.6, 0, 0, 0, 0.6, 0, 0, 0)
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 0, 0)
shape = SubResource("CylinderShape3D_rfhqb")
@ -24,3 +22,11 @@ shape = SubResource("CylinderShape3D_rfhqb")
stream = ExtResource("3_4n8sw")
attenuation_model = 3
volume_db = -2.0
[node name="Model" type="Node3D" parent="."]
transform = Transform3D(0.6, 0, 0, 0, 0.6, 0, 0, 0, 0.6, 0, 0, 0)
[node name="Outer" parent="Model" instance=ExtResource("1_liglp")]
[node name="Inner" parent="Model" instance=ExtResource("4_2dw4y")]
visible = false

Binary file not shown.

@ -0,0 +1,37 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://ci53c7a5h2ew4"
path="res://.godot/imported/heart_inner.glb-bffbd9f247776c2e62af12110cb6c91a.scn"
[deps]
source_file="res://Mods/copyThrower/Resources/heart_inner.glb"
dest_files=["res://.godot/imported/heart_inner.glb-bffbd9f247776c2e62af12110cb6c91a.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
_subresources={}
gltf/naming_version=1
gltf/embedded_image_handling=1

@ -21,31 +21,31 @@ var current_head_bump := Quaternion.IDENTITY
var triggers = {
# First number is chance to stick.
"" : [ 0.15, colored_heart(Color.RED) ],
"🧡" : [ 0.15, colored_heart(Color.ORANGE) ],
"💛" : [ 0.15, colored_heart(Color.YELLOW) ],
"💚" : [ 0.15, colored_heart(Color.GREEN) ],
"🩵" : [ 0.15, colored_heart(Color.AQUA) ],
"💙" : [ 0.15, colored_heart(Color.BLUE) ],
"💜" : [ 0.15, colored_heart(Color.PURPLE) ],
"🩷" : [ 0.15, colored_heart(Color.PINK) ],
"🤎" : [ 0.15, colored_heart(Color.BROWN) ],
"🖤" : [ 0.15, colored_heart(Color(0.1, 0.1, 0.1)) ],
"🩶" : [ 0.15, colored_heart(Color.DARK_GRAY) ],
"🤍" : [ 0.15, colored_heart(Color.WHITE_SMOKE) ],
"" : [ 0.15, colored_heart(Color.RED) ], # Oldschool heart
"<3" : [ 0.15, colored_heart(Color8(145, 70, 255)) ], # Twitch purple heart
"AsexualPride" : [ 0.15, textured_heart("asexual") ],
"BisexualPride" : [ 0.15, textured_heart("bisexual") ],
"GayPride" : [ 0.15, textured_heart("gay") ],
"GenderFluidPride" : [ 0.15, textured_heart("genderfluid") ],
"IntersexPride" : [ 0.15, textured_heart("intersex") ],
"LesbianPride" : [ 0.15, textured_heart("lesbian") ],
"NonbinaryPride" : [ 0.15, textured_heart("nonbinary") ],
"PansexualPride" : [ 0.15, textured_heart("pansexual") ],
"TransgenderPride" : [ 0.15, textured_heart("transgender") ],
"" : [ 0.15, Color.RED ],
"🧡" : [ 0.25, Color.ORANGE ],
"💛" : [ 0.15, Color.YELLOW ],
"💚" : [ 0.35, Color.GREEN ],
"🩵" : [ 0.15, Color.AQUA ],
"💙" : [ 0.15, Color.BLUE ],
"💜" : [ 0.35, Color.PURPLE ],
"🩷" : [ 0.15, Color.PINK ],
"🤎" : [ 0.15, Color.BROWN ],
"🖤" : [ 0.15, Color(0.1, 0.1, 0.1) ],
"🩶" : [ 0.15, Color.DARK_GRAY ],
"🤍" : [ 0.15, Color.WHITE_SMOKE ],
"" : [ 0.15, Color.RED ], # Oldschool heart
"<3" : [ 0.35, Color8(145, 70, 255) ], # Twitch purple heart
"AsexualPride" : [ 0.25, pride("asexual") ],
"BisexualPride" : [ 0.15, pride("bisexual") ],
"GayPride" : [ 0.15, pride("gay") ],
"GenderFluidPride" : [ 0.15, pride("genderfluid") ],
"IntersexPride" : [ 0.15, pride("intersex") ],
"LesbianPride" : [ 0.35, pride("lesbian") ],
"NonbinaryPride" : [ 0.15, pride("nonbinary") ],
"PansexualPride" : [ 0.15, pride("pansexual") ],
"TransgenderPride" : [ 0.35, pride("transgender") ],
}
var queue: Array[RigidBody3D] = []
@ -61,7 +61,7 @@ func handle_channel_chat_message(
# Collect all the matching substrings in the `matches` array.
for trigger in triggers:
var sticky: float = triggers[trigger][0]
var material: StandardMaterial3D = triggers[trigger][1]
var material: Variant = triggers[trigger][1]
var from_index := 0
while true:
var found := message.find(trigger, from_index)
@ -163,13 +163,5 @@ func on_collide(object: RigidBody3D, body: CharacterBody3D) -> void:
vel.y *= 0.25 # Less vertical influence.
body_bump += vel * object.size * 0.05
static func colored_heart(color: Color) -> StandardMaterial3D:
var material := StandardMaterial3D.new()
material.albedo_color = color
return material
static func textured_heart(pride: String) -> StandardMaterial3D:
var texture: Texture2D = load("res://Mods/copyThrower/Resources/pride/" + pride + ".png")
var material := StandardMaterial3D.new()
material.albedo_texture = texture
return material
static func pride(value: String) -> Texture2D:
return load("res://Mods/copyThrower/Resources/pride/" + value + ".png")

Loading…
Cancel
Save