forked from Viniixd/Remastered-AssetsEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppearanceSyncHelper.cs
More file actions
61 lines (52 loc) · 1.5 KB
/
AppearanceSyncHelper.cs
File metadata and controls
61 lines (52 loc) · 1.5 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System.Collections.Generic;
using Tibia.Protobuf.Appearances;
namespace Assets_Editor;
/// <summary>
/// Provides helper methods to keep Market and Cyclopedia flag identifiers aligned with the owning appearance id.
/// </summary>
public static class AppearanceSyncHelper
{
public static void SyncMarketAndCyclopedia(Appearance appearance)
{
if (appearance == null)
{
return;
}
if (appearance.Flags == null)
{
return;
}
uint id = appearance.Id;
if (appearance.Flags.Market != null)
{
appearance.Flags.Market.TradeAsObjectId = id;
appearance.Flags.Market.ShowAsObjectId = id;
}
if (appearance.Flags.Cyclopediaitem != null)
{
appearance.Flags.Cyclopediaitem.CyclopediaType = id;
}
}
public static void SyncMarketAndCyclopedia(IEnumerable<Appearance> appearances)
{
if (appearances == null)
{
return;
}
foreach (var appearance in appearances)
{
SyncMarketAndCyclopedia(appearance);
}
}
public static void SyncMarketAndCyclopedia(Appearances appearances)
{
if (appearances == null)
{
return;
}
SyncMarketAndCyclopedia(appearances.Object);
SyncMarketAndCyclopedia(appearances.Outfit);
SyncMarketAndCyclopedia(appearances.Effect);
SyncMarketAndCyclopedia(appearances.Missile);
}
}