public void MoveObjectInSlot(OldSlotScript slot, ContainerData from, ContainerData to) { if (from.items.Count != 0) { if (to.items.Count < to.maxCapacity) { //Add clone and update its currentContainer ItemData clone = slot.slotItem.GetClone(); clone.currentContainer = to; to.items.Add(clone); //Update new container slots //Remove item from its old container from.items.RemoveAt(slot.SlotID); Debug.Log("Moved " + slot.slotItem.itemName + " from " + from.containerName + " to " + to.containerName); //Update old container slots slot.ParentContainer.UpdateAllSlots(); } else { Debug.Log(to.containerName + " is full!"); } } else { Debug.Log(from.containerName + " is empty!"); } }
public void CreateContainerUIElement(ContainerData container, int x, int y) { GameObject containerObject = Instantiate<GameObject>(containerPrefab, transform); listOfActiveContainers.Add(containerObject.GetComponent<ContainerUI>()); containerObject.GetComponent<ContainerUI>().InitializeContainer(container, x, y, this); containerObject.name = container.containerName; }
public void MoveObject(ItemData item, ContainerData from, ContainerData to) { if (from.items.Count != 0) { ItemData tempItem = FindItemInContainer(item, from); if (to.items.Count < to.maxCapacity) { to.items.Add(tempItem.GetClone()); from.items.RemoveAt(0); Debug.Log("Moved " + tempItem.itemName + " from " + from.containerName + " to " + to.containerName); //uiHandler.UpdateContainer(from, to); } else { Debug.Log(to.containerName + " is full!"); } } else { Debug.Log(from.containerName + " is empty!"); } }
public override Container onOpen(ContainerData data, EntityPlayer player) { base.onOpen(data, player); this.setSelected(0, false); return(this); }
public ContainerGump(Item item, Graphic gumpid) : base(item.Serial, 0) { _item = item; _data = ContainerManager.Get(gumpid); CanMove = true; AddChildren(new GumpPicContainer(0, 0, _data.Graphic, 0, item)); }
public static GameObject CreateBackpackCloth(ContainerData ContainerData, Vector3 worldPos, Transform parent = null, ClothingVariantType CVT = ClothingVariantType.Default, int variant = -1, GameObject PrefabOverride = null) { if (Instance.uniBackpack == null) { Logger.LogError("UniBackPack Prefab not found", Category.SpriteHandler); return(null); } GameObject clothObj; if (PrefabOverride != null) { clothObj = PoolManager.PoolNetworkInstantiate(PrefabOverride, worldPos, parent); } else { clothObj = PoolManager.PoolNetworkInstantiate(Instance.uniBackpack, worldPos, parent); } var _Clothing = clothObj.GetComponent <Clothing>(); var Item = clothObj.GetComponent <ItemAttributes>(); var Storage = clothObj.GetComponent <StorageObject>(); _Clothing.SpriteInfo = StaticSpriteHandler.SetupSingleSprite(ContainerData.Sprites.Equipped); Item.SetUpFromClothingData(ContainerData.Sprites, ContainerData.ItemAttributes); _Clothing.SetSynchronise(ConD: ContainerData); Storage.SetUpFromStorageObjectData(ContainerData.StorageData); return(clothObj); }
void DropHeldItemToContainer(ContainerItem container, int x, int y) { var bounds = ContainerData.Get(container.ItemID).Bounds; var provider = Service.Get <IResourceProvider>(); var itemTexture = provider.GetItemTexture(HeldItem.DisplayItemID); if (x < bounds.Left) { x = bounds.Left; } if (x > bounds.Right - itemTexture.Width) { x = bounds.Right - itemTexture.Width; } if (y < bounds.Top) { y = bounds.Top; } if (y > bounds.Bottom - itemTexture.Height) { y = bounds.Bottom - itemTexture.Height; } _network.Send(new DropItemPacket(HeldItem.Serial, (ushort)x, (ushort)y, 0, 0, container.Serial)); ClearHolding(); }
public Bag() { ObjectTypeMask |= TypeMask.Container; ObjectTypeId = TypeId.Container; m_containerData = new ContainerData(); }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="chest">The in-game chest.</param> /// <param name="context">The <see cref="ItemGrabMenu.context"/> value which indicates what opened the menu.</param> /// <param name="reflection">Simplifies access to private code.</param> public ChestContainer(Chest chest, object context, IReflectionHelper reflection) { this.Chest = chest; this.Context = context; this.Reflection = reflection; this.Data = ContainerData.ParseName(chest.Name, this.DefaultName); }
private void DropHeldItemToContainer(Container container, int x, int y) { Rectangle containerBounds = ContainerData.GetData(container.ItemID).Bounds; IResourceProvider provider = ServiceRegistry.GetService <IResourceProvider>(); Texture2D itemTexture = provider.GetItemTexture(HeldItem.DisplayItemID); if (x < containerBounds.Left) { x = containerBounds.Left; } if (x > containerBounds.Right - itemTexture.Width) { x = containerBounds.Right - itemTexture.Width; } if (y < containerBounds.Top) { y = containerBounds.Top; } if (y > containerBounds.Bottom - itemTexture.Height) { y = containerBounds.Bottom - itemTexture.Height; } m_Network.Send(new DropItemPacket(HeldItem.Serial, (ushort)x, (ushort)y, 0, 0, container.Serial)); ClearHolding(); }
public void SyncFindData(string syncString) { if (string.IsNullOrEmpty(syncString)) { return; } SynchronisedString = syncString; if (ClothFactory.Instance.ClothingStoredData.ContainsKey(syncString)) { clothingData = ClothFactory.Instance.ClothingStoredData[syncString]; TryInit(); } else if (ClothFactory.Instance.BackpackStoredData.ContainsKey(syncString)) { containerData = ClothFactory.Instance.BackpackStoredData[syncString]; TryInit(); } else if (ClothFactory.Instance.HeadSetStoredData.ContainsKey(syncString)) { headsetData = ClothFactory.Instance.HeadSetStoredData[syncString]; TryInit(); } else { Logger.LogError($"No Cloth Data found for {syncString}", Category.SpriteHandler); } }
public static Multiblock InstantiateVoxels(Vector3 position, Dictionary <VoxelMaterial, List <Vector3> > voxels, string name) { var map = Map.Instance; Vector3 zeroVec; var size = GetSize(out zeroVec, voxels); var data = new ContainerData(size, position + zeroVec); foreach (var type in voxels.Keys) { foreach (var v in voxels[type]) { data.SetVoxel((int)(v.x - zeroVec.x), (int)(v.y - zeroVec.y), (int)(v.z - zeroVec.z), type); } } var container = CreateContainer <Multiblock>(position + zeroVec, data, MaterialRegistry.Instance.Materials, name); if (map != null) { container.transform.parent = map.transform; for (var x = Mathf.Max(0, (int)((position.x) / Chunk.ChunkSize)); x < Mathf.Min(map.MapData.Chunks.GetLength(0), (position.x + size) / Chunk.ChunkSize); x++) { for (var y = Mathf.Max(0, (int)((position.y) / Chunk.ChunkSize)); y < Mathf.Min(map.MapData.Chunks.GetLength(1), (position.y + size) / Chunk.ChunkSize); y++) { for (var z = Mathf.Max(0, (int)((position.z) / Chunk.ChunkSize)); z < Mathf.Min(map.MapData.Chunks.GetLength(2), (position.z + size) / Chunk.ChunkSize); z++) { if (map.MapData.Chunks[x, y, z] != null) { map.MapData.Chunks[x, y, z].AttachMultiblock((Multiblock)container); } } } } } return((Multiblock)container); }
protected async override Task <int> ExecuteCommandAsync(AccountsOptions options) { var appDir = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)); var cosmicDir = appDir.CreateSubdirectory("cosmic"); var connectionsDir = cosmicDir.CreateSubdirectory("connections"); var activeContainerFile = new FileInfo($"{cosmicDir}/activeContainer.json"); ContainerData activeContainerData = null; if (activeContainerFile.Exists) { activeContainerData = JsonConvert.DeserializeObject <ContainerData>(await File.ReadAllTextAsync(activeContainerFile.FullName)); } bool isActive(string connectionId) { return(activeContainerData != null && activeContainerData.ConnectionId.ToLowerInvariant() == connectionId.ToLowerInvariant()); } connectionsDir.GetFiles() .Where(x => x.Extension.ToLowerInvariant() == ".json") .ToDictionary(x => x.Name.Split('.').First(), x => JsonConvert.DeserializeObject <ConnectionData>(File.ReadAllText(x.FullName))) .ToList() .ForEach(x => Console.WriteLine($"{(isActive(x.Key) ? '*' : ' ')} {x.Key.PadRight(20)} {x.Value.ConnectionString.Substring(0, x.Value.ConnectionString.LastIndexOf("AccountKey")).TrimEnd(';')}")); return(0); }
public AssetBundle(AssetPreloadData preloadData) { var sourceFile = preloadData.sourceFile; var a_Stream = preloadData.sourceFile.a_Stream; a_Stream.Position = preloadData.Offset; var m_Name = a_Stream.ReadAlignedString(a_Stream.ReadInt32()); var size = a_Stream.ReadInt32(); for (int i = 0; i < size; i++) { sourceFile.ReadPPtr(); } size = a_Stream.ReadInt32(); for (int i = 0; i < size; i++) { var temp = new ContainerData(); temp.first = a_Stream.ReadAlignedString(a_Stream.ReadInt32()); temp.second = new AssetInfo(); temp.second.preloadIndex = a_Stream.ReadInt32(); temp.second.preloadSize = a_Stream.ReadInt32(); temp.second.asset = sourceFile.ReadPPtr(); m_Container.Add(temp); } }
private void BuildGump() { CanMove = true; CanBeSaved = true; LocalSerial = _item.Serial; _isCorspeContainer = _gumpID == 0x0009; _item.Items.Added += ItemsOnAdded; _item.Items.Removed += ItemsOnRemoved; _data = ContainerManager.Get(_gumpID); Graphic g = _data.Graphic; Add(new GumpPicContainer(0, 0, g, 0, _item)); if (_isCorspeContainer) { Add(_eyeGumpPic = new GumpPic(45, 30, 0x0045, 0)); } ContainerManager.CalculateContainerPosition(g); X = ContainerManager.X; Y = ContainerManager.Y; if (_data.OpenSound != 0) { Engine.SceneManager.CurrentScene.Audio.PlaySound(_data.OpenSound); } }
protected async override Task <int> ExecuteCommandAsync(TOptions options) { var appDir = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)); var cosmicDir = appDir.CreateSubdirectory("cosmic"); ContainerData containerData = null; if (options.ContainerPath is null) { var activeContainerFile = await File.ReadAllTextAsync($"{cosmicDir}/activeContainer.json"); containerData = JsonConvert.DeserializeObject <ContainerData>(activeContainerFile); } else { var path = options.ContainerPath.Split('/'); containerData = new ContainerData { ConnectionId = path[0].ToLowerInvariant(), DatabaseId = path[1], ContainerId = path[2] }; } var connectionsDir = cosmicDir.CreateSubdirectory("connections"); var connectionFile = await File.ReadAllTextAsync($"{connectionsDir}/{containerData.ConnectionId}.json"); var connection = JsonConvert.DeserializeObject <ConnectionData>(connectionFile); Container = new CosmosClient(connection.ConnectionString) .GetDatabase(containerData.DatabaseId) .GetContainer(containerData.ContainerId); return(0); }
protected async override Task <int> ExecuteCommandAsync(SwitchOptions options) { var path = options.Path.Split('/'); if (path.Length != 3) { throw new Exception("Path should be in the format '<connection>/<database>/<container>'."); } var connectionId = path[0].ToLowerInvariant(); var container = new ContainerData { ConnectionId = connectionId, DatabaseId = path[1], ContainerId = path[2] }; var appDir = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)); var cosmicDir = appDir.CreateSubdirectory("cosmic"); await File.WriteAllTextAsync($"{cosmicDir}/activeContainer.json", JsonConvert.SerializeObject(container)); Console.WriteLine($"Switched to connection '{container.ConnectionId}', database '{container.DatabaseId}', container '{container.ContainerId}'."); return(0); }
private static GameObject CreateBackpackCloth(ContainerData ContainerData, Vector3?worldPos = null, Transform parent = null, ClothingVariantType CVT = ClothingVariantType.Default, int variant = -1, GameObject PrefabOverride = null) { if (uniBackpack == null) { uniBackpack = GetPrefabByName("UniBackPack"); } if (uniBackpack == null) { Logger.LogError("UniBackPack Prefab not found", Category.SpriteHandler); return(null); } GameObject clothObj; if (PrefabOverride != null && PrefabOverride != uniBackpack) { clothObj = Spawn.ServerPrefab(PrefabOverride, worldPos, parent).GameObject; } else { clothObj = Spawn.ServerPrefab(uniBackpack, worldPos, parent).GameObject; } var _Clothing = clothObj.GetComponent <Clothing>(); var Item = clothObj.GetComponent <ItemAttributes>(); _Clothing.SpriteInfo = StaticSpriteHandler.SetupSingleSprite(ContainerData.Sprites.Equipped); Item.SetUpFromClothingData(ContainerData.Sprites, ContainerData.ItemAttributes); _Clothing.SetSynchronise(ConD: ContainerData); return(clothObj); }
public ActionResult History() { if (Session["user"] == null) { return(RedirectToAction("NotAuthentication", "Home")); } var u = Session["user"] as customer; var h = data.histories.Where(it => it.id_customer == u.id).OrderByDescending(it => it.id).ToList(); var historyWithDetails = new List <HistoryWithDetails>(); foreach (var item in h) { historyWithDetails.Add(new HistoryWithDetails { h = item, history_Details = data.history_details.Where(it => it.id_history == item.id).ToList() }); } var container = new ContainerData { historyWithDetails = historyWithDetails }; return(View(Tuple.Create(container))); }
public TileEntityChest(World world, int x, int y, int z, int meta) : base(world, x, y, z) //, References.list.chestPrefab) { { this.chestData = new ContainerData(3, 3); //this.gameObject.transform.position = new Vector3(x, y - 0.05f, z); //this.gameObject.transform.rotation = Quaternion.Euler(0, meta * 90, 0); //this.chestOpen = this.gameObject.GetComponent<ChestOpen>(); }
public override void ProcessValuesUpdate(Packet packet, UpdateMask updateMask) { base.ProcessValuesUpdate(packet, updateMask); var containerUpdateMask = updateMask.LeftShift(ObjectData.BitCount + ItemData.BitCount); ContainerData.ProcessValuesUpdate(packet, containerUpdateMask); }
public void GatherData() { PlayerCustomisationData.getPlayerCustomisationDatas(DataPCD); ClothingData.getClothingDatas(DataClothingData); ContainerData.getContainerData(DataContainerData); HeadsetData.getHeadsetData(DataHeadsetData); PlayerTextureData.getClothingDatas(DataRaceData); }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="location">The location whose shipping bin to manage.</param> /// <param name="mode">The type of shipping bin menu to create.</param> public ShippingBinContainer(GameLocation location, ShippingBinMode mode) { this.Location = location; this.Farm = location as Farm ?? Game1.getFarm(); this.ShippingBin = this.Farm.getShippingBin(Game1.player); this.Data = ContainerData.FromModData(location.modData, defaultInternalName: null, discriminator: ShippingBinContainer.ModDataDiscriminator); this.Mode = mode; }
public List <SlotScript> UpdateContainer(ContainerData containerData) { this.containerData = containerData; UpdateUIFrameSize(containerData.maxCapacity); AdjustSlots(containerData.maxCapacity); containerText.text = containerData.containerName; return(slots); }
private void Awake() { smallChestUI = FindObjectOfType <SmallChestUI>().gameObject; itemContainer.InitContainer(smallChestUI); containerData = new ContainerData(itemContainer.GetContainerSize()); closeChestButton.onClick.AddListener(CloseChest); }
/********* ** Public methods *********/ /// <summary>Construct an instance.</summary> /// <param name="chest">The in-game chest.</param> /// <param name="context">The <see cref="ItemGrabMenu.context"/> value which indicates what opened the menu.</param> /// <param name="showColorPicker">Whether to show the chest color picker.</param> /// <param name="reflection">Simplifies access to private code.</param> public ChestContainer(Chest chest, object context, bool showColorPicker, IReflectionHelper reflection) { this.Chest = chest; this.Context = context; this.ShowColorPicker = showColorPicker; this.Reflection = reflection; this.Data = ContainerData.FromModData(chest.modData, this.DefaultName); }
/// <summary> /// On the event an item is placed, swap the values in the appropiate arrays /// </summary> /// <param name="desc">The description of the event, containing source and destination cells as well /// as item details</param> public void OnItemPlace(DragAndDropCell.DropDescriptor desc) { ContainerData source = desc.sourceCell.gameObject.GetComponent <ContainerData> (); ContainerData dest = desc.destinationCell.gameObject.GetComponent <ContainerData> (); Player[] players = data.Players; Item temp; if (dest.type == "Item") { if (source.type == "Item") { temp = items [source.Index]; items [source.Index] = items [dest.Index]; items [dest.Index] = temp; } else //if source.type == "Player" { temp = players [source.Index].Item; players [source.Index].Item = items [dest.Index]; items [dest.Index] = temp; } } else if (dest.type == "Delete") // THIS ELSE IF ADDED ASSESSMENT 3 { if (source.type == "Item") { items[source.Index] = null; } else { //if source.type == "Player" players[source.Index].Item = null; } } else //if dest.type == "Player" { if (source.type == "Item") { temp = items [source.Index]; items [source.Index] = players [dest.Index].Item; players [dest.Index].Item = temp; } else //if source.type == "Player" { temp = players [source.Index].Item; players [source.Index].Item = players [dest.Index].Item; players [dest.Index].Item = temp; } } for (var i = 0; i <= 5; i++) { Debug.Log(PlayerData.instance.data.Items[i]); } Debug.Log("Source: " + source.Type); Debug.Log("Destination: " + dest.Type); //Debug.Log ("Item Name: " + desc.item.GetComponent<ItemData> ().Item.Name); }
void DropHeldItemToContainer(ContainerItem container) { // get random coords and drop the item there. var bounds = ContainerData.Get(container.ItemID).Bounds; var x = Utility.RandomValue(bounds.Left, bounds.Right); var y = Utility.RandomValue(bounds.Top, bounds.Bottom); DropHeldItemToContainer(container, x, y); }
public ContainerGump(AEntity containerItem, int gumpID) : base(containerItem.Serial, 0) { _data = ContainerData.Get(gumpID); _item = (ContainerItem)containerItem; _item.SetCallbacks(OnItemUpdated, OnItemDisposed); IsMoveable = true; AddControl(new GumpPicContainer(this, 0, 0, _data.GumpID, 0, _item)); }
public static ContainerData Get(ushort graphic) { //if the server requests for a non present gump in container data dictionary, create it, but without any particular sound. if (!_data.TryGetValue(graphic, out ContainerData value)) { _data[graphic] = value = new ContainerData(graphic, 0, 0, 44, 65, 186, 159); } return(value); }
public override void UpdateContainerData() { if (ItemID == 0x4910 || ItemID == 0x4911) { ContainerData = new ContainerData(0x3E8, new Rectangle2D(90, 90, 460, 280), 0x42); return; } base.UpdateContainerData(); }