Files
WLUS/structures.py
Wesley e9122ffa01 Lots of Stuff
Added ghosting distance, started mission implementation, lots of other stuff
2018-06-06 00:22:06 -04:00

54 lines
1.7 KiB
Python

from pyraknet.bitstream import *
import math
#Ripped this straight off of PYLUS Because I had no idea how to make the char_size of strings equal to 1. Idk why it was removed as a parameter but whatever I guess
class CString(Serializable):
def __init__(self, data='', allocated_length=None, length_type=None):
self.data = data
self.allocated_length = allocated_length
self.length_type = length_type
def serialize(self, stream):
stream.write(self.data if isinstance(self.data, bytes) else bytes(self.data, 'latin1'),
allocated_length=self.allocated_length, length_type=self.length_type)
def deserialize(self, stream):
return stream.read(bytes, allocated_length=self.allocated_length, length_type=self.length_type).decode('latin1')
class Vector3():
def __init__(self, X : float, Y : float, Z : float):
self.X : float = X
self.Y : float = Y
self.Z : float = Z
def translate(self, X : float, Y : float, Z : float):
self.X += X
self.Y += Y
self.Z += Z
def set(self, X : float, Y : float, Z : float):
self.X = X
self.Y = Y
self.Z = Z
def distance(self, point):
XVal = pow(self.X - point.X, 2)
YVal = pow(self.Y - point.Y, 2)
ZVal = pow(self.Z - point.Z, 2)
return math.sqrt(XVal + YVal + ZVal)
class Vector4():
def __init__(self, X : float, Y : float, Z : float, W : float):
self.X : float = X
self.Y : float = Y
self.Z : float = Z
self.W : float = W
def translate(self, X : float, Y : float, Z : float, W : float):
self.X += X
self.Y += Y
self.Z += Z
self.W += W
def set(self, X : float, Y : float, Z : float, W : float):
self.X = X
self.Y = Y
self.Z = Z
self.W = W