mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Clean up some uses of Point to prep for update.
This commit is contained in:
parent
bafc9dc65e
commit
df7be8603b
@ -4,10 +4,10 @@ import logging
|
|||||||
import random
|
import random
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import ClassVar, TYPE_CHECKING, Type, Any, Iterator, Optional
|
from typing import Any, ClassVar, Iterator, Optional, TYPE_CHECKING, Type
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
from dcs import Point
|
from dcs.unittype import ShipType, StaticType, UnitType as DcsUnitType, VehicleType
|
||||||
|
|
||||||
from game.data.groups import GroupTask
|
from game.data.groups import GroupTask
|
||||||
from game.data.radar_db import UNITS_WITH_RADAR
|
from game.data.radar_db import UNITS_WITH_RADAR
|
||||||
@ -15,13 +15,10 @@ from game.dcs.groundunittype import GroundUnitType
|
|||||||
from game.dcs.helpers import static_type_from_name
|
from game.dcs.helpers import static_type_from_name
|
||||||
from game.dcs.shipunittype import ShipUnitType
|
from game.dcs.shipunittype import ShipUnitType
|
||||||
from game.dcs.unittype import UnitType
|
from game.dcs.unittype import UnitType
|
||||||
from game.point_with_heading import PointWithHeading
|
|
||||||
from game.layout.layout import TgoLayout, AntiAirLayout, TgoLayoutGroup
|
|
||||||
from dcs.unittype import UnitType as DcsUnitType, VehicleType, ShipType, StaticType
|
|
||||||
|
|
||||||
from game.theater.theatergroup import TheaterGroup
|
|
||||||
|
|
||||||
from game.layout import LAYOUTS
|
from game.layout import LAYOUTS
|
||||||
|
from game.layout.layout import AntiAirLayout, TgoLayout, TgoLayoutGroup
|
||||||
|
from game.point_with_heading import PointWithHeading
|
||||||
|
from game.theater.theatergroup import TheaterGroup
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from game import Game
|
from game import Game
|
||||||
@ -218,10 +215,7 @@ class ForceGroup:
|
|||||||
unit.id = game.next_unit_id()
|
unit.id = game.next_unit_id()
|
||||||
unit.name = unit.unit_type.name if unit.unit_type else unit.type.name
|
unit.name = unit.unit_type.name if unit.unit_type else unit.type.name
|
||||||
unit.position = PointWithHeading.from_point(
|
unit.position = PointWithHeading.from_point(
|
||||||
Point(
|
ground_object.position + unit.position,
|
||||||
ground_object.position.x + unit.position.x,
|
|
||||||
ground_object.position.y + unit.position.y,
|
|
||||||
),
|
|
||||||
# Align heading to GroundObject defined by the campaign designer
|
# Align heading to GroundObject defined by the campaign designer
|
||||||
unit.position.heading + ground_object.heading,
|
unit.position.heading + ground_object.heading,
|
||||||
)
|
)
|
||||||
|
|||||||
@ -26,7 +26,6 @@ from .ato.flighttype import FlightType
|
|||||||
from .campaignloader import CampaignAirWingConfig
|
from .campaignloader import CampaignAirWingConfig
|
||||||
from .coalition import Coalition
|
from .coalition import Coalition
|
||||||
from .db.gamedb import GameDb
|
from .db.gamedb import GameDb
|
||||||
from .factions.faction import Faction
|
|
||||||
from .infos.information import Information
|
from .infos.information import Information
|
||||||
from .profiling import logged_duration
|
from .profiling import logged_duration
|
||||||
from .settings import Settings
|
from .settings import Settings
|
||||||
@ -472,11 +471,6 @@ class Game:
|
|||||||
continue
|
continue
|
||||||
zones.append(package.target.position)
|
zones.append(package.target.position)
|
||||||
|
|
||||||
# Else 0,0, since we need a default value
|
|
||||||
# (in this case this means the whole map is owned by the same player, so it is not an issue)
|
|
||||||
if len(zones) == 0:
|
|
||||||
zones.append(Point(0, 0))
|
|
||||||
|
|
||||||
self.__culling_zones = zones
|
self.__culling_zones = zones
|
||||||
|
|
||||||
def add_destroyed_units(self, data: dict[str, Union[float, str]]) -> None:
|
def add_destroyed_units(self, data: dict[str, Union[float, str]]) -> None:
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import copy
|
||||||
import logging
|
import logging
|
||||||
import random
|
import random
|
||||||
from typing import Any, Union
|
from typing import Any, Union
|
||||||
@ -244,7 +245,7 @@ class FlightGroupSpawner:
|
|||||||
group.points[0].type = "TakeOffParkingHot"
|
group.points[0].type = "TakeOffParkingHot"
|
||||||
|
|
||||||
for i in range(self.flight.count - 1):
|
for i in range(self.flight.count - 1):
|
||||||
group.units[1 + i].position = Point(helipad.x, helipad.y)
|
group.units[1 + i].position = copy.copy(helipad.position)
|
||||||
group.units[1 + i].heading = helipad.units[0].heading
|
group.units[1 + i].heading = helipad.units[0].heading
|
||||||
try:
|
try:
|
||||||
self.helipads[cp].pop()
|
self.helipads[cp].pop()
|
||||||
|
|||||||
@ -10,19 +10,7 @@ from __future__ import annotations
|
|||||||
import logging
|
import logging
|
||||||
import random
|
import random
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from typing import (
|
from typing import Any, Dict, Iterator, List, Optional, TYPE_CHECKING, Type
|
||||||
Any,
|
|
||||||
Dict,
|
|
||||||
Generic,
|
|
||||||
Iterator,
|
|
||||||
List,
|
|
||||||
Optional,
|
|
||||||
TYPE_CHECKING,
|
|
||||||
Type,
|
|
||||||
TypeVar,
|
|
||||||
List,
|
|
||||||
Any,
|
|
||||||
)
|
|
||||||
|
|
||||||
from dcs import Mission, Point, unitgroup
|
from dcs import Mission, Point, unitgroup
|
||||||
from dcs.action import DoScript, SceneryDestructionZone
|
from dcs.action import DoScript, SceneryDestructionZone
|
||||||
@ -37,9 +25,8 @@ from dcs.ships import (
|
|||||||
CV_1143_5,
|
CV_1143_5,
|
||||||
KUZNECOW,
|
KUZNECOW,
|
||||||
Stennis,
|
Stennis,
|
||||||
ship_map,
|
|
||||||
)
|
)
|
||||||
from dcs.statics import Fortification, fortification_map, warehouse_map
|
from dcs.statics import Fortification
|
||||||
from dcs.task import (
|
from dcs.task import (
|
||||||
ActivateBeaconCommand,
|
ActivateBeaconCommand,
|
||||||
ActivateICLSCommand,
|
ActivateICLSCommand,
|
||||||
@ -49,13 +36,11 @@ from dcs.task import (
|
|||||||
)
|
)
|
||||||
from dcs.translation import String
|
from dcs.translation import String
|
||||||
from dcs.triggers import Event, TriggerOnce, TriggerStart, TriggerZone
|
from dcs.triggers import Event, TriggerOnce, TriggerStart, TriggerZone
|
||||||
from dcs.unit import InvisibleFARP, Ship, Unit, Vehicle
|
from dcs.unit import Unit
|
||||||
from dcs.unitgroup import ShipGroup, StaticGroup, VehicleGroup, MovingGroup
|
from dcs.unitgroup import MovingGroup, ShipGroup, StaticGroup, VehicleGroup
|
||||||
from dcs.unittype import ShipType, StaticType, VehicleType
|
from dcs.unittype import ShipType, VehicleType
|
||||||
from dcs.vehicles import vehicle_map
|
from dcs.vehicles import vehicle_map
|
||||||
|
|
||||||
from game.data.building_data import FORTIFICATION_UNITS, FORTIFICATION_UNITS_ID
|
|
||||||
from game.dcs.helpers import static_type_from_name, unit_type_from_name
|
|
||||||
from game.radio.radios import RadioFrequency, RadioRegistry
|
from game.radio.radios import RadioFrequency, RadioRegistry
|
||||||
from game.radio.tacan import TacanBand, TacanChannel, TacanRegistry, TacanUsage
|
from game.radio.tacan import TacanBand, TacanChannel, TacanRegistry, TacanUsage
|
||||||
from game.theater import ControlPoint, TheaterGroundObject, TheaterUnit
|
from game.theater import ControlPoint, TheaterGroundObject, TheaterUnit
|
||||||
@ -139,11 +124,7 @@ class GroundObjectGenerator:
|
|||||||
vehicle_group.units[0].name = unit.unit_name
|
vehicle_group.units[0].name = unit.unit_name
|
||||||
self.set_alarm_state(vehicle_group)
|
self.set_alarm_state(vehicle_group)
|
||||||
else:
|
else:
|
||||||
vehicle_unit = Vehicle(
|
vehicle_unit = self.m.vehicle(unit.unit_name, unit.type)
|
||||||
self.m.next_unit_id(),
|
|
||||||
unit.unit_name,
|
|
||||||
unit.type.id,
|
|
||||||
)
|
|
||||||
vehicle_unit.player_can_drive = True
|
vehicle_unit.player_can_drive = True
|
||||||
vehicle_unit.position = unit.position
|
vehicle_unit.position = unit.position
|
||||||
vehicle_unit.heading = unit.position.heading.degrees
|
vehicle_unit.heading = unit.position.heading.degrees
|
||||||
@ -175,11 +156,7 @@ class GroundObjectGenerator:
|
|||||||
ship_group.units[0].name = unit.unit_name
|
ship_group.units[0].name = unit.unit_name
|
||||||
self.set_alarm_state(ship_group)
|
self.set_alarm_state(ship_group)
|
||||||
else:
|
else:
|
||||||
ship_unit = Ship(
|
ship_unit = self.m.ship(unit.unit_name, unit.type)
|
||||||
self.m.next_unit_id(),
|
|
||||||
unit.unit_name,
|
|
||||||
unit.type,
|
|
||||||
)
|
|
||||||
if frequency:
|
if frequency:
|
||||||
ship_unit.set_frequency(frequency.hertz)
|
ship_unit.set_frequency(frequency.hertz)
|
||||||
ship_unit.position = unit.position
|
ship_unit.position = unit.position
|
||||||
@ -569,9 +546,13 @@ class HelipadGenerator:
|
|||||||
self.helipads.append(sg)
|
self.helipads.append(sg)
|
||||||
name_i = name + "_" + str(i)
|
name_i = name + "_" + str(i)
|
||||||
logging.info("Generating helipad static : " + name_i)
|
logging.info("Generating helipad static : " + name_i)
|
||||||
pad = InvisibleFARP(unit_id=self.m.next_unit_id(), name=name_i)
|
pad = self.m.farp(
|
||||||
pad.position = Point(helipad.x, helipad.y)
|
country,
|
||||||
pad.heading = helipad.heading.degrees
|
name_i,
|
||||||
|
helipad,
|
||||||
|
heading=helipad.heading.degrees,
|
||||||
|
farp_type="InvisibleFARP",
|
||||||
|
)
|
||||||
sg.add_unit(pad)
|
sg.add_unit(pad)
|
||||||
# Generate a FARP Ammo and Fuel stack for each pad
|
# Generate a FARP Ammo and Fuel stack for each pad
|
||||||
self.m.static_group(
|
self.m.static_group(
|
||||||
|
|||||||
@ -15,10 +15,6 @@ if TYPE_CHECKING:
|
|||||||
class Bullseye:
|
class Bullseye:
|
||||||
position: Point
|
position: Point
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def from_pydcs(cls, bulls: Dict[str, float]) -> Bullseye:
|
|
||||||
return cls(Point(bulls["x"], bulls["y"]))
|
|
||||||
|
|
||||||
def to_pydcs(self) -> Dict[str, float]:
|
def to_pydcs(self) -> Dict[str, float]:
|
||||||
return {"x": self.position.x, "y": self.position.y}
|
return {"x": self.position.x, "y": self.position.y}
|
||||||
|
|
||||||
|
|||||||
@ -41,7 +41,6 @@ class ReferencePoint:
|
|||||||
class ConflictTheater:
|
class ConflictTheater:
|
||||||
terrain: Terrain
|
terrain: Terrain
|
||||||
|
|
||||||
reference_points: Tuple[ReferencePoint, ReferencePoint]
|
|
||||||
overview_image: str
|
overview_image: str
|
||||||
landmap: Optional[Landmap]
|
landmap: Optional[Landmap]
|
||||||
"""
|
"""
|
||||||
@ -293,10 +292,6 @@ class ConflictTheater:
|
|||||||
class CaucasusTheater(ConflictTheater):
|
class CaucasusTheater(ConflictTheater):
|
||||||
terrain = caucasus.Caucasus()
|
terrain = caucasus.Caucasus()
|
||||||
overview_image = "caumap.gif"
|
overview_image = "caumap.gif"
|
||||||
reference_points = (
|
|
||||||
ReferencePoint(caucasus.Gelendzhik.position, Point(176, 298)),
|
|
||||||
ReferencePoint(caucasus.Batumi.position, Point(1307, 1205)),
|
|
||||||
)
|
|
||||||
|
|
||||||
landmap = load_landmap(Path("resources/caulandmap.p"))
|
landmap = load_landmap(Path("resources/caulandmap.p"))
|
||||||
daytime_map = {
|
daytime_map = {
|
||||||
@ -326,10 +321,6 @@ class CaucasusTheater(ConflictTheater):
|
|||||||
class PersianGulfTheater(ConflictTheater):
|
class PersianGulfTheater(ConflictTheater):
|
||||||
terrain = persiangulf.PersianGulf()
|
terrain = persiangulf.PersianGulf()
|
||||||
overview_image = "persiangulf.gif"
|
overview_image = "persiangulf.gif"
|
||||||
reference_points = (
|
|
||||||
ReferencePoint(persiangulf.Jiroft.position, Point(1692, 1343)),
|
|
||||||
ReferencePoint(persiangulf.Liwa_AFB.position, Point(358, 3238)),
|
|
||||||
)
|
|
||||||
landmap = load_landmap(Path("resources/gulflandmap.p"))
|
landmap = load_landmap(Path("resources/gulflandmap.p"))
|
||||||
daytime_map = {
|
daytime_map = {
|
||||||
"dawn": (6, 8),
|
"dawn": (6, 8),
|
||||||
@ -358,10 +349,6 @@ class PersianGulfTheater(ConflictTheater):
|
|||||||
class NevadaTheater(ConflictTheater):
|
class NevadaTheater(ConflictTheater):
|
||||||
terrain = nevada.Nevada()
|
terrain = nevada.Nevada()
|
||||||
overview_image = "nevada.gif"
|
overview_image = "nevada.gif"
|
||||||
reference_points = (
|
|
||||||
ReferencePoint(nevada.Mina.position, Point(252, 295)),
|
|
||||||
ReferencePoint(nevada.Laughlin.position, Point(844, 909)),
|
|
||||||
)
|
|
||||||
landmap = load_landmap(Path("resources/nevlandmap.p"))
|
landmap = load_landmap(Path("resources/nevlandmap.p"))
|
||||||
daytime_map = {
|
daytime_map = {
|
||||||
"dawn": (4, 6),
|
"dawn": (4, 6),
|
||||||
@ -390,10 +377,6 @@ class NevadaTheater(ConflictTheater):
|
|||||||
class NormandyTheater(ConflictTheater):
|
class NormandyTheater(ConflictTheater):
|
||||||
terrain = normandy.Normandy()
|
terrain = normandy.Normandy()
|
||||||
overview_image = "normandy.gif"
|
overview_image = "normandy.gif"
|
||||||
reference_points = (
|
|
||||||
ReferencePoint(normandy.Needs_Oar_Point.position, Point(515, 329)),
|
|
||||||
ReferencePoint(normandy.Evreux.position, Point(2029, 1709)),
|
|
||||||
)
|
|
||||||
landmap = load_landmap(Path("resources/normandylandmap.p"))
|
landmap = load_landmap(Path("resources/normandylandmap.p"))
|
||||||
daytime_map = {
|
daytime_map = {
|
||||||
"dawn": (6, 8),
|
"dawn": (6, 8),
|
||||||
@ -422,10 +405,6 @@ class NormandyTheater(ConflictTheater):
|
|||||||
class TheChannelTheater(ConflictTheater):
|
class TheChannelTheater(ConflictTheater):
|
||||||
terrain = thechannel.TheChannel()
|
terrain = thechannel.TheChannel()
|
||||||
overview_image = "thechannel.gif"
|
overview_image = "thechannel.gif"
|
||||||
reference_points = (
|
|
||||||
ReferencePoint(thechannel.Abbeville_Drucat.position, Point(2005, 2390)),
|
|
||||||
ReferencePoint(thechannel.Detling.position, Point(706, 382)),
|
|
||||||
)
|
|
||||||
landmap = load_landmap(Path("resources/channellandmap.p"))
|
landmap = load_landmap(Path("resources/channellandmap.p"))
|
||||||
daytime_map = {
|
daytime_map = {
|
||||||
"dawn": (6, 8),
|
"dawn": (6, 8),
|
||||||
@ -454,10 +433,6 @@ class TheChannelTheater(ConflictTheater):
|
|||||||
class SyriaTheater(ConflictTheater):
|
class SyriaTheater(ConflictTheater):
|
||||||
terrain = syria.Syria()
|
terrain = syria.Syria()
|
||||||
overview_image = "syria.gif"
|
overview_image = "syria.gif"
|
||||||
reference_points = (
|
|
||||||
ReferencePoint(syria.Eyn_Shemer.position, Point(564, 1289)),
|
|
||||||
ReferencePoint(syria.Tabqa.position, Point(1329, 491)),
|
|
||||||
)
|
|
||||||
landmap = load_landmap(Path("resources/syrialandmap.p"))
|
landmap = load_landmap(Path("resources/syrialandmap.p"))
|
||||||
daytime_map = {
|
daytime_map = {
|
||||||
"dawn": (6, 8),
|
"dawn": (6, 8),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user