Esempio n. 1
0
            private void ObtainActions()
            {
                Dictionary <string, float> actions = Owner.AvatarCtrl.GetActions().ToDictionary();

                foreach (KeyValuePair <string, float> pair in actions)
                {
                    Owner.ChosenActions.Host[ControlMapper.Idx(pair.Key)] = pair.Value;
                }

                Owner.ChosenActions.SafeCopyToDevice();
            }
Esempio n. 2
0
        public override void Validate(MyValidator validator)
        {
            validator.AssertError(Controls != null, this, "No controls available");

            validator.AssertError(File.Exists(SaveFile), this, "Please specify a correct SaveFile path in world properties.");
            validator.AssertError(File.Exists(TilesetTable), this, "Please specify a correct TilesetTable path in world properties.");
            validator.AssertError(RunFile == "" || File.Exists(RunFile), this, "Please enter an existing lua script file in world properties.");

            validator.AssertError(FoFSize > 0, this, "FoF size has to be positive.");
            validator.AssertError(FoFResWidth > 0, this, "FoF resolution width has to be positive.");
            validator.AssertError(FoFResHeight > 0, this, "FoF resolution height has to be positive.");
            validator.AssertError(FoVSize > 0, this, "FoV size has to be positive.");
            validator.AssertError(FoVResWidth > 0, this, "FoV resolution width has to be positive.");
            validator.AssertError(FoVResHeight > 0, this, "FoV resolution height has to be positive.");
            validator.AssertError(Width > 0, this, "Free view width has to be positive.");
            validator.AssertError(Height > 0, this, "Free view height has to be positive.");
            validator.AssertError(ResolutionWidth > 0, this, "Free view resolution width has to be positive.");
            validator.AssertError(ResolutionHeight > 0, this, "Free view resolution height has to be positive.");
            validator.AssertError(ToolSize > 0, this, "Tool size has to be positive.");
            validator.AssertError(ToolResWidth > 0, this, "Tool resolution width has to be positive.");
            validator.AssertError(ToolResHeight > 0, this, "Tool resolution height has to be positive.");

            ControlMapper.CheckControlSize(validator, Controls, this);

            TryToyWorld();

            foreach (TWLogMessage message in TWLog.GetAllLogMessages())
            {
                switch (message.Severity)
                {
                case TWSeverity.Error:
                {
                    validator.AssertError(false, this, message.ToString());
                    break;
                }

                case TWSeverity.Warn:
                {
                    validator.AssertWarning(false, this, message.ToString());
                    break;
                }
                }
            }
        }
Esempio n. 3
0
            public override void Execute()
            {
                if (SimulationStep != 0 && SimulationStep % Owner.RunEvery != 0)
                {
                    return;
                }

                Owner.Controls.SafeCopyToHost();

                float leftSignal     = Owner.Controls.Host[ControlMapper.Idx("left")];
                float rightSignal    = Owner.Controls.Host[ControlMapper.Idx("right")];
                float fwSignal       = Owner.Controls.Host[ControlMapper.Idx("forward")];
                float bwSignal       = Owner.Controls.Host[ControlMapper.Idx("backward")];
                float rotLeftSignal  = Owner.Controls.Host[ControlMapper.Idx("rot_left")];
                float rotRightSignal = Owner.Controls.Host[ControlMapper.Idx("rot_right")];

                float fof_left  = Owner.Controls.Host[ControlMapper.Idx("fof_left")];
                float fof_right = Owner.Controls.Host[ControlMapper.Idx("fof_right")];
                float fof_up    = Owner.Controls.Host[ControlMapper.Idx("fof_up")];
                float fof_down  = Owner.Controls.Host[ControlMapper.Idx("fof_down")];

                float rotation   = ConvertBiControlToUniControl(rotRightSignal, rotLeftSignal);
                float speed      = ConvertBiControlToUniControl(fwSignal, bwSignal);
                float rightSpeed = ConvertBiControlToUniControl(rightSignal, leftSignal);
                float fof_x      = ConvertBiControlToUniControl(fof_left, fof_right);
                float fof_y      = ConvertBiControlToUniControl(fof_up, fof_down);

                bool interact = Owner.Controls.Host[ControlMapper.Idx("interact")] > 0.5;
                bool use      = Owner.Controls.Host[ControlMapper.Idx("use")] > 0.5;
                bool pickup   = Owner.Controls.Host[ControlMapper.Idx("pickup")] > 0.5;

                IAvatarControls ctrl = new AvatarControls(100, speed, rightSpeed, rotation, interact, use, pickup,
                                                          fof: new PointF(fof_x, fof_y));

                Owner.AvatarCtrl.SetActions(ctrl);
            }