Commit Graph

28 Commits

Author SHA1 Message Date
RoosterDragon
9f526610dd Fix CA1864 2023-11-16 09:29:17 +02:00
RoosterDragon
b97d1a4c6c Fix IDE0090 2023-11-15 19:13:17 +02:00
RoosterDragon
b7e0ed9b87 Improve lookups of nodes by key in MiniYaml.
When handling the Nodes collection in MiniYaml, individual nodes are located via one of two methods:

// Lookup a single key with linear search.
var node = yaml.Nodes.FirstOrDefault(n => n.Key == "SomeKey");

// Convert to dictionary, expecting many key lookups.
var dict = nodes.ToDictionary();

// Lookup a single key in the dictionary.
var node = dict["SomeKey"];

To simplify lookup of individual keys via linear search, provide helper methods NodeWithKeyOrDefault and NodeWithKey. These helpers do the equivalent of Single{OrDefault} searches. Whilst this requires checking the whole list, it provides a useful correctness check. Two duplicated keys in TS yaml are fixed as a result. We can also optimize the helpers to not use LINQ, avoiding allocation of the delegate to search for a key.

Adjust existing code to use either lnear searches or dictionary lookups based on whether it will be resolving many keys. Resolving few keys can be done with linear searches to avoid building a dictionary. Resolving many keys should be done with a dictionary to avoid quaradtic runtime from repeated linear searches.
2023-09-23 14:31:04 +02:00
dnqbob
5d2f2bdd1d Add TraitLocation to all bot modules. 2023-09-11 14:33:32 +03:00
RoosterDragon
949ba589c0 MiniYaml becomes an immutable data structure.
This changeset is motivated by a simple concept - get rid of the MiniYaml.Clone and MiniYamlNode.Clone methods to avoid deep copying yaml trees during merging. MiniYaml becoming immutable allows the merge function to reuse existing yaml trees rather than cloning them, saving on memory and improving merge performance. On initial loading the YAML for all maps is processed, so this provides a small reduction in initial loading time.

The rest of the changeset is dealing with the change in the exposed API surface. Some With* helper methods are introduced to allow creating new YAML from existing YAML. Areas of code that generated small amounts of YAML are able to transition directly to the immutable model without too much ceremony. Some use cases are far less ergonomic even with these helper methods and so a MiniYamlBuilder is introduced to retain mutable creation functionality. This allows those areas to continue to use the old mutable structures. The main users are the update rules and linting capabilities.
2023-08-07 21:57:10 +03:00
RoosterDragon
231bf01f18 Fix CA1854 2023-06-20 17:57:40 +02:00
RoosterDragon
8a285f9b19 Fix IDE0090 2023-04-08 16:51:51 +03:00
RoosterDragon
8ee6957e6a Fix IDE0048 2023-03-01 21:56:28 +02:00
abcdefg30
5bf7fe852c Remove the copyright year numbers 2023-01-11 11:58:54 +02:00
abcdefg30
6a31b1f9f3 Update the copyright header year 2022-05-28 00:35:10 -05:00
dnqbob
242d589c45 Make AI airstrike aircraft spawns randomly 2022-01-17 15:43:20 +01:00
Andre Mohren
6810469634 Updated copyright years. 2021-06-29 18:33:21 -05:00
teinarss
53b781960c Change FieldLoader.LoadUsing to use nameof 2021-02-28 18:43:51 +01:00
darkademic
8f9c212921 Make AI randomly select from map squares with above average attractiveness when using support powers. 2020-11-01 21:20:00 +00:00
teinarss
27f1a7ab27 Use out var syntax 2020-08-19 18:11:07 +01:00
Matthias Mailänder
ea9992247d Reorder string placeholders. 2020-08-02 12:00:53 +02:00
Matthias Mailänder
b90fecff76 Remove the prefixed method name. 2020-08-02 12:00:53 +02:00
Matthias Mailänder
a4fc9fea3b Unify AIUtils.BotDebug prefixes. 2020-08-02 12:00:53 +02:00
abcdefg30
27d0465891 Remove workarounds for querying the PlayerActor in Created 2020-05-30 19:47:29 +02:00
abcdefg30
23b3c237b7 Update the year numbers in all license headers to 2020 2020-01-05 17:00:34 +00:00
matjaeck
5ac9d2c2f1 Fix botmodules querying the Player actor before it is assigned. 2019-12-05 01:48:56 +01:00
Paul Chote
865d8d77e0 Expire invalid instances from the SupportPowerBotModule cache. 2019-10-01 19:25:30 +02:00
Paul Chote
cf427f8cb3 Drop invalid power references when loading save games. 2019-10-01 19:25:30 +02:00
Paul Chote
100ec17ef0 Implement IGameSaveTraitData on BotModules. 2019-05-05 09:30:58 +02:00
abcdefg30
cadbd0d9ab Change the year number in all cs headers from 2018 to 2019 2019-01-26 23:15:21 +01:00
reaperrr
54c2894b4e Split off last bot modules
And dissolve AI namespace.
There would have been so little left in Common.AI,
that keeping it made no sense anymore.
2018-12-31 10:56:01 +00:00
Paul Chote
3e490e5843 Cache FrozenActorLayer on the Player object.
This avoids unnecessary trait queries.
2018-12-17 22:19:26 +01:00
reaperrr
451a38338b Convert AISupportPowerManager to module 2018-11-25 19:00:44 +01:00