本文整理汇总了C#中IDefinitionManager.GetItemDefinitions方法的典型用法代码示例。如果您正苦于以下问题:C# IDefinitionManager.GetItemDefinitions方法的具体用法?C# IDefinitionManager.GetItemDefinitions怎么用?C# IDefinitionManager.GetItemDefinitions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDefinitionManager
的用法示例。
在下文中一共展示了IDefinitionManager.GetItemDefinitions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Deserialize
/// <summary>
/// Deserialisiert den Player aus dem angegebenen BinaryReader.
/// </summary>
/// <param name="reader">Der BinaryWriter, mit dem gelesen wird.</param>
/// <param name="definitionManager">Der aktuell verwendete <see cref="IDefinitionManager"/>.</param>
public override void Deserialize(BinaryReader reader, IDefinitionManager definitionManager)
{
// Entity
base.Deserialize(reader, definitionManager);
// Radius
Radius = reader.ReadSingle();
// Angle
Angle = reader.ReadSingle();
// Height
Height = reader.ReadSingle();
// Tilt
Tilt = reader.ReadSingle();
// FlyMode
FlyMode = reader.ReadBoolean();
// Inventory Limit
// TODO: Noch nicht persistiert
// Inventory
int inventoryCount = reader.ReadInt32();
for (int i = 0; i < inventoryCount; i++)
{
string definitionName = reader.ReadString();
decimal amount = reader.ReadDecimal();
var definition = definitionManager.GetItemDefinitions().FirstOrDefault(d => d.GetType().FullName.Equals(definitionName));
if (definition != null)
{
InventorySlot slot = new InventorySlot();
slot.Definition = definition;
slot.Amount = amount;
Inventory.Add(slot);
}
}
// Inventory Tools (Index auf Inventory)
byte toolCount = reader.ReadByte();
for (byte i = 0; i < toolCount; i++)
{
byte index = reader.ReadByte();
string definitionType = reader.ReadString();
InventorySlot slot = Inventory.FirstOrDefault(s => s.Definition.GetType().FullName.Equals(definitionType));
if (slot != null)
Tools[index] = slot;
}
}