# HG changeset patch # User Alys Brooks # Date 2021-11-17 08:24:50 # Node ID 5ba5c12dbc67c597c39cbb587f09713f1e6cb710 # Parent 88f7be5927888ec17f5a209fce236284081abd90 Pause when dialog opens. diff --git a/isometric-park-fna/Engines/EventEngine.cs b/isometric-park-fna/Engines/EventEngine.cs --- a/isometric-park-fna/Engines/EventEngine.cs +++ b/isometric-park-fna/Engines/EventEngine.cs @@ -54,7 +54,7 @@ var campaignEntity = CreateEntity(); - AddComponent(campaignEntity, new TreeDeltaComponent{deltaTrees = new Fact(40)}); + AddComponent(campaignEntity, new TreeDeltaComponent{deltaTrees = new Fact(50*12)}); AddComponent(campaignEntity, new EventComponent{}); } if (this.Random.Next(0, 100) == 4) @@ -63,7 +63,7 @@ var campaignEntity = CreateEntity(); - AddComponent(campaignEntity, new TreeDeltaComponent{deltaTrees = new Fact(-100)}); + AddComponent(campaignEntity, new TreeDeltaComponent{deltaTrees = new Fact(-50*12)}); AddComponent(campaignEntity, new EventComponent{}); SendMessage(new SpawnDialogMessage { Path = "MassVandalism" }); diff --git a/isometric-park-fna/Engines/SimulationBridgeEngine.cs b/isometric-park-fna/Engines/SimulationBridgeEngine.cs --- a/isometric-park-fna/Engines/SimulationBridgeEngine.cs +++ b/isometric-park-fna/Engines/SimulationBridgeEngine.cs @@ -12,7 +12,6 @@ namespace isometricparkfna.Engines { - [Receives(typeof(GameRateMessage), typeof(TogglePauseMessage))] [Sends(typeof(SpawnContractMessage), typeof(SpawnDialogMessage), typeof(TickMessage))] [Reads(typeof(AreaComponent), typeof(BudgetComponent), @@ -66,19 +65,6 @@ }); } - foreach (ref readonly var message in ReadMessages()) - { - this.simulation.paused = message.paused; - if (message.rate != null) - { - this.simulation.setRate(message.rate ?? 0); - } - } - - foreach (ref readonly var message in ReadMessages()) - { - this.simulation.paused = !this.simulation.paused; - } decimal new_contract_amount = 0M; decimal new_enforcement_amount = 0M; diff --git a/isometric-park-fna/Engines/SimulationGameRateBridgeEngine.cs b/isometric-park-fna/Engines/SimulationGameRateBridgeEngine.cs new file mode 100644 --- /dev/null +++ b/isometric-park-fna/Engines/SimulationGameRateBridgeEngine.cs @@ -0,0 +1,47 @@ +using System; +using System.Linq; +using System.Collections.Generic; + +using Microsoft.Xna.Framework; + +using Encompass; + +using isometricparkfna.Messages; +using isometricparkfna.Components; + +namespace isometricparkfna.Engines +{ + [Receives(typeof(GameRateMessage), typeof(TogglePauseMessage))] + public class SimulationGameRateBridgeEngine : Engine + { + public Simulation simulation; + private Random random_generator; + + public SimulationGameRateBridgeEngine(Simulation simulation) + { + this.simulation = simulation; + this.random_generator = new Random(); + + } + + + public override void Update(double dt) + { + foreach (ref readonly var message in ReadMessages()) + { + this.simulation.paused = message.paused; + if (message.rate != null) + { + this.simulation.setRate(message.rate ?? 0); + } + } + + foreach (ref readonly var message in ReadMessages()) + { + this.simulation.paused = !this.simulation.paused; + } + + } + + } +} diff --git a/isometric-park-fna/Engines/Spawners/DialogSpawner.cs b/isometric-park-fna/Engines/Spawners/DialogSpawner.cs --- a/isometric-park-fna/Engines/Spawners/DialogSpawner.cs +++ b/isometric-park-fna/Engines/Spawners/DialogSpawner.cs @@ -21,6 +21,7 @@ [Reads(typeof(DialogComponent))] [Receives(typeof(SpawnDialogMessage))] + [Sends(typeof(GameRateMessage))] class DialogSpawner : Spawner { @@ -108,6 +109,7 @@ ImageIndex = index}); Logging.Success("Spawned new dialog."); + SendMessage(new GameRateMessage { paused = true }); } else { diff --git a/isometric-park-fna/FNAGame.cs b/isometric-park-fna/FNAGame.cs --- a/isometric-park-fna/FNAGame.cs +++ b/isometric-park-fna/FNAGame.cs @@ -269,6 +269,8 @@ WorldBuilder.AddEngine(new DialogSpawner(this.Story, this.grammar)); WorldBuilder.AddEngine(new PolicyEngine()); WorldBuilder.AddEngine(new TraceryBridgeEngine(this.grammar)); + WorldBuilder.AddEngine(new SimulationGameRateBridgeEngine(this.simulation)); + WorldBuilder.AddGeneralRenderer(new AreaRenderer(this.batch, this.monoFont), 1); WorldBuilder.AddGeneralRenderer(new ImGuiWindowRenderer(this, this.simulation, this.imGuiWindowBridgeEngine, this.gdm) , 2);