wavelength 1.0.0
Loading...
Searching...
No Matches
stickevent.h
Go to the documentation of this file.
1#pragma once
2
3#include "os/binstream.h"
4
14template <int kId>
16public:
18 StickEvent() = default;
19
27 StickEvent(unsigned char nPlayer, float fX, float fY) : mPlayer(nPlayer), mX(fX), mY(fY) {
28 }
29
35 explicit StickEvent(BinStream &stream) {
36 Load(stream);
37 }
38
44 void Save(BinStream &stream) const {
45 const unsigned char nPlayer = mPlayer;
46 stream.Write(&nPlayer, sizeof(nPlayer));
47 float fValue = mX;
48 stream.WriteEndian(&fValue, sizeof(fValue));
49 fValue = mY;
50 stream.WriteEndian(&fValue, sizeof(fValue));
51 }
52
58 void Load(BinStream &stream) {
59 stream.Read(&mPlayer, sizeof(mPlayer));
60 stream.ReadEndian(&mX, sizeof(mX));
61 stream.ReadEndian(&mY, sizeof(mY));
62 }
63
65 float GetY() const {
66 return mY;
67 }
68
70 void SetY(float fY) {
71 mY = fY;
72 }
73
75 float GetX() const {
76 return mX;
77 }
78
80 void SetX(float fX) {
81 mX = fX;
82 }
83
85 unsigned char GetPlayer() const {
86 return mPlayer;
87 }
88
90 void SetPlayer(unsigned char nPlayer) {
91 mPlayer = nPlayer;
92 }
93
94private:
95 unsigned char mPlayer;
96 float mX;
97 float mY;
98};
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
void ReadEndian(void *pData, int nBytes)
Read a value of 2, 4, 8, or 16 bytes, reversing its bytes unless the stream is little endian.
virtual void Read(void *pData, int nBytes)=0
Read bytes.
virtual void Write(const void *pData, int nBytes)=0
Write bytes.
void WriteEndian(const void *pData, int nBytes)
Write a value of 2, 4, 8, or 16 bytes, reversing its bytes unless the stream is little endian.
void Load(BinStream &stream)
Read the event Save() records.
Definition stickevent.h:58
StickEvent(BinStream &stream)
Construct the event from a recording.
Definition stickevent.h:35
unsigned char GetPlayer() const
Definition stickevent.h:85
void SetX(float fX)
Definition stickevent.h:80
StickEvent(unsigned char nPlayer, float fX, float fY)
Construct an event.
Definition stickevent.h:27
float GetY() const
Definition stickevent.h:65
StickEvent()=default
Construct an event with unset members.
void SetY(float fY)
Definition stickevent.h:70
float GetX() const
Definition stickevent.h:75
void Save(BinStream &stream) const
Record the player in one byte and each position in four bytes of the console's byte order.
Definition stickevent.h:44
void SetPlayer(unsigned char nPlayer)
Definition stickevent.h:90