Beispiel #1
0
 public WindowQueue(ScreenId id, GameObject prefab, ControllerData paramsModal, ViewElementData screenElement)
 {
     Id            = id;
     Prafab        = prefab;
     ParamsModal   = paramsModal;
     ScreenElement = screenElement;
 }
Beispiel #2
0
    /* Работа с экранами несколько отличается от работы модальных окон
     * Модальное окно может быть в единсвенном колличестве и они в очереди открытия, одно за другим
     * Экрны же могут открываться сворачивая предыдущий экран, а когда экран закрывается, то разворачивается предыдущий
     * в этом и вся разница
     */

    public void CreateMainScreen <TController, TView>(ControllerData paramsScreen) where TController : IControllerUI <TView>
    {
        titlePanelUIView.gameObject.SetActive(true);
        var id = ScreenId.GetMainScreen();

        if (id == null)
        {
            Debug.LogError("ВНИМАНИЕ!!! НЕТ ГЛАВНОГО ЭКРАНА В КОНФИГЕ!!!");
            return;
        }

        var controller = default(TController);

        controller = (TController)Activator.CreateInstance(typeof(TController));

        controller.SetData(paramsScreen);
        var createdAction = new Action <object>((obj) => { controller.OnCreatedView(((TView)obj)); });
        var prefab        = GetPrefab(id, "[Screen]");
        var screen        = Instantiate(prefab, screenRect).GetComponent <AbstractView>();

        closedActionMain  = new Action(() => { controller.OnWantToCloseView((TView)(screen as object)); });
        destroyActionMain = new Action(() => { controller.OnDestoyView((TView)(screen as object)); });

        currentMainScreen = screen;
        screen.GetComponent <RectTransform>().SetSiblingIndex(-999999);
        createdAction?.Invoke(screen);

        titlePanelUIView.SetScreenConfig("Main Screen", id.Config.TitleConfig);
    }
    ControllerData ICharacterController.Controll()
    {
        ControllerData cd = new ControllerData();

        if (Input.GetKey(KeyCode.LeftArrow))
        {
            cd.isLeft = true;
        }

        if (Input.GetKey(KeyCode.RightArrow))
        {
            cd.isRight = true;
        }

        if (Input.GetKey(KeyCode.DownArrow))
        {
            cd.isDown = true;
        }

        if (Input.GetKey(KeyCode.UpArrow))
        {
            cd.isUp = true;
        }

        return(cd);
    }
Beispiel #4
0
    public static void OpenMessage(string text)
    {
        var data = new ControllerData();

        data.SetParam("Text", text);
        windowManager.CreateWindow <WindowMessageUIController, IWindowMessageUIView>(ScreenId.MessageWindow, data);
    }
