private void Staging(ActionMachine action) { bool closed = true; float position_target = 0f; float velocity = 0f; switch (action) { case ActionMachine.LockBottom: velocity = -MyProperty.locker_velocity; position_target = MyProperty.locker_position_min; bottom_mergers.On(); bottom_pistons.Velocity(velocity); WriteText($"Bottom mergers: On", true); WriteText($"Velocity: {velocity}", true); WriteText($"Target Position={position_target}", true); closed = true; bottom_pistons.ForEach(delegate(IMyPistonBase block) { WriteText($"Position={block.CurrentPosition}", true); }); if (bottom_pistons.IsLessPosition(position_target)) { Stage++; } break; case ActionMachine.UnlockBottom: closed = true; top_mergers.ForEach(delegate(IMyShipMergeBlock block) { if (!block.IsConnected) { closed = false; } }); if (!closed) { WriteText($"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", true); WriteText($"Security: Top mergers is Off", true); } else { velocity = MyProperty.locker_velocity; position_target = MyProperty.locker_position_max; bottom_mergers.Off(); bottom_pistons.Velocity(velocity); WriteText($"Bottom mergers: Off", true); WriteText($"Velocity: {velocity}", true); WriteText($"Target Position={position_target}", true); closed = true; bottom_pistons.ForEach(delegate(IMyPistonBase block) { WriteText($"Position={block.CurrentPosition}", true); }); if (bottom_pistons.IsMorePosition(position_target)) { Stage++; } } break; case ActionMachine.LockTop: velocity = -MyProperty.locker_velocity; position_target = MyProperty.locker_position_min; top_mergers.On(); top_pistons.Velocity(velocity); WriteText($"Bottom mergers: On", true); WriteText($"Velocity: {velocity}", true); WriteText($"Target Position={position_target}", true); closed = true; top_pistons.ForEach(delegate(IMyPistonBase block) { WriteText($"Position={block.CurrentPosition}", true); }); if (top_pistons.IsLessPosition(position_target)) { connector.Lock(); Stage++; } break; case ActionMachine.UnlockTop: closed = true; bottom_mergers.ForEach(delegate(IMyShipMergeBlock block) { if (!block.IsConnected) { closed = false; } }); if (!closed) { WriteText($"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", true); WriteText($"Security: Bottom mergers is Off", true); } else { velocity = MyProperty.locker_velocity; position_target = MyProperty.locker_position_max; top_mergers.Off(); top_pistons.Velocity(velocity); connector.Unlock(); WriteText($"Top mergers: Off", true); WriteText($"Connector: Unlock", true); WriteText($"Velocity: {velocity}", true); WriteText($"Target Position={position_target}", true); closed = true; top_pistons.ForEach(delegate(IMyPistonBase block) { WriteText($"Position={block.CurrentPosition}", true); }); if (top_pistons.IsMorePosition(position_target)) { Stage++; } } break; case ActionMachine.Down: levage_pistons.On(); WriteText($"Piston Levage: On", true); velocity = MyProperty.elevator_velocity_min; if (Mode == ModeMachine.Up) { velocity = MyProperty.elevator_velocity_max; } WriteText($"Piston Velocity: {velocity}", true); levage_pistons.Velocity(velocity); position_target = MyProperty.elevator_position_max; WriteText($"Target Position={position_target}", true); levage_pistons.ForEach(delegate(IMyPistonBase block) { WriteText($"Position={block.CurrentPosition}", true); }); //projector_count = projector.List[0].RemainingBlocks; if (levage_pistons.IsMorePosition(position_target)) { Stage++; } break; case ActionMachine.Up: levage_pistons.On(); WriteText($"Piston Levage: On", true); velocity = -MyProperty.elevator_velocity_max; if (Mode == ModeMachine.Up) { velocity = -MyProperty.elevator_velocity_min; } WriteText($"Piston Velocity: {velocity}", true); levage_pistons.Velocity(velocity); position_target = MyProperty.elevator_position_min; WriteText($"Target Position={position_target}", true); levage_pistons.ForEach(delegate(IMyPistonBase block) { WriteText($"Position={block.CurrentPosition}", true); }); //projector_count = projector.List[0].RemainingBlocks; if (levage_pistons.IsLessPosition(position_target + 0.1f)) { Stage++; } break; case ActionMachine.StartWelder: projector.On(); welders.On(); WriteText($"Welders: On", true); Stage++; break; case ActionMachine.StopWelder: welders.Off(); projector.Off(); WriteText($"Welders: Off", true); Stage++; break; case ActionMachine.StartGrinder: grinders.On(); //projector.On(); WriteText($"Grinders: On", true); Stage++; break; case ActionMachine.StopGrinder: grinders.Off(); //projector.Off(); WriteText($"Grinders: Off", true); Stage++; break; case ActionMachine.Terminated: Cycle -= 1; if (Cycle == 0) { Mode = ModeMachine.Stop; } Stage = 0; break; case ActionMachine.Start: MyProperty.Load(); light.On(); drills.On(); Stage++; break; case ActionMachine.Stop: projector.Off(); light.Off(); drills.Off(); Stage++; break; } }