private void StopPistonGroup(EPistonGroupType pistonGroupType) { foreach (IMyPistonBase piston in pistonGroups[(int)pistonGroupType]) { if ((piston.Status == PistonStatus.Extending) || (piston.Status == PistonStatus.Retracting)) { piston.Velocity = 0.0f; } } }
private bool IsPistonGroupFinished(EPistonGroupType pistonGroupType, bool extend) { bool ret = true; foreach (IMyPistonBase piston in pistonGroups[(int)pistonGroupType]) { if (piston.Status != (extend ? PistonStatus.Extended : PistonStatus.Retracted)) { ret = false; break; } } return(ret); }
private bool MovePistonGroup(EPistonGroupType pistonGroupType, float velocity) { bool ret = true; List <IMyPistonBase> piston_group = pistonGroups[(int)pistonGroupType]; float initial_velocity_per_piston = ((piston_group.Count > 0) ? (velocity / piston_group.Count) : 0.0f); foreach (IMyPistonBase piston in piston_group) { piston.Velocity = initial_velocity_per_piston; if (((velocity < 0.0f) && (piston.Status != PistonStatus.Retracted)) || ((velocity > 0.0f) && (piston.Status != PistonStatus.Extended))) { ret = false; } } return(ret); }