Beispiel #5
0
    public static void LoadControllerData()
    {
        string data = ReadControllerData();

        if (data != null)
        {
            ControllerData controllerData = JsonUtility.FromJson <ControllerData>(data);

            PersistentData.Instance.UpPath    = controllerData.upPath;
            PersistentData.Instance.LeftPath  = controllerData.leftPath;
            PersistentData.Instance.RightPath = controllerData.rightPath;
            PersistentData.Instance.DownPath  = controllerData.downPath;
            PersistentData.Instance.DodgePath = controllerData.dodgePath;
            PersistentData.Instance.UsePath   = controllerData.usePath;
            PersistentData.Instance.SwordPath = controllerData.swordPath;
            PersistentData.Instance.GunPath   = controllerData.gunPath;
        }
        else
        {
            PersistentData.Instance.UpPath    = "<Keyboard>/w";
            PersistentData.Instance.LeftPath  = "<Keyboard>/a";
            PersistentData.Instance.RightPath = "<Keyboard>/d";
            PersistentData.Instance.DownPath  = "<Keyboard>/s";
            PersistentData.Instance.DodgePath = "<Keyboard>/space";
            PersistentData.Instance.UsePath   = "<Keyboard>/e";
            PersistentData.Instance.SwordPath = "<Mouse>/leftButton";
            PersistentData.Instance.GunPath   = "<Mouse>/rightButton";
        }
    }
        internal static IEnumerable <EndpointData> GetControllerEndpoints(ControllerData controller)
        {
            foreach (var method in controller.ControllerType.Methods)
            {
                if (method.DeclaringType != controller.ControllerType && method.DeclaringType.HasAttribute <DeprecatedAttribute>())
                {
                    continue;
                }
                if (method.TryGetAttribute <DeprecatedAttribute>(out var deprecatedAttribute) && deprecatedAttribute.Hide)
                {
                    continue;
                }
                if (!method.TryGetAttribute <HttpMethodAttribute>(out var httpMethodAttribute))
                {
                    continue;
                }

                var name = httpMethodAttribute.HttpMethods.FirstOrDefault();

                if (name != null && HttpMethods.TryGetValue(name, out var httpMethod))
                {
                    yield return(new EndpointData(method, httpMethod, controller, controller.Deprecated || deprecatedAttribute != null));
                }
            }
        }
		public void Initialise()
		{
			Controllers = new ControllerData[NO_OF_CONTROLLERS];
			for (int i = 0; i < NO_OF_CONTROLLERS; ++i)
			{
				Controllers[i] = new ControllerData{PlayerIndex = (PlayerIndex) i, Left = 0f, Right = 0f };
			}
		}
        private MethodInfo GetBodyAction(string name, ControllerData data, MemoryContentBase content, Method method)
        {
            var candidates = data.Methods.Where(m => m.Name.ToLower() == name.ToLower());

            if (method != Method.GET)
            {
                candidates = candidates.Where(t =>
                {
                    var att = t.GetCustomAttribute <FromMethod>();
                    if (att == null)
                    {
                        return(false);
                    }
                    return(att.Method == method);
                });
            }

            MethodInfo noParam = null;

            foreach (var candidate in candidates)
            {
                var parameters = candidate.GetParameters();
                if (parameters.Length <= 0)
                {
                    noParam = candidate;
                }

                if (parameters.Length > 1)
                {
                    continue;
                }

                var attribute = candidate.GetCustomAttribute <FromJson>();
                if (content is JsonContent && attribute != null)
                {
                    return(candidate);
                }

                if (content is StringContent && parameters[0].ParameterType == typeof(string))
                {
                    return(candidate);
                }

                if (content is FormContent && parameters[0].ParameterType == typeof(FormContent))
                {
                    return(candidate);
                }
            }

            if (noParam != null)
            {
                return(noParam);
            }

            return(null);
        }
Beispiel #9
0
        /// <summary>
        /// 获取未编译文件
        /// </summary>
        /// <param name="controllerType">当前要识别的控制器类型</param>
        /// <param name="oneControllerData">当前正在操作的控制器实体</param>
        private static void GetNotCompileClass(Type controllerType, ControllerData oneControllerData)
        {
            if (controllerType.Assembly.Location == null)
            {
                return;
            }

            var rightPath = GetRightPath(controllerType);

            if (string.IsNullOrEmpty(rightPath))
            {
                return;
            }

            List <string> strList = new List <string>();

            using (FileStream fs = new FileStream(rightPath, FileMode.Open, FileAccess.Read))
            {
                using (StreamReader m_streamReader = new StreamReader(fs))
                {
                    //使用StreamReader类来读取文件
                    m_streamReader.BaseStream.Seek(0, SeekOrigin.Begin);
                    //  从数据流中读取每一行,直到文件的最后一行,并在richTextBox1中显示出内容

                    string strLine = m_streamReader.ReadLine();

                    string oneMethodData = string.Empty;

                    while (strLine != null)
                    {
                        if (@"/// <summary>" == strLine.Trim())
                        {
                            oneMethodData = string.Empty;

                            strLine        = m_streamReader.ReadLine();
                            oneMethodData += strLine;

                            while (strLine != null && (strLine.IndexOf("///") > -1) || strLine.IndexOf("[") > -1 || strLine.IndexOf("public") > -1)
                            {
                                if (strLine.IndexOf("public") > -1)
                                {
                                    GetMethodAnnotation(strLine, oneMethodData, oneControllerData);

                                    oneMethodData = string.Empty;
                                }

                                strLine        = m_streamReader.ReadLine();
                                oneMethodData += strLine;
                            }
                        }

                        strLine = m_streamReader.ReadLine();
                    }
                }
            }
        }
