Update waypoint.py and store.py
This commit is contained in:
parent
b1e3621490
commit
b2f2dc520e
@ -1,6 +1,6 @@
|
||||
from .base import Base
|
||||
from .base import Base, Reference
|
||||
from nullptr.models.system import System
|
||||
from nullptr.util import *
|
||||
from dataclasses import field
|
||||
|
||||
class Waypoint(Base):
|
||||
def define(self):
|
||||
@ -9,6 +9,7 @@ class Waypoint(Base):
|
||||
self.type:str = 'unknown'
|
||||
self.traits:list = []
|
||||
self.faction:str = ''
|
||||
self.system = None
|
||||
|
||||
def update(self, d):
|
||||
self.seta('x', d)
|
||||
@ -16,6 +17,7 @@ class Waypoint(Base):
|
||||
self.seta('type', d)
|
||||
self.seta('faction', d, 'faction.symbol')
|
||||
self.setlst('traits', d, 'traits', 'symbol')
|
||||
self.seta('system', d, self.store.getter(System))
|
||||
|
||||
@classmethod
|
||||
def ext(self):
|
||||
|
@ -7,6 +7,7 @@ from .util import *
|
||||
from time import time
|
||||
import pickle
|
||||
from struct import unpack, pack
|
||||
from functools import partial
|
||||
|
||||
class ChunkHeader:
|
||||
def __init__(self):
|
||||
@ -156,6 +157,11 @@ class Store:
|
||||
return None
|
||||
return self.data[typ][symbol]
|
||||
|
||||
def getter(self, typ, create=False):
|
||||
if type(typ) == str and typ in self.model_names:
|
||||
typ = self.model_names[typ]
|
||||
return partial(self.get, typ=typ, create=create)
|
||||
|
||||
def update(self, typ, data, symbol=None):
|
||||
if type(typ) == str and typ in self.model_names:
|
||||
typ = self.model_names[typ]
|
||||
|
Loading…
Reference in New Issue
Block a user