Skip to content

Commit 10351a2

Browse files
committed
cutscenes; format python
1 parent b79f70d commit 10351a2

File tree

17 files changed

+139
-50
lines changed

17 files changed

+139
-50
lines changed

c/uwapi/uwapi/modules/botsConnection.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ extern "C"
7171
UNNATURAL_API void uwSetForceColor(float r, float g, float b); // [0 .. 1]
7272
UNNATURAL_API void uwSetForceRace(uint32 raceProto);
7373
UNNATURAL_API void uwForceJoinTeam(uint32 team);
74+
UNNATURAL_API void uwSkipCutscene(void);
7475

7576
typedef struct UwMyPlayer
7677
{

c/uwapi/uwapi/modules/game.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ extern "C"
2121
UwGameStateEnum_Preparation = 2,
2222
UwGameStateEnum_Starting = 3,
2323
UwGameStateEnum_Game = 4,
24-
UwGameStateEnum_Finish = 5,
25-
UwGameStateEnum_Pause = 6,
26-
UwGameStateEnum_CutscenePaused = 7,
27-
UwGameStateEnum_CutsceneRunning = 8,
24+
UwGameStateEnum_Pause = 5,
25+
UwGameStateEnum_CutscenePaused = 6,
26+
UwGameStateEnum_CutsceneRunning = 7,
27+
UwGameStateEnum_Finish = 8,
2828
} UwGameStateEnum;
2929
#ifdef UNNATURAL_BOTS
3030
typedef void (*UwGameStateCallbackType)(UwGameStateEnum state);

c/uwapi/uwapi/modules/scriptsServer.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,17 @@ extern "C"
4444
UNNATURAL_API void uwSetForeignPolicy(uint32 force1, uint32 force2, UwForeignPolicyEnum policy);
4545

4646
UNNATURAL_API uint32 uwCreateAiPlayer(void);
47-
// UNNATURAL_API void uwDestroyAiPlayer(uint32 player);
4847
UNNATURAL_API void uwSetPlayerAiConfig(uint32 player, const UwPlayerAiConfigComponent *config);
4948
UNNATURAL_API void uwSetPlayerForce(uint32 player, uint32 force);
49+
UNNATURAL_API void uwPlayerCamera(uint32 player, uint32 tileIndex, bool resetToDefaultZoomAndOrientation, float duration, float smooth); // use -1 to send to all players, use NaN for default values
50+
UNNATURAL_API void uwPlayerCameraPosition(uint32 player, uint32 tileIndex, float yaw, float pitch, float eyeDistance, float duration, float smooth); // use -1 to send to all players, use NaN for default values
51+
UNNATURAL_API void uwPlayerCameraTransform(uint32 player, const float targetPosition[3], const float eyePosition[3], const float eyeUp[3], float duration, float smooth); // use -1 to send to all players, use NaN for default values
52+
UNNATURAL_API float uwPlayerDialogue(uint32 player, uint32 avatarId, uint32 voicelineId, uint32 translatedTextId); // use -1 to send to all players, use 0 for no avatar/voice/text, returns duration of the voice/text
53+
54+
UNNATURAL_API void uwCutsceneBegin(void);
55+
UNNATURAL_API void uwCutsceneEnd(void);
56+
UNNATURAL_API void uwCutsceneGameSimulation(bool runGameSimulation);
57+
UNNATURAL_API float uwCutsceneTime(void); // seconds since start of the cutscene
5058

5159
UNNATURAL_API void uwStandardVictoryConditions(bool enable);
5260
UNNATURAL_API void uwSendChat(const char *msg, UwChatTargetFlags flags, uint32 targetId);

csharp/uwapi/game.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ public static void ForceJoinTeam(uint team)
4646
Interop.uwForceJoinTeam(team);
4747
}
4848

