Add day_started signal and related functionality to event bus and systems
This commit is contained in:
15
max-effort/Scenes/.idea/.gitignore
generated
vendored
15
max-effort/Scenes/.idea/.gitignore
generated
vendored
@@ -1,15 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Rider ignored files
|
||||
/projectSettingsUpdater.xml
|
||||
/.idea.Scenes.iml
|
||||
/modules.xml
|
||||
/contentModel.xml
|
||||
# Ignored default folder with query files
|
||||
/queries/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Ask2AgentMigrationStateService">
|
||||
<option name="migrationStatus" value="COMPLETED" />
|
||||
</component>
|
||||
</project>
|
||||
4
max-effort/Scenes/.idea/encodings.xml
generated
4
max-effort/Scenes/.idea/encodings.xml
generated
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||
</project>
|
||||
8
max-effort/Scenes/.idea/indexLayout.xml
generated
8
max-effort/Scenes/.idea/indexLayout.xml
generated
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,6 +0,0 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
</profile>
|
||||
</component>
|
||||
@@ -10,5 +10,6 @@ pub const LIFT_VISUAL_HEIGHT: &str = "lift_visual_height";
|
||||
pub const CAMERA_TRAUMA: &str = "camera_trauma";
|
||||
pub const HAZARD_SPAWNED: &str = "hazard_spawned";
|
||||
pub const HAZARD_RESOLVED: &str = "hazard_resolved";
|
||||
pub const DAY_STARTED: &str = "day_started";
|
||||
|
||||
pub const VIGNETTE_INTENSITY_PARAM: &str = "vignette_intensity";
|
||||
|
||||
@@ -43,6 +43,9 @@ impl EventBus {
|
||||
#[signal]
|
||||
fn hazard_resolved(type_: HazardType);
|
||||
|
||||
#[signal]
|
||||
fn day_started(day_index: i32);
|
||||
|
||||
#[func]
|
||||
pub fn publish_lift_effort(&mut self, strength: f32) {
|
||||
self.base_mut()
|
||||
@@ -95,4 +98,10 @@ impl EventBus {
|
||||
self.base_mut()
|
||||
.emit_signal("hazard_resolved", &[type_.to_variant()]);
|
||||
}
|
||||
|
||||
#[func]
|
||||
pub fn publish_day_started(&mut self, day_index: i32) {
|
||||
self.base_mut()
|
||||
.emit_signal("day_started", &[day_index.to_variant()]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,12 +93,13 @@ impl BenchPressSystem {
|
||||
self.current_progress += self.power_per_click * delta;
|
||||
|
||||
if self.current_progress >= self.target_value {
|
||||
bus.clone().bind_mut().publish_lift_completed(true);
|
||||
self.is_lift_complete = true;
|
||||
bus.call_deferred("publish_lift_completed", &[true.to_variant()]);
|
||||
}
|
||||
}
|
||||
|
||||
#[func]
|
||||
fn on_lift_completed(&mut self) {
|
||||
fn on_lift_completed(&mut self, _success: bool) {
|
||||
self.is_lift_complete = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ impl INode for CameraShakeSystem {
|
||||
&self.base().callable("on_focus_changed"),
|
||||
);
|
||||
bus.connect(consts::CAMERA_TRAUMA, &self.base().callable("add_trauma"));
|
||||
bus.connect(consts::DAY_STARTED, &self.base().callable("on_day_started"));
|
||||
|
||||
self.event_bus = Some(bus);
|
||||
}
|
||||
@@ -103,4 +104,15 @@ impl CameraShakeSystem {
|
||||
self.trauma += amount;
|
||||
self.trauma = self.trauma.clamp(0.0, 1.0);
|
||||
}
|
||||
|
||||
#[func]
|
||||
fn on_day_started(&mut self, _day_index: i32) {
|
||||
self.trauma = 0.0;
|
||||
self.current_focus = 0.0;
|
||||
|
||||
if let Some(camera) = &mut self.camera {
|
||||
camera.set_offset(Vector2::ZERO);
|
||||
camera.set_rotation(0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,9 @@ impl INode for DeadliftSystem {
|
||||
|
||||
if self.hold_timer >= self.target_value {
|
||||
bus.clone().bind_mut().publish_camera_trauma(1.0);
|
||||
bus.clone().bind_mut().publish_lift_completed(true);
|
||||
|
||||
bus.call_deferred("publish_lift_completed", &[true.to_variant()]);
|
||||
self.is_lift_complete = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,7 +136,7 @@ impl DeadliftSystem {
|
||||
}
|
||||
|
||||
#[func]
|
||||
fn on_lift_completed(&mut self) {
|
||||
fn on_lift_completed(&mut self, _success: bool) {
|
||||
self.is_lift_complete = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -120,6 +120,10 @@ impl GameManager {
|
||||
.set_available_hazards(config_bind.available_hazards.clone());
|
||||
}
|
||||
|
||||
if let Some(bus) = &mut self.event_bus {
|
||||
bus.clone().bind_mut().publish_day_started(index);
|
||||
}
|
||||
|
||||
if let Some(l) = &mut self.day_label {
|
||||
l.set_text(&config_bind.day_title);
|
||||
}
|
||||
@@ -136,9 +140,6 @@ impl GameManager {
|
||||
game.queue_free();
|
||||
self.current_mini_game = None;
|
||||
}
|
||||
if let Some(hs) = &mut self.hazard_system {
|
||||
hs.bind_mut().clear_hazards();
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_win(&mut self) {
|
||||
|
||||
@@ -56,6 +56,8 @@ impl INode for HazardSystem {
|
||||
&self.base().callable("on_hazard_resolved"),
|
||||
);
|
||||
|
||||
bus.connect(consts::DAY_STARTED, &self.base().callable("on_day_started"));
|
||||
|
||||
self.event_bus = Some(bus);
|
||||
}
|
||||
|
||||
@@ -170,4 +172,11 @@ impl HazardSystem {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[func]
|
||||
fn on_day_started(&mut self, _day_index: i32) {
|
||||
self.clear_hazards();
|
||||
self.timer = 0.0;
|
||||
self.current_focus = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ impl INode for TunnelSystem {
|
||||
consts::FOCUS_RELEASED,
|
||||
&self.base().callable("on_focus_release"),
|
||||
);
|
||||
bus.connect(consts::DAY_STARTED, &self.base().callable("on_day_started"));
|
||||
|
||||
self.event_bus = Some(bus);
|
||||
}
|
||||
@@ -114,4 +115,22 @@ impl TunnelSystem {
|
||||
fn on_focus_release(&mut self) {
|
||||
self.is_efforting = false;
|
||||
}
|
||||
|
||||
#[func]
|
||||
fn on_day_started(&mut self, _day_index: i32) {
|
||||
self.current_focus = 0.0;
|
||||
self.is_efforting = false;
|
||||
|
||||
if let Some(overlay) = &mut self.vignette_overlay {
|
||||
if let Some(material) = overlay.get_material() {
|
||||
if let Ok(mut mat) = material.try_cast::<ShaderMaterial>() {
|
||||
mat.set_shader_parameter(consts::VIGNETTE_INTENSITY_PARAM, &0.0.to_variant());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(bus) = &mut self.event_bus {
|
||||
bus.bind_mut().publish_focus_changed(0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user