public void RegisterScriptController(ScriptControllers SC)
 {
     lock (scriptedcontrols)
     {
         scriptedcontrols[SC.itemID] = SC;
     }
     m_sp.ControllingClient.SendTakeControls((int) SC.eventControls, true, true);
 }
            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 void RegisterControlEventsToScript(int controls, int accept, int pass_on, ISceneChildEntity part,
                                                      UUID Script_item_UUID)
            {
                ScriptControllers obj = new ScriptControllers
                                            {
                                                ignoreControls = ScriptControlled.CONTROL_ZERO,
                                                eventControls = ScriptControlled.CONTROL_ZERO,
                                                itemID = Script_item_UUID,
                                                part = part
                                            };

                if (pass_on == 0 && accept == 0)
                {
                    IgnoredControls |= (ScriptControlled) controls;
                    obj.ignoreControls = (ScriptControlled) controls;
                }

                if (pass_on == 0 && accept == 1)
                {
                    IgnoredControls |= (ScriptControlled) controls;
                    obj.ignoreControls = (ScriptControlled) controls;
                    obj.eventControls = (ScriptControlled) controls;
                }
                if (pass_on == 1 && accept == 1)
                {
                    IgnoredControls = ScriptControlled.CONTROL_ZERO;
                    obj.eventControls = (ScriptControlled) controls;
                    obj.ignoreControls = ScriptControlled.CONTROL_ZERO;
                }

                lock (scriptedcontrols)
                {
                    if (pass_on == 1 && accept == 0)
                    {
                        IgnoredControls &= ~(ScriptControlled) controls;
                        if (scriptedcontrols.ContainsKey(Script_item_UUID))
                            scriptedcontrols.Remove(Script_item_UUID);
                    }
                    else
                    {
                        scriptedcontrols[Script_item_UUID] = obj;
                    }
                }
                m_sp.ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true);
            }