-
Notifications
You must be signed in to change notification settings - Fork 38
/
RequirementConfig.cs
74 lines (66 loc) · 2.37 KB
/
RequirementConfig.cs
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
62
63
64
65
66
67
68
69
70
71
72
73
74
using Jotunn.Entities;
namespace Jotunn.Configs
{
/// <summary>
/// Configuration class for requirements needed to craft items or build pieces.
/// </summary>
public class RequirementConfig
{
/// <summary>
/// Name of the item prefab of this requirement.
/// </summary>
public string Item { get; set; } = string.Empty;
/// <summary>
/// Amount that is needed to fulfill the requirement. Defaults to 1.
/// </summary>
public int Amount { get; set; } = 1;
/// <summary>
/// How much more of this requirement is needed per item level. Defaults to 0.
/// </summary>
public int AmountPerLevel { get; set; } = 0;
/// <summary>
/// Determines if the used requirement will be rewarded again after dismanteling a piece. Defaults to false.
/// </summary>
public bool Recover { get; set; } = false;
/// <summary>
/// Creates a new requirement config with default values.
/// </summary>
public RequirementConfig() { }
/// <summary>
/// Creates a new requirement config with the given values.
/// </summary>
/// <param name="item"></param>
/// <param name="amount"></param>
/// <param name="amountPerLevel"></param>
/// <param name="recover"></param>
public RequirementConfig(string item, int amount, int amountPerLevel = 0, bool recover = false)
{
Item = item;
Amount = amount;
AmountPerLevel = amountPerLevel;
Recover = recover;
}
/// <summary>
/// Creates a Valheim Piece.Requirement from this config.
/// </summary>
/// <returns></returns>
public Piece.Requirement GetRequirement()
{
return new Piece.Requirement
{
m_resItem = Mock<ItemDrop>.Create(Item),
m_amount = Amount,
m_amountPerLevel = AmountPerLevel,
m_recover = Recover
};
}
/// <summary>
/// Checks if the requirement has any item and amount set.
/// </summary>
/// <returns></returns>
public bool IsValid()
{
return !string.IsNullOrEmpty(Item) && (Amount > 0 || AmountPerLevel > 0);
}
}
}