Survivalcraft API 1.8.2.3
v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
WireDomainElectricElement.cs
浏览该文件的文档.
1
using
Engine
;
2
3
namespace
Game
{
4
public
class
WireDomainElectricElement
:
ElectricElement
{
5
public
float
m_voltage
;
6
7
public
WireDomainElectricElement
(
SubsystemElectricity
subsystemElectricity, IEnumerable<CellFace> cellFaces) : base(
8
subsystemElectricity,
9
cellFaces
10
) { }
11
12
public
override
float
GetOutputVoltage
(
int
face) =>
m_voltage
;
13
14
public
override
bool
Simulate
() {
15
float
voltage =
m_voltage
;
16
int
num = 0;
17
foreach
(
ElectricConnection
connection
in
Connections
) {
18
if
(connection.
ConnectorType
!=
ElectricConnectorType
.Output
19
&& connection.
NeighborConnectorType
!= 0) {
20
num |= (int)MathF.Round(connection.
NeighborElectricElement
.
GetOutputVoltage
(connection.
NeighborConnectorFace
) * 15f);
21
}
22
}
23
m_voltage
= num / 15f;
24
return
m_voltage
!= voltage;
25
}
26
27
public
override
void
OnNeighborBlockChanged
(
CellFace
cellFace,
int
neighborX,
int
neighborY,
int
neighborZ) {
28
int
cellValue =
SubsystemElectricity
.SubsystemTerrain.Terrain.GetCellValue(cellFace.
X
, cellFace.
Y
, cellFace.
Z
);
29
int
num =
Terrain
.
ExtractContents
(cellValue);
30
if
(!(
BlocksManager
.
Blocks
[num] is
WireBlock
)) {
31
return
;
32
}
33
int
wireFacesBitmask =
WireBlock
.
GetWireFacesBitmask
(cellValue);
34
int
num2 = wireFacesBitmask;
35
if
(
WireBlock
.
WireExistsOnFace
(cellValue, cellFace.
Face
)) {
36
Point3
point =
CellFace
.
FaceToPoint3
(cellFace.
Face
);
37
int
cellValue2 =
SubsystemElectricity
.SubsystemTerrain.Terrain.GetCellValue(
38
cellFace.
X
- point.
X
,
39
cellFace.
Y
- point.
Y
,
40
cellFace.
Z
- point.
Z
41
);
42
Block
block =
BlocksManager
.
Blocks
[
Terrain
.
ExtractContents
(cellValue2)];
43
if
(block.
IsFaceNonAttachable
(
SubsystemElectricity
.SubsystemTerrain, cellFace.
Face
, cellValue2, cellValue)) {
44
num2 &= ~(1 << cellFace.
Face
);
45
}
46
}
47
if
(num2 == 0) {
48
SubsystemElectricity
.SubsystemTerrain.DestroyCell(
49
0,
50
cellFace.
X
,
51
cellFace.
Y
,
52
cellFace.
Z
,
53
0,
54
false
,
55
false
56
);
57
}
58
else
if
(num2 != wireFacesBitmask) {
59
int
newValue =
WireBlock
.
SetWireFacesBitmask
(cellValue, num2);
60
SubsystemElectricity
.SubsystemTerrain.DestroyCell(
61
0,
62
cellFace.
X
,
63
cellFace.
Y
,
64
cellFace.
Z
,
65
newValue,
66
false
,
67
false
68
);
69
}
70
}
71
}
72
}
Game.Block
定义
Block.cs:5
Game.Block.IsFaceNonAttachable
virtual bool IsFaceNonAttachable(SubsystemTerrain subsystemTerrain, int face, int value, int attachBlockValue)
定义
Block.cs:554
Game.BlocksManager
定义
BlocksManager.cs:10
Game.BlocksManager.Blocks
static Block[] Blocks
定义
BlocksManager.cs:41
Game.ElectricConnection
定义
ElectricConnection.cs:2
Game.ElectricConnection.NeighborConnectorFace
int NeighborConnectorFace
定义
ElectricConnection.cs:13
Game.ElectricConnection.NeighborElectricElement
ElectricElement NeighborElectricElement
定义
ElectricConnection.cs:9
Game.ElectricConnection.ConnectorType
ElectricConnectorType ConnectorType
定义
ElectricConnection.cs:7
Game.ElectricConnection.NeighborConnectorType
ElectricConnectorType NeighborConnectorType
定义
ElectricConnection.cs:15
Game.ElectricElement.SubsystemElectricity
SubsystemElectricity SubsystemElectricity
定义
ElectricElement.cs:5
Game.ElectricElement.GetOutputVoltage
virtual float GetOutputVoltage(int face)
定义
ElectricElement.cs:22
Game.ElectricElement.ElectricElement
ElectricElement(SubsystemElectricity subsystemElectricity, IEnumerable< CellFace > cellFaces)
定义
ElectricElement.cs:11
Game.ElectricElement.Connections
List< ElectricConnection > Connections
定义
ElectricElement.cs:9
Game.Terrain
定义
Terrain.cs:5
Game.Terrain.ExtractContents
static int ExtractContents(int value)
定义
Terrain.cs:303
Game.WireBlock
定义
WireBlock.cs:5
Game.WireBlock.WireExistsOnFace
static bool WireExistsOnFace(int value, int face)
定义
WireBlock.cs:209
Game.WireBlock.SetWireFacesBitmask
static int SetWireFacesBitmask(int value, int bitmask)
定义
WireBlock.cs:218
Game.WireBlock.GetWireFacesBitmask
static int GetWireFacesBitmask(int value)
定义
WireBlock.cs:211
Game.WireDomainElectricElement.GetOutputVoltage
override float GetOutputVoltage(int face)
定义
WireDomainElectricElement.cs:12
Game.WireDomainElectricElement.Simulate
override bool Simulate()
定义
WireDomainElectricElement.cs:14
Game.WireDomainElectricElement.OnNeighborBlockChanged
override void OnNeighborBlockChanged(CellFace cellFace, int neighborX, int neighborY, int neighborZ)
定义
WireDomainElectricElement.cs:27
Game.WireDomainElectricElement.WireDomainElectricElement
WireDomainElectricElement(SubsystemElectricity subsystemElectricity, IEnumerable< CellFace > cellFaces)
定义
WireDomainElectricElement.cs:7
Game.WireDomainElectricElement.m_voltage
float m_voltage
定义
WireDomainElectricElement.cs:5
Engine
定义
BaseSound.cs:10
Game
定义
ContentFileBridge.cs:4
Game.ElectricConnectorType
ElectricConnectorType
定义
ElectricConnectorType.cs:2
Engine.Point3
定义
Point3.cs:2
Engine.Point3.Y
int Y
定义
Point3.cs:5
Engine.Point3.X
int X
定义
Point3.cs:3
Engine.Point3.Z
int Z
定义
Point3.cs:7
Game.CellFace
定义
CellFace.cs:4
Game.CellFace.X
int X
定义
CellFace.cs:5
Game.CellFace.Y
int Y
定义
CellFace.cs:7
Game.CellFace.Face
int Face
定义
CellFace.cs:11
Game.CellFace.FaceToPoint3
static Point3 FaceToPoint3(int face)
定义
CellFace.cs:48
Game.CellFace.Z
int Z
定义
CellFace.cs:9
SurvivalcraftApi 1.8.2.3
Survivalcraft.Windows
Game
WireDomainElectricElement.cs
制作者
1.16.1