Ejemplo n.º 1
0
 private static void OnSetTimer(MySyncTimerBlock sync, ref SetTimerMsg msg, MyNetworkClient sender)
 {
     sync.m_timer.SetTimer(msg.Time);
     if (Sync.IsServer)
     {
         Sync.Layer.SendMessageToAll(ref msg);
     }
 }
Ejemplo n.º 2
0
 private static void OnTriggered(MySyncTimerBlock syncObject, ref TriggerMsg msg, MyNetworkClient sender)
 {
     MyTimerBlock.Trigger(syncObject.m_timer);
     if (Sync.IsServer)
     {
         Sync.Layer.SendMessageToAll(ref msg);
     }
 }
Ejemplo n.º 3
0
 private static void OnToggle(MySyncTimerBlock sync, ref ToggleMsg msg, MyNetworkClient sender)
 {
     if (msg.Start)
     {
         sync.m_timer.Start();
     }
     else
     {
         sync.m_timer.Stop();
     }
     if (Sync.IsServer)
     {
         Sync.Layer.SendMessageToAll(ref msg);
     }
 }
Ejemplo n.º 4
0
            private static void OnToolbarItemChanged(MySyncTimerBlock sync, ref ChangeToolbarItemMsg msg, MyNetworkClient sender)
            {
                sync.m_syncing = true;
                MyToolbarItem item = null;

                if (msg.Item.EntityID != 0)
                {
                    item = ToolbarItem.ToItem(msg.Item);
                }
                sync.m_timer.Toolbar.SetItemAtIndex(msg.Index, item);
                sync.m_syncing = false;
                if (Sync.IsServer)
                {
                    Sync.Layer.SendMessageToAll(ref msg);
                }
            }
Ejemplo n.º 5
0
            private static void OnToolbarItemChanged(MySyncTimerBlock sync, ref ChangeToolbarItemMsg 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
                    {
                        MyTimerBlock parent;
                        if (MyEntities.TryGetEntityById <MyTimerBlock>(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_timer.Toolbar.SetItemAtIndex(msg.Index, item);
                sync.m_syncing = false;
                if (Sync.IsServer)
                {
                    Sync.Layer.SendMessageToAll(ref msg);
                }
            }
Ejemplo n.º 6
0
 private static void OnToolbarItemChanged(MySyncTimerBlock sync, ref ChangeToolbarItemMsg msg, MyNetworkClient sender)
 {
     sync.m_syncing = true;
     MyToolbarItem item = null;
     if (msg.Item.EntityID != 0)
         item = ToolbarItem.ToItem(msg.Item);
     sync.m_timer.Toolbar.SetItemAtIndex(msg.Index, item);
     sync.m_syncing = false;
     if (Sync.IsServer)
         Sync.Layer.SendMessageToAll(ref msg);
 }
Ejemplo n.º 7
0
 private static void OnSetTimer(MySyncTimerBlock sync, ref SetTimerMsg msg, MyNetworkClient sender)
 {
     sync.m_timer.SetTimer(msg.Time);
     if (Sync.IsServer)
         Sync.Layer.SendMessageToAll(ref msg);
 }
Ejemplo n.º 8
0
 private static void OnToggle(MySyncTimerBlock sync, ref ToggleMsg msg, MyNetworkClient sender)
 {
     if (msg.Start)
         sync.m_timer.Start();
     else
         sync.m_timer.Stop();
     if (Sync.IsServer)
         Sync.Layer.SendMessageToAll(ref msg);
 }
Ejemplo n.º 9
0
 private static void OnTriggered(MySyncTimerBlock syncObject, ref TriggerMsg msg, MyNetworkClient sender)
 {
     MyTimerBlock.Trigger(syncObject.m_timer);
     if (Sync.IsServer)
         Sync.Layer.SendMessageToAll(ref msg);
 }
Ejemplo n.º 10
0
 private static void OnToolbarItemChanged(MySyncTimerBlock sync, ref ChangeToolbarItemMsg 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
         {
             MyTimerBlock parent;
             if (MyEntities.TryGetEntityById<MyTimerBlock>(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_timer.Toolbar.SetItemAtIndex(msg.Index, item);
     sync.m_syncing = false;
     if (Sync.IsServer)
         Sync.Layer.SendMessageToAll(ref msg);
 }