Description:
Clean up indentation.
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r610:0cfd5b8d29fc -

@@ -12,48 +12,42
12 [Reads(typeof(TrespassingPolicyComponent))]
12 [Reads(typeof(TrespassingPolicyComponent))]
13 [Writes(typeof(TrespassingPolicyComponent),
13 [Writes(typeof(TrespassingPolicyComponent),
14 typeof(BudgetLineComponent))]
14 typeof(BudgetLineComponent))]
15 public class PolicyEngine : Engine
15 public class PolicyEngine : Engine
16 {
16 {
17
18 public PolicyEngine()
17 public PolicyEngine()
19 {
18 {
20 }
19 }
21
20
22
23 public override void Update(double dt)
21 public override void Update(double dt)
24 {
22 {
25 foreach (ref readonly var message
23 foreach (ref readonly var message
26 in ReadMessages<SetTrespassingPolicyMessage>())
24 in ReadMessages<SetTrespassingPolicyMessage>())
27 {
25 {
28 foreach (ref readonly var entity
26 foreach (ref readonly var entity
29 in ReadEntities<TrespassingPolicyComponent>())
27 in ReadEntities<TrespassingPolicyComponent>())
30 {
28 {
31
29
32 SetComponent<TrespassingPolicyComponent>(entity,
30 SetComponent<TrespassingPolicyComponent>(entity,
33 new TrespassingPolicyComponent
31 new TrespassingPolicyComponent
34 {
32 {
35 tresspassingPolicy
33 tresspassingPolicy
36 = message.newEnforcementLevel
34 = message.newEnforcementLevel
37 });
35 });
38
36
39 var newCost = message.newEnforcementLevel switch {
37 var newCost = message.newEnforcementLevel switch {
40 EnforcementLevel.Unspecified => 0,
38 EnforcementLevel.Unspecified => 0,
41 EnforcementLevel.NoEnforcement => 0,
39 EnforcementLevel.NoEnforcement => 0,
42 EnforcementLevel.EnforcedWithWarnings => 100,
40 EnforcementLevel.EnforcedWithWarnings => 100,
43 EnforcementLevel.EnforcedWithFines => 100,
41 EnforcementLevel.EnforcedWithFines => 100,
44 _ => 0 //C# enums can take on non-declared vaues. Sigh.
42 _ => 0 //C# enums can take on non-declared vaues. Sigh.
45 };
43 };
46
44
47 SetComponent<BudgetLineComponent>(entity,
45 SetComponent<BudgetLineComponent>(entity,
48 new BudgetLineComponent
46 new BudgetLineComponent
49 {
47 {category = "Enforcement",
50 category = "Enforcement",
48 amount = newCost});
51 amount = newCost
52 });
53 }
49 }
54 }
50 }
55
56 }
51 }
57
58 }
52 }
59 }
53 }
@@ -75,10 +75,6
75 decimal new_contract_amount = 0M;
75 decimal new_contract_amount = 0M;
76 decimal new_enforcement_amount = 0M;
76 decimal new_enforcement_amount = 0M;
77 decimal new_misc_amount = 0M;
77 decimal new_misc_amount = 0M;
78 // decimal new_upkeep_amount = 0M;
79
80 // this.simulation.PreserveCells.Clear();
81
82
78
83 foreach (ref readonly var entity in ReadEntities<BudgetLineComponent>())
79 foreach (ref readonly var entity in ReadEntities<BudgetLineComponent>())
84 {
80 {
@@ -102,14 +98,11
102 new_misc_amount += budgetComponent.amount;
98 new_misc_amount += budgetComponent.amount;
103 break;
99 break;
104 }
100 }
105
106 }
101 }
107
102
108
103
109
110 if (this.ticksToSend > 0)
104 if (this.ticksToSend > 0)
111 {
105 {
112
113 Logging.Trace(String.Format("{0} ticks to send in update", this.ticksToSend));
106 Logging.Trace(String.Format("{0} ticks to send in update", this.ticksToSend));
114 }
107 }
115 if (this.ticksToSend > 1)
108 if (this.ticksToSend > 1)
@@ -120,21 +113,18
120 {
113 {
121
114
122 #region calculate_preserve_cells
115 #region calculate_preserve_cells
123 // var preserve_cells = new HashSet<isometricparkfna.CellMap.Cell>();
124 var preserve_cell_coordinates = new List<(int, int)>();
116 var preserve_cell_coordinates = new List<(int, int)>();
125 // var count = 0;
126
117
127 Stopwatch iterPreserves = new Stopwatch();
118 Stopwatch iterPreserves = new Stopwatch();
128 iterPreserves.Start();
119 iterPreserves.Start();
129
120
130 foreach (ref readonly var entity in ReadEntities<PreserveComponent>()) {
121 foreach (ref readonly var entity in ReadEntities<PreserveComponent>()) {
131 ref readonly var areaComponent = ref GetComponent<AreaComponent>(entity);
122 ref readonly var areaComponent = ref GetComponent<AreaComponent>(entity);
132
123
133 foreach (var square in areaComponent.squares) {
124 foreach (var square in areaComponent.squares) {
134 // preserve_cells.Add(this.simulation.map.cells[(int)square.X][(int)square.Y]);
125 preserve_cell_coordinates.Add(((int)square.X, (int)square.Y));
135 preserve_cell_coordinates.Add(((int)square.X, (int)square.Y));
126 }
136 }
127 }
137 }
138 iterPreserves.Stop();
128 iterPreserves.Stop();
139 Logging.Info(String.Format("Preserve entities: {0:F3}", iterPreserves.Elapsed.TotalMilliseconds.ToString()));
129 Logging.Info(String.Format("Preserve entities: {0:F3}", iterPreserves.Elapsed.TotalMilliseconds.ToString()));
140
130
@@ -167,15 +157,13
167 }
157 }
168 //*/
158 //*/
169 iterCells.Stop();
159 iterCells.Stop();
170 Logging.Info(String.Format("Cell loop: {0:F3}", iterCells.Elapsed.TotalMilliseconds.ToString()));
160 Logging.Info(String.Format("Cell loop: {0:F3}", iterCells.Elapsed.TotalMilliseconds.ToString()));
171
161
172 #endregion
162 #endregion
173 SendMessage<TickMessage>(new TickMessage { SimulationDateTime = simulation.DateTime });
163 SendMessage<TickMessage>(new TickMessage { SimulationDateTime = simulation.DateTime });
174 //For now:
164 //For now:
175 SendMessage<SpawnContractMessage>(new SpawnContractMessage
165 SendMessage<SpawnContractMessage>(new SpawnContractMessage {name = string.Format("#logging_company.capitalizeAll# {0}",
176 { //max_squares = 100,
166 this.simulation.DateTime.ToShortDateString()) });
177 name = string.Format("#logging_company.capitalizeAll# {0}", this.simulation.DateTime.ToShortDateString())
178 });
179
167
180 #region events
168 #region events
181 if (simulation.latestBudget.DateTime != default)
169 if (simulation.latestBudget.DateTime != default)
@@ -187,12 +175,12
187 SendMessage<SpawnDialogMessage>(new SpawnDialogMessage {Path = "EndLowFunds"});
175 SendMessage<SpawnDialogMessage>(new SpawnDialogMessage {Path = "EndLowFunds"});
188 }
176 }
189 else if (simulation.latestBudget.money < 10_000M
177 else if (simulation.latestBudget.money < 10_000M
190 && simulation.previousBudget.money >= 10_000M)
178 && simulation.previousBudget.money >= 10_000M)
191 {
179 {
192 SendMessage<SpawnDialogMessage>(new SpawnDialogMessage {Path = "VeryLowFunds"});
180 SendMessage<SpawnDialogMessage>(new SpawnDialogMessage {Path = "VeryLowFunds"});
193 }
181 }
194 else if (simulation.latestBudget.money < 25_000M
182 else if (simulation.latestBudget.money < 25_000M
195 && simulation.previousBudget.money >= 25_000M)
183 && simulation.previousBudget.money >= 25_000M)
196 {
184 {
197 SendMessage<SpawnDialogMessage>(new SpawnDialogMessage {Path = "LowFunds"});
185 SendMessage<SpawnDialogMessage>(new SpawnDialogMessage {Path = "LowFunds"});
198 }
186 }
@@ -180,7 +180,6
180
180
181 public CellMap map;
181 public CellMap map;
182
182
183 // public HashSet<Cell> PreserveCells;
184 public int[,] PreserveCounts;
183 public int[,] PreserveCounts;
185
184
186 public int ticksPerAdvance;
185 public int ticksPerAdvance;
@@ -266,7 +265,6
266
265
267 this.BridgeEngine = new SimulationBridgeEngine(this);
266 this.BridgeEngine = new SimulationBridgeEngine(this);
268
267
269 // this.PreserveCells = new HashSet<Cell>();
270 this.PreserveCounts = new int[this.map.MapWidth, this.map.MapHeight];
268 this.PreserveCounts = new int[this.map.MapWidth, this.map.MapHeight];
271 }
269 }
272
270
@@ -443,7 +441,6
443 //through t=120, so that's what we want to track in lastAdvance.
441 //through t=120, so that's what we want to track in lastAdvance.
444 this.lastAdvance += advancesToSimulate * millisecondsPerAdvance;
442 this.lastAdvance += advancesToSimulate * millisecondsPerAdvance;
445 }
443 }
446
447 }
444 }
448 }
445 }
449 }
446 }
You need to be logged in to leave comments. Login now