-
Notifications
You must be signed in to change notification settings - Fork 4
/
Atom.h
83 lines (65 loc) · 2.06 KB
/
Atom.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//
// Atom.h
// Fission
//
// Created by C0deH4cker on 2/23/14.
// Copyright (c) 2014 C0deH4cker. All rights reserved.
//
#ifndef FSN_ATOM_H
#define FSN_ATOM_H
#include <cstdint>
#include <ostream>
#include "common.h"
#include "Direction.h"
#include "Point.h"
namespace fsn {
struct AtomicData {
int64_t mass;
int64_t energy;
AtomicData& operator+=(const AtomicData& other);
AtomicData& operator-=(const AtomicData& other);
AtomicData& operator*=(const AtomicData& other);
AtomicData& operator/=(const AtomicData& other);
};
AtomicData operator+(const AtomicData& a, const AtomicData& b);
AtomicData operator-(const AtomicData& a, const AtomicData& b);
AtomicData operator*(const AtomicData& a, const AtomicData& b);
AtomicData operator/(const AtomicData& a, const AtomicData& b);
ENUM_BITFIELD(AtomicFlags, uint8_t) {
None = 0,
Printing = 1<<0,
Setting = 1<<1,
Debug = 1<<2
};
class Atom: public AtomicData {
public:
static unsigned lastid;
Point pos;
Direction dir;
AtomicFlags flags;
unsigned id;
Atom(const Point& startingPos, Direction startingDir);
Atom(const Atom& other);
Atom& operator=(const Atom& other);
Atom move(int w, int h, int64_t steps = 1) const;
void show(std::ostream& os, char hit) const;
friend class Grid;
private:
Atom activate() const;
};
bool operator==(const Atom& a, const Atom& b);
bool operator!=(const Atom& a, const Atom& b);
bool operator<(const Atom& a, const Atom& b);
bool operator<=(const Atom& a, const Atom& b);
bool operator>(const Atom& a, const Atom& b);
bool operator>=(const Atom& a, const Atom& b);
Atom operator+(const Atom& a, const AtomicData& b);
Atom operator+(const AtomicData& a, const Atom& b);
Atom operator-(const Atom& a, const AtomicData& b);
Atom operator-(const AtomicData& a, const Atom& b);
Atom operator*(const Atom& a, const AtomicData& b);
Atom operator*(const AtomicData& a, const Atom& b);
Atom operator/(const Atom& a, const AtomicData& b);
Atom operator/(const AtomicData& a, const Atom& b);
}
#endif /* FSN_ATOM_H */