Description:
Pause when dialog opens.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -0,0 +1,47 | |||||
|
|
1 | using System; | ||
|
|
2 | using System.Linq; | ||
|
|
3 | using System.Collections.Generic; | ||
|
|
4 | |||
|
|
5 | using Microsoft.Xna.Framework; | ||
|
|
6 | |||
|
|
7 | using Encompass; | ||
|
|
8 | |||
|
|
9 | using isometricparkfna.Messages; | ||
|
|
10 | using isometricparkfna.Components; | ||
|
|
11 | |||
|
|
12 | namespace isometricparkfna.Engines | ||
|
|
13 | { | ||
|
|
14 | [Receives(typeof(GameRateMessage), typeof(TogglePauseMessage))] | ||
|
|
15 | public class SimulationGameRateBridgeEngine : Engine | ||
|
|
16 | { | ||
|
|
17 | public Simulation simulation; | ||
|
|
18 | private Random random_generator; | ||
|
|
19 | |||
|
|
20 | public SimulationGameRateBridgeEngine(Simulation simulation) | ||
|
|
21 | { | ||
|
|
22 | this.simulation = simulation; | ||
|
|
23 | this.random_generator = new Random(); | ||
|
|
24 | |||
|
|
25 | } | ||
|
|
26 | |||
|
|
27 | |||
|
|
28 | public override void Update(double dt) | ||
|
|
29 | { | ||
|
|
30 | foreach (ref readonly var message in ReadMessages<GameRateMessage>()) | ||
|
|
31 | { | ||
|
|
32 | this.simulation.paused = message.paused; | ||
|
|
33 | if (message.rate != null) | ||
|
|
34 | { | ||
|
|
35 | this.simulation.setRate(message.rate ?? 0); | ||
|
|
36 | } | ||
|
|
37 | } | ||
|
|
38 | |||
|
|
39 | foreach (ref readonly var message in ReadMessages<TogglePauseMessage>()) | ||
|
|
40 | { | ||
|
|
41 | this.simulation.paused = !this.simulation.paused; | ||
|
|
42 | } | ||
|
|
43 | |||
|
|
44 | } | ||
|
|
45 | |||
|
|
46 | } | ||
|
|
47 | } |
@@ -54,7 +54,7 | |||||
|
54 |
|
54 | ||
|
55 | var campaignEntity = CreateEntity(); |
|
55 | var campaignEntity = CreateEntity(); |
|
56 |
|
56 | ||
|
57 |
AddComponent(campaignEntity, new TreeDeltaComponent{deltaTrees = new Fact<int>( |
|
57 | AddComponent(campaignEntity, new TreeDeltaComponent{deltaTrees = new Fact<int>(50*12)}); |
|
58 | AddComponent(campaignEntity, new EventComponent{}); |
|
58 | AddComponent(campaignEntity, new EventComponent{}); |
|
59 | } |
|
59 | } |
|
60 | if (this.Random.Next(0, 100) == 4) |
|
60 | if (this.Random.Next(0, 100) == 4) |
@@ -63,7 +63,7 | |||||
|
63 |
|
63 | ||
|
64 | var campaignEntity = CreateEntity(); |
|
64 | var campaignEntity = CreateEntity(); |
|
65 |
|
65 | ||
|
66 |
AddComponent(campaignEntity, new TreeDeltaComponent{deltaTrees = new Fact<int>(-1 |
|
66 | AddComponent(campaignEntity, new TreeDeltaComponent{deltaTrees = new Fact<int>(-50*12)}); |
|
67 | AddComponent(campaignEntity, new EventComponent{}); |
|
67 | AddComponent(campaignEntity, new EventComponent{}); |
|
68 |
|
68 | ||
|
69 | SendMessage(new SpawnDialogMessage { Path = "MassVandalism" }); |
|
69 | SendMessage(new SpawnDialogMessage { Path = "MassVandalism" }); |
@@ -12,7 +12,6 | |||||
|
12 | namespace isometricparkfna.Engines |
|
12 | namespace isometricparkfna.Engines |
|
13 | { |
|
13 | { |
|
14 |
|
14 | ||
|
15 | [Receives(typeof(GameRateMessage), typeof(TogglePauseMessage))] |
|
||
|
16 |
|
|
15 | [Sends(typeof(SpawnContractMessage), typeof(SpawnDialogMessage), typeof(TickMessage))] |
|
17 | [Reads(typeof(AreaComponent), |
|
16 | [Reads(typeof(AreaComponent), |
|
18 | typeof(BudgetComponent), |
|
17 | typeof(BudgetComponent), |
@@ -66,19 +65,6 | |||||
|
66 | }); |
|
65 | }); |
|
67 | } |
|
66 | } |
|
68 |
|
67 | ||
|
69 | foreach (ref readonly var message in ReadMessages<GameRateMessage>()) |
|
||
|
70 | { |
|
||
|
71 | this.simulation.paused = message.paused; |
|
||
|
72 | if (message.rate != null) |
|
||
|
73 | { |
|
||
|
74 | this.simulation.setRate(message.rate ?? 0); |
|
||
|
75 | } |
|
||
|
76 | } |
|
||
|
77 |
|
|||
|
78 | foreach (ref readonly var message in ReadMessages<TogglePauseMessage>()) |
|
||
|
79 | { |
|
||
|
80 | this.simulation.paused = !this.simulation.paused; |
|
||
|
81 | } |
|
||
|
82 |
|
68 | ||
|
83 | decimal new_contract_amount = 0M; |
|
69 | decimal new_contract_amount = 0M; |
|
84 | decimal new_enforcement_amount = 0M; |
|
70 | decimal new_enforcement_amount = 0M; |
@@ -21,6 +21,7 | |||||
|
21 |
|
21 | ||
|
22 | [Reads(typeof(DialogComponent))] |
|
22 | [Reads(typeof(DialogComponent))] |
|
23 | [Receives(typeof(SpawnDialogMessage))] |
|
23 | [Receives(typeof(SpawnDialogMessage))] |
|
|
24 | [Sends(typeof(GameRateMessage))] | ||
|
24 | class DialogSpawner : Spawner<SpawnDialogMessage> |
|
25 | class DialogSpawner : Spawner<SpawnDialogMessage> |
|
25 |
|
26 | ||
|
26 | { |
|
27 | { |
@@ -108,6 +109,7 | |||||
|
108 | ImageIndex = index}); |
|
109 | ImageIndex = index}); |
|
109 |
|
110 | ||
|
110 | Logging.Success("Spawned new dialog."); |
|
111 | Logging.Success("Spawned new dialog."); |
|
|
112 | SendMessage(new GameRateMessage { paused = true }); | ||
|
111 | } |
|
113 | } |
|
112 | else |
|
114 | else |
|
113 | { |
|
115 | { |
@@ -269,6 +269,8 | |||||
|
269 | WorldBuilder.AddEngine(new DialogSpawner(this.Story, this.grammar)); |
|
269 | WorldBuilder.AddEngine(new DialogSpawner(this.Story, this.grammar)); |
|
270 | WorldBuilder.AddEngine(new PolicyEngine()); |
|
270 | WorldBuilder.AddEngine(new PolicyEngine()); |
|
271 | WorldBuilder.AddEngine(new TraceryBridgeEngine(this.grammar)); |
|
271 | WorldBuilder.AddEngine(new TraceryBridgeEngine(this.grammar)); |
|
|
272 | WorldBuilder.AddEngine(new SimulationGameRateBridgeEngine(this.simulation)); | ||
|
|
273 | |||
|
272 |
|
274 | ||
|
273 | WorldBuilder.AddGeneralRenderer(new AreaRenderer(this.batch, this.monoFont), 1); |
|
275 | WorldBuilder.AddGeneralRenderer(new AreaRenderer(this.batch, this.monoFont), 1); |
|
274 | WorldBuilder.AddGeneralRenderer(new ImGuiWindowRenderer(this, this.simulation, this.imGuiWindowBridgeEngine, this.gdm) , 2); |
|
276 | WorldBuilder.AddGeneralRenderer(new ImGuiWindowRenderer(this, this.simulation, this.imGuiWindowBridgeEngine, this.gdm) , 2); |
You need to be logged in to leave comments.
Login now