Beispiel #10
0
    private void Start()
    {
        ControllerData.InitServer(playerTemplate);

        QrCode      = generateQR(GetLocalIPAddress());
        isShowingQr = true;

        NetworkServer.Listen(ControllerData.APPLICATION_PORT);
        NetworkServer.RegisterHandler(ControllerData.DEFAULT_MESSAGE_TYPE, ServerReceiveMessage);
    }
    public static ControllerData Build(object obj)
    {
        var signal = new ControllerData();
        var fields = obj.GetType().GetFields();

        foreach (var field in fields)
        {
            signal.SetParam(field.Name, field.GetValue(obj));
        }
        return(signal);
    }
 public void unassign()
 {
     this.controller  = null;
     this.buttonIndex = -1;
     if (this.joystick != null)
     {
         this.joystick.Unacquire();
         this.joystick.SetNotification(null);
     }
     this.joystick = null;
 }
        internal static ApiVersion GetControllerApiVersion(ControllerData controller)
        {
            var apiVersion = GetMemberApiVersion(controller.ControllerType);

            if (apiVersion == null)
            {
                throw new ControllerException($"Could not find {nameof(ApiVersionAttribute)}.", controller.ControllerType);
            }

            return(apiVersion);
        }
Beispiel #14
0
 private static void ControllerDataMapper(ControllerData constrollerData, Item item)
 {
     foreach (var viewData in constrollerData.GetViews())
     {
         var viewItem = new Item {
             Title = viewData.GetViewName()
         };
         item.AddItem(viewItem);
         ViewDataMapper(viewData, viewItem);
     }
 }
Beispiel #15
0
 public void SetAllLights(ControllerData data)
 {
     foreach (FieldInfo field in data.GetType().GetFields(BindingFlags.Instance |
                                                          BindingFlags.Static |
                                                          BindingFlags.NonPublic |
                                                          BindingFlags.Public))
     {
         LightColor color = GetLightColor(data, field);
         string     id    = field.Name;
         SetLightForId(id, color);
     }
 }
Beispiel #16
0
    private void ServerReceiveMessage(NetworkMessage rawMessage)
    {
        string message = rawMessage.ReadMessage <StringMessage>().value;
        int    id      = rawMessage.conn.connectionId;

        Debug.Log("id " + id);

        if (!lockPlayerControls)
        {
            ControllerData.ApplyControllerDataServer(0, message);
        }
    }
    public static T Parse <T>(ControllerData signal) where T : new()
    {
        var obj = new T();

        if (signal != null)
        {
            foreach (var p in signal.list)
            {
                obj.GetType().GetField(p.Key).SetValue(obj, p.Value);
            }
        }
        return(obj);
    }