49+
public static void SkipCutscene()
50+
{
51+
Interop.uwSkipCutscene();
52+
}
53+
4954
public static void SetConnectStartGui(bool startGui, string extraParams = "--observer 1")
5055
{
5156
Interop.uwSetConnectStartGui(startGui, extraParams);

csharp/uwapi/interop.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ public static extern void uwConnectNewServer(uint visibility, [MarshalAs(Unmanag
190190
[DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
191191
public static extern void uwForceJoinTeam(uint team);
192192

193+
[DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
194+
public static extern void uwSkipCutscene();
195+
193196
[StructLayout(LayoutKind.Sequential)]
194197
public struct UwMyPlayer
195198
{
@@ -698,10 +701,10 @@ public enum UwGameStateEnum
698701
Preparation = 2,
699702
Starting = 3,
700703
Game = 4,
701-
Finish = 5,
702-
Pause = 6,
703-
CutscenePaused = 7,
704-
CutsceneRunning = 8,
704+
Pause = 5,
705+
CutscenePaused = 6,
706+
CutsceneRunning = 7,
707+
Finish = 8,
705708
}
706709

707710
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]

python/uwapi/admin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from .interop import *
22

3+
34
class Admin:
45
_instance = None
56

@@ -68,4 +69,5 @@ def send_chat(self, msg: str, flags, id: int = INVALID) -> None:
6869
def send_ping(self, position: int, ping, id: int) -> None:
6970
uw_interop.uwAdminSendPing(position, ping, id)
7071

72+
7173
uw_admin = Admin()

python/uwapi/bots.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ void uwPlayerJoinForce(uint32 force);
147147
void uwSetForceColor(float r, float g, float b);
148148
void uwSetForceRace(uint32 raceProto);
149149
void uwForceJoinTeam(uint32 team);
150+
void uwSkipCutscene(void);
150151

151152
typedef struct UwMyPlayer
152153
{
@@ -433,10 +434,10 @@ typedef enum UwGameStateEnum
433434
UwGameStateEnum_Preparation = 2,
434435
UwGameStateEnum_Starting = 3,
435436
UwGameStateEnum_Game = 4,
436-
UwGameStateEnum_Finish = 5,
437-
UwGameStateEnum_Pause = 6,
438-
UwGameStateEnum_CutscenePaused = 7,
439-
UwGameStateEnum_CutsceneRunning = 8,
437+
UwGameStateEnum_Pause = 5,
438+
UwGameStateEnum_CutscenePaused = 6,
439+
UwGameStateEnum_CutsceneRunning = 7,
440+
UwGameStateEnum_Finish = 8,
440441
} UwGameStateEnum;
441442

442443
typedef void (*UwGameStateCallbackType)(UwGameStateEnum state);

python/uwapi/commands.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from .interop import *
22

3+
34
class Commands:
45
_instance = None
56

@@ -54,14 +55,16 @@ def place_construction(
5455
position: int,
5556
yaw: float = 0,
5657
recipe_proto: int = 0,
57-
priority: UwPriorityEnum = UwPriorityEnum.Normal
58+
priority: UwPriorityEnum = UwPriorityEnum.Normal,
5859
) -> None:
59-
uw_interop.uwCommandPlaceConstruction(construction_proto, position, yaw, recipe_proto, priority)
60+
uw_interop.uwCommandPlaceConstruction(
61+
construction_proto, position, yaw, recipe_proto, priority
62+
)
6063

6164
def set_recipe(self, unit_id: int, recipe_proto: int) -> None:
6265
uw_interop.uwCommandSetRecipe(unit_id, recipe_proto)
6366

64-
def set_priority(self, unit_id: int, priority : UwPriorityEnum) -> None:
67+
def set_priority(self, unit_id: int, priority: UwPriorityEnum) -> None:
6568
uw_interop.uwCommandSetPriority(unit_id, priority)
6669

6770
def load(self, unit_id: int, resource_proto: int) -> None:
@@ -83,6 +86,9 @@ def self_destruct(self, entity_id: int) -> None:
8386
uw_interop.uwCommandSelfDestruct(entity_id)
8487

8588
def _default_order(self) -> UwOrder:
86-
return UwOrder(INVALID, INVALID, UwOrderTypeEnum.Nothing, UwOrderPriorityFlags.User)
89+
return UwOrder(
90+
INVALID, INVALID, UwOrderTypeEnum.Nothing, UwOrderPriorityFlags.User
91+
)
92+
8793

8894
uw_commands = Commands()

python/uwapi/entity.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
from .interop import *
44
from .prototypes import uw_prototypes, Prototype
55

6+
67
def _make_empty_UwUnitUpgrades() -> UwUnitUpgrades:
78
return UwUnitUpgrades(0, 0, 0, 0, 0, 0, 0)
89

10+
911
@dataclass
1012
class Entity:
1113
id: int
@@ -40,10 +42,16 @@ def pos(self) -> int:
4042

4143
def policy(self) -> UwForeignPolicyEnum:
4244
from .world import uw_world
43-
return uw_world.policy(self.Owner.force) if self.Owner is not None else UwForeignPolicyEnum.Nothing
45+
46+
return (
47+
uw_world.policy(self.Owner.force)
48+
if self.Owner is not None
49+
else UwForeignPolicyEnum.Nothing
50+
)
4451

4552
def own(self) -> bool:
4653
from .world import uw_world
54+
4755
return self.Owner is not None and self.Owner.force == uw_world.my_force_id()
4856

4957
def ally(self) -> bool:
@@ -53,7 +61,11 @@ def enemy(self) -> bool:
5361
return self.policy() == UwForeignPolicyEnum.Enemy
5462

5563
def type(self) -> UwPrototypeTypeEnum:
56-
return uw_prototypes.type(self.Proto.proto) if self.Proto is not None else UwPrototypeTypeEnum.Nothing
64+
return (
65+
uw_prototypes.type(self.Proto.proto)
66+
if self.Proto is not None
67+
else UwPrototypeTypeEnum.Nothing
68+
)
5769

5870
def proto(self) -> Prototype:
5971
if self.Proto is not None:
@@ -63,4 +75,9 @@ def proto(self) -> Prototype:
6375

6476
def unit_upgrades(self) -> UwUnitUpgrades:
6577
from .world import uw_world
66-
return uw_world.unit_upgrades(self.id) if self.type() == UwPrototypeTypeEnum.Unit else _make_empty_UwUnitUpgrades()
78+
79+
return (
80+
uw_world.unit_upgrades(self.id)
81+
if self.type() == UwPrototypeTypeEnum.Unit
82+
else _make_empty_UwUnitUpgrades()
83+
)

python/uwapi/events.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import Callable, List
33
from .interop import *
44

5+
56
class Events:
67
_instance = None
78
_connection_state_listeners: List[Callable[[UwConnectionStateEnum], None]] = []
@@ -33,7 +34,9 @@ def initialize(self) -> None:
3334

3435
# ---------------------
3536

36-
def on_connection_state(self, listener: Callable[[UwConnectionStateEnum], None]) -> None:
37+
def on_connection_state(
38+
self, listener: Callable[[UwConnectionStateEnum], None]
39+
) -> None:
3740
self._connection_state_listeners.append(listener)
3841

3942
def on_game_state(self, listener: Callable[[UwGameStateEnum], None]) -> None:
@@ -87,15 +90,20 @@ def _force_eliminated_callback(self, force: int) -> None:
8790
for listener in self._force_eliminated_listeners:
8891
listener(force)
8992

90-
def _chat_callback(self, message: str, sender: int, flags: UwChatTargetFlags) -> None:
93+
def _chat_callback(
94+
self, message: str, sender: int, flags: UwChatTargetFlags
95+
) -> None:
9196
for listener in self._chat_listeners:
9297
listener(message, sender, flags)
9398

94-
def _task_completed_callback(self, task_user_data: int, type: UwTaskTypeEnum) -> None:
95-
pass # todo
99+
def _task_completed_callback(
100+
self, task_user_data: int, type: UwTaskTypeEnum
101+
) -> None:
102+
pass # todo
96103

97104
def _map_state_callback(self, state: UwMapStateEnum) -> None:
98105
for listener in self._map_state_listeners:
99106
listener(state)
100107

108+
101109
uw_events = Events()

0 commit comments

Comments
 (0)