Calculate orientation of specific TGOs automatically

This will allow to automatically calculate the orientation of TGOs which are required to head to the conflict if the campaign designer has not defined a specific heading in the campaign miz. This is for example required for silkworm, scuds or some SAM systems like the SA-11.
Added the should_head_to_conflict property to the TGO
This commit is contained in:
RndName
2022-05-06 17:30:43 +02:00
parent 2d39fb496c
commit a10e55cfd7
3 changed files with 37 additions and 0 deletions

View File

@@ -286,6 +286,18 @@ class Game:
for tgo in control_point.connected_objectives:
self.db.tgos.add(tgo.id, tgo)
# Correct the heading of specifc TGOs, can only be done after init turn 0
for tgo in self.theater.ground_objects:
# If heading is 0 then we change the orientation to head towards the
# closest conflict. Heading of 0 means that the campaign designer wants
# to determine the heading automatically by liberation. Values other
# than 0 mean it is custom defined.
if tgo.should_head_to_conflict and tgo.heading.degrees == 0:
# Calculate the heading to conflict
heading = self.theater.heading_to_conflict_from(tgo.position)
# Rotate the whole TGO with the new heading
tgo.rotate(heading or tgo.heading)
self.blue.preinit_turn_0()
self.red.preinit_turn_0()
# We don't need to actually stream events for turn zero because we haven't given