Add icons for goals
This commit is contained in:
parent
8886a0d99d
commit
63cb3ef3fe
BIN
godot/assets/goal_icon.png
Normal file
BIN
godot/assets/goal_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.0 KiB |
42
godot/assets/goal_icon.png.import
Normal file
42
godot/assets/goal_icon.png.import
Normal file
@ -0,0 +1,42 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bn21glvbfmyvd"
|
||||
path.s3tc="res://.godot/imported/goal_icon.png-1fe98cf554c289fa7a08923cb33858c6.s3tc.ctex"
|
||||
path.etc2="res://.godot/imported/goal_icon.png-1fe98cf554c289fa7a08923cb33858c6.etc2.ctex"
|
||||
metadata={
|
||||
"imported_formats": ["s3tc_bptc", "etc2_astc"],
|
||||
"vram_texture": true
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/goal_icon.png"
|
||||
dest_files=["res://.godot/imported/goal_icon.png-1fe98cf554c289fa7a08923cb33858c6.s3tc.ctex", "res://.godot/imported/goal_icon.png-1fe98cf554c289fa7a08923cb33858c6.etc2.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=2
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=true
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=0
|
||||
78
godot/raw_assets/goal_icon.svg
Normal file
78
godot/raw_assets/goal_icon.svg
Normal file
@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="210mm"
|
||||
height="297mm"
|
||||
viewBox="0 0 210 297"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
inkscape:version="1.4.4 (dcaf3e7d9e, 2026-05-05)"
|
||||
sodipodi:docname="goal_icon.svg"
|
||||
inkscape:export-filename="../assets/goal_icon.png"
|
||||
inkscape:export-xdpi="120"
|
||||
inkscape:export-ydpi="120"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:zoom="2.0157702"
|
||||
inkscape:cx="222.24756"
|
||||
inkscape:cy="442.01468"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1011"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="layer1"
|
||||
inkscape:export-bgcolor="#ffffff00" />
|
||||
<defs
|
||||
id="defs1" />
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1">
|
||||
<ellipse
|
||||
style="fill:none;stroke:#000000;stroke-width:2.67372;stroke-dasharray:none"
|
||||
id="path2"
|
||||
cx="61.296879"
|
||||
cy="144.29915"
|
||||
rx="22.951746"
|
||||
ry="8.0717163" />
|
||||
<rect
|
||||
style="fill:none;stroke:#000000;stroke-width:2.4738;stroke-dasharray:none"
|
||||
id="rect3"
|
||||
width="0.059541382"
|
||||
height="22.098837"
|
||||
x="38.385548"
|
||||
y="121.17725" />
|
||||
<rect
|
||||
style="fill:none;stroke:#000000;stroke-width:2.4738;stroke-dasharray:none"
|
||||
id="rect3-3"
|
||||
width="0.059541382"
|
||||
height="22.098837"
|
||||
x="84.232483"
|
||||
y="120.43052" />
|
||||
<circle
|
||||
style="fill:none;stroke:#000000;stroke-width:2.5;stroke-dasharray:none"
|
||||
id="path3"
|
||||
cx="59.262398"
|
||||
cy="115.04649"
|
||||
r="6.103436" />
|
||||
<path
|
||||
style="fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-dasharray:12, 1.5;stroke-dashoffset:0;stroke-opacity:1"
|
||||
d="m 63.922011,106.84295 c 10.216192,-9.632488 16.737034,-11.948724 34.52051,1.57507"
|
||||
id="path4"
|
||||
sodipodi:nodetypes="cc" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.4 KiB |
43
godot/raw_assets/goal_icon.svg.import
Normal file
43
godot/raw_assets/goal_icon.svg.import
Normal file
@ -0,0 +1,43 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://cmmtk8f4vvpdf"
|
||||
path="res://.godot/imported/goal_icon.svg-48e59e693e428cdafd0d963c1996b76d.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://raw_assets/goal_icon.svg"
|
||||
dest_files=["res://.godot/imported/goal_icon.svg-48e59e693e428cdafd0d963c1996b76d.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
||||
@ -1,6 +1,7 @@
|
||||
[gd_scene format=3 uid="uid://c1r8nk58cci3a"]
|
||||
|
||||
[ext_resource type="Shader" uid="uid://bafca0fr7yxgo" path="res://shaders/goal_shader.gdshader" id="1_vdq5s"]
|
||||
[ext_resource type="Texture2D" uid="uid://bn21glvbfmyvd" path="res://assets/goal_icon.png" id="2_sxx5i"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_sxx5i"]
|
||||
resource_local_to_scene = true
|
||||
@ -19,8 +20,9 @@ cap_bottom = false
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_1cgct"]
|
||||
radius = 2.0
|
||||
|
||||
[node name="goal" type="Goal" unique_id=177528504 node_paths=PackedStringArray("mesh")]
|
||||
[node name="goal" type="Goal" unique_id=177528504 node_paths=PackedStringArray("mesh", "icon")]
|
||||
mesh = NodePath("mesh_instance_3d")
|
||||
icon = NodePath("goal_icon")
|
||||
collision_layer = 8
|
||||
collision_mask = 11
|
||||
|
||||
@ -31,3 +33,10 @@ mesh = SubResource("CylinderMesh_1cgct")
|
||||
[node name="collision_shape_3d" type="CollisionShape3D" parent="." unique_id=2021568043]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
shape = SubResource("CylinderShape3D_1cgct")
|
||||
|
||||
[node name="goal_icon" type="Sprite3D" parent="." unique_id=625339734]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.9555063, 0)
|
||||
pixel_size = 0.005
|
||||
billboard = 1
|
||||
no_depth_test = true
|
||||
texture = ExtResource("2_sxx5i")
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
use godot::{
|
||||
classes::{Area3D, IArea3D, MeshInstance3D, ShaderMaterial},
|
||||
classes::{Area3D, IArea3D, MeshInstance3D, ShaderMaterial, Sprite3D},
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
@ -17,6 +17,8 @@ pub struct Goal {
|
||||
pub team: u8,
|
||||
#[export]
|
||||
pub mesh: Option<Gd<MeshInstance3D>>,
|
||||
#[export]
|
||||
pub icon: Option<Gd<Sprite3D>>,
|
||||
|
||||
base: Base<Area3D>,
|
||||
}
|
||||
@ -39,20 +41,29 @@ impl IArea3D for Goal {
|
||||
|
||||
impl Goal {
|
||||
fn update_color(&mut self) {
|
||||
if let Some(mesh) = &mut self.mesh
|
||||
&& let Some(mat) = mesh.get_active_material(0)
|
||||
&& let Ok(mut mat) = mat.try_cast::<ShaderMaterial>()
|
||||
let color = if let Some(game) = Game::singleton()
|
||||
&& let Some(team) = game.bind().get_team(self.team)
|
||||
{
|
||||
if let Some(game) = Game::singleton()
|
||||
&& let Some(team) = game.bind().get_team(self.team)
|
||||
Some(team.bind().color())
|
||||
} else if let Some(playback) = &StandaloneReplayManager::singleton().bind().playback
|
||||
&& let Some(team) = playback.bind().replay.teams.get(self.team as usize)
|
||||
{
|
||||
let color: Color = team.color.clone().into();
|
||||
Some(color)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
if let Some(color) = color {
|
||||
if let Some(mesh) = &mut self.mesh
|
||||
&& let Some(mat) = mesh.get_active_material(0)
|
||||
&& let Ok(mut mat) = mat.try_cast::<ShaderMaterial>()
|
||||
{
|
||||
mat.set_shader_parameter("goal_color", &team.bind().color().to_variant());
|
||||
} else if let Some(playback) = &StandaloneReplayManager::singleton().bind().playback
|
||||
&& let Some(team) = playback.bind().replay.teams.get(self.team as usize)
|
||||
{
|
||||
let color: Color = team.color.clone().into();
|
||||
mat.set_shader_parameter("goal_color", &color.to_variant());
|
||||
}
|
||||
if let Some(icon) = &mut self.icon {
|
||||
icon.set_modulate(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user