26 public Dictionary<Point3, QueuedAction>
m_actions = [];
52 public virtual void Update(
float dt) {
70 delegate(
int newData) {
89 delegate(
int newData) {
96 if (electricElement !=
null) {
106 public override void OnBlockRemoved(
int value,
int newValue,
int x,
int y,
int z) {
184 DynamicArray<IMovingBlockSet> dynamicArray =
new();
187 if (item.
Id ==
"Piston") {
194 base.Load(valuesDictionary);
207 foreach (KeyValuePair<Point3, QueuedAction> tmpAction
in m_tmpActions) {
208 Point3 key = tmpAction.Key;
215 else if (value.
Stop) {
221 foreach (KeyValuePair<Point3, QueuedAction> tmpAction2
in m_tmpActions) {
222 Point3 key2 = tmpAction2.Key;
224 if (value2.
Move.HasValue
229 for (
int i = -1; i <= 1; i++) {
230 for (
int j = -1; j <= 1; j++) {
232 if (chunkAtCell ==
null
243 foreach (KeyValuePair<Point3, QueuedAction> tmpAction3
in m_tmpActions) {
244 Point3 key3 = tmpAction3.Key;
246 if (!value3.
Move.HasValue
255 if (movingBlockSet.
Id ==
"Piston") {
263 int num =
int.MaxValue;
267 float num2 = movingBlockSet.Position.X * p.X + movingBlockSet.Position.Y * p.Y + movingBlockSet.Position.Z * p.
Z;
268 float num3 = point.X * p.X + point.Y * p.Y + point.Z * p.Z;
270 if (num + num2 - num3 > 1f) {
282 && num + num2 - num3 <= 0f) {
283 movingBlockSet.
SetBlock(p * num, 0);
291 switch (pistonSpeed) {
294 smoothness =
new Vector2(0f, 0.5f);
298 smoothness =
new Vector2(0.6f, 0.6f);
302 smoothness =
new Vector2(0.9f, 0.9f);
306 smoothness =
new Vector2(1.2f, 1.2f);
320 length = Math.Clamp(length, 0, maxExtension + 1);
326 int cellValue = terrain.
GetCellValue(position.
X + offset.
X, position.
Y + offset.
Y, position.
Z + offset.
Z);
334 item =
new MovingBlock { Offset = offset, Value = cellValue };
335 movingBlocks.
Add(item);
349 movingBlocks2.
Add(item);
352 int cellValue2 = terrain.
GetCellValue(position.
X + offset.
X, position.
Y + offset.
Y, position.
Z + offset.
Z);
353 if (!
IsBlockMovable(cellValue2, face, position.
Y + offset.
Y, out
bool isEnd)) {
357 item =
new MovingBlock { Offset = offset, Value = cellValue2 };
358 movingBlocks3.
Add(item);
367 Point3 p = position + (length - num) * point;
380 if (movingBlockSet !=
null) {
413 for (
int i = 0; i < pullCount + 1; i++) {
414 int cellValue3 = terrain.
GetCellValue(position.
X + offset.
X, position.
Y + offset.
Y, position.
Z + offset.
Z);
415 if (!
IsBlockMovable(cellValue3, face, position.
Y + offset.
Y, out
bool isEnd2)) {
419 item =
new MovingBlock { Offset = offset, Value = cellValue3 };
420 movingBlocks4.
Add(item);
428 && num4 < pullCount + 1) {
433 float s = length == 0 ? 0.01f : 0f;
447 if (movingBlockSet !=
null) {
473 if (movingBlockSet !=
null) {
477 bool flag = num == 237;
478 bool isExtended =
false;
484 if (!(
new Point3(x, y, z) == position)) {
486 if (flag || num2 != 238) {
506 if (movingBlockSet.
Id !=
"Piston") {
515 int num = p.X * point2.X + p.Y * point2.Y + p.Z * point2.
Z;
516 int num2 = point.X * point2.X + point.Y * point2.Y + point.Z * point2.
Z;
519 movingBlockSet.
Stop();
536 if (movingBlockSet.
Id !=
"Piston"
537 || movingBlockSet.
Tag is not
Point3 tag) {
549 public static bool IsBlockMovable(
int value,
int pistonFace,
int y, out
bool isEnd) {
static int Min(int x1, int x2)
virtual bool IsMovableByPiston(int value, int pistonFace, int y, out bool isEnd)
virtual bool IsBlockingPiston(int value)
ContainerWidget GuiWidget
DragHostWidget DragHostWidget
static void ShowDialog(ContainerWidget parentWidget, Dialog dialog)
static PistonMode GetMode(int data)
static int GetPullCount(int data)
static int GetFace(int data)
static int GetMaxExtension(int data)
static int SetIsExtended(int data, bool isExtended)
static int GetSpeed(int data)
static int GetFace(int data)
static int SetFace(int data, int face)
static int SetMode(int data, PistonMode mode)
static int SetIsShaft(int data, bool isShaft)
SubsystemTerrain SubsystemTerrain
void QueueElectricElementForSimulation(ElectricElement electricElement, int circuitStep)
ElectricElement GetElectricElement(int x, int y, int z, int mountingFace)
virtual void Update(float dt)
const int PistonMaxExtension
const int PistonMaxMovedBlocks
void MovingBlocksCollidedWithTerrain(IMovingBlockSet movingBlockSet, Point3 p)
SubsystemMovingBlocks m_subsystemMovingBlocks
void ProcessQueuedActions()
override void Load(ValuesDictionary valuesDictionary)
virtual void UpdateMovableBlocks()
override int[] HandledBlocks
SubsystemAudio m_subsystemAudio
bool m_allowPistonHeadRemove
SubsystemTerrain m_subsystemTerrain
static void GetSpeedAndSmoothness(int pistonSpeed, out float speed, out Vector2 smoothness)
override bool OnEditInventoryItem(IInventory inventory, int slotIndex, ComponentPlayer componentPlayer)
override bool OnEditBlock(int x, int y, int z, int value, ComponentPlayer componentPlayer)
override void OnChunkDiscarding(TerrainChunk chunk)
override void OnBlockRemoved(int value, int newValue, int x, int y, int z)
const int PistonMaxSpeedSetting
SubsystemTime m_subsystemTime
static bool IsBlockBlocking(int value)
void StopPiston(Point3 position)
List< KeyValuePair< Point3, QueuedAction > > m_tmpActions
bool MovePiston(Point3 position, int length)
Dictionary< Point3, QueuedAction > m_actions
SubsystemPlayers m_subsystemPlayers
static bool IsBlockMovable(int value, int pistonFace, int y, out bool isEnd)
void MovingBlocksStopped(IMovingBlockSet movingBlockSet)
void AdjustPiston(Point3 position, int length)
DynamicArray< MovingBlock > m_movingBlocks
static int ExtractContents(int value)
static int ReplaceData(int value, int data)
virtual int GetCellValue(int x, int y, int z)
static int ToCell(float x)
static int MakeBlockValue(int contents)
static int ExtractData(int value)
ValuesDictionary ValuesDictionary
int RemoveSlotItems(int slotIndex, int count)
实际移除的数量
int GetSlotCount(int slotIndex)
void AddSlotItems(int slotIndex, int value, int count)
int GetSlotValue(int slotIndex)
List< MovingBlock > Blocks
void SetBlock(Point3 offset, int value)
static readonly Point3 Zero
static Point3 FaceToPoint3(int face)