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; }
public void SendToolbarItemChanged(ToolbarItem item, int index) { if (m_syncing) { return; } var msg = new ChangeMySensorToolbarItemMsg(); msg.EntityId = m_block.EntityId; msg.Item = item; msg.Index = index; Sync.Layer.SendMessageToAll(ref msg); }
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; }
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; }
public void SendToolbarItemChanged(ToolbarItem item, int index) { if (m_syncing) return; var msg = new ChangeMySensorToolbarItemMsg(); msg.EntityId = m_block.EntityId; msg.Item = item; msg.Index = index; Sync.Layer.SendMessageToAll(ref msg); }
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) item = ToolbarItem.ToItem(msg.Item); sync.m_block.Toolbar.SetItemAtIndex(msg.Index, item); sync.m_syncing = false; }