Skip to content

Commit 9c74cbc

Browse files
committed
Full restructure due to recent pymhf changes. Remove anything not compatible with latest game version
1 parent 6f8c01b commit 9c74cbc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+6278
-879432
lines changed

.github/workflows/pipeline.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ jobs:
2929
- name: Install dependencies
3030
run: |
3131
python -m pip install --upgrade pip uv
32-
uv sync --frozen --group dev
32+
uv sync --frozen --all-groups --all-extras
3333
- name: Build Python ${{ matrix.py_ver.version}} wheel
3434
run: uv build
3535
- name: Lint and format code
36-
run: uv run python -m twine check ./dist/*
37-
# uv run ruff check ./NMSpy
38-
# uv run ruff format --check ./NMSpy
39-
# uv run python -m twine check ./dist/*
36+
run: |
37+
uv run python -m twine check ./dist/*
38+
uv run ruff check ./nmspy
39+
uv run ruff format --check ./nmspy
40+
uv run python -m twine check ./dist/*
4041
- name: Upload Wheels
4142
uses: actions/upload-artifact@v4
4243
with:
@@ -67,6 +68,8 @@ jobs:
6768

6869
test-release:
6970
name: Release NMSpy wheels and source build to test-PyPI
71+
# Release to the test PyPI if we have merged into master or if we have tagged.
72+
if: ${{ (github.ref == 'refs/heads/master') || startsWith(github.ref, 'refs/tags') }}
7073
needs:
7174
- build_test
7275
runs-on: ubuntu-latest
@@ -86,4 +89,3 @@ jobs:
8689
with:
8790
repository-url: https://test.pypi.org/legacy/
8891
attestations: true
89-
verbose: true

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ logs/
88

99
.venv/
1010
build/*
11-
NMS.py.egg-info/*
11+
*.egg-info/*
-72.6 KB
Binary file not shown.
-67 KB
Binary file not shown.

example_mods/gravityManipulator.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import logging
2-
from dataclasses import dataclass
2+
import ctypes
3+
from dataclasses import dataclass, field
34

45
from pymhf.core.hooking import on_key_pressed
56
from pymhf.core.mod_loader import ModState
6-
from nmspy import NMSMod
7-
from pymhf.core.calling import call_function
7+
from pymhf import Mod
88
from pymhf.gui import FLOAT
9-
import nmspy.data.functions.hooks as hooks
9+
import nmspy.data.types as nms
1010

1111
# A quick mod used to change the gravity multiplier on all planets simultaneously, utilizing pyMHF's auto-gui.
1212

@@ -17,13 +17,13 @@
1717
class gravModState(ModState):
1818
# A special class inheriting from ModState which persists between mod Hot Reloads, allowing mod developers
1919
# to cache pointers, values etc.
20-
gravity: int = 1
21-
planetAddresses: list[int] = []
20+
gravity: float = 1
21+
planets: list[nms.cGcPlanet] = field(default_factory=list)
2222

2323

24-
class gravityManipulator(NMSMod):
24+
class gravityManipulator(Mod):
2525
# General "Nice To Have"s
26-
__author__ = "ThatBomberBoi"
26+
__author__ = ["ThatBomberBoi", "monkeyman192"]
2727
__description__ = "Gravity Manipulator"
2828
__version__ = "0.2"
2929
__NMSPY_required_version__ = "0.7.0"
@@ -49,20 +49,22 @@ def gravMult(self, value):
4949
# Functions are hooked by specifying the function to be hooked from the list of in game functions
5050
# available. You can specify whether you want your detour to run either before or after the original
5151
# function as shown below.
52-
@hooks.cGcPlanet.SetupRegionMap.after
53-
def onRegionMap(self, this):
52+
@nms.cGcPlanet.SetupRegionMap.after
53+
def onRegionMap(self, this: ctypes._Pointer[nms.cGcPlanet]):
5454
# Include each in-game function's arguments seperately in the function, or use *args to get all
5555
# arguments without knowing them prior.
5656
# In this case we know that the argument is `this` which is a pointer to the instance of `cGcPlanet`
5757
# which is automatically passed into this function by the game.
58-
logger.info(f"Generated A Planet!")
59-
self.state.planetAddresses.append(this)
60-
logger.debug(f"Found {len(self.state.planetAddresses)} Planets So Far")
58+
planet = this.contents
59+
self.state.planets.append(this.contents)
60+
biome = planet.mPlanetGenerationInputData.Biome
61+
logger.info(f"Generated a {biome.name} Planet!")
62+
logger.debug(f"Found {len(self.state.planets)} Planets So Far")
6163

6264
@on_key_pressed("o")
6365
def modifyGravity(self):
64-
for ptr in self.state.planetAddresses:
66+
for planet in self.state.planets:
6567
# Call an in-game function directly from your mod code.
6668
# You will need to provide the arguments for the in-game function
67-
call_function("cGcPlanet::UpdateGravity", ptr, self.state.gravity)
69+
planet.UpdateGravity(self.state.gravity)
6870
logger.info(f"Set Planetary Gravity Multiplier To {self.state.gravity} For All Planets")

mods/disable_mod_warning.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

mods/misc_tests.py

Lines changed: 0 additions & 123 deletions
This file was deleted.

mods/test_mod.py

Lines changed: 0 additions & 102 deletions
This file was deleted.

nmspy/__init__.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,4 @@
66
except PackageNotFoundError:
77
pass
88

9-
from nmspy._types import NMSMod # noqa
10-
11-
import nmspy.data.structs
12-
import nmspy.data
13-
14-
__pymhf_types__ = nmspy.data.structs
15-
__pymhf_functions__ = nmspy.data.functions
9+
import nmspy.data # noqa

0 commit comments

Comments
 (0)