public Toon(string name, int classId, ToonFlags flags, byte level, Account account) // Toon with **newly generated** persistent ID : base(StringHashHelper.HashIdentity(name)) { this.SetFields(name, GetClassByID(classId), flags, level, account); }
//<<<<<<< HEAD // public Toon(ulong persistantId, string name, byte @class, byte gender, byte level, long accountId) // Toon with given persistent ID // :base(persistantId) // { // this.SetFields(name, (ToonClass)@class, (ToonFlags)gender, level, AccountManager.GetAccountByPersistantID((ulong)accountId)); // } // public Toon(string name, int classId, ToonFlags flags, byte level, Account account) // Toon with **newly generated** persistent ID // : base(StringHashHelper.HashIdentity(name)) // { // this.SetFields(name, GetClassByID(classId), flags, level, account); // } //======= //>>>>>>> 8574c238179fe15ed89f064963d15f70293617bc private void SetFields(string name, ToonClass @class, ToonFlags flags, byte level, Account owner) { this.ToonHandle = new ToonHandleHelper(this.PersistentID); this.D3EntityID = this.ToonHandle.ToD3EntityID(); this.BnetEntityID = this.ToonHandle.ToBnetEntityID(); this.Name = name; this.Class = @class; this.Flags = flags; this.Level = level; this.Owner = owner; var itemsGenerator = new Items.ItemTypeGenerator(); var visualItems = new[] { // Head D3.Hero.VisualItem.CreateBuilder() .SetGbid(itemsGenerator.generateRandomElement(Items.ItemType.Helm).Gbid) .SetDyeType(0) .SetItemEffectType(0) .SetEffectLevel(0) .Build(), // Chest D3.Hero.VisualItem.CreateBuilder() .SetGbid(itemsGenerator.generateRandomElement(Items.ItemType.ChestArmor).Gbid) .SetDyeType(0) .SetItemEffectType(0) .SetEffectLevel(0) .Build(), // Feet D3.Hero.VisualItem.CreateBuilder() .SetGbid(itemsGenerator.generateRandomElement(Items.ItemType.Boots).Gbid) .SetDyeType(0) .SetItemEffectType(0) .SetEffectLevel(0) .Build(), // Hands D3.Hero.VisualItem.CreateBuilder() .SetGbid(itemsGenerator.generateRandomElement(Items.ItemType.Gloves).Gbid) .SetDyeType(0) .SetItemEffectType(0) .SetEffectLevel(0) .Build(), // Weapon (1) D3.Hero.VisualItem.CreateBuilder() .SetGbid(itemsGenerator.generateRandomElement(Items.ItemType.Sword_1H).Gbid) .SetDyeType(0) .SetItemEffectType(0) .SetEffectLevel(0) .Build(), // Weapon (2) D3.Hero.VisualItem.CreateBuilder() .SetGbid(itemsGenerator.generateRandomElement(Items.ItemType.Shield).Gbid) .SetDyeType(0) .SetItemEffectType(0) .SetEffectLevel(0) .Build(), // Shoulders D3.Hero.VisualItem.CreateBuilder() .SetGbid(itemsGenerator.generateRandomElement(Items.ItemType.Shoulders).Gbid) .SetDyeType(0) .SetItemEffectType(0) .SetEffectLevel(0) .Build(), // Legs D3.Hero.VisualItem.CreateBuilder() .SetGbid(itemsGenerator.generateRandomElement(Items.ItemType.Pants).Gbid) .SetDyeType(0) .SetItemEffectType(0) .SetEffectLevel(0) .Build(), }; this.Equipment = D3.Hero.VisualEquipment.CreateBuilder().AddRangeVisualItem(visualItems).Build(); this.Digest = D3.Hero.Digest.CreateBuilder().SetVersion(891) .SetHeroId(this.D3EntityID) .SetHeroName(this.Name) .SetGbidClass((int)this.ClassID) .SetPlayerFlags((uint)this.Flags) .SetLevel(this.Level) .SetVisualEquipment(this.Equipment) .SetLastPlayedAct(0) .SetHighestUnlockedAct(0) .SetLastPlayedDifficulty(0) .SetHighestUnlockedDifficulty(0) .SetLastPlayedQuest(-1) .SetLastPlayedQuestStep(-1) .SetTimePlayed(0) .Build(); }
private void SetFields(string name, ToonClass @class, ToonFlags flags, byte level, Account owner) { this.ToonHandle = new ToonHandleHelper(this.PersistentID); this.D3EntityID = this.ToonHandle.ToD3EntityID(); this.BnetEntityID = this.ToonHandle.ToBnetEntityID(); this.Name = name; this.Class = @class; this.Flags = flags; this.Level = level; this.Owner = owner; var itemsGenerator = new Items.ItemTypeGenerator(); var visualItems = new[] { // Head D3.Hero.VisualItem.CreateBuilder() .SetGbid( itemsGenerator.generateRandomElement(Items.ItemType.Helm).Gbid) .SetDyeType(0) .SetItemEffectType(0) .SetEffectLevel(0) .Build(), // Chest D3.Hero.VisualItem.CreateBuilder() .SetGbid(itemsGenerator.generateRandomElement(Items.ItemType.ChestArmor).Gbid) .SetDyeType(0) .SetItemEffectType(0) .SetEffectLevel(0) .Build(), // Feet D3.Hero.VisualItem.CreateBuilder() .SetGbid(itemsGenerator.generateRandomElement(Items.ItemType.Boots).Gbid) .SetDyeType(0) .SetItemEffectType(0) .SetEffectLevel(0) .Build(), // Hands D3.Hero.VisualItem.CreateBuilder() .SetGbid(itemsGenerator.generateRandomElement(Items.ItemType.Gloves).Gbid) .SetDyeType(0) .SetItemEffectType(0) .SetEffectLevel(0) .Build(), // Weapon (1) D3.Hero.VisualItem.CreateBuilder() .SetGbid(itemsGenerator.generateRandomElement(Items.ItemType.Sword_1H).Gbid) .SetDyeType(0) .SetItemEffectType(0) .SetEffectLevel(0) .Build(), // Weapon (2) D3.Hero.VisualItem.CreateBuilder() .SetGbid(itemsGenerator.generateRandomElement(Items.ItemType.Shield).Gbid) .SetDyeType(0) .SetItemEffectType(0) .SetEffectLevel(0) .Build(), // Shoulders D3.Hero.VisualItem.CreateBuilder() .SetGbid(itemsGenerator.generateRandomElement(Items.ItemType.Shoulders).Gbid) .SetDyeType(0) .SetItemEffectType(0) .SetEffectLevel(0) .Build(), // Legs D3.Hero.VisualItem.CreateBuilder() .SetGbid(itemsGenerator.generateRandomElement(Items.ItemType.Pants).Gbid) .SetDyeType(0) .SetItemEffectType(0) .SetEffectLevel(0) .Build(), }; this.Equipment = D3.Hero.VisualEquipment.CreateBuilder().AddRangeVisualItem(visualItems).Build(); this.Digest = D3.Hero.Digest.CreateBuilder().SetVersion(891) .SetHeroId(this.D3EntityID) .SetHeroName(this.Name) .SetGbidClass((int)this.ClassID) .SetPlayerFlags((uint)this.Flags) .SetLevel(this.Level) .SetVisualEquipment(this.Equipment) .SetLastPlayedAct(0) .SetHighestUnlockedAct(0) .SetLastPlayedDifficulty(0) .SetHighestUnlockedDifficulty(0) .SetLastPlayedQuest(-1) .SetLastPlayedQuestStep(-1) .SetTimePlayed(0) .Build(); }
public static Dictionary<ulong, Toon> GetToonsForAccount(Account account) { return Toons.Where(pair => (ulong)pair.Value.Owner.PersistentID == account.PersistentID).ToDictionary(pair => pair.Key, pair => pair.Value); }