Update waypoint.py and store.py

This commit is contained in:
Richard Bronkhorst 2023-07-10 20:12:29 +02:00
parent b1e3621490
commit b2f2dc520e
2 changed files with 11 additions and 3 deletions

View File

@ -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,13 +9,15 @@ class Waypoint(Base):
self.type:str = 'unknown'
self.traits:list = []
self.faction:str = ''
self.system = None
def update(self, d):
self.seta('x', d)
self.seta('y', d)
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):

View File

@ -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]