Beispiel #18
0
        internal static string GetControllerName(ControllerData controller)
        {
            const string suffix = "Controller";

            var name = GetMemberName(controller.ControllerType, suffix);

            if (name == null)
            {
                throw new ControllerException($"The name '{controller.ControllerType.Name}' does have the suffix '{suffix}'.", controller.ControllerType);
            }

            return(name);
        }
 // get if the ILaserPointer (controller) pressing on some GameObject
 public ILaserPointer IsLaserPointerPressingAt(GameObject go)
 {
     for (int i = _controllerData.Count - 1; i > 0; i--)
     {
         ILaserPointer  laserPointer = _controllerData.ElementAt(i).Key;
         ControllerData data         = _controllerData.ElementAt(i).Value;
         if (data.currentPressed == go)
         {
             return(laserPointer);
         }
     }
     return(null);
 }
        private Boolean getFirstPressedButton(System.Windows.Forms.Form parent, ControllerData controllerData, ButtonAssignment buttonAssignment)
        {
            Boolean gotAssignment = false;

            if (controllerData.guid == UDP_NETWORK_CONTROLLER_GUID)
            {
                PCarsUDPreader gameDataReader = (PCarsUDPreader)GameStateReaderFactory.getInstance().getGameStateReader(GameDefinition.pCarsNetwork);
                int            assignedButton = gameDataReader.getButtonIndexForAssignment();
                if (assignedButton != -1)
                {
                    removeAssignmentsForControllerAndButton(controllerData.guid, assignedButton);
                    buttonAssignment.controller  = controllerData;
                    buttonAssignment.buttonIndex = assignedButton;
                    listenForAssignment          = false;
                    gotAssignment = true;
                }
            }
            else
            {
                listenForAssignment = true;
                // Instantiate the joystick
                var joystick = new Joystick(directInput, controllerData.guid);
                // Acquire the joystick
                joystick.SetCooperativeLevel(parent, (CooperativeLevel.NonExclusive | CooperativeLevel.Background));
                joystick.Properties.BufferSize = 128;
                joystick.Acquire();
                while (listenForAssignment)
                {
                    Boolean[] buttons = joystick.GetCurrentState().Buttons;
                    for (int i = 0; i < buttons.Count(); i++)
                    {
                        if (buttons[i])
                        {
                            Console.WriteLine("Got button at index " + i);
                            removeAssignmentsForControllerAndButton(controllerData.guid, i);
                            buttonAssignment.controller  = controllerData;
                            buttonAssignment.joystick    = joystick;
                            buttonAssignment.buttonIndex = i;
                            listenForAssignment          = false;
                            gotAssignment = true;
                        }
                    }
                }
                if (!gotAssignment)
                {
                    joystick.Unacquire();
                }
            }
            return(gotAssignment);
        }
            public ControllerData[] Serialize()
            {
                lock (scriptedcontrols)
                {
                    ControllerData[] controls = new ControllerData[scriptedcontrols.Count];
                    int i = 0;

                    foreach (ScriptControllers c in scriptedcontrols.Values)
                    {
                        controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls);
                    }
                    return(controls);
                }
            }
Beispiel #22
0
 public ControllerBase(GameContext context, ControllerData data, Entity entity)
 {
     _context                    = context;
     _controllerData             = data;
     _entity                     = entity;
     entity.GearEvent.OnChanged += () =>
     {
         _spaceworthy = entity.GetBehavior <Thruster>() != null && entity.GetBehavior <Reactor>() != null;
         if (_spaceworthy)
         {
             CreateBehaviors();
         }
     };
 }
Beispiel #23
0
        private static IFormController GetFormController(ControllerData d)
        {
            var table = d.PerfTable.Item;

            if (table is BoeingPerfTable)
            {
                return(new BoeingController(d));
            }
            if (table is AirbusPerfTable)
            {
                return(new AirbusController(d));
            }
            throw new ArgumentException();
        }
        // get if the ILaserPointer (controller) pointing at some GameObject
        public ILaserPointer IsLaserPointerPointingAt(GameObject go)
        {
            Debug.Log("Laset pointer pointing at : " + go);

            for (int i = _controllerData.Count - 1; i > 0; i--)
            {
                ILaserPointer  laserPointer = _controllerData.ElementAt(i).Key;
                ControllerData data         = _controllerData.ElementAt(i).Value;
                if (data.currentPoint == go)
                {
                    return(laserPointer);
                }
            }
            return(null);
        }
