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(); }
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); }