-
Notifications
You must be signed in to change notification settings - Fork 497
/
TriggerPipeSignal.java
106 lines (93 loc) · 2.1 KB
/
TriggerPipeSignal.java
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/**
* Copyright (c) SpaceToad, 2011
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.transport.triggers;
import buildcraft.api.gates.ITriggerParameter;
import buildcraft.api.gates.Trigger;
import buildcraft.api.transport.IPipe;
import buildcraft.core.DefaultProps;
import buildcraft.transport.ITriggerPipe;
import buildcraft.transport.Pipe;
public class TriggerPipeSignal extends Trigger implements ITriggerPipe {
boolean active;
IPipe.WireColor color;
public TriggerPipeSignal(int id, boolean active, IPipe.WireColor color) {
super(id);
this.active = active;
this.color = color;
}
@Override
public int getIndexInTexture() {
if (active) {
switch (color) {
case Red:
return 0 * 16 + 3;
case Blue:
return 0 * 16 + 5;
case Green:
return 0 * 16 + 7;
case Yellow:
return 0 * 16 + 9;
}
} else {
switch (color) {
case Red:
return 0 * 16 + 2;
case Blue:
return 0 * 16 + 4;
case Green:
return 0 * 16 + 6;
case Yellow:
return 0 * 16 + 8;
}
}
return 0;
}
@Override
public boolean hasParameter() {
return false;
}
@Override
public String getDescription() {
if (active) {
switch (color) {
case Red:
return "Red Pipe Signal On";
case Blue:
return "Blue Pipe Signal On";
case Green:
return "Green Pipe Signal On";
case Yellow:
return "Yellow Pipe Signal On";
}
} else {
switch (color) {
case Red:
return "Red Pipe Signal Off";
case Blue:
return "Blue Pipe Signal Off";
case Green:
return "Green Pipe Signal Off";
case Yellow:
return "Yellow Pipe Signal Off";
}
}
return "";
}
@Override
public boolean isTriggerActive(Pipe pipe, ITriggerParameter parameter) {
if (active)
return pipe.signalStrength[color.ordinal()] > 0;
else
return pipe.signalStrength[color.ordinal()] == 0;
}
@Override
public String getTexture() {
return DefaultProps.TEXTURE_TRIGGERS;
}
}