public Player(ClientConnection connection, CharacterData characterData) : base(ObjectFamily.Player) { Connection = connection; DatabaseCharacterData = characterData; Position = new Position(new Vector3(characterData.PositionX, characterData.PositionY, characterData.PositionZ)); Ai = new PlayerAI(this, CfgCore.Default.VisibleRangeDistance); }
public void Dispose() { Release(); //release factories Action(PlayerAction.Logout); //handle logout action for processors CancelTokenSource = null; Connection = null; DatabaseCharacterData = null; }
public override void Process(ClientConnection client, byte[] data) { var info = new CharacterData(); using (var stream = new MemoryStream(data)) using (var reader = new BinaryReader(stream)) { var profession = (ClassType)reader.ReadByte(); if (!Enum.IsDefined(typeof(ClassType), profession)) { Log.Error("Profession with hashcode {0} are not exist", profession); return; } var unk = reader.ReadByte(); var name = reader.ReadString(62).Replace("\0", ""); var zodiac = (Zodiac)reader.ReadByte(); if (!Enum.IsDefined(typeof(Zodiac), zodiac)) { Log.Error("Zodiac with hashcode {0} are not exist", zodiac); return; } var appearancePresets = reader.ReadBytes(10); var appearanceOptions = reader.ReadBytes(800); #if DEBUG Log.Debug( "Character creation report\n\tName: '{0}'\n\tUnk: {1}\n\tProfession: '{2}'\n\tZodiac: '{3}'", name, unk, profession, zodiac); #endif Log.Info(appearancePresets.FormatHex()); Log.Info(appearanceOptions.FormatHex()); info.AccountId = client.Account.Id; info.CharacterName = name; info.ClassType = profession; info.Zodiac = zodiac; info.AppearancePresets = appearancePresets; info.AppearanceOptions = appearanceOptions; Core.Act(s => s.LobbyProcessor.CreateCharacterProcess(client, info)); } }
public SpCharacterInformation(CharacterData character) { _character = character; }
public void CreateCharacterProcess(ClientConnection connection, CharacterData info) { var characterData = info; using (var db = _gsDbFactory.OpenSession()) { if (db.QueryOver<CharacterData>().Where(s => s.CharacterName == info.CharacterName).Take(1).SingleOrDefault() != null) { new SpCreateCharacterError().Send(connection); return; } using (var transaction = db.BeginTransaction()) { try { characterData.CharacterId = _characterUidsFactory.Next(); characterData.Surname = connection.Account.FamilyName; characterData.Level = 1; characterData.CreationDate = DateTime.Now; characterData.CreatedId = 0;//for nhibernate driver characterData.PositionX = -96297; characterData.PositionY = -3872; characterData.PositionZ = 77811; var inventory = InventoryStorage.GetDefault(characterData.ClassType); foreach (var daoItem in inventory.Items.Select(item => new CharacterItem { CharacterId = characterData.CharacterId, ItemId = item.Value.ItemId, ItemUid = _itemsUidsFactory.Next(), Slot = item.Key - 1, Count = item.Value.Count, StorageType = (int) ((InventoryItem)item.Value).StorageType })) db.Save(daoItem); db.Save(characterData); connection.Characters.Add(characterData); new SpCreateCharacter(characterData).Send(connection, false); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); Log.Error($"Cannot create character\n{ex}"); } } } }
public SpCreateCharacter(CharacterData info) { _info = info; }