Exemplo n.º 1
0
        private static void OnToolbarItemChanged(MySyncSensorBlock sync, ref ChangeMySensorToolbarItemMsg msg, MyNetworkClient sender)
        {
            sync.m_syncing = true;
            MyToolbarItem item = null;

            if (msg.Item.EntityID != 0)
            {
                item = ToolbarItem.ToItem(msg.Item);
            }
            sync.m_block.Toolbar.SetItemAtIndex(msg.Index, item);
            sync.m_syncing = false;
        }
Exemplo n.º 2
0
        private static void OnToolbarItemChanged(MySyncSensorBlock sync, ref ChangeMySensorToolbarItemMsg msg, MyNetworkClient sender)
        {
            sync.m_syncing = true;
            MyToolbarItem item = null;

            if (msg.Item.EntityID != 0)
            {
                item = ToolbarItem.ToItem(msg.Item);
            }
            sync.m_block.Toolbar.SetItemAtIndex(msg.Index, item);
            sync.m_syncing = false;
            if (Sync.IsServer)
            {
                Sync.Layer.SendMessageToAllButOne(ref msg, sender.SteamUserId);
            }
        }
        private static void OnToolbarItemChanged(MySyncSensorBlock sync, ref ChangeMySensorToolbarItemMsg msg, MyNetworkClient sender)
        {
            sync.m_syncing = true;
            MyToolbarItem item = null;

            if (msg.Item.EntityID != 0)
            {
                if (string.IsNullOrEmpty(msg.Item.GroupName))
                {
                    MyTerminalBlock block;
                    if (MyEntities.TryGetEntityById <MyTerminalBlock>(msg.Item.EntityID, out block))
                    {
                        var builder = MyToolbarItemFactory.TerminalBlockObjectBuilderFromBlock(block);
                        builder.Action = msg.Item.Action;
                        item           = MyToolbarItemFactory.CreateToolbarItem(builder);
                    }
                }
                else
                {
                    MySensorBlock parent;
                    if (MyEntities.TryGetEntityById <MySensorBlock>(msg.Item.EntityID, out parent))
                    {
                        var grid      = parent.CubeGrid;
                        var groupName = msg.Item.GroupName;
                        var group     = grid.GridSystems.TerminalSystem.BlockGroups.Find((x) => x.Name.ToString() == groupName);
                        if (group != null)
                        {
                            var builder = MyToolbarItemFactory.TerminalGroupObjectBuilderFromGroup(group);
                            builder.Action        = msg.Item.Action;
                            builder.BlockEntityId = msg.Item.EntityID;
                            item = MyToolbarItemFactory.CreateToolbarItem(builder);
                        }
                    }
                }
            }
            sync.m_block.Toolbar.SetItemAtIndex(msg.Index, item);
            sync.m_syncing = false;
        }
Exemplo n.º 4
0
        private static void OnToolbarItemChanged(MySyncSensorBlock sync, ref ChangeMySensorToolbarItemMsg msg, MyNetworkClient sender)
        {
            sync.m_syncing = true;
            MyToolbarItem item = null;
            if (msg.Item.EntityID != 0)
                if (string.IsNullOrEmpty(msg.Item.GroupName))
                {
                    MyTerminalBlock block;
                    if (MyEntities.TryGetEntityById<MyTerminalBlock>(msg.Item.EntityID, out block))
                    {
                        var builder = MyToolbarItemFactory.TerminalBlockObjectBuilderFromBlock(block);
                        builder.Action = msg.Item.Action;
                        item = MyToolbarItemFactory.CreateToolbarItem(builder);
                    }
                }
                else
                {
                    MySensorBlock parent;
                    if (MyEntities.TryGetEntityById<MySensorBlock>(msg.Item.EntityID, out parent))
                    {
                        var grid = parent.CubeGrid;
                        var groupName = msg.Item.GroupName;
                        var group = grid.GridSystems.TerminalSystem.BlockGroups.Find((x) => x.Name.ToString() == groupName);
                        if (group != null)
                        {
                            var builder = MyToolbarItemFactory.TerminalGroupObjectBuilderFromGroup(group);
                            builder.Action = msg.Item.Action;
                            builder.BlockEntityId = msg.Item.EntityID;
                            item = MyToolbarItemFactory.CreateToolbarItem(builder);
                        }
                    }

                }
            sync.m_block.Toolbar.SetItemAtIndex(msg.Index, item);
            sync.m_syncing = false;
        }
Exemplo n.º 5
0
 private static void OnToolbarItemChanged(MySyncSensorBlock sync, ref ChangeMySensorToolbarItemMsg msg, MyNetworkClient sender)
 {
     sync.m_syncing = true;
     MyToolbarItem item = null;
     if (msg.Item.EntityID != 0)
         item = ToolbarItem.ToItem(msg.Item);
     sync.m_block.Toolbar.SetItemAtIndex(msg.Index, item);
     sync.m_syncing = false;
     if (Sync.IsServer)
     {
         Sync.Layer.SendMessageToAllButOne(ref msg, sender.SteamUserId);
     }
 }
Exemplo n.º 6
0
 private static void OnToolbarItemChanged(MySyncSensorBlock sync, ref ChangeMySensorToolbarItemMsg msg, MyNetworkClient sender)
 {
     sync.m_syncing = true;
     MyToolbarItem item = null;
     if (msg.Item.EntityID != 0)
         item = ToolbarItem.ToItem(msg.Item);
     sync.m_block.Toolbar.SetItemAtIndex(msg.Index, item);
     sync.m_syncing = false;
 }