blob: e49f92d9d9890a11a62f8568cf904fe90a2aa5ec (
plain)
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
|
#pragma once
#include "StarGameTypes.hpp"
#include "StarWorldGeometry.hpp"
#include "StarDataStream.hpp"
namespace Star {
STAR_CLASS(WireCoordinator);
STAR_CLASS(WireConnector);
enum class WireDirection {
Input,
Output
};
WireDirection otherWireDirection(WireDirection direction);
// Identifier for a specific WireNode in a WireEntity, node indexes for input
// and output nodes are separate.
struct WireNode {
WireDirection direction;
size_t nodeIndex;
};
DataStream& operator>>(DataStream& ds, WireNode& wireNode);
DataStream& operator<<(DataStream& ds, WireNode const& wireNode);
// Connection from a given WireNode to another WireNode, the direction must be
// implied based on the context.
struct WireConnection {
Vec2I entityLocation;
size_t nodeIndex;
bool operator==(WireConnection const& wireConnection) const;
};
template <>
struct hash<WireConnection> {
size_t operator()(WireConnection const& wireConnection) const;
};
DataStream& operator>>(DataStream& ds, WireConnection& wireConnection);
DataStream& operator<<(DataStream& ds, WireConnection const& wireConnection);
class WireCoordinator {
public:
virtual ~WireCoordinator() {}
virtual bool readInputConnection(WireConnection const& connection) = 0;
};
class WireConnector {
public:
enum SwingResult {
Connect,
Mismatch,
Protected,
Nothing
};
virtual ~WireConnector() {}
virtual SwingResult swing(WorldGeometry const& geometry, Vec2F position, FireMode mode) = 0;
virtual bool connecting() = 0;
};
}
|