Beispiel #25
0
 private void Update()
 {
     if (client.isConnected)
     {
         ControllerData.SendData(client);
         if (isReadingQr)
         {
             camTexture.Stop();
             isReadingQr = false;
         }
     }
     else
     {
     }
 }
Beispiel #26
0
    private void Move()
    {
        ControllerData cd = controller.Controll();

        float deltaMovementSpeed = movementSpeed * Time.deltaTime;

        if (cd.isLeft)
        {
            this.transform.Translate(new Vector3(-deltaMovementSpeed, 0, 0));
        }
        if (cd.isRight)
        {
            this.transform.Translate(new Vector3(deltaMovementSpeed, 0, 0));
        }
    }
Beispiel #27
0
        public static ResultModel GetApiData(Type[] types)
        {
            var result = new ResultModel();

            //获取本程序集中所有定义的类
            //Type[] types = Assembly.GetExecutingAssembly().GetTypes();

            //遍历类
            for (int i = 0; i < types.Length; i++)
            {
                //找到所有接口类
                if (types[i].Name.IndexOf("Controller") < 0)
                {
                    continue;
                }


                if (ApiDataModel.ControllerList == null)
                {
                    ApiDataModel.ControllerList = new List <ControllerData>();
                }


                var oneControllerData = new ControllerData();

                oneControllerData.ControllerName = types[i].Name;


                GetMethodList(types[i], oneControllerData);

                if (oneControllerData.MethodList == null || oneControllerData.MethodList.Count <= 0)
                {
                    continue;
                }
                if (oneControllerData.MethodList.Count <= 0)
                {
                    continue;
                }
                GetNotCompileClass(types[i], oneControllerData);

                ApiDataModel.ControllerList.Add(oneControllerData);
            }


            result.Status  = ResultStatus.HasResult;
            result.Message = "已成功执行完毕";
            return(result);
        }
Beispiel #28
0
    // Update is called once per frame
    void Update()
    {
        for (int i = 0; i < maxControllerID; i++)
        {
            if (input.InputButtonDown(EInputButtons.A, i) && controller.Select(p => p.InputIndex).Contains(i) == false)
            {
                TextMeshProUGUI text = Instantiate(playerInfoPrefab);
                text.rectTransform.SetParent(mainText);
                text.rectTransform.localPosition = new Vector3(0, yOffset, 0) * controller.Count;

                ControllerData data = new ControllerData(i, text);
                controller.Add(data);

                Debug.Log("Received Input from Controller " + i);
            }
        }

        for (int i = 0; i < controller.Count; i++)
        {
            ControllerData data = controller[i];
            if (input.InputButtonDown(EInputButtons.B, data.InputIndex))
            {
                data.Team = (data.Team + 1);
                if (data.Team == Team.LastIndex)
                {
                    data.Team = 0;
                }
            }

            data.UpdateText();
        }

        bool startGame = true;

        foreach (ControllerData data in controller)
        {
            if (input.InputButton(EInputButtons.Y, data.InputIndex) == false)
            {
                startGame = false;
            }
        }

        if (controller.Count > 0 && startGame)
        {
            ConnectedController.Instance.controllerData = controller;
            UnityEngine.SceneManagement.SceneManager.LoadScene("MainScene");
        }
    }
