public IItem AddItem(Guid guid, int blueprintId, IContainer container) { ItemBlueprintBase blueprint = GetItemBlueprint(blueprintId); if (blueprint == null) { Log.Default.WriteLine(LogLevels.Error, $"World.AddItem: unknown blueprintId {blueprintId}"); return(null); } IItem item = AddItem(guid, blueprint, container); if (item == null) { Log.Default.WriteLine(LogLevels.Error, $"World.AddItem: Unknown blueprint id {blueprintId} or type {blueprint.GetType().FullName}"); } return(item); }
public IItem AddItem(Guid guid, ItemBlueprintBase blueprint, IContainer container) { var weaponBlueprint = blueprint as ItemWeaponBlueprint; if (weaponBlueprint != null) { return(AddItemWeapon(guid, weaponBlueprint, container)); } var containerBlueprint = blueprint as ItemContainerBlueprint; if (containerBlueprint != null) { return(AddItemContainer(guid, containerBlueprint, container)); } var armorBlueprint = blueprint as ItemArmorBlueprint; if (armorBlueprint != null) { return(AddItemArmor(guid, armorBlueprint, container)); } var lightBlueprint = blueprint as ItemLightBlueprint; if (lightBlueprint != null) { return(AddItemLight(guid, lightBlueprint, container)); } var furnitureBlueprint = blueprint as ItemFurnitureBlueprint; if (furnitureBlueprint != null) { return(AddItemFurniture(guid, furnitureBlueprint, container)); } var jewelryBlueprint = blueprint as ItemJewelryBlueprint; if (jewelryBlueprint != null) { return(AddItemJewelry(guid, jewelryBlueprint, container)); } var shieldBlueprint = blueprint as ItemShieldBlueprint; if (shieldBlueprint != null) { return(AddItemShield(guid, shieldBlueprint, container)); } var keyBlueprint = blueprint as ItemKeyBlueprint; if (keyBlueprint != null) { return(AddItemKey(guid, keyBlueprint, container)); } var portalBlueprint = blueprint as ItemPortalBlueprint; if (portalBlueprint != null) { IRoom destination = Rooms.FirstOrDefault(x => x.Blueprint?.Id == portalBlueprint.Destination); return(AddItemPortal(guid, portalBlueprint, destination, container)); } // TODO: other blueprint Log.Default.WriteLine(LogLevels.Error, $"World.AddItem: Invalid blueprint type {blueprint.GetType().FullName}"); return(null); }