public Gyroscopes(IMyTerminalBlock referenceBlock, List <IMyTerminalBlock> blocks) : base(referenceBlock) { UpdateGyroscopes(blocks); IMyGyro gyro = gyroscopeBlocks[0]; Min = gyro.GetMininum <float>(GyroAction.Pitch.Name); Max = gyro.GetMaximum <float>(GyroAction.Pitch.Name); Default = gyro.GetDefaultValue <float>(GyroAction.Pitch.Name); }
public void UpdateBlocks(List <IMyTerminalBlock> list) { gyros = new List <IMyGyro>(); thrusters = new Dictionary <VRageMath.Vector3, List <IMyThrust> >(); VRageMath.Matrix tmp = new VRageMath.Matrix(); for (int i = 0; i < list.Count; ++i) { var block = list[i]; if (block is IMyGyro) { IMyGyro gyro = (IMyGyro)block; if (gyros.Count == 0) { gyroRotateMin = gyro.GetMininum <float>(GyroAction.Pitch.GetName()); gyroRotateMax = gyro.GetMaximum <float>(GyroAction.Pitch.GetName()); } gyros.Add(gyro); } else if (block is IMyThrust) { IMyThrust thruster = block as IMyThrust; if (thrusters.Count == 0) { thrusterOverrideMin = thruster.GetMininum <float>("Override"); thrusterOverrideMax = thruster.GetMaximum <float>("Override"); } block.Orientation.GetMatrix(out tmp); // The exhaust is directed to the Forward vector of the thruster, so it accelerates to Backward. VRageMath.Vector3 dir = tmp.Backward; if (!thrusters.ContainsKey(dir)) { thrusters[dir] = new List <IMyThrust>(); } thrusters[dir].Add(thruster); } } }