Skip to content

Commit 09681f0

Browse files
committed
add player init
1 parent bae9bbe commit 09681f0

File tree

2 files changed

+22
-25
lines changed

2 files changed

+22
-25
lines changed

TaleKit.Phoenix/PhoenixActionBridge.cs

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,16 @@
55
using PhoenixWrapped.Messaging.Combat;
66
using PhoenixWrapped.Messaging.Interaction;
77
using PhoenixWrapped.Messaging.Movement;
8-
using PartnerSkill = TaleKit.Game.Combat.PartnerSkill;
98

109
namespace TaleKit.Phoenix;
1110

12-
public class PhoenixActionBridge : IActionBridge
11+
public class PhoenixActionBridge(PhoenixClient client) : IActionBridge
1312
{
14-
private readonly PhoenixClient client;
15-
16-
public PhoenixActionBridge(PhoenixClient client)
17-
{
18-
this.client = client;
19-
}
20-
2113
public Session? Session { get; set; }
2214

23-
public void Walk(Position position, int speed)
24-
{
25-
this.client.SendMessage(new PlayerWalk
26-
{
27-
X = position.X,
28-
Y = position.Y
29-
});
30-
}
31-
3215
public void Walk(Character character, Position position)
3316
{
34-
this.client.SendMessage(new PlayerWalk
17+
client.SendMessage(new PlayerWalk
3518
{
3619
X = position.X,
3720
Y = position.Y
@@ -40,7 +23,7 @@ public void Walk(Character character, Position position)
4023

4124
public void WalkNosmate(SummonedNosmate nosmate, Position position)
4225
{
43-
this.client.SendMessage(new PetsWalk
26+
client.SendMessage(new PetsWalk
4427
{
4528
X = position.X,
4629
Y = position.Y
@@ -49,15 +32,15 @@ public void WalkNosmate(SummonedNosmate nosmate, Position position)
4932

5033
public void Attack(LivingEntity entity)
5134
{
52-
this.client.SendMessage(new Attack
35+
client.SendMessage(new Attack
5336
{
5437
MonsterId = entity.Id
5538
});
5639
}
5740

5841
public void Attack(LivingEntity entity, Skill skill)
5942
{
60-
this.client.SendMessage(new PlayerSkill
43+
client.SendMessage(new PlayerSkill
6144
{
6245
MonsterId = entity.Id,
6346
SkillId = skill.CastId
@@ -66,7 +49,7 @@ public void Attack(LivingEntity entity, Skill skill)
6649

6750
public void PickUp(Drop drop)
6851
{
69-
this.client.SendMessage(new PickUp
52+
client.SendMessage(new PickUp
7053
{
7154
ItemId = drop.Id
7255
});

TaleKit.Phoenix/PhoenixFactory.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static Session CreateSession(PhoenixClient client)
7373
case QueryMapEntities entities:
7474
foreach (var monsterInfo in entities.Monsters)
7575
{
76-
var monster = MonsterFactory.CreateMonster((int) monsterInfo.Id, monsterInfo.Vnum);
76+
var monster = MonsterFactory.CreateMonster(monsterInfo.Id, monsterInfo.Vnum);
7777

7878
monster.HpPercentage = monsterInfo.HpPercent;
7979
monster.MpPercentage = monsterInfo.HpPercent;
@@ -85,7 +85,7 @@ public static Session CreateSession(PhoenixClient client)
8585

8686
foreach (var dropInfo in entities.Items)
8787
{
88-
var drop = DropFactory.CreateDrop((int) dropInfo.Id, dropInfo.Vnum, dropInfo.Quantity);
88+
var drop = DropFactory.CreateDrop(dropInfo.Id, dropInfo.Vnum, dropInfo.Quantity);
8989

9090
drop.Map = session.Character.Map;
9191
drop.Position = new Position(dropInfo.X, dropInfo.Y);
@@ -105,6 +105,20 @@ public static Session CreateSession(PhoenixClient client)
105105
session.Character.Map.AddEntity(npc);
106106
}
107107

108+
foreach (var playerInfo in entities.Players)
109+
{
110+
var player = new Player
111+
{
112+
Position = new Position(playerInfo.X, playerInfo.Y),
113+
HpPercentage = playerInfo.HpPercent,
114+
MpPercentage = playerInfo.MpPercent,
115+
Name = playerInfo.Name,
116+
Map = session.Character.Map
117+
};
118+
119+
session.Character.Map.AddEntity(player);
120+
}
121+
108122
break;
109123
case QuerySkills skillInfos:
110124
var skills = new HashSet<Skill>();

0 commit comments

Comments
 (0)