Beispiel #29
0
        // update the cursor location and whether it is enabled
        // this code is based on Unity's DragMe.cs code provided in the UI drag and drop example
        private void UpdateCursor(ref ControllerData ctrl)
        {
            if (ctrl.ray != null)
            {
                ctrl.ray.OverrideRayTarget(Vector3.zero);
            }

            if (ctrl.eventData.pointerCurrentRaycast.gameObject != null)
            {
                if (ctrl.eventData.pointerEnter != null)
                {
                    RectTransform draggingPlane = ctrl.eventData.pointerEnter.GetComponent <RectTransform>();
                    Vector3       globalLookPos;
                    if ((draggingPlane != null) &&
                        RectTransformUtility.ScreenPointToWorldPointInRectangle(
                            draggingPlane,
                            ctrl.eventData.position,
                            ctrl.eventData.enterEventCamera,
                            out globalLookPos))
                    {
                        if (ctrl.ray)
                        {
                            ctrl.ray.OverrideRayTarget(globalLookPos);
                        }
                        //					Cursors[index].position = globalLookPos;
                        //					Cursors[index].rotation = draggingPlane.rotation;

                        // scale cursor based on distance to camera
                        //					float lookPointDistance = (Cursors[index].position - Camera.main.transform.position).magnitude;
                        //					float cursorScale = lookPointDistance * NormalCursorScale;
                        //					if (cursorScale < NormalCursorScale)
                        //					{
                        //						cursorScale = NormalCursorScale;
                        //					}

                        //					Cursors[index].localScale = Vector3.one * cursorScale;
                    }
                }
            }
            else
            {
                //			Cursors[index].gameObject.SetActive(false);
                if (ctrl.ray)
                {
                    ctrl.ray.OverrideRayTarget(Vector3.zero);
                }
            }
        }
        private void CheckConditions(GatewayData gatewayData, ControllerData controllerData)
        {
            if (string.IsNullOrEmpty(gatewayData.Serial))
            {
                throw new ArgumentNullException(nameof(gatewayData.Serial));
            }

            if (!this.dummyWebService.IsGatewayProduced(gatewayData.Serial))
            {
                throw new InvalidOperationException("Gateway does not exist");
            }

            if (!this.dummyWebService.IsControllerProduced(controllerData.Serial))
            {
                throw new InvalidOperationException("Controller does not exist");
            }
        }
 // get if the ILaserPointer (controller) pointing at a child of some transform
 public ILaserPointer IsLaserPointerPointingAtChildOF(Transform parent)
 {
     for (int i = _controllerData.Count - 1; i > 0; i--)
     {
         ILaserPointer     laserPointer    = _controllerData.ElementAt(i).Key;
         ControllerData    data            = _controllerData.ElementAt(i).Value;
         List <GameObject> currentPointing = data.pointerEvent.hovered;
         foreach (GameObject go in currentPointing)
         {
             if (go.transform.IsChildOf(parent))
             {
                 return(laserPointer);
             }
         }
     }
     return(null);
 }
Beispiel #32
0
 async Task<ControllerData> FillControllerData(IContext context, RnetController o, ControllerData d)
 {
     await FillDeviceData(context, o, d);
     return d;
 }
