Description:
Add company generation.
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
@@ -15,7 +15,8 | |||||
|
15 | namespace isometricparkfna.Spawners { |
|
15 | namespace isometricparkfna.Spawners { |
|
16 |
|
16 | ||
|
17 | [Receives(typeof(SpawnContractMessage))] |
|
17 | [Receives(typeof(SpawnContractMessage))] |
|
18 |
[Reads(typeof(AreaComponent), typeof(ContractStatusComponent) |
|
18 | [Reads(typeof(AreaComponent), typeof(ContractStatusComponent), |
|
|
19 | typeof(OffersContractsComponent))] | ||
|
19 | class ContractSpawner : Spawner<SpawnContractMessage> |
|
20 | class ContractSpawner : Spawner<SpawnContractMessage> |
|
20 | { |
|
21 | { |
|
21 | private Random random_generator; |
|
22 | private Random random_generator; |
@@ -91,6 +92,10 | |||||
|
91 | //for now: |
|
92 | //for now: |
|
92 | var occupied = new List<Vector2>(); |
|
93 | var occupied = new List<Vector2>(); |
|
93 |
|
94 | ||
|
|
95 | var contractOrganizations = ReadEntities<OffersContractsComponent>().ToArray(); | ||
|
|
96 | |||
|
|
97 | var contractCount = contractOrganizations.Count(); | ||
|
|
98 | |||
|
94 |
|
99 | ||
|
95 | foreach (var (entity, status) in ReadEntities<AreaComponent>().SelectWhereF((e) => (e, GetComponent<ContractStatusComponent>(e)), |
|
100 | foreach (var (entity, status) in ReadEntities<AreaComponent>().SelectWhereF((e) => (e, GetComponent<ContractStatusComponent>(e)), |
|
96 | (e) => (e.Item2.status != ContractStatus.Expired)) |
|
101 | (e) => (e.Item2.status != ContractStatus.Expired)) |
@@ -132,6 +137,12 | |||||
|
132 | AddComponent(contract, new ImageComponent {ImageIndex = image_index}); |
|
137 | AddComponent(contract, new ImageComponent {ImageIndex = image_index}); |
|
133 | AddComponent(contract, new WindowTypeComponent { type = Window.Contract}); |
|
138 | AddComponent(contract, new WindowTypeComponent { type = Window.Contract}); |
|
134 | AddComponent(contract, new VisibilityComponent { visible = false}); |
|
139 | AddComponent(contract, new VisibilityComponent { visible = false}); |
|
|
140 | |||
|
|
141 | if (contractCount > 0) | ||
|
|
142 | { | ||
|
|
143 | var organization_index = random_generator.Next(0, contractCount); | ||
|
|
144 | AddComponent(contract, new RelatedOrganizationComponent { Entity = contractOrganizations[organization_index] }); | ||
|
|
145 | } | ||
|
135 | } |
|
146 | } |
|
136 |
|
147 | ||
|
137 | } |
|
148 | } |
@@ -219,6 +219,7 | |||||
|
219 | WorldBuilder.AddEngine(new ContractStatusEngine(this.simulation)); |
|
219 | WorldBuilder.AddEngine(new ContractStatusEngine(this.simulation)); |
|
220 |
|
220 | ||
|
221 | WorldBuilder.AddEngine(new ContractSpawner(simulation.map.MapWidth, simulation.map.MapHeight, this.simulation, this.grammar)); |
|
221 | WorldBuilder.AddEngine(new ContractSpawner(simulation.map.MapWidth, simulation.map.MapHeight, this.simulation, this.grammar)); |
|
|
222 | WorldBuilder.AddEngine(new OrganizationSpawner(this.simulation, this.grammar)); | ||
|
222 |
|
223 | ||
|
223 | WorldBuilder.AddGeneralRenderer(new AreaRenderer(this.batch, this.monoFont), 1); |
|
224 | WorldBuilder.AddGeneralRenderer(new AreaRenderer(this.batch, this.monoFont), 1); |
|
224 | WorldBuilder.AddGeneralRenderer(new ImGuiWindowRenderer(debugWindow.monoFont, this.imGuiWindowBridgeEngine), 2); |
|
225 | WorldBuilder.AddGeneralRenderer(new ImGuiWindowRenderer(debugWindow.monoFont, this.imGuiWindowBridgeEngine), 2); |
@@ -253,6 +254,12 | |||||
|
253 | } |
|
254 | } |
|
254 |
|
255 | ||
|
255 | } |
|
256 | } |
|
|
257 | |||
|
|
258 | for (int i = 0; i < 10; i++) | ||
|
|
259 | { | ||
|
|
260 | |||
|
|
261 | WorldBuilder.SendMessage(new SpawnOrganizationtMessage { offersContracts = true }); | ||
|
|
262 | } | ||
|
256 | WorldBuilder.SendMessage(new SpawnContractMessage |
|
263 | WorldBuilder.SendMessage(new SpawnContractMessage |
|
257 | { |
|
264 | { |
|
258 | squares = squares, |
|
265 | squares = squares, |
@@ -33,6 +33,15 | |||||
|
33 | var amount = GetComponent<BudgetLineComponent>(entity).amount; |
|
33 | var amount = GetComponent<BudgetLineComponent>(entity).amount; |
|
34 | var tree_delta = GetComponent<TreeDeltaComponent>(entity).deltaTreesName; |
|
34 | var tree_delta = GetComponent<TreeDeltaComponent>(entity).deltaTreesName; |
|
35 | var image_index = GetComponent<ImageComponent>(entity).ImageIndex; |
|
35 | var image_index = GetComponent<ImageComponent>(entity).ImageIndex; |
|
|
36 | |||
|
|
37 | |||
|
|
38 | if (HasComponent<RelatedOrganizationComponent>(entity)) | ||
|
|
39 | { | ||
|
|
40 | var related_organization = GetComponent<RelatedOrganizationComponent>(entity).Entity; | ||
|
|
41 | |||
|
|
42 | name = GetComponent<NameComponent>(related_organization).DisplayName; | ||
|
|
43 | } | ||
|
|
44 | |||
|
36 | return (entity, name, status, amount, tree_delta, image_index); |
|
45 | return (entity, name, status, amount, tree_delta, image_index); |
|
37 |
|
46 | ||
|
38 | } |
|
47 | } |
You need to be logged in to leave comments.
Login now