Skip to content

Commit 863720b

Browse files
committed
Linked up more useful common structs
1 parent d7999a5 commit 863720b

File tree

4 files changed

+82
-37
lines changed

4 files changed

+82
-37
lines changed

nmspy/common.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@
66
class GameData:
77
GcApplication: nms.cGcApplication = None # type: ignore
88

9+
@property
10+
def environment(self) -> Optional[nms.cGcEnvironment]:
11+
if (sim := self.simulation) is not None:
12+
return sim.mEnvironment
13+
14+
@property
15+
def player_environment(self) -> Optional[nms.cGcPlayerEnvironment]:
16+
if (env := self.environment) is not None:
17+
return env.mPlayerEnvironment
18+
919
@property
1020
def game_state(self) -> Optional[nms.cGcGameState]:
1121
if self.GcApplication is not None:

nmspy/data/enums/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
StateEnum,
77
eStormState,
88
eLanguageRegion,
9+
EnvironmentLocation,
910
)
1011

1112
# The following list is auto-generated.

nmspy/data/enums/internal_enums.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,23 @@ class eLanguageRegion(IntEnum):
7777
SimplifiedChinese = 0xE
7878
TencentChinese = 0xF
7979
Korean = 0x10
80+
81+
82+
class EnvironmentLocation():
83+
class Enum(IntEnum):
84+
None_ = 0x0
85+
Default = 0x1
86+
SpaceStation = 0x2
87+
PlanetOnFoot = 0x3
88+
PlanetInShip = 0x4
89+
PlanetInVehicle = 0x5
90+
Underwater = 0x6
91+
Cave = 0x7
92+
IndoorInBase = 0x8
93+
Freighter = 0x9
94+
FreighterInternals = 0xA
95+
AbandonedFreighter = 0xB
96+
InFleet = 0xC
97+
InSpaceObject = 0xD
98+
Nexus = 0xE
99+
Anomaly = 0xF

nmspy/data/types.py

Lines changed: 51 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -613,8 +613,59 @@ def Update(
613613
): ...
614614

615615

616+
@partial_struct
617+
class cGcPlayerEnvironment(Structure):
618+
mPlayerTM: Annotated[basic.cTkMatrix34, Field(basic.cTkMatrix34, 0x0)]
619+
mUp: Annotated[basic.Vector3f, Field(basic.Vector3f, 0x40)]
620+
621+
# Found below the call to cTkDynamicGravityControl::GetGravity in cGcPlayerEnvironment::Update
622+
miNearestPlanetIndex: Annotated[int, Field(c_uint32, 0x2BC)]
623+
mfDistanceFromPlanet: Annotated[float, Field(c_float, 0x2C0)]
624+
mfNearestPlanetSealevel: Annotated[float, Field(c_float, 0x2C4)]
625+
mNearestPlanetPos: Annotated[basic.Vector3f, Field(basic.Vector3f, 0x2D0)]
626+
mbInsidePlanetAtmosphere: Annotated[bool, Field(c_bool, 0x2EC)]
627+
meLocation: Annotated[
628+
enums.EnvironmentLocation.Enum,
629+
Field(c_enum32[enums.EnvironmentLocation.Enum], 0x458)
630+
]
631+
meLocationStable: Annotated[
632+
enums.EnvironmentLocation.Enum,
633+
Field(c_enum32[enums.EnvironmentLocation.Enum], 0x464)
634+
]
635+
636+
@function_hook("48 83 EC ? 80 B9 ? ? ? ? ? C6 04 24")
637+
def IsOnboardOwnFreighter(
638+
self, this: "_Pointer[cGcPlayerEnvironment]"
639+
) -> c_bool: ...
640+
641+
@function_hook("8B 81 ? ? ? ? 83 E8 ? 83 F8 ? 0F 96 C0 C3 48 83 EC")
642+
def IsOnPlanet(self, this: "_Pointer[cGcPlayerEnvironment]") -> c_bool: ...
643+
644+
@function_hook("48 8B C4 F3 0F 11 48 ? 55 53 41 54")
645+
def Update(
646+
self,
647+
this: "_Pointer[cGcPlayerEnvironment]",
648+
lfTimeStep: Annotated[float, c_float],
649+
): ...
650+
651+
652+
@partial_struct
653+
class cGcEnvironment(Structure):
654+
# Passed into multiple cGcPlayerEnvironment methods.
655+
mPlayerEnvironment: Annotated[cGcPlayerEnvironment, 0x8A0]
656+
657+
@function_hook(
658+
"48 8B C4 48 89 48 ? 55 53 56 57 41 54 41 55 41 56 41 57 48 8D A8 ? ? ? ? 48 81 EC ? ? ? ? 0F 29 70 ? 4C 8B E9"
659+
)
660+
def UpdateRender(self, this: "_Pointer[cGcEnvironment]"):
661+
# TODO: There could be a few good functions to get which are called in here...
662+
...
663+
664+
616665
@partial_struct
617666
class cGcSimulation(Structure):
667+
# Found in cGcSimulation::Update. Passed into cGcEnvironment::Update.
668+
mEnvironment: Annotated[cGcEnvironment, 0xAF790]
618669
mPlayer: Annotated[cGcPlayer, 0x24DE40]
619670
# Found in cGcSimulation::Update. Passed into cGcSolarSystem::Update.
620671
mpSolarSystem: Annotated[_Pointer[cGcSolarSystem], 0x24C670]
@@ -885,34 +936,6 @@ def UpdateGravityPoint(
885936
]
886937