Beispiel #33
0
 public static extern int GetNewestData(int which, out ControllerData data);
 private Boolean getFirstPressedButton(System.Windows.Forms.Form parent, ControllerData controllerData, ButtonAssignment buttonAssignment)
 {
     listenForAssignment = true;
     // Instantiate the joystick
     var joystick = new Joystick(directInput, controllerData.guid);
     // Acquire the joystick
     joystick.SetCooperativeLevel(parent, (CooperativeLevel.NonExclusive | CooperativeLevel.Background));
     joystick.Properties.BufferSize = 128;
     joystick.Acquire();
     Boolean gotAssignment = false;
     while (listenForAssignment)
     {
         Boolean[] buttons = joystick.GetCurrentState().Buttons;
         for (int i = 0; i < buttons.Count(); i++)
         {
             if (buttons[i])
             {
                 Console.WriteLine("Got button at index " + i);
                 removeAssignmentsForControllerAndButton(controllerData.guid, i);
                 buttonAssignment.controller = controllerData;
                 buttonAssignment.joystick = joystick;
                 buttonAssignment.buttonIndex = i;
                 listenForAssignment = false;
                 gotAssignment = true;
             }
         }
     }
     if (!gotAssignment)
     {
         joystick.Unacquire();
     }
     return gotAssignment;
 }
 private Boolean getFirstPressedButton(System.Windows.Forms.Form parent, ControllerData controllerData, ButtonAssignment buttonAssignment)
 {
     Boolean gotAssignment = false;
     if (controllerData.guid == NETWORK_CONSOLE_CONTROLLER_GUID)
     {
         PCarsUDPreader gameDataReader = (PCarsUDPreader)GameStateReaderFactory.getInstance().getGameStateReader(GameDefinition.pCarsNetwork);
         int assignedButton = gameDataReader.getButtonIndexForAssignment();
         if (assignedButton != -1)
         {
             removeAssignmentsForControllerAndButton(controllerData.guid, assignedButton);
             buttonAssignment.controller = controllerData;
             buttonAssignment.buttonIndex = assignedButton;
             listenForAssignment = false;
             gotAssignment = true;
         }
     }
     else
     {
         listenForAssignment = true;
         // Instantiate the joystick
         var joystick = new Joystick(directInput, controllerData.guid);
         // Acquire the joystick
         joystick.SetCooperativeLevel(parent, (CooperativeLevel.NonExclusive | CooperativeLevel.Background));
         joystick.Properties.BufferSize = 128;
         joystick.Acquire();
         while (listenForAssignment)
         {
             Boolean[] buttons = joystick.GetCurrentState().Buttons;
             for (int i = 0; i < buttons.Count(); i++)
             {
                 if (buttons[i])
                 {
                     Console.WriteLine("Got button at index " + i);
                     removeAssignmentsForControllerAndButton(controllerData.guid, i);
                     buttonAssignment.controller = controllerData;
                     buttonAssignment.joystick = joystick;
                     buttonAssignment.buttonIndex = i;
                     listenForAssignment = false;
                     gotAssignment = true;
                 }
             }
         }
         if (!gotAssignment)
         {
             joystick.Unacquire();
         }
     }
     return gotAssignment;
 }
            public void Deserialize(ControllerData[] controllerData)
            {
                lock (scriptedcontrols)
                {
                    scriptedcontrols.Clear();

#if (!ISWIN)
                    foreach (ControllerData c in controllerData)
                    {
                        ScriptControllers sc = new ScriptControllers
                                                   {
                                                       itemID = c.ItemID,
                                                       part = m_sp.Scene.GetSceneObjectPart(c.ObjectID),
                                                       ignoreControls = (ScriptControlled) c.IgnoreControls,
                                                       eventControls = (ScriptControlled) c.EventControls
                                                   };
                        if (sc.part != null)
                        {
                            scriptedcontrols[sc.itemID] = sc;
                        }
                    }
#else
                    foreach (ScriptControllers sc in controllerData.Select(c => new ScriptControllers
                                                                                    {
                                                                                        itemID = c.ItemID,
                                                                                        part = m_sp.Scene.GetSceneObjectPart(c.ObjectID),
                                                                                        ignoreControls = (ScriptControlled) c.IgnoreControls,
                                                                                        eventControls = (ScriptControlled) c.EventControls
                                                                                    }).Where(sc => sc.part != null))
                    {
                        scriptedcontrols[sc.itemID] = sc;
                    }
#endif
                }
            }
            public ControllerData[] Serialize()
            {
                lock (scriptedcontrols)
                {
                    ControllerData[] controls = new ControllerData[scriptedcontrols.Count];
                    int i = 0;

                    foreach (ScriptControllers c in scriptedcontrols.Values)
                    {
                        controls[i++] = new ControllerData(c.itemID, c.part.UUID, (uint) c.ignoreControls,
                                                           (uint) c.eventControls);
                    }
                    return controls;
                }
            }
 public void unassign()
 {
     this.controller = null;
     this.buttonIndex = -1;
     this.joystick.Unacquire();
     this.joystick.SetNotification(null);
     this.joystick = null;
 }