Skip to content

Commit 79b8186

Browse files
committed
feat: add effect
1 parent c60e1a9 commit 79b8186

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using TaleKit.Game.Entities;
2+
using TaleKit.Game.Event;
3+
4+
namespace TaleKit.Game.Animation;
5+
6+
public class EffectEvent : IEvent
7+
{
8+
public Session Session { get; init; }
9+
public Entity Entity { get; init; }
10+
public int EffectId { get; init; }
11+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using TaleKit.Extension;
2+
using TaleKit.Game;
3+
using TaleKit.Game.Animation;
4+
using TaleKit.Game.Entities;
5+
6+
namespace TaleKit.Network.Packet.Animation;
7+
8+
public class Eff : IPacket
9+
{
10+
public EntityType EntityType { get; set; }
11+
public int EntityId { get; set; }
12+
public int EffectId { get; set; }
13+
}
14+
15+
public class EffBuilder : PacketBuilder<Eff>
16+
{
17+
public override string Header { get; } = "eff";
18+
19+
protected override Eff CreatePacket(string[] body)
20+
{
21+
return new Eff
22+
{
23+
EntityType = body[0].ToEnum<EntityType>(),
24+
EntityId = body[1].ToInt(),
25+
EffectId = body[2].ToInt()
26+
};
27+
}
28+
}
29+
30+
public class EffProcessor : PacketProcessor<Eff>
31+
{
32+
protected override void Process(Session session, Eff packet)
33+
{
34+
var entity = session.Character.Map.GetEntity<Entity>(packet.EntityType, packet.EntityId);
35+
if (entity is null)
36+
return;
37+
38+
session.Emit(new EffectEvent
39+
{
40+
Session = session,
41+
Entity = entity,
42+
EffectId = packet.EffectId
43+
});
44+
}
45+
}

0 commit comments

Comments
 (0)