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 nullptr.util import *
|
||||||
from dataclasses import field
|
|
||||||
|
|
||||||
class Waypoint(Base):
|
class Waypoint(Base):
|
||||||
def define(self):
|
def define(self):
|
||||||
@ -9,13 +9,15 @@ class Waypoint(Base):
|
|||||||
self.type:str = 'unknown'
|
self.type:str = 'unknown'
|
||||||
self.traits:list = []
|
self.traits:list = []
|
||||||
self.faction:str = ''
|
self.faction:str = ''
|
||||||
|
self.system = None
|
||||||
|
|
||||||
def update(self, d):
|
def update(self, d):
|
||||||
self.seta('x', d)
|
self.seta('x', d)
|
||||||
self.seta('y', d)
|
self.seta('y', d)
|
||||||
self.seta('type', d)
|
self.seta('type', d)
|
||||||
self.seta('faction', d, 'faction.symbol')
|
self.seta('faction', d, 'faction.symbol')
|
||||||
self.setlst('traits', d, 'traits', 'symbol')
|
self.setlst('traits', d, 'traits', 'symbol')
|
||||||
|
self.seta('system', d, self.store.getter(System))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def ext(self):
|
def ext(self):
|
||||||
|
@ -7,6 +7,7 @@ from .util import *
|
|||||||
from time import time
|
from time import time
|
||||||
import pickle
|
import pickle
|
||||||
from struct import unpack, pack
|
from struct import unpack, pack
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
class ChunkHeader:
|
class ChunkHeader:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -156,6 +157,11 @@ class Store:
|
|||||||
return None
|
return None
|
||||||
return self.data[typ][symbol]
|
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):
|
def update(self, typ, data, symbol=None):
|
||||||
if type(typ) == str and typ in self.model_names:
|
if type(typ) == str and typ in self.model_names:
|
||||||
typ = self.model_names[typ]
|
typ = self.model_names[typ]
|
||||||
|
Loading…
Reference in New Issue
Block a user