Exemple #1
0
 public static ToolbarItem FromItem(MyToolbarItem item)
 {
     var tItem = new ToolbarItem();
     tItem.EntityID = 0;
     var terminalItem = item as MyToolbarItemTerminalBlock;
     if (terminalItem != null)
     {
         var block = item.GetObjectBuilder() as MyObjectBuilder_ToolbarItemTerminalBlock;
         tItem.EntityID = block.BlockEntityId;
         tItem.Action = block._Action;
         tItem.Parameters = block.Parameters;
     }
     else if (item is MyToolbarItemTerminalGroup)
     {
         var block = item.GetObjectBuilder() as MyObjectBuilder_ToolbarItemTerminalGroup;
         tItem.EntityID = block.BlockEntityId;
         tItem.Action = block._Action;
         tItem.GroupName = block.GroupName;
         tItem.Parameters = block.Parameters;
     }
     else if ( item is MyToolbarItemWeapon)
     {
         var weapon = item.GetObjectBuilder() as MyObjectBuilder_ToolbarItemWeapon;
         tItem.GunId = weapon.DefinitionId;
     }
     return tItem;
 }
Exemple #2
0
 private ToolbarItem GetToolbarItem(MyToolbarItem item)
 {
     var tItem = new ToolbarItem();
     tItem.EntityID = 0;
     if (item is MyToolbarItemTerminalBlock)
     {
         var block = item.GetObjectBuilder() as MyObjectBuilder_ToolbarItemTerminalBlock;
         tItem.EntityID = block.BlockEntityId;
         tItem.Action = block.Action;
     }
     else if (item is MyToolbarItemTerminalGroup)
     {
         var block = item.GetObjectBuilder() as MyObjectBuilder_ToolbarItemTerminalGroup;
         tItem.EntityID = block.BlockEntityId;
         tItem.Action = block.Action;
         tItem.GroupName = block.GroupName;
     }
     return tItem;
 }