0ptr/nullptr/models/waypoint.py

35 lines
884 B
Python
Raw Normal View History

2023-07-10 18:12:29 +00:00
from .base import Base, Reference
from nullptr.models.system import System
from nullptr.util import *
from time import time
2024-01-04 20:34:31 +00:00
from math import sqrt
2023-07-10 17:25:01 +00:00
class Waypoint(Base):
def define(self):
self.x:int = 0
self.y:int = 0
self.type:str = 'unknown'
self.traits:list = []
self.faction:str = ''
self.is_under_construction:bool = False
2023-07-12 20:26:25 +00:00
self.system = self.get_system()
self.uncharted = True
2023-07-10 18:12:29 +00:00
def update(self, d):
self.seta('x', d)
self.seta('y', d)
self.seta('type', d)
self.seta('faction', d, 'faction.symbol')
self.seta('is_under_construction', d, 'isUnderConstruction')
self.setlst('traits', d, 'traits', 'symbol')
self.uncharted = 'UNCHARTED' in self.traits
2024-01-04 20:34:31 +00:00
def distance(self, other):
return int(sqrt((self.x - other.x) ** 2 + (self.y - other.y) ** 2))
@classmethod
def ext(self):
return 'way'