예제 #1
0
 private static void Worker()
 {
     while (!m_disposed)
     {
         Thread.Sleep(0x10);
         MyNetworkWriter.SendAll();
         MyGameService.ServerUpdate();
         MyNetworkReader.ReceiveAll();
         Action onTick = OnTick;
         if (onTick != null)
         {
             onTick();
         }
     }
 }
예제 #2
0
        public static void LoadInventoryConfig(MyEntity toolEntity, MyAssetModifierComponent skinComponent)
        {
            if (toolEntity == null)
            {
                throw new ArgumentNullException("toolEntity");
            }
            if (skinComponent == null)
            {
                throw new ArgumentNullException("skinComponent");
            }
            if (MyGameService.IsActive)
            {
                MyObjectBuilder_SkinInventory inventory;
                string path = Path.Combine(MyFileSystem.SavesPath, activeInventoryFile);
                switch (inventory.Tools)
                {
                case ((!MyFileSystem.FileExists(path) || !MyObjectBuilderSerializer.DeserializeXML <MyObjectBuilder_SkinInventory>(path, out inventory)) || ((null) || (null))):
                    break;

                default:
                {
                    IMyHandheldGunObject <MyDeviceBase> obj2 = toolEntity as IMyHandheldGunObject <MyDeviceBase>;
                    MyPhysicalItemDefinition            physicalItemDefinition = obj2.PhysicalItemDefinition;
                    MyGameInventoryItemSlot             none = MyGameInventoryItemSlot.None;
                    if (obj2 is MyHandDrill)
                    {
                        none = MyGameInventoryItemSlot.Drill;
                    }
                    else if (obj2 is MyAutomaticRifleGun)
                    {
                        none = MyGameInventoryItemSlot.Rifle;
                    }
                    else if (obj2 is MyWelder)
                    {
                        none = MyGameInventoryItemSlot.Welder;
                    }
                    else if (obj2 is MyAngleGrinder)
                    {
                        none = MyGameInventoryItemSlot.Grinder;
                    }
                    if (none != MyGameInventoryItemSlot.None)
                    {
                        List <MyGameInventoryItem> items = new List <MyGameInventoryItem>();
                        using (List <ulong> .Enumerator enumerator = inventory.Tools.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                MyGameInventoryItem item = MyGameService.InventoryItems.FirstOrDefault <MyGameInventoryItem>(delegate(MyGameInventoryItem i) {
                                        ulong itemId;
                                        return(i.ID == itemId);
                                    });
                                if ((item != null) && ((physicalItemDefinition != null) && ((physicalItemDefinition == null) || (item.ItemDefinition.ItemSlot == none))))
                                {
                                    item.IsInUse = true;
                                    items.Add(item);
                                }
                            }
                        }
                        MyGameService.GetItemsCheckData(items, checkDataResult => skinComponent.TryAddAssetModifier(checkDataResult));
                    }
                    break;
                }
                }
            }
        }
예제 #3
0
        public static void LoadInventoryConfig(MyCharacter character, bool setModel = true)
        {
            MyObjectBuilder_SkinInventory inventory;

            if (character == null)
            {
                throw new ArgumentNullException("character");
            }
            if (!MyGameService.IsActive)
            {
                return;
            }
            string path = Path.Combine(MyFileSystem.SavesPath, activeInventoryFile);

            if (!MyFileSystem.FileExists(path))
            {
                ResetAllInventorySlots(character);
                return;
            }
            if (!MyObjectBuilderSerializer.DeserializeXML <MyObjectBuilder_SkinInventory>(path, out inventory))
            {
                ResetAllInventorySlots(character);
                return;
            }
            if ((inventory.Character != null) && (MyGameService.InventoryItems != null))
            {
                MyAssetModifierComponent       comp;
                List <MyGameInventoryItem>     items = new List <MyGameInventoryItem>();
                List <MyGameInventoryItemSlot> list2 = Enum.GetValues(typeof(MyGameInventoryItemSlot)).Cast <MyGameInventoryItemSlot>().ToList <MyGameInventoryItemSlot>();
                list2.Remove(MyGameInventoryItemSlot.None);
                using (List <ulong> .Enumerator enumerator = inventory.Character.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        MyGameInventoryItem item = MyGameService.InventoryItems.FirstOrDefault <MyGameInventoryItem>(delegate(MyGameInventoryItem i) {
                            ulong itemId;
                            return(i.ID == itemId);
                        });
                        if (item != null)
                        {
                            item.IsInUse = true;
                            items.Add(item);
                            list2.Remove(item.ItemDefinition.ItemSlot);
                        }
                    }
                }
                if (!character.Components.TryGet <MyAssetModifierComponent>(out comp))
                {
                    goto TR_0007;
                }
                else
                {
                    MyGameService.GetItemsCheckData(items, checkDataResult => comp.TryAddAssetModifier(checkDataResult));
                    foreach (MyGameInventoryItemSlot slot in list2)
                    {
                        comp.ResetSlot(slot);
                    }
                    goto TR_0007;
                }
            }
            ResetAllInventorySlots(character);
TR_0007:
            if (setModel && !string.IsNullOrEmpty(inventory.Model))
            {
                character.ModelName = inventory.Model;
            }
            character.ColorMask = (Vector3)inventory.Color;
        }