public MateEntity(IPlayerEntity owner, CharacterMateDto dto, NpcMonsterDto npcMonster) : base(VisualType.Monster, dto.Id) { Owner = owner; Mate = dto; NpcMonster = npcMonster; Level = dto.Level; LevelXp = dto.Experience; Hp = dto.Hp; HpMax = dto.Hp; Mp = dto.Mp; MpMax = dto.Mp; IsTeamMember = dto.IsTeamMember; MateType = dto.MateType; PetId = 0; Movable = new MovableComponent(this, NpcMonster.Speed) { Actual = new Position <short> { X = dto.MapX, Y = dto.MapY }, Destination = new Position <short> { X = dto.MapX, Y = dto.MapY } }; _visibility = new VisibilityComponent(this); SkillComponent = new SkillComponent(this); Components = new Dictionary <Type, IComponent> { { typeof(VisibilityComponent), _visibility }, { typeof(MovableComponent), Movable }, { typeof(SkillComponent), SkillComponent } }; }
protected override async Task Handle(AddPetEvent e, CancellationToken cancellation) { if (!(e.Sender is IPlayerEntity player)) { return; } NpcMonsterDto heldMonster = _npcMonsterService.GetById(e.MonsterVnum); if (heldMonster == null) { return; } var mate = new CharacterMateDto { NpcMonsterId = (short)e.MonsterVnum, CanPickUp = false, CharacterId = player.Id, Attack = 0, Defence = 0, Direction = 0, Experience = 0, Hp = heldMonster.MaxHp, Level = 1, IsSummonable = false, IsTeamMember = true, Loyalty = 1000, MapX = player.Position.X, MapY = player.Position.Y, Mp = heldMonster.MaxMp, Name = heldMonster.Name, Skin = 0, Agility = 0, MateType = e.MateType }; IMateEntity mateEn = await _entityFactory.CreateNewMateEntityAsync(player, mate); await player.AddPet(mateEn); await player.SendPacketAsync(player.GenerateInfoBubble("PET_LEAVE_BEAD")); }
public async Task <IMateEntity> CreateNewMateEntityAsync(IPlayerEntity owner, long characterMateId) { CharacterMateDto mate = await _characterMate.GetByIdAsync(characterMateId); return(await CreateNewMateEntityAsync(owner, mate)); }
public async Task <IMateEntity> CreateNewMateEntityAsync(IPlayerEntity owner, CharacterMateDto dto) { NpcMonsterDto npcMonster = await _npcMonsterService.GetByIdAsync(dto.NpcMonsterId); return(new MateEntity(owner, dto, npcMonster)); }