887938

888-
@partial_struct
889-
class cGcPlayerEnvironment(Structure):
890-
mPlayerTM: Annotated[basic.cTkMatrix34, Field(basic.cTkMatrix34, 0x0)]
891-
mUp: Annotated[basic.Vector3f, Field(basic.Vector3f, 0x40)]
892-
893-
# Found below the call to cTkDynamicGravityControl::GetGravity in cGcPlayerEnvironment::Update
894-
miNearestPlanetIndex: Annotated[int, Field(c_uint32, 0x2BC)]
895-
mfDistanceFromPlanet: Annotated[float, Field(c_float, 0x2C0)]
896-
mfNearestPlanetSealevel: Annotated[float, Field(c_float, 0x2C4)]
897-
mNearestPlanetPos: Annotated[basic.Vector3f, Field(basic.Vector3f, 0x2D0)]
898-
mbInsidePlanetAtmosphere: Annotated[bool, Field(c_bool, 0x2EC)]
899-
900-
@function_hook("48 83 EC ? 80 B9 ? ? ? ? ? C6 04 24")
901-
def IsOnboardOwnFreighter(
902-
self, this: "_Pointer[cGcPlayerEnvironment]"
903-
) -> c_bool: ...
904-
905-
@function_hook("8B 81 ? ? ? ? 83 E8 ? 83 F8 ? 0F 96 C0 C3 48 83 EC")
906-
def IsOnPlanet(self, this: "_Pointer[cGcPlayerEnvironment]") -> c_bool: ...
907-
908-
@function_hook("48 8B C4 F3 0F 11 48 ? 55 53 41 54")
909-
def Update(
910-
self,
911-
this: "_Pointer[cGcPlayerEnvironment]",
912-
lfTimeStep: Annotated[float, c_float],
913-
): ...
914-
915-
916939
class Engine:
917940
@static_function_hook("40 53 48 83 EC ? 44 8B D1 44 8B C1")
918941
@staticmethod
@@ -1156,15 +1179,6 @@ def StateChange(
11561179
): ...
11571180

11581181

1159-
class cGcEnvironment(Structure):
1160-
@function_hook(
1161-
"48 8B C4 48 89 48 ? 55 53 56 57 41 54 41 55 41 56 41 57 48 8D A8 ? ? ? ? 48 81 EC ? ? ? ? 0F 29 70 ? 4C 8B E9"
1162-
)
1163-
def UpdateRender(self, this: "_Pointer[cGcEnvironment]"):
1164-
# TODO: There could be a few good functions to get which are called in here...
1165-
...
1166-
1167-
11681182
class cGcPlayerNotifications(Structure):
11691183
@function_hook("48 89 5C 24 ? 48 89 74 24 ? 57 48 81 EC ? ? ? ? 44 8B 81")
11701184
def AddTimedMessage(

0 commit comments

Comments
 (0)