Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
DispenserElectricElement.cs
浏览该文件的文档.
1using Engine;
2
3namespace Game {
5 public bool m_isDispenseAllowed = true;
6
7 public double? m_lastDispenseTime;
8
10
11 public DispenserElectricElement(SubsystemElectricity subsystemElectricity, Point3 point) : base(
12 subsystemElectricity,
13 new List<CellFace> {
14 new(point.X, point.Y, point.Z, 0),
15 new(point.X, point.Y, point.Z, 1),
16 new(point.X, point.Y, point.Z, 2),
17 new(point.X, point.Y, point.Z, 3),
18 new(point.X, point.Y, point.Z, 4),
19 new(point.X, point.Y, point.Z, 5)
20 }
22
23 public override bool Simulate() {
24 if (CalculateHighInputsCount() > 0) {
25 if (m_isDispenseAllowed && (!m_lastDispenseTime.HasValue || SubsystemElectricity.SubsystemTime.GameTime - m_lastDispenseTime > 0.1)) {
26 m_isDispenseAllowed = false;
27 m_lastDispenseTime = SubsystemElectricity.SubsystemTime.GameTime;
28 m_subsystemBlockEntities.GetBlockEntity(CellFaces[0].Point.X, CellFaces[0].Point.Y, CellFaces[0].Point.Z)
29 ?.Entity.FindComponent<ComponentDispenser>()
30 ?.Dispense();
31 }
32 }
33 else {
35 }
36 return false;
37 }
38 }
39}
DispenserElectricElement(SubsystemElectricity subsystemElectricity, Point3 point) override bool Simulate()
SubsystemElectricity SubsystemElectricity
ElectricElement(SubsystemElectricity subsystemElectricity, IEnumerable< CellFace > cellFaces)
ReadOnlyList< CellFace > CellFaces
virtual Subsystem FindSubsystem(Type type, string name, bool throwOnError)