/// <summary> /// Adds the item spawn. /// </summary> /// <param name="message">The message.</param> /// <param name="itemSpawn">The item spawn.</param> public static void AddItemSpawn(this NetworkMessage message, IItemSpawn itemSpawn) { message.AddUInt16(itemSpawn.Item.SpriteId); // TODO: MARK_UNMARKED message.AddByte(0xFF); IStackableItemSpawn stackableItemSpawn = itemSpawn.GetFeature <IStackableItemSpawn>(); if (stackableItemSpawn != null) { message.AddByte((byte)stackableItemSpawn.Count); } else { // TODO: Replace feature with properties PoolFeature poolFeature = itemSpawn.GetFeature <PoolFeature>(); if (poolFeature != null) { message.AddByte((byte)poolFeature.Fluid.Color); } } // TODO: Replace feature with properties // TODO: Random phase (0xFF for async) if (itemSpawn.Item.Features.Any(s => s is AnimationFeature)) { message.AddByte(0xFE); } }
/// <summary> /// Adds the specified message. /// </summary> /// <param name="message">The message.</param> /// <param name="inventoryItem">The inventory item.</param> /// <param name="slotType">Type of the slot.</param> public static void Add(NetworkMessage message, IItemSpawn inventoryItem, SlotType slotType) { if (inventoryItem != null) { message.AddPacketType(GamePacketType.InventoryItem); message.AddSlotType(slotType); message.AddItemSpawn(inventoryItem); } else { message.AddPacketType(GamePacketType.InventoryItemEmpty); message.AddSlotType(slotType); } }
/// <summary> /// Gets the feature. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="itemSpawn">The item spawn.</param> /// <returns>The feature.</returns> public static T GetFeature <T>(this IItemSpawn itemSpawn) { return(itemSpawn.Item.GetFeature <T>()); }