Beispiel #1
0
        private void ReloadItem(ServerItem item)
        {
            if (!this.Loaded || item == null)
            {
                return;
            }

            // to avoid problems with events
            ServerItem tmpItem = this.CurrentServerItem;
            this.CurrentServerItem = null;

            ClientItem clientItem;
            if (this.CurrentPlugin.Instance.Items.TryGetValue(item.ClientId, out clientItem))
            {
                Trace.WriteLine(string.Format("Reloading item id: {0}.", item.ID));

                ushort tmpId = item.ID;
                item.CopyPropertiesFrom(clientItem);
                item.ID = tmpId;
                Buffer.BlockCopy(clientItem.SpriteHash, 0, item.SpriteHash, 0, clientItem.SpriteHash.Length);

                this.CurrentServerItem = tmpItem;
            }
        }
Beispiel #2
0
        private ServerItem CreateItem(Item item = null)
        {
            // create a new otb item
            ServerItem newItem = new ServerItem();
            newItem.ID = (ushort)(this.serverItems.MaxId + 1);

            if (item != null)
            {
                newItem.CopyPropertiesFrom(item);
                newItem.ClientId = item.ID;
                newItem.SpriteHash = new byte[16];
                Buffer.BlockCopy(item.SpriteHash, 0, newItem.SpriteHash, 0, newItem.SpriteHash.Length);
            }
            else
            {
                newItem.ClientId = this.serverItems.MinId;
                newItem.SpriteHash = new byte[16];
                newItem.IsCustomCreated = true;
            }

            return newItem;
        }