dcs-retribution/game/dcs/helpers.py
RndName d154069877 Refactor ground objects and prepare template system
- completly refactored the way TGO handles groups and replaced the usage of the pydcs ground groups (vehicle, ship, static) with an own Group and Unit class.
- this allows us to only take care of dcs group generation during miz generation, where it should have always been.
- We can now have any type of unit (even statics) in the same logic ground group we handle in liberation. this is independent from the dcs group handling. the dcs group will only be genarted when takeoff is pressed.
- Refactored the unitmap and the scenery object handling to adopt to changes that now TGOs can hold all Units we want.
- Cleaned up many many many lines of uneeded hacks to build stuff around dcs groups.
- Removed IDs for TGOs as the names we generate are unique and for liberation to work we need no ids. Unique IDs for dcs will be generated for the units and groups only.
2022-02-21 20:45:41 +01:00

36 lines
1.0 KiB
Python

from typing import Optional, Type
from dcs.helicopters import helicopter_map
from dcs.planes import plane_map
from dcs.ships import ship_map
from dcs.unittype import UnitType
from dcs.vehicles import vehicle_map
from dcs.statics import fortification_map, groundobject_map, warehouse_map, cargo_map
def unit_type_from_name(name: str) -> Optional[Type[UnitType]]:
if name in vehicle_map:
return vehicle_map[name]
elif name in plane_map:
return plane_map[name]
elif name in ship_map:
return ship_map[name]
if name in helicopter_map:
return helicopter_map[name]
else:
# Try statics
return static_type_from_name(name)
def static_type_from_name(name: str) -> Optional[Type[UnitType]]:
if name in fortification_map:
return fortification_map[name]
elif name in groundobject_map:
return groundobject_map[name]
elif name in warehouse_map:
return warehouse_map[name]
if name in cargo_map:
return cargo_map[name]
else:
return None