public Item(World world, int actorSNO, int gbid, ItemType type) : base(world, world.NewActorID) { this.SNOId = actorSNO; this.GBHandle.Type = (int)GBHandleType.Gizmo; this.GBHandle.GBID = gbid; this.ItemType = type; this.EquipmentSlot = 0; this.InventoryLocation = new Vector2D { X = 0, Y = 0 }; this.Scale = 1.0f; this.RotationAmount = 0.0f; this.RotationAxis.Set(0.0f, 0.0f, 1.0f); this.Field2 = 0x00000000; this.Field3 = 0x00000000; this.Field7 = 0; this.Field8 = 0; this.Field9 = 0x00000000; this.Field10 = 0x00; List<IItemAttributeCreator> attributeCreators = new AttributeCreatorFactory().Create(type); foreach (IItemAttributeCreator creator in attributeCreators) { creator.CreateAttributes(this); } this.World.Enter(this); // Enter only once all fields have been initialized to prevent a run condition }
public Item CreateItem(String itemName, int actorSNO, ItemType itemType) { Item item = Generate(itemName, actorSNO, itemType); List<IItemAttributeCreator> attributeCreators = new AttributeCreatorFactory().Create(itemType); foreach (IItemAttributeCreator creator in attributeCreators) { creator.CreateAttributes(item); } return item; }
// Allows cooking a custom item. public static Item Cook(Player player, string name, int snoId, ItemType type) { var item = new Item(player.World, snoId, StringHashHelper.HashItemName(name), type); player.GroundItems[item.DynamicID] = item; var attributeCreators = new AttributeCreatorFactory().Create(type); foreach (IItemAttributeCreator creator in attributeCreators) { creator.CreateAttributes(item); } return item; }
// Creates an item based on supplied definition. public static Item CreateItem(Player player, ItemDefinition definition) { Logger.Trace("Creating item: {0} [type: {1}, mode: {2}, sno:{3}, gbid {4}]", definition.Name, definition.Type, definition.DifficultyMode, definition.SNOId, definition.GBId); var item = new Item(player.World, definition.SNOId, definition.GBId, definition.Type); player.GroundItems[item.DynamicID] = item; var attributeCreators = new AttributeCreatorFactory().Create(definition.Type); foreach (IItemAttributeCreator creator in attributeCreators) { creator.CreateAttributes(item); } return item; }
public virtual void OnRequestBuyItem(Players.Player player, Item item) { // TODO: Check gold here if (!player.Inventory.HasInventorySpace(item)) { return; } // TODO: Remove the gold var newItem = new Item(this.World, item.SNOId, item.GBHandle.GBID, item.ItemType); var attributeCreators = new AttributeCreatorFactory().Create(item.ItemType); foreach (IItemAttributeCreator creator in attributeCreators) { creator.CreateAttributes(item); } player.Inventory.PickUp(newItem); // TODO: Dont use pickup? ;) }