Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.IO;
- namespace FEXNA_Library
- {
- public enum Item_Data_Type { Weapon, Item }
- public class Item_Data
- {
- public Item_Data_Type Type = Item_Data_Type.Weapon;
- public int Id = 0;
- public int Uses = 0;
- public int Cost = 0;
- #region Serialization
- public static Item_Data read(BinaryReader reader)
- {
- int count = reader.ReadInt32();
- if (count == 4)
- return new Item_Data(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32());
- else //Debug
- return new Item_Data(reader.ReadInt32(), reader.ReadInt32(), reader.ReadInt32());
- }
- public void write(BinaryWriter writer)
- {
- if (true) //Debug
- {
- writer.Write(4);
- writer.Write((int)Type);
- writer.Write(Id);
- writer.Write(Uses);
- writer.Write(Cost);
- }
- }
- #endregion
- public Item_Data() { }
- public Item_Data(Item_Data_Type type, int id, int uses)
- {
- Type = type;
- Id = id;
- Uses = uses;
- }
- public Item_Data(Item_Data_Type type, int id, int uses, int cost)
- {
- Type = type;
- Id = id;
- Uses = uses;
- Cost = cost;
- }
- public Item_Data(int type, int id, int uses, int cost) : this((Item_Data_Type)type, id, uses, cost) { }
- public Item_Data(Item_Data data) : this(data.Type, data.Id, data.Uses, data.Cost) { }
- public bool is_weapon
- {
- get { return Type == Item_Data_Type.Weapon; }
- }
- public bool is_item
- {
- get { return Type == Item_Data_Type.Item; }
- }
- public bool blank_item
- {
- get { return Type == Item_Data_Type.Weapon && Id == 0 && Uses == 0; }
- }
- public bool same_item(Item_Data item)
- {
- return Type == item.Type && Id == item.Id;
- }
- }
- }
Add Comment
Please, Sign In to add comment