Skip to content

Commit 1379240

Browse files
committed
python inbterop converting structs (wip)
1 parent a41f485 commit 1379240

File tree

11 files changed

+731
-229
lines changed

11 files changed

+731
-229
lines changed

python/bot/bot.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ def Updating(self, stepping: bool):
3737

3838
def __init__(self):
3939
game.LogInfo("bot-py start")
40+
st = game.GameState()
41+
print(f"{st}")
4042
if not game.TryReconnect():
4143
game.SetConnectStartGui(True)
4244
if not game.ConnectEnvironment():

python/uwapi/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22
# THIS FILE IS GENERATED BY SCRIPT
33
# DO NOT MODIFY
44

5-
from .interop import *
6-
from .library import UwapiLibrary
5+
from .admin import admin
6+
from .commands import commands
7+
from .entity import Entity
78
from .game import game
9+
from .library import UwapiLibrary
10+
from .map import map_
11+
from .prototypes import prototypes
12+
from .world import world
13+
from .interop import *
814

9-
__all__ = ["UwapiLibrary","game","Severity","LogCallback","ConnectionState","MyPlayer","AssistConfig","PerformanceStatistics","OrderType","OrderPriority","Order","Orders","Ids","Priority","Ping","PathState","ForeignPolicy","ChatTarget","ProtoComponent","OwnerComponent","ControllerComponent","PositionComponent","UnitState","UnitComponent","LifeComponent","ManaComponent","MoveComponent","AimComponent","RecipeComponent","RecipeStatisticsComponent","LogisticsTimestampComponent","PriorityComponent","AmountComponent","AttachmentComponent","PingComponent","PlayerState","PlayerConnectionClass","PlayerComponent","PlayerAiConfigComponent","ForceState","ForceComponent","ForceDetailsComponent","ForeignPolicyComponent","DiplomacyProposalComponent","GameState","ShootingUnit","ShootingData","ShootingArray","ExplosionData","ExplosionsArray","TaskType","MapState","MapInfo","MapStartingPosition","MapStartingPositionsArray","Tile","Cluster","ClustersDistancesQuery","ClustersDistancesResult","PrototypeType","MyForceStatistics","UnitUpgrades","Overview","OverviewExtract","UnitPathfindingQuery","UnitPathfindingResult"]
15+
__all__ = ["admin","commands","Entity","game","UwapiLibrary","map_","prototypes","world","Severity","LogCallback","ConnectionState","MyPlayer","AssistConfig","PerformanceStatistics","OrderType","OrderPriority","Order","Orders","Ids","Priority","Ping","PathState","ForeignPolicy","ChatTarget","ProtoComponent","OwnerComponent","ControllerComponent","PositionComponent","UnitState","UnitComponent","LifeComponent","ManaComponent","MoveComponent","AimComponent","RecipeComponent","RecipeStatisticsComponent","LogisticsTimestampComponent","PriorityComponent","AmountComponent","AttachmentComponent","PingComponent","PlayerState","PlayerConnectionClass","PlayerComponent","PlayerAiConfigComponent","ForceState","ForceComponent","ForceDetailsComponent","ForeignPolicyComponent","DiplomacyProposalComponent","GameState","ShootingUnit","ShootingData","ShootingArray","ExplosionData","ExplosionsArray","TaskType","MapState","MapInfo","MapStartingPosition","MapStartingPositionsArray","Tile","Cluster","ClustersDistancesQuery","ClustersDistancesResult","PrototypeType","MyForceStatistics","UnitUpgrades","Overview","OverviewExtract","UnitPathfindingQuery","UnitPathfindingResult"]

python/uwapi/admin.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from .interop import *
2+
3+
class Admin:
4+
_instance = None
5+
6+
def __new__(cls):
7+
if cls._instance is None:
8+
cls._instance = super().__new__(cls)
9+
return cls._instance
10+
11+
admin = Admin()

python/uwapi/commands.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from .interop import *
2+
3+
class Commands:
4+
_instance = None
5+
6+
def __new__(cls):
7+
if cls._instance is None:
8+
cls._instance = super().__new__(cls)
9+
return cls._instance
10+
11+
commands = Commands()

python/uwapi/entity.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from .interop import *
12

23
class Entity:
34
def __init__(self):

python/uwapi/game.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,53 @@ def __new__(cls):
88
cls._instance = super().__new__(cls)
99
return cls._instance
1010

11+
def Initialize(self):
12+
interop.uwSetExceptionCallback(self._ExceptionCallback)
13+
interop.uwSetLogCallback(self._LogCallback)
14+
interop.uwSetConnectionStateCallback(self._ConnectionStateCallback)
15+
interop.uwSetGameStateCallback(self._GameStateCallback)
16+
interop.uwSetUpdateCallback(self._UpdateCallback)
17+
interop.uwSetShootingCallback(self._ShootingCallback)
18+
interop.uwSetExplosionsCallback(self._ExplosionsCallback)
19+
interop.uwSetForceEliminatedCallback(self._ForceEliminatedCallback)
20+
interop.uwSetChatCallback(self._ChatCallback)
21+
interop.uwSetTaskCompletedCallback(self._TaskCompletedCallback)
22+
interop.uwSetMapStateCallback(self._MapStateCallback)
23+
24+
def _ExceptionCallback(self, message: str) -> None:
25+
print(message)
26+
breakpoint
27+
28+
def _LogCallback(self, log: UwLogCallback) -> None:
29+
print(log.message)
30+
31+
def _ConnectionStateCallback(self, state: UwConnectionStateEnum) -> None:
32+
print(state)
33+
34+
def _GameStateCallback(self, state: UwGameStateEnum) -> None:
35+
print(state)
36+
37+
def _UpdateCallback(self, tick: int, stepping: bool) -> None:
38+
print(f"update, tick: {tick}, stepping: {stepping}")
39+
40+
def _ShootingCallback(self, data: UwShootingArray) -> None:
41+
pass
42+
43+
def _ExplosionsCallback(self, data: UwExplosionsArray) -> None:
44+
pass
45+
46+
def _ForceEliminatedCallback(self, force: int) -> None:
47+
pass
48+
49+
def _ChatCallback(self, message: str, sender: int, flags: UwChatTargetFlags) -> None:
50+
pass
51+
52+
def _TaskCompletedCallback(self, something: int, type: UwTaskTypeEnum) -> None:
53+
pass
54+
55+
def _MapStateCallback(self, state: UwMapStateEnum) -> None:
56+
print(state)
57+
1158
def LogInfo(self, message: str) -> None:
1259
interop.uwLog(UwSeverityEnum.Info, message)
1360

0 commit comments

Comments
 (0)