Enable/Disable environment when entering/exiting breakable wall room

This commit is contained in:
2026-06-06 15:24:34 -07:00
parent 011f72fb63
commit 09db0ccd88
9 changed files with 276 additions and 191 deletions
+4 -3
View File
@@ -8,12 +8,12 @@ namespace Zennysoft.Game.Ma;
public partial class BGMPlayer : DimmableAudioStreamPlayer public partial class BGMPlayer : DimmableAudioStreamPlayer
{ {
private static string _bgmPath = $"res://src/audio/bgm/"; private static readonly string _bgmPath = $"res://src/audio/bgm/";
private IDictionary<BackgroundMusic, AudioStream> _bgmDictionary; private Dictionary<BackgroundMusic, AudioStream> _bgmDictionary;
public override void _Ready() public override void _Ready()
{ {
_bgmDictionary = new Dictionary<BackgroundMusic, AudioStream>(); _bgmDictionary = [];
var backgroundMusic = Enum.GetValues(typeof(BackgroundMusic)); var backgroundMusic = Enum.GetValues(typeof(BackgroundMusic));
foreach (var bgm in backgroundMusic) foreach (var bgm in backgroundMusic)
_bgmDictionary.Add((BackgroundMusic)bgm, GD.Load<AudioStream>(_bgmPath + bgm + ".ogg")); _bgmDictionary.Add((BackgroundMusic)bgm, GD.Load<AudioStream>(_bgmPath + bgm + ".ogg"));
@@ -21,6 +21,7 @@ public partial class BGMPlayer : DimmableAudioStreamPlayer
public void Play(BackgroundMusic backgroundMusic) public void Play(BackgroundMusic backgroundMusic)
{ {
FadeOut();
_bgmDictionary.TryGetValue(backgroundMusic, out var stream); _bgmDictionary.TryGetValue(backgroundMusic, out var stream);
Stream = stream; Stream = stream;
FadeIn(); FadeIn();
@@ -1,16 +1,14 @@
[gd_scene load_steps=7 format=3 uid="uid://6ca5oildpf3n"] [gd_scene load_steps=6 format=3 uid="uid://6ca5oildpf3n"]
[ext_resource type="Script" uid="uid://c5p0e4ywktyvd" path="res://src/items/misc/Plastique.cs" id="1_jk2qh"] [ext_resource type="Script" uid="uid://c5p0e4ywktyvd" path="res://src/items/misc/Plastique.cs" id="1_jk2qh"]
[ext_resource type="Script" uid="uid://b5w4iw4iqmxtn" path="res://src/items/effect/EffectItemStats.cs" id="2_p8vuq"] [ext_resource type="Script" uid="uid://b5w4iw4iqmxtn" path="res://src/items/effect/EffectItemStats.cs" id="2_p8vuq"]
[ext_resource type="Texture2D" uid="uid://tvy57alffi36" path="res://src/items/misc/textures/plastique icon1.png" id="4_vv5l4"] [ext_resource type="Texture2D" uid="uid://mk5pjmup7xgo" path="res://src/items/misc/textures/Plastique.png" id="2_vv5l4"]
[sub_resource type="Resource" id="Resource_p8vuq"]
metadata/__load_path__ = "res://src/items/Icons/plastique icon1.png"
[sub_resource type="Resource" id="Resource_vv5l4"] [sub_resource type="Resource" id="Resource_vv5l4"]
script = ExtResource("2_p8vuq") script = ExtResource("2_p8vuq")
UsableItemTag = 0 UsableItemTag = 0
ElementalDamageType = 4 ElementalDamageType = 4
InitialCount = 0
Name = "Plastique" Name = "Plastique"
StatDescription = "" StatDescription = ""
FlavorText = "Stable destructive substance." FlavorText = "Stable destructive substance."
@@ -30,7 +28,7 @@ CurseResistance = 0
ThrowSpeed = 12.0 ThrowSpeed = 12.0
ThrowDamage = 5 ThrowDamage = 5
ItemTag = 0 ItemTag = 0
Texture = SubResource("Resource_p8vuq") Texture = ExtResource("2_vv5l4")
metadata/_custom_type_script = "uid://b5w4iw4iqmxtn" metadata/_custom_type_script = "uid://b5w4iw4iqmxtn"
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_etomv"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_etomv"]
@@ -55,7 +53,7 @@ double_sided = false
alpha_antialiasing_mode = 1 alpha_antialiasing_mode = 1
texture_filter = 0 texture_filter = 0
render_priority = 100 render_priority = 100
texture = ExtResource("4_vv5l4") texture = ExtResource("2_vv5l4")
[node name="CollisionShape3D" type="CollisionShape3D" parent="Pickup"] [node name="CollisionShape3D" type="CollisionShape3D" parent="Pickup"]
shape = SubResource("CapsuleShape3D_etomv") shape = SubResource("CapsuleShape3D_etomv")
+1 -1
View File
@@ -35,7 +35,7 @@ public partial class SetItem : RigidBody3D
private void ExplosionArea_AreaEntered(Area3D area) private void ExplosionArea_AreaEntered(Area3D area)
{ {
if (area.GetOwner() is ExplodableWall wall) if (area.GetParent() is ExplodableWall wall)
wall.Demolish(); wall.Demolish();
if (area.GetOwner() is IEnemy enemy) if (area.GetOwner() is IEnemy enemy)
enemy.HealthComponent.Damage(10, ElementType.Igneous); enemy.HealthComponent.Damage(10, ElementType.Igneous);
@@ -9,10 +9,18 @@ public partial class ExplodableWall : Node3D
[Node] public StaticBody3D Collision { get; set; } [Node] public StaticBody3D Collision { get; set; }
public bool IsExploded { get; private set; } = false;
[Signal]
public delegate void WallExplodedEventHandler();
public override void _Notification(int what) => this.Notify(what); public override void _Notification(int what) => this.Notify(what);
public void Demolish() public void Demolish()
{ {
AnimationPlayer.Play("Animation"); AnimationPlayer.Play("Animation");
Collision.QueueFree(); Collision.QueueFree();
IsExploded = true;
EmitSignal(SignalName.WallExploded);
} }
} }
File diff suppressed because one or more lines are too long
@@ -0,0 +1,46 @@
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Godot;
[Meta(typeof(IAutoNode))]
public partial class BreakableWallRoom : Node3D
{
public override void _Notification(int what) => this.Notify(what);
[Node] public WorldEnvironment WorldEnvironment { get; set; }
[Node] public Area3D OutsideArea { get; set; }
[Node] public ExplodableWall ExplodableWall { get; set; }
public void OnReady()
{
OutsideArea.AreaEntered += OutsideArea_AreaEntered;
OutsideArea.AreaExited += OutsideArea_AreaExited;
ExplodableWall.WallExploded += ExplodableWall_WallExploded;
}
private void ExplodableWall_WallExploded()
{
OutsideArea.SetDeferred(Area3D.PropertyName.Monitorable, true);
OutsideArea.SetDeferred(Area3D.PropertyName.Monitoring, true);
}
private void OutsideArea_AreaEntered(Area3D area)
{
if (!ExplodableWall.IsExploded)
return;
WorldEnvironment.Environment = GD.Load<Environment>($"res://src/map/dungeon/rooms/Special Rooms/OutsideEnvironment.tres");
WorldEnvironment.CameraAttributes = GD.Load<CameraAttributesPractical>($"res://src/map/dungeon/rooms/Special Rooms/OutsideEnvironmentCameraAtt.tres");
}
private void OutsideArea_AreaExited(Area3D area)
{
if (!ExplodableWall.IsExploded)
return;
WorldEnvironment.Environment = null;
WorldEnvironment.CameraAttributes = null;
}
}
@@ -0,0 +1 @@
uid://c3ptkim7p6muc
@@ -0,0 +1,62 @@
[gd_resource type="Environment" load_steps=4 format=3 uid="uid://kmhqi2bt3dcj"]
[ext_resource type="Shader" uid="uid://c4a68uhm5o2h4" path="res://src/map/map shaders/Altar Sky Environment.gdshader" id="1_uhr3g"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_hlln8"]
shader = ExtResource("1_uhr3g")
shader_parameter/day_top_color = Color(0.110511, 0.211694, 0.207729, 1)
shader_parameter/day_bottom_color = Color(0.330221, 0.542076, 0.605553, 1)
shader_parameter/sunset_top_color = Color(0.375928, 0.529835, 0.733631, 1)
shader_parameter/sunset_bottom_color = Color(0, 0.263846, 0.458067, 1)
shader_parameter/night_top_color = Color(0.02, 0, 0.04, 1)
shader_parameter/night_bottom_color = Color(0.1, 0, 0.2, 1)
shader_parameter/horizon_color = Color(0, 0.7, 0.8, 1)
shader_parameter/horizon_blur = 0.25
shader_parameter/sun_color = Color(0.900585, 0.632559, 0.334535, 1)
shader_parameter/sun_sunset_color = Color(0.806005, 0, 0.0992685, 1)
shader_parameter/sun_size = 0.062
shader_parameter/sun_blur = 0.214
shader_parameter/moon_color = Color(1, 0.95, 0.7, 1)
shader_parameter/moon_size = 0.06
shader_parameter/moon_blur = 0.1
shader_parameter/clouds_edge_color = Color(1, 1, 1, 1)
shader_parameter/clouds_top_color = Color(1, 1, 1, 1)
shader_parameter/clouds_middle_color = Color(0.92, 0.92, 0.98, 1)
shader_parameter/clouds_bottom_color = Color(0.99, 0.99, 0.99, 1)
shader_parameter/clouds_speed = 20.0
shader_parameter/clouds_direction = -0.276923
shader_parameter/clouds_scale = 4.0
shader_parameter/clouds_cutoff = 0.32
shader_parameter/clouds_fuzziness = 0.35
shader_parameter/clouds_weight = 0.0
shader_parameter/clouds_blur = 0.12
shader_parameter/stars_speed = 1.0
shader_parameter/overwritten_time = 0.0
[sub_resource type="Sky" id="Sky_gbv4o"]
resource_local_to_scene = true
sky_material = SubResource("ShaderMaterial_hlln8")
[resource]
resource_local_to_scene = true
background_mode = 2
sky = SubResource("Sky_gbv4o")
ambient_light_source = 1
reflected_light_source = 1
sdfgi_use_occlusion = true
sdfgi_read_sky_light = false
sdfgi_min_cell_size = 0.01
sdfgi_cascade0_distance = 0.64
sdfgi_max_distance = 10.24
glow_enabled = true
glow_intensity = 0.46
glow_strength = 0.7
glow_bloom = 0.2
glow_blend_mode = 0
fog_density = 0.0565
fog_height = -47.63
fog_height_density = 0.2481
volumetric_fog_enabled = true
volumetric_fog_density = 0.01
volumetric_fog_albedo = Color(0.439054, 0.435171, 0.424614, 1)
volumetric_fog_emission_energy = 0.0
@@ -0,0 +1,7 @@
[gd_resource type="CameraAttributesPractical" format=3 uid="uid://dmxxjkk3faxy6"]
[resource]
auto_exposure_enabled = true
dof_blur_far_enabled = true
dof_blur_far_distance = 29.84
dof_blur_amount = 0.06