Commit Graph

38 Commits

Author SHA1 Message Date
dnqbob
5d2f2bdd1d Add TraitLocation to all bot modules. 2023-09-11 14:33:32 +03:00
RoosterDragon
23f3f8d90c Add helper methods to locate actors that can be reached via a path.
Previously, the ClosestTo and PositionClosestTo existed to perform a simple distance based check to choose the closest location from a choice of locations to a single other location. For some functions this is sufficient, but for many functions we want to then move between the locations. If the location selected is in fact unreachable (e.g. on another island) then we would not want to consider it.

We now introduce ClosestToIgnoringPath for checks where we don't care about a path existing, e.g. weapons hitting nearby targets. When we do care about paths, we introduce ClosestToWithPathFrom and ClosestToWithPathTo which will check that a path exists. The PathFrom check will make sure one of the actors from the list can make it to the single target location. The PathTo check will make sure the single actor can make it to one of the target locations. This difference allows us to specify which actor will be doing the moving. This is important as a path might exists for one actor, but not another. Consider two islands with a hovercraft on one and a tank on the other. The hovercraft can path to the tank, but the tank cannot path to the hovercraft.

We also introduce WithPathFrom and WithPathTo. These will perform filtering by checking for valid paths, but won't select the closest location.

By employing the new methods that filter for paths, we fix various behaviour that would cause actors to get confused. Imagine an islands map, by checking for paths we ensure logic will locate reachable locations on the island, rather than considering a location on a nearby island that is physically closer but unreachable. This fixes AI squad automation, and other automated behaviours such as rearming.
2023-09-07 17:46:35 +03:00
RoosterDragon
93a97d5d6f Fix CA1851, assume_method_enumerates_parameters = true 2023-08-20 20:41:27 +02: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
8a285f9b19 Fix IDE0090 2023-04-08 16:51:51 +03:00
RoosterDragon
bd2b3d9793 Fix IDE0074 2023-04-08 16:51:51 +03:00
abcdefg30
5bf7fe852c Remove the copyright year numbers 2023-01-11 11:58:54 +02:00
Matthias Mailänder
943751547e Don't hardcode enemy aircraft ignorance. 2022-12-25 22:24:57 +01:00
Matthias Mailänder
24ed5f7a1a Add linting to AI squad manager types. 2022-12-25 22:24:57 +01:00
Gustas
858d782af1 Simplify 'default' expression (IDE0034) 2022-10-11 17:40:05 +02:00
abcdefg30
6a31b1f9f3 Update the copyright header year 2022-05-28 00:35:10 -05:00
Eduardo Cáceres
79f321cb44 .Any(), .Count() -> .Count or .Length 2022-05-18 11:42:36 -05:00
Matthias Mailänder
5eaba4f893 Unhardcode AI defensive priorities. 2021-12-05 13:17:32 +01:00
Matthias Mailänder
e82aa9977e Unhardcode AI air units and exclude scripted aircraft. 2021-12-05 13:17:32 +01:00
Andre Mohren
6810469634 Updated copyright years. 2021-06-29 18:33:21 -05:00
Paul Chote
d52ba83f96 Replace terniary null checks with coalescing. 2021-03-08 18:11:25 +01:00
Paul Chote
7c852d90fb Ignore aircraft when searching for enemy targets. 2020-12-07 23:39:22 +01:00
abcdefg30
718cf37146 Misc code improvements 2020-11-14 11:04:41 +00:00
abcdefg30
10f645bf77 Replace usage of the Stances dict by a method call 2020-11-14 11:04:41 +00:00
abcdefg30
eda9966d27 Rename Stance to PlayerRelationship 2020-11-14 11:04:41 +00:00
reaperrr
8d1f72c104 Fix for SquadManagerBotModule
Aircraft and ships are immediately assigned a squad,
so adding them to `unitsHangingAroundTheBase` is bogus.
2020-10-04 00:31:35 +01:00
Andre Mohren
006a87692a Removed unused imports. 2020-07-28 18:22:51 +02:00
darkademic
ae882b85a9 Make AI randomly scan map for targets for its air squads. 2020-07-02 23:05:49 +02:00
abcdefg30
27d0465891 Remove workarounds for querying the PlayerActor in Created 2020-05-30 19:47:29 +02:00
atlimit8
2dac16ee02 add SquadManagerBotModuleInfo.IgnoredEnemyTargetTypes 2020-05-17 22:02:32 +01:00
dnqbob
86394eb56c "FindEnemy" functions ignore hidden actors
(helped by reaperrr and abcdefg30)
2020-04-28 15:35:02 +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
blackhand1001
70b1df6ce7 Fix squadmanager adding naval units to ground attack forces.
Fix squadmanager adding naval units to ground attack forces. This was breaking the behavior of both naval and ground squads.
2019-11-09 11:19:09 +01:00
Paul Chote
c30bb28210 Filter invalid actors when loading and saving games. 2019-10-05 17:50:10 +02:00
Paul Chote
8b0f2e1462 Fix NRE in SquadManagerBotModule. 2019-08-24 14:33:11 +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
Paul Chote
5a8f7f1a5f Increase squad calculation intervals.
These were unnecessarily short, increasing the
AI performance overhead, and making it difficult
for units to escape concave terrain features.
2019-01-03 02:04:08 +01:00
Paul Chote
3d9e877eb2 Disable rush attacks against enemy aircraft. 2019-01-03 02:04:08 +01:00
Paul Chote
8a6a68feef Unify Squad enemy unit filtering. 2019-01-03 02:04:08 +01:00
Paul Chote
4d56ecb3a8 Remove unused MaximumDefenseRadius parameter. 2019-01-01 12:43:10 +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