mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
Core: provide a way to add to CollectionState init and copy
SM: use that way OoT: use that way
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Dict, Set, Tuple, List, Optional, TextIO, Any
|
||||
from typing import Dict, Set, Tuple, List, Optional, TextIO, Any, Callable
|
||||
|
||||
from BaseClasses import MultiWorld, Item, CollectionState, Location
|
||||
from Options import Option
|
||||
@@ -35,8 +35,13 @@ class AutoWorldRegister(type):
|
||||
class AutoLogicRegister(type):
|
||||
def __new__(cls, name, bases, dct):
|
||||
new_class = super().__new__(cls, name, bases, dct)
|
||||
function: Callable
|
||||
for item_name, function in dct.items():
|
||||
if not item_name.startswith("__"):
|
||||
if item_name == "copy_mixin":
|
||||
CollectionState.additional_copy_functions.append(function)
|
||||
elif item_name == "init_mixin":
|
||||
CollectionState.additional_init_functions.append(function)
|
||||
elif not item_name.startswith("__"):
|
||||
if hasattr(CollectionState, item_name):
|
||||
raise Exception(f"Name conflict on Logic Mixin {name} trying to overwrite {item_name}")
|
||||
setattr(CollectionState, item_name, function)
|
||||
@@ -193,6 +198,7 @@ class World(metaclass=AutoWorldRegister):
|
||||
def write_spoiler_end(self, spoiler_handle: TextIO):
|
||||
"""Write to the end of the spoiler"""
|
||||
pass
|
||||
|
||||
# end of ordered Main.py calls
|
||||
|
||||
def create_item(self, name: str) -> Item:
|
||||
@@ -240,7 +246,6 @@ class World(metaclass=AutoWorldRegister):
|
||||
self.world.itempool.append(self.create_item(self.get_filler_item_name()))
|
||||
|
||||
|
||||
|
||||
# any methods attached to this can be used as part of CollectionState,
|
||||
# please use a prefix as all of them get clobbered together
|
||||
class LogicMixin(metaclass=AutoLogicRegister):
|
||||
|
Reference in New Issue
Block a user