mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Remove useless wrappers from db.py.
This commit is contained in:
parent
758feab413
commit
36f74ae0a9
10
game/db.py
10
game/db.py
@ -21,7 +21,7 @@ from dcs.ships import (
|
||||
Stennis,
|
||||
ship_map,
|
||||
)
|
||||
from dcs.unittype import ShipType, UnitType, VehicleType
|
||||
from dcs.unittype import ShipType, UnitType
|
||||
from dcs.vehicles import (
|
||||
vehicle_map,
|
||||
)
|
||||
@ -161,14 +161,6 @@ def unit_type_from_name(name: str) -> Optional[Type[UnitType]]:
|
||||
return None
|
||||
|
||||
|
||||
def vehicle_type_from_name(name: str) -> Type[VehicleType]:
|
||||
return vehicle_map[name]
|
||||
|
||||
|
||||
def ship_type_from_name(name: str) -> Type[ShipType]:
|
||||
return ship_map[name]
|
||||
|
||||
|
||||
def country_id_from_name(name: str) -> int:
|
||||
for k, v in country_dict.items():
|
||||
if v.name == name:
|
||||
|
||||
@ -11,41 +11,44 @@ import logging
|
||||
import random
|
||||
from collections import defaultdict
|
||||
from typing import (
|
||||
Any,
|
||||
Dict,
|
||||
Generic,
|
||||
Iterator,
|
||||
List,
|
||||
Optional,
|
||||
TYPE_CHECKING,
|
||||
Type,
|
||||
List,
|
||||
TypeVar,
|
||||
Any,
|
||||
Generic,
|
||||
Union,
|
||||
)
|
||||
|
||||
from dcs import Mission, Point, unitgroup
|
||||
from dcs.action import SceneryDestructionZone, DoScript
|
||||
from dcs.action import DoScript, SceneryDestructionZone
|
||||
from dcs.condition import MapObjectIsDead
|
||||
from dcs.country import Country
|
||||
from dcs.point import StaticPoint
|
||||
from dcs.ships import ship_map
|
||||
from dcs.statics import Fortification, fortification_map, warehouse_map
|
||||
from dcs.task import (
|
||||
ActivateBeaconCommand,
|
||||
ActivateICLSCommand,
|
||||
EPLRS,
|
||||
OptAlarmState,
|
||||
FireAtPoint,
|
||||
OptAlarmState,
|
||||
)
|
||||
from dcs.translation import String
|
||||
from dcs.triggers import TriggerStart, TriggerZone, Event, TriggerOnce
|
||||
from dcs.unit import Ship, Unit, Vehicle, InvisibleFARP
|
||||
from dcs.triggers import Event, TriggerOnce, TriggerStart, TriggerZone
|
||||
from dcs.unit import InvisibleFARP, Ship, Unit, Vehicle
|
||||
from dcs.unitgroup import ShipGroup, StaticGroup, VehicleGroup
|
||||
from dcs.unittype import StaticType, ShipType, VehicleType
|
||||
from dcs.unittype import ShipType, StaticType, VehicleType
|
||||
from dcs.vehicles import vehicle_map
|
||||
|
||||
from game import db
|
||||
from game.data.building_data import FORTIFICATION_UNITS, FORTIFICATION_UNITS_ID
|
||||
from game.db import unit_type_from_name, ship_type_from_name, vehicle_type_from_name
|
||||
from game.db import unit_type_from_name
|
||||
from game.radio.radios import RadioFrequency, RadioRegistry
|
||||
from game.radio.tacan import TacanBand, TacanChannel, TacanRegistry, TacanUsage
|
||||
from game.theater import ControlPoint, TheaterGroundObject
|
||||
from game.theater.theatergroundobject import (
|
||||
BuildingGroundObject,
|
||||
@ -53,15 +56,13 @@ from game.theater.theatergroundobject import (
|
||||
FactoryGroundObject,
|
||||
GenericCarrierGroundObject,
|
||||
LhaGroundObject,
|
||||
ShipGroundObject,
|
||||
MissileSiteGroundObject,
|
||||
SceneryGroundObject,
|
||||
ShipGroundObject,
|
||||
)
|
||||
from game.unitmap import UnitMap
|
||||
from game.utils import Heading, feet, knots, mps
|
||||
from game.radio.radios import RadioFrequency, RadioRegistry
|
||||
from gen.runways import RunwayData
|
||||
from game.radio.tacan import TacanBand, TacanChannel, TacanRegistry, TacanUsage
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from game import Game
|
||||
@ -106,7 +107,7 @@ class GenericGroundObjectGenerator(Generic[TgoT]):
|
||||
logging.warning(f"Found empty group in {self.ground_object}")
|
||||
continue
|
||||
|
||||
unit_type = vehicle_type_from_name(group.units[0].type)
|
||||
unit_type = vehicle_map[group.units[0].type]
|
||||
vg = self.m.vehicle_group(
|
||||
self.country,
|
||||
group.name,
|
||||
@ -410,7 +411,7 @@ class GenericCarrierGenerator(GenericGroundObjectGenerator[GenericCarrierGroundO
|
||||
self._register_unit_group(group, ship_group)
|
||||
|
||||
def get_carrier_type(self, group: ShipGroup) -> Type[ShipType]:
|
||||
return ship_type_from_name(group.units[0].type)
|
||||
return ship_map[group.units[0].type]
|
||||
|
||||
def configure_carrier(
|
||||
self, group: ShipGroup, atc_channel: RadioFrequency
|
||||
@ -561,7 +562,7 @@ class ShipObjectGenerator(GenericGroundObjectGenerator[ShipGroundObject]):
|
||||
if not group.units:
|
||||
logging.warning(f"Found empty group in {self.ground_object}")
|
||||
continue
|
||||
self.generate_group(group, ship_type_from_name(group.units[0].type))
|
||||
self.generate_group(group, ship_map[group.units[0].type])
|
||||
|
||||
def generate_group(
|
||||
self, group_def: ShipGroup, first_unit_type: Type[ShipType]
|
||||
|
||||
@ -10,6 +10,7 @@ from dcs.mapping import Point
|
||||
from dcs.triggers import TriggerZone
|
||||
from dcs.unit import Unit
|
||||
from dcs.unitgroup import ShipGroup, VehicleGroup
|
||||
from dcs.vehicles import vehicle_map
|
||||
|
||||
from .. import db
|
||||
from ..data.radar_db import LAUNCHER_TRACKER_PAIRS, TELARS, TRACK_RADARS
|
||||
@ -526,7 +527,7 @@ class SamGroundObject(IadsGroundObject):
|
||||
max_telar_range = meters(0)
|
||||
launchers = set()
|
||||
for unit in group.units:
|
||||
unit_type = db.vehicle_type_from_name(unit.type)
|
||||
unit_type = vehicle_map[unit.type]
|
||||
if unit_type in TRACK_RADARS:
|
||||
live_trs.add(unit_type)
|
||||
elif unit_type in TELARS:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user