예제 #1
0
 private static void OnModifyGroupSuccess(MySyncGrid sync, ref ModifyBlockGroupMsg msg, MyNetworkClient sender)
 {
     if (msg.Blocks == null || msg.Blocks.Count() == 0)
         foreach (var group in sync.Entity.BlockGroups)
         {
             if (group.Name.ToString().Equals(msg.Name))
             {
                 sync.Entity.RemoveGroup(group);
                 break;
             }
         }
     else
     {
         MyBlockGroup group = new MyBlockGroup(sync.Entity);
         group.Name.Clear().Append(msg.Name);
         foreach (var blockId in msg.Blocks)
         {
             MyTerminalBlock block = null;
             if (MyEntities.TryGetEntityById(blockId, out block))
                 group.Blocks.Add(block);
         }
         sync.Entity.AddGroup(group);
     }
 }
예제 #2
0
        public void ModifyGroup(MyBlockGroup group)
        {
            var msg = new ModifyBlockGroupMsg();

            msg.GridEntityId = Entity.EntityId;
            msg.Name = group.Name.ToString();
            foreach (var block in group.Blocks)
                m_tmpBlockIdList.Add(block.EntityId);
            msg.Blocks = m_tmpBlockIdList.ToArray();
            m_tmpBlockIdList.Clear();

            Sync.Layer.SendMessageToAll(ref msg);
        }