Exemplo n.º 1
0
        static MyMotorSuspension()
        {
            var steering = new MyTerminalControlCheckbox <MyMotorSuspension>("Steering", MySpaceTexts.BlockPropertyTitle_Motor_Steering, MySpaceTexts.BlockPropertyDescription_Motor_Steering);

            steering.Getter = (x) => x.Steering;
            steering.Setter = (x, v) => x.SyncObject.ChangeSteering(v);
            steering.EnableAction();
            steering.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(steering);

            var maxSteerAngle = new MyTerminalControlSlider <MyMotorSuspension>("MaxSteerAngle", MySpaceTexts.BlockPropertyTitle_Motor_MaxSteerAngle, MySpaceTexts.BlockPropertyDescription_Motor_MaxSteerAngle);

            maxSteerAngle.SetLimits((x) => 0, (x) => x.BlockDefinition.MaxSteer);
            maxSteerAngle.DefaultValue = 0.45f;
            maxSteerAngle.Getter       = (x) => x.GetMaxSteerAngleForTerminal();
            maxSteerAngle.Setter       = (x, v) => x.SyncObject.ChangeSlider(MySyncMotorSuspension.SliderEnum.MaxSteerAngle, v);
            maxSteerAngle.Writer       = (x, res) => MyMotorStator.WriteAngle(x.GetMaxSteerAngleForTerminal(), res);
            maxSteerAngle.EnableActionsWithReset();
            maxSteerAngle.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(maxSteerAngle);

            var steerSpeed = new MyTerminalControlSlider <MyMotorSuspension>("SteerSpeed", MySpaceTexts.BlockPropertyTitle_Motor_SteerSpeed, MySpaceTexts.BlockPropertyDescription_Motor_SteerSpeed);

            steerSpeed.SetLimits((x) => 0, (x) => x.BlockDefinition.SteeringSpeed * 100);
            steerSpeed.DefaultValue = 2f;
            steerSpeed.Getter       = (x) => x.GetSteerSpeedForTerminal();
            steerSpeed.Setter       = (x, v) => x.SyncObject.ChangeSlider(MySyncMotorSuspension.SliderEnum.SteerSpeed, v / 100);
            steerSpeed.Writer       = (x, res) => MyValueFormatter.AppendTorqueInBestUnit(x.GetSteerSpeedForTerminal(), res);
            steerSpeed.EnableActionsWithReset();
            steerSpeed.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(steerSpeed);

            var steerReturnSpeed = new MyTerminalControlSlider <MyMotorSuspension>("SteerReturnSpeed", MySpaceTexts.BlockPropertyTitle_Motor_SteerReturnSpeed, MySpaceTexts.BlockPropertyDescription_Motor_SteerReturnSpeed);

            steerReturnSpeed.SetLimits((x) => 0, (x) => x.BlockDefinition.SteeringSpeed * 100);
            steerReturnSpeed.DefaultValue = 1f;
            steerReturnSpeed.Getter       = (x) => x.GetSteerReturnSpeedForTerminal();
            steerReturnSpeed.Setter       = (x, v) => x.SyncObject.ChangeSlider(MySyncMotorSuspension.SliderEnum.SteerReturnSpeed, v / 100);
            steerReturnSpeed.Writer       = (x, res) => MyValueFormatter.AppendTorqueInBestUnit(x.GetSteerReturnSpeedForTerminal(), res);
            steerReturnSpeed.EnableActionsWithReset();
            steerReturnSpeed.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(steerReturnSpeed);

            var invertSteer = new MyTerminalControlCheckbox <MyMotorSuspension>("InvertSteering", MySpaceTexts.BlockPropertyTitle_Motor_InvertSteer, MySpaceTexts.BlockPropertyDescription_Motor_InvertSteer);

            invertSteer.Getter = (x) => x.InvertSteer;
            invertSteer.Setter = (x, v) => x.SyncObject.ChangeSlider(MySyncMotorSuspension.SliderEnum.InvertSteer, (v ? 1 : 0));
            invertSteer.EnableAction();
            invertSteer.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(invertSteer);

            var propulsion = new MyTerminalControlCheckbox <MyMotorSuspension>("Propulsion", MySpaceTexts.BlockPropertyTitle_Motor_Propulsion, MySpaceTexts.BlockPropertyDescription_Motor_Propulsion);

            propulsion.Getter = (x) => x.Propulsion;
            propulsion.Setter = (x, v) => x.SyncObject.ChangePropulsion(v);
            propulsion.EnableAction();
            propulsion.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(propulsion);

            var power = new MyTerminalControlSlider <MyMotorSuspension>("Power", MySpaceTexts.BlockPropertyTitle_Motor_Power, MySpaceTexts.BlockPropertyDescription_Motor_Power);

            power.SetLimits(0, 100);
            power.DefaultValue = 100;
            power.Getter       = (x) => x.GetPowerForTerminal();
            power.Setter       = (x, v) => x.SyncObject.ChangePower(v / 100);
            power.Writer       = (x, res) => res.AppendInt32((int)(x.Power * 100)).Append("%");
            power.EnableActions();
            power.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(power);

            var friction = new MyTerminalControlSlider <MyMotorSuspension>("Friction", MySpaceTexts.BlockPropertyTitle_Motor_Friction, MySpaceTexts.BlockPropertyDescription_Motor_Friction);

            friction.SetLimits(0, 100);
            friction.DefaultValue = 150f / 800;
            friction.Getter       = (x) => x.GetFrictionForTerminal();
            friction.Setter       = (x, v) => x.SyncObject.ChangeFriction(v / 100);
            friction.Writer       = (x, res) => res.AppendInt32((int)(x.Friction * 100)).Append("%");
            friction.EnableActions();
            friction.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(friction);

            var damping = new MyTerminalControlSlider <MyMotorSuspension>("Damping", MySpaceTexts.BlockPropertyTitle_Motor_Damping, MySpaceTexts.BlockPropertyTitle_Motor_Damping);

            damping.SetLimits(0, 100);
            damping.Getter = (x) => x.GetDampingForTerminal();
            damping.Setter = (x, v) => x.SyncObject.ChangeDamping(v * 0.002f);
            damping.Writer = (x, res) => res.AppendInt32((int)(x.Damping / 0.002f)).Append("%");
            damping.EnableActions();
            damping.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(damping);

            var strength = new MyTerminalControlSlider <MyMotorSuspension>("Strength", MySpaceTexts.BlockPropertyTitle_Motor_Strength, MySpaceTexts.BlockPropertyTitle_Motor_Strength);

            strength.SetLimits(0, 100);
            strength.Getter = (x) => x.GetStrengthForTerminal();
            strength.Setter = (x, v) => x.SyncObject.ChangeStrength(v * 0.002f);
            strength.Writer = (x, res) => res.AppendInt32((int)(x.Strength / 0.002f)).Append("%");
            strength.EnableActions();
            strength.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(strength);

            var height = new MyTerminalControlSlider <MyMotorSuspension>("Height", MySpaceTexts.BlockPropertyTitle_Motor_Height, MySpaceTexts.BlockPropertyDescription_Motor_Height);

            height.SetLimits((x) => x.BlockDefinition.MinHeight, (x) => x.BlockDefinition.MaxHeight);
            height.DefaultValue = 0;
            height.Getter       = (x) => x.GetHeightForTerminal();
            height.Setter       = (x, v) => x.SyncObject.ChangeSlider(MySyncMotorSuspension.SliderEnum.Height, v);
            height.Writer       = (x, res) => MyValueFormatter.AppendDistanceInBestUnit(x.Height, res);
            height.EnableActionsWithReset();
            height.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(height);

            var travel = new MyTerminalControlSlider <MyMotorSuspension>("Travel", MySpaceTexts.BlockPropertyTitle_Motor_SuspensionTravel, MySpaceTexts.BlockPropertyDescription_Motor_SuspensionTravel);

            travel.SetLimits(0, 100);
            travel.DefaultValue = 100;
            travel.Getter       = (x) => x.GetSuspensionTravelForTerminal();
            travel.Setter       = (x, v) => x.SyncObject.ChangeSlider(MySyncMotorSuspension.SliderEnum.SuspensionTravel, v / 100.0f);
            travel.Writer       = (x, res) => res.AppendInt32((int)x.GetSuspensionTravelForTerminal()).Append("%");
            travel.EnableActionsWithReset();
            travel.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(travel);
        }
