forked from jo3bingham/TibiaAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMap.cs
More file actions
43 lines (38 loc) · 1.49 KB
/
Map.cs
File metadata and controls
43 lines (38 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System.Collections.Generic;
using OXGaming.TibiaAPI.Appearances;
using OXGaming.TibiaAPI.Constants;
using OXGaming.TibiaAPI.Utilities;
namespace OXGaming.TibiaAPI.Network.ServerPackets
{
public class Map : ServerPacket
{
public List<(int TilesToSkip, List<ObjectInstance> Objects, Position Position)> Fields { get; } =
new List<(int TilesToSkip, List<ObjectInstance> Objects, Position Position)>();
public override void AppendToNetworkMessage(NetworkMessage message)
{
foreach (var (TilesToSkip, Objects, _) in Fields)
{
foreach (var obj in Objects)
{
if (obj.Id == (int)CreatureInstanceType.UnknownCreature ||
obj.Id == (int)CreatureInstanceType.OutdatedCreature ||
obj.Id == (int)CreatureInstanceType.Creature)
{
var creature = Client.CreatureStorage.GetCreature(obj.Data);
if (creature == null)
{
continue;
}
message.Write((ushort)creature.InstanceType);
message.Write(creature, creature.InstanceType);
}
else
{
message.Write(obj);
}
}
message.Write((ushort)(TilesToSkip + 0xFF00));
}
}
}
}