Add goals
This commit is contained in:
parent
7a7a1c549c
commit
d0558d918c
@ -3,6 +3,7 @@
|
||||
[ext_resource type="PackedScene" uid="uid://ct70bpbca8one" path="res://scenes/player/local_player.tscn" id="1_yjvui"]
|
||||
[ext_resource type="PackedScene" uid="uid://kfxc0migw80o" path="res://scenes/player/remote_player.tscn" id="2_kcncr"]
|
||||
[ext_resource type="PackedScene" uid="uid://dfnbc8sbufa4j" path="res://scenes/misc/ball.tscn" id="3_e0nj3"]
|
||||
[ext_resource type="PackedScene" uid="uid://c1r8nk58cci3a" path="res://scenes/misc/goal.tscn" id="4_w7til"]
|
||||
|
||||
[sub_resource type="ImageTexture" id="ImageTexture_3vyb7"]
|
||||
|
||||
@ -55,7 +56,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.1396794, 3.9666176, 6.2400
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 7.244197, 3.9666176, -6.361364)
|
||||
|
||||
[node name="ball_spawner" type="Node3D" parent="." unique_id=1149426253]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 5.080344, 4.78083, -9.363691)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.03390026, 4.7808294, -0.102864265)
|
||||
|
||||
[node name="killbox" type="Killbox" parent="." unique_id=1018578438]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -5.367467, 0)
|
||||
@ -64,3 +65,10 @@ collision_mask = 7
|
||||
|
||||
[node name="collision_shape_3d" type="CollisionShape3D" parent="killbox" unique_id=447460010]
|
||||
shape = SubResource("BoxShape3D_3g557")
|
||||
|
||||
[node name="goal" parent="." unique_id=177528504 instance=ExtResource("4_w7til")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -12.468555, 0.0050001144, 4.4860663)
|
||||
|
||||
[node name="goal2" parent="." unique_id=1997661586 instance=ExtResource("4_w7til")]
|
||||
team = 1
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8.417626, 0.0050001144, -3.8839006)
|
||||
|
||||
31
godot/scenes/misc/goal.tscn
Normal file
31
godot/scenes/misc/goal.tscn
Normal file
@ -0,0 +1,31 @@
|
||||
[gd_scene format=3 uid="uid://c1r8nk58cci3a"]
|
||||
|
||||
[ext_resource type="Shader" uid="uid://bafca0fr7yxgo" path="res://shaders/goal_shader.gdshader" id="1_vdq5s"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_sxx5i"]
|
||||
resource_local_to_scene = true
|
||||
render_priority = 0
|
||||
shader = ExtResource("1_vdq5s")
|
||||
shader_parameter/goal_color = Vector3(0, 0, 0)
|
||||
|
||||
[sub_resource type="CylinderMesh" id="CylinderMesh_1cgct"]
|
||||
resource_local_to_scene = true
|
||||
material = SubResource("ShaderMaterial_sxx5i")
|
||||
top_radius = 2.0
|
||||
bottom_radius = 2.0
|
||||
cap_top = false
|
||||
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")]
|
||||
mesh = NodePath("mesh_instance_3d")
|
||||
|
||||
[node name="mesh_instance_3d" type="MeshInstance3D" parent="." unique_id=587608036]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0)
|
||||
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")
|
||||
16
godot/shaders/goal_shader.gdshader
Normal file
16
godot/shaders/goal_shader.gdshader
Normal file
@ -0,0 +1,16 @@
|
||||
shader_type spatial;
|
||||
render_mode blend_mix, depth_draw_opaque, depth_test_default, diffuse_lambert, specular_schlick_ggx, world_vertex_coords, cull_disabled;
|
||||
|
||||
uniform vec3 goal_color;
|
||||
|
||||
void vertex() {
|
||||
float height = max(0.0, (1.0 - VERTEX.y));
|
||||
float boost = (sin(TIME) + 3.0)/4.0;
|
||||
COLOR = vec4(goal_color * boost * height, boost * height);
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
ALBEDO = COLOR.xyz;
|
||||
ALPHA = COLOR.w;
|
||||
EMISSION = COLOR.xyz * 2.0;
|
||||
}
|
||||
1
godot/shaders/goal_shader.gdshader.uid
Normal file
1
godot/shaders/goal_shader.gdshader.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://bafca0fr7yxgo
|
||||
34
rust/src/goal.rs
Normal file
34
rust/src/goal.rs
Normal file
@ -0,0 +1,34 @@
|
||||
use godot::{
|
||||
classes::{Area3D, IArea3D, MeshInstance3D, ShaderMaterial},
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
use crate::game_manager::Game;
|
||||
|
||||
#[derive(GodotClass)]
|
||||
#[class(base=Area3D, init)]
|
||||
pub struct Goal {
|
||||
#[export]
|
||||
pub team: u8,
|
||||
#[export]
|
||||
pub mesh: Option<Gd<MeshInstance3D>>,
|
||||
|
||||
base: Base<Area3D>,
|
||||
}
|
||||
|
||||
#[godot_api]
|
||||
impl IArea3D for Goal {
|
||||
fn ready(&mut self) {
|
||||
if let Some(game) = Game::singleton() {
|
||||
if let Some(team) = game.bind().get_team(self.team)
|
||||
&& let Some(mesh) = &mut self.mesh
|
||||
&& let Some(mat) = mesh.get_active_material(0)
|
||||
&& let Ok(mut mat) = mat.try_cast::<ShaderMaterial>()
|
||||
{
|
||||
godot_print!("{}", mat);
|
||||
godot_print!("{}", team.bind().color);
|
||||
mat.set_shader_parameter("goal_color", &team.bind().color.to_variant());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,7 @@ use godot::prelude::*;
|
||||
|
||||
pub mod ball;
|
||||
pub mod game_manager;
|
||||
pub mod goal;
|
||||
pub mod killbox;
|
||||
pub mod map;
|
||||
pub mod map_resource;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user