Exemplo n.º 2
0
        protected override void CreateTerminalControls()
        {
            if (MyTerminalControlFactory.AreControlsCreated <MyMotorSuspension>())
            {
                return;
            }
            base.CreateTerminalControls();

            var addWheelHead = new MyTerminalControlButton <MyMotorSuspension>("Add Top Part", MySpaceTexts.BlockActionTitle_AddWheel, MySpaceTexts.BlockActionTooltip_AddWheel, (b) => b.RecreateTop());

            addWheelHead.Enabled = (b) => (b.TopBlock == null);
            addWheelHead.EnableAction(MyTerminalActionIcons.STATION_ON);
            MyTerminalControlFactory.AddControl(addWheelHead);

            var steering = new MyTerminalControlCheckbox <MyMotorSuspension>("Steering", MySpaceTexts.BlockPropertyTitle_Motor_Steering, MySpaceTexts.BlockPropertyDescription_Motor_Steering);

            steering.Getter = (x) => x.Steering;
            steering.Setter = (x, v) => x.Steering = v;
            steering.EnableAction();
            steering.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(steering);

            var maxSteerAngle = new MyTerminalControlSlider <MyMotorSuspension>("MaxSteerAngle", MySpaceTexts.BlockPropertyTitle_Motor_MaxSteerAngle, MySpaceTexts.BlockPropertyDescription_Motor_MaxSteerAngle);

            maxSteerAngle.SetLimits((x) => 0, (x) => x.BlockDefinition.MaxSteer);
            maxSteerAngle.DefaultValue = 0.45f;
            maxSteerAngle.Getter       = (x) => x.GetMaxSteerAngleForTerminal();
            maxSteerAngle.Setter       = (x, v) => x.MaxSteerAngle = v;
            maxSteerAngle.Writer       = (x, res) => MyMotorStator.WriteAngle(x.GetMaxSteerAngleForTerminal(), res);
            maxSteerAngle.EnableActionsWithReset();
            maxSteerAngle.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(maxSteerAngle);

            var steerSpeed = new MyTerminalControlSlider <MyMotorSuspension>("SteerSpeed", MySpaceTexts.BlockPropertyTitle_Motor_SteerSpeed, MySpaceTexts.BlockPropertyDescription_Motor_SteerSpeed);

            steerSpeed.SetLimits((x) => 0, (x) => x.BlockDefinition.SteeringSpeed * 100);
            steerSpeed.DefaultValue = 2f;
            steerSpeed.Getter       = (x) => x.GetSteerSpeedForTerminal();
            steerSpeed.Setter       = (x, v) => x.SteerSpeed = v / 100;
            steerSpeed.Writer       = (x, res) => MyValueFormatter.AppendTorqueInBestUnit(x.GetSteerSpeedForTerminal(), res);
            steerSpeed.EnableActionsWithReset();
            steerSpeed.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(steerSpeed);

            var steerReturnSpeed = new MyTerminalControlSlider <MyMotorSuspension>("SteerReturnSpeed", MySpaceTexts.BlockPropertyTitle_Motor_SteerReturnSpeed, MySpaceTexts.BlockPropertyDescription_Motor_SteerReturnSpeed);

            steerReturnSpeed.SetLimits((x) => 0, (x) => x.BlockDefinition.SteeringSpeed * 100);
            steerReturnSpeed.DefaultValue = 1f;
            steerReturnSpeed.Getter       = (x) => x.GetSteerReturnSpeedForTerminal();
            steerReturnSpeed.Setter       = (x, v) => x.SteerReturnSpeed = v / 100;
            steerReturnSpeed.Writer       = (x, res) => MyValueFormatter.AppendTorqueInBestUnit(x.GetSteerReturnSpeedForTerminal(), res);
            steerReturnSpeed.EnableActionsWithReset();
            steerReturnSpeed.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(steerReturnSpeed);

            var invertSteer = new MyTerminalControlCheckbox <MyMotorSuspension>("InvertSteering", MySpaceTexts.BlockPropertyTitle_Motor_InvertSteer, MySpaceTexts.BlockPropertyDescription_Motor_InvertSteer);

            invertSteer.Getter = (x) => x.InvertSteer;
            invertSteer.Setter = (x, v) => x.InvertSteer = v;
            invertSteer.EnableAction();
            invertSteer.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(invertSteer);

            var propulsion = new MyTerminalControlCheckbox <MyMotorSuspension>("Propulsion", MySpaceTexts.BlockPropertyTitle_Motor_Propulsion, MySpaceTexts.BlockPropertyDescription_Motor_Propulsion);

            propulsion.Getter = (x) => x.Propulsion;
            propulsion.Setter = (x, v) => x.Propulsion = v;
            propulsion.EnableAction();
            propulsion.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(propulsion);

            var invertPropulsion = new MyTerminalControlCheckbox <MyMotorSuspension>("InvertPropulsion", MySpaceTexts.BlockPropertyTitle_Motor_InvertPropulsion, MySpaceTexts.BlockPropertyDescription_Motor_InvertPropulsion);

            invertPropulsion.Getter = (x) => x.InvertPropulsion;
            invertPropulsion.Setter = (x, v) => x.InvertPropulsion = v;
            invertPropulsion.EnableAction();
            invertPropulsion.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(invertPropulsion);

            var power = new MyTerminalControlSlider <MyMotorSuspension>("Power", MySpaceTexts.BlockPropertyTitle_Motor_Power, MySpaceTexts.BlockPropertyDescription_Motor_Power);

            power.SetLimits(0, 100);
            power.DefaultValue = 100;
            power.Getter       = (x) => x.GetPowerForTerminal();
            power.Setter       = (x, v) => x.Power = v / 100;
            power.Writer       = (x, res) => res.AppendInt32((int)(x.Power * 100)).Append("%");
            power.EnableActions();
            power.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(power);

            var friction = new MyTerminalControlSlider <MyMotorSuspension>("Friction", MySpaceTexts.BlockPropertyTitle_Motor_Friction, MySpaceTexts.BlockPropertyDescription_Motor_Friction);

            friction.SetLimits(0, 100);
            friction.DefaultValue = 150f / 800;
            friction.Getter       = (x) => x.GetFrictionForTerminal();
            friction.Setter       = (x, v) => x.Friction = v / 100;
            friction.Writer       = (x, res) => res.AppendInt32((int)(x.Friction * 100)).Append("%");
            friction.EnableActions();
            friction.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(friction);

            var damping = new MyTerminalControlSlider <MyMotorSuspension>("Damping", MySpaceTexts.BlockPropertyTitle_Motor_Damping, MySpaceTexts.BlockPropertyTitle_Motor_Damping);

            damping.SetLimits(0, 100);
            damping.Getter = (x) => x.GetDampingForTerminal();
            damping.Setter = (x, v) => x.Damping = v / 100;
            damping.Writer = (x, res) => res.AppendInt32((int)(x.GetDampingForTerminal())).Append("%");
            damping.EnableActions();
            damping.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(damping);

            var strength = new MyTerminalControlSlider <MyMotorSuspension>("Strength", MySpaceTexts.BlockPropertyTitle_Motor_Strength, MySpaceTexts.BlockPropertyTitle_Motor_Strength);

            strength.SetLimits(0, 100);
            strength.Getter = (x) => x.GetStrengthForTerminal();
            strength.Setter = (x, v) => x.Strength = v / 100;
            strength.Writer = (x, res) => res.AppendInt32((int)(x.GetStrengthForTerminal())).Append("%");
            strength.EnableActions();
            strength.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(strength);

            var height = new MyTerminalControlSlider <MyMotorSuspension>("Height", MySpaceTexts.BlockPropertyTitle_Motor_Height, MySpaceTexts.BlockPropertyDescription_Motor_Height);

            height.SetLimits((x) => x.BlockDefinition.MinHeight, (x) => x.BlockDefinition.MaxHeight);
            height.DefaultValue = 0;
            height.Getter       = (x) => x.GetHeightForTerminal();
            height.Setter       = (x, v) => x.Height = v;
            height.Writer       = (x, res) => MyValueFormatter.AppendDistanceInBestUnit(x.Height, res);
            height.EnableActionsWithReset();
            height.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(height);

            var travel = new MyTerminalControlSlider <MyMotorSuspension>("Travel", MySpaceTexts.BlockPropertyTitle_Motor_SuspensionTravel, MySpaceTexts.BlockPropertyDescription_Motor_SuspensionTravel);

            travel.SetLimits(0, 100);
            travel.DefaultValue = 100;
            travel.Getter       = (x) => x.GetSuspensionTravelForTerminal();
            travel.Setter       = (x, v) => x.SuspensionTravel = v / 100.0f;
            travel.Writer       = (x, res) => res.AppendInt32((int)x.GetSuspensionTravelForTerminal()).Append("%");
            travel.EnableActionsWithReset();
            travel.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(travel);

            var speed = new MyTerminalControlSlider <MyMotorSuspension>("Speed Limit", MySpaceTexts.BlockPropertyTitle_Motor_SuspensionSpeed, MySpaceTexts.BlockPropertyDescription_Motor_SuspensionSpeed);

            speed.SetLimits(0, MaxSpeedLimit);
            speed.DefaultValue = MaxSpeedLimit;
            speed.Getter       = (x) => x.SpeedLimit;
            speed.Setter       = (x, v) => x.SpeedLimit = v;
            speed.Writer       = (x, res) =>
            {
                if (x.SpeedLimit >= MyMotorSuspension.MaxSpeedLimit)
                {
                    res.AppendStringBuilder(MyTexts.Get(MySpaceTexts.BlockPropertyValue_MotorAngleUnlimited));
                }
                else
                {
                    res.AppendInt32((int)x.SpeedLimit).Append("km/h");
                }
            };
            speed.EnableActionsWithReset();
            speed.Enabled = (x) => x.m_constraint != null;
            MyTerminalControlFactory.AddControl(speed);
        }
 public MyDebugRenderComponentMotorStator(MyMotorStator motor):base(motor)
 {
     m_motor = motor;
 }
Exemplo n.º 4
0
 public MySyncMotorStator(MyMotorStator stator)
     : base(stator)
 {
 }