Esempio n. 1
0
        public void Extend(VRageMath.Vector3 dir, int id, float value)
        {
            if (!XUtils.Directions.Contains(dir))
            {
                throw new Exception("Invalid direction vector used: " + dir);
            }

            if (id < 0 || id >= CountSensors)
            {
                throw new Exception("Parameter id (= " + id + ") out of range [" + 0 + ", " + CountSensors + ").");
            }

            if (value < Min || value > Max)
            {
                throw new Exception("Parameter value (= " + value + ") out of range [" + Min + ", " + Max + "].");
            }

            IMySensorBlock sensor = sensorBlocks[id];

            VRageMath.Matrix toSensor;
            sensor.Orientation.GetMatrix(out toSensor);
            VRageMath.Matrix.Transpose(ref toSensor, out toSensor);
            VRageMath.Matrix toGrid;
            referenceBlock.Orientation.GetMatrix(out toGrid);
            VRageMath.Vector3.Transform(ref dir, ref toGrid, out dir);
            VRageMath.Vector3.Transform(ref dir, ref toSensor, out dir);

            string propteryId = extendDirections[dir];

            sensor.SetValue(propteryId, value);
        }