///<summary> ///Returns the item currently in the parameter location ///<summary> public EquipableItem GetItemInSlot(EquipmentLocation loc) { if (!equippedItems.ContainsKey(loc)) { return(null); } else { return(equippedItems[loc]); } }
///<summary> ///Places the parameter item in the location parameter ///<summary> public void AddItemToEquipmentLocation(EquipmentLocation loc, EquipableItem item) { Debug.Assert(item.GetAllowedEquipLocation() == loc); equippedItems[loc] = item; if (equipmentUpdated != null) { Debug.Log("Got here in AddItem in EquipItem!"); equipmentUpdated(); } }
private bool UpgradeEquipmentLocation(UpLoadDataPackage data, Equipment model, out string preSiteId) { preSiteId = null; var handler = new EquipmentLocationHandle(Repository); var lc = handler.First(t => t.EquipId == model.Id); var add = (null == lc); // 首次进入基站 if (add && !data.IsOut) { lc = new EquipmentLocation { EquipId = model.Id, SiteId = data.SiteId, Status = (short)LocationStatus.In, TagId = data.TagId, UpTime = data.TTime }; handler.Add(lc); return(true); } // 进入基站,并且位置发生变化 if (!add && !data.IsOut && lc.SiteId != data.SiteId) { lc.SiteId = data.SiteId; lc.Status = (short)LocationStatus.In; lc.TagId = data.TagId; lc.UpTime = data.TTime; handler.Add(lc); return(true); } // 离开基站,并且当前位置状态依然是进入状态 if (!add && data.IsOut && lc.SiteId == data.SiteId && lc.Status != (short)LocationStatus.Out) { lc.TagId = data.TagId; lc.UpTime = data.TTime; lc.Status = (short)LocationStatus.Out; handler.Modify(lc); } return(false); }
public static EquipmentLocation GetLocation(IUnitOfWork uow, Equipment equ) { var result = new EquipmentLocation(); var lastWarehouseOp = uow.Session.QueryOver <WarehouseMovementOperation>() .Where(o => o.Equipment == equ) .OrderBy(o => o.OperationTime).Desc .Take(1) .SingleOrDefault(); var lastCouterpartyOp = uow.Session.QueryOver <CounterpartyMovementOperation>() .Where(o => o.Equipment == equ) .OrderBy(o => o.OperationTime).Desc .Take(1) .SingleOrDefault(); if (lastWarehouseOp == null && lastCouterpartyOp == null) { result.Type = EquipmentLocation.LocationType.NoMovements; } else if (lastWarehouseOp != null && lastWarehouseOp.IncomingWarehouse != null && (lastCouterpartyOp == null || lastCouterpartyOp.OperationTime < lastWarehouseOp.OperationTime)) { result.Type = EquipmentLocation.LocationType.Warehouse; result.Warehouse = lastWarehouseOp.IncomingWarehouse; result.Operation = lastWarehouseOp; } else if (lastCouterpartyOp != null && lastCouterpartyOp.IncomingCounterparty != null && (lastWarehouseOp == null || lastWarehouseOp.OperationTime < lastCouterpartyOp.OperationTime)) { result.Type = EquipmentLocation.LocationType.Couterparty; result.Operation = lastCouterpartyOp; result.Counterparty = lastCouterpartyOp.IncomingCounterparty; result.DeliveryPoint = lastCouterpartyOp.IncomingDeliveryPoint; } else { result.Type = EquipmentLocation.LocationType.Superposition; } return(result); }
///<summary> ///Removes item from the location parameter ///<summary> public void RemoveItemFromEquipmentLocation(EquipmentLocation loc) { if (equippedItems.TryGetValue(loc, out EquipableItem removeItem)) { //if there is something to remove if (Inventory.GetPlayerInventory().HasSpaceForItem(removeItem)) { //if there is room for item Inventory.GetPlayerInventory().FindFirstEmptySlot().AddItemToSlot(removeItem, 1); } else { Debug.Log("No room for item"); //TODO implement solution for having no inventory space } } equippedItems.Remove(loc); if (equipmentUpdated != null) { Debug.Log("Got here in removeItem!"); equipmentUpdated(); } }
public static byte[] Build(EquipmentLocation location) { return new byte[] { 0x61, ((byte) location), ((byte) (((ushort) location) >> 8)) }; }
public ChangeMercEquipment(EquipmentLocation location) : base(Build(location)) { this.location = location; if (location != EquipmentLocation.NotApplicable) { this.unequip = true; } }
// Methods public ChangeMercEquipment(byte[] data) : base(data) { this.location = (EquipmentLocation) BitConverter.ToUInt16(data, 1); if (this.location != EquipmentLocation.NotApplicable) { this.unequip = true; } }
public static byte[] Build(EquipmentLocation location) { byte[] buffer = new byte[3]; buffer[0] = 0x1c; buffer[1] = (byte) location; return buffer; }
public UnequipItem(EquipmentLocation location) : base(Build(location)) { this.location = location; }
// Methods public UnequipItem(byte[] data) : base(data) { this.location = (EquipmentLocation) data[1]; }
public static byte[] Build(uint uid, EquipmentLocation location) { byte[] buffer = new byte[9]; buffer[0] = 0x1d; buffer[1] = (byte) uid; buffer[2] = (byte) (uid >> 8); buffer[3] = (byte) (uid >> 0x10); buffer[4] = (byte) (uid >> 0x18); buffer[5] = (byte) location; return buffer; }
public SwapEquippedItem(uint uid, EquipmentLocation location) : base(Build(uid, location)) { this.uid = uid; this.location = location; }
// Methods public SwapEquippedItem(byte[] data) : base(data) { this.uid = BitConverter.ToUInt32(data, 1); this.location = (EquipmentLocation) data[5]; }
public static EquipmentLocation GetLocation(IUnitOfWork uow, Equipment equ) { var result = new EquipmentLocation(); var lastWarehouseOp = uow.Session.QueryOver<WarehouseMovementOperation>() .Where(o => o.Equipment == equ) .OrderBy(o => o.OperationTime).Desc .Take(1) .SingleOrDefault(); var lastCouterpartyOp = uow.Session.QueryOver<CounterpartyMovementOperation>() .Where(o => o.Equipment == equ) .OrderBy(o => o.OperationTime).Desc .Take(1) .SingleOrDefault(); if (lastWarehouseOp == null && lastCouterpartyOp == null) result.Type = EquipmentLocation.LocationType.NoMovements; else if (lastWarehouseOp != null && lastWarehouseOp.IncomingWarehouse != null && (lastCouterpartyOp == null || lastCouterpartyOp.OperationTime < lastWarehouseOp.OperationTime)) { result.Type = EquipmentLocation.LocationType.Warehouse; result.Warehouse = lastWarehouseOp.IncomingWarehouse; result.Operation = lastWarehouseOp; } else if( lastCouterpartyOp != null && lastCouterpartyOp.IncomingCounterparty != null && (lastWarehouseOp == null || lastWarehouseOp.OperationTime < lastCouterpartyOp.OperationTime)) { result.Type = EquipmentLocation.LocationType.Couterparty; result.Operation = lastCouterpartyOp; result.Counterparty = lastCouterpartyOp.IncomingCounterparty; result.DeliveryPoint = lastCouterpartyOp.IncomingDeliveryPoint; } else { result.Type = EquipmentLocation.LocationType.Superposition; } return result; }
// Methods public ItemAction(byte[] data) : base(data) { this.superiorType = SuperiorItemType.NotApplicable; this.charClass = CharacterClass.NotApplicable; this.level = -1; this.usedSockets = -1; this.use = -1; this.graphic = -1; this.color = -1; this.stats = new List<StatBase>(); this.unknown1 = -1; this.runewordID = -1; this.runewordParam = -1; BitReader br = new BitReader(data, 1); this.action = (ItemActionType) br.ReadByte(); br.SkipBytes(1); this.category = (ItemCategory) br.ReadByte(); this.uid = br.ReadUInt32(); if (data[0] == 0x9d) { br.SkipBytes(5); } this.flags = (ItemFlags) br.ReadUInt32(); this.version = (ItemVersion) br.ReadByte(); this.unknown1 = br.ReadByte(2); this.destination = (ItemDestination) br.ReadByte(3); if (this.destination == ItemDestination.Ground) { this.x = br.ReadUInt16(); this.y = br.ReadUInt16(); } else { this.location = (EquipmentLocation) br.ReadByte(4); this.x = br.ReadByte(4); this.y = br.ReadByte(3); this.container = (ItemContainer) br.ReadByte(4); } if ((this.action == ItemActionType.AddToShop) || (this.action == ItemActionType.RemoveFromShop)) { int num = ((int) this.container) | 0x80; if ((num & 1) == 1) { num--; this.y += 8; } this.container = (ItemContainer) num; } else if (this.container == ItemContainer.Unspecified) { if (this.location == EquipmentLocation.NotApplicable) { if ((this.Flags & ItemFlags.InSocket) == ItemFlags.InSocket) { this.container = ItemContainer.Item; this.y = -1; } else if ((this.action == ItemActionType.PutInBelt) || (this.action == ItemActionType.RemoveFromBelt)) { this.container = ItemContainer.Belt; this.y = this.x / 4; this.x = this.x % 4; } } else { this.x = -1; this.y = -1; } } if ((this.flags & ItemFlags.Ear) == ItemFlags.Ear) { this.charClass = (CharacterClass) br.ReadByte(3); this.level = br.ReadByte(7); this.name = br.ReadString(7, '\0', 0x10); this.baseItem = BaseItem.Get(ItemType.Ear); } else { this.baseItem = BaseItem.GetByID(this.category, br.ReadUInt32()); if (this.baseItem.Type == ItemType.Gold) { this.stats.Add(new SignedStat(BaseStat.Get(StatType.Quantity), br.ReadInt32(br.ReadBoolean(1) ? 0x20 : 12))); } else { this.usedSockets = br.ReadByte(3); if ((this.flags & (ItemFlags.Compact | ItemFlags.Gamble)) == ItemFlags.None) { BaseStat stat; int num2; this.level = br.ReadByte(7); this.quality = (ItemQuality) br.ReadByte(4); if (br.ReadBoolean(1)) { this.graphic = br.ReadByte(3); } if (br.ReadBoolean(1)) { this.color = br.ReadInt32(11); } if ((this.flags & ItemFlags.Identified) == ItemFlags.Identified) { switch (this.quality) { case ItemQuality.Inferior: this.prefix = new ItemAffix(ItemAffixType.InferiorPrefix, br.ReadByte(3)); break; case ItemQuality.Superior: this.prefix = new ItemAffix(ItemAffixType.SuperiorPrefix, 0); this.superiorType = (SuperiorItemType) br.ReadByte(3); break; case ItemQuality.Magic: this.prefix = new ItemAffix(ItemAffixType.MagicPrefix, br.ReadUInt16(11)); this.suffix = new ItemAffix(ItemAffixType.MagicSuffix, br.ReadUInt16(11)); break; case ItemQuality.Set: this.setItem = BaseSetItem.Get(br.ReadUInt16(12)); break; case ItemQuality.Rare: case ItemQuality.Crafted: this.prefix = new ItemAffix(ItemAffixType.RarePrefix, br.ReadByte(8)); this.suffix = new ItemAffix(ItemAffixType.RareSuffix, br.ReadByte(8)); break; case ItemQuality.Unique: if (this.baseItem.Code != "std") { try { this.uniqueItem = BaseUniqueItem.Get(br.ReadUInt16(12)); } catch{} } break; } } if ((this.quality == ItemQuality.Rare) || (this.quality == ItemQuality.Crafted)) { this.magicPrefixes = new List<MagicPrefixType>(); this.magicSuffixes = new List<MagicSuffixType>(); for (int i = 0; i < 3; i++) { if (br.ReadBoolean(1)) { this.magicPrefixes.Add((MagicPrefixType) br.ReadUInt16(11)); } if (br.ReadBoolean(1)) { this.magicSuffixes.Add((MagicSuffixType) br.ReadUInt16(11)); } } } if ((this.Flags & ItemFlags.Runeword) == ItemFlags.Runeword) { this.runewordID = br.ReadUInt16(12); this.runewordParam = br.ReadUInt16(4); num2 = -1; if (this.runewordParam == 5) { num2 = this.runewordID - (this.runewordParam * 5); if (num2 < 100) { num2--; } } else if (this.runewordParam == 2) { num2 = ((this.runewordID & 0x3ff) >> 5) + 2; } br.ByteOffset -= 2; this.runewordParam = br.ReadUInt16(); this.runewordID = num2; if (num2 == -1) { throw new Exception("Unknown Runeword: " + this.runewordParam); } this.runeword = BaseRuneword.Get(num2); } if ((this.Flags & ItemFlags.Personalized) == ItemFlags.Personalized) { this.name = br.ReadString(7, '\0', 0x10); } if (this.baseItem is BaseArmor) { stat = BaseStat.Get(StatType.ArmorClass); this.stats.Add(new SignedStat(stat, br.ReadInt32(stat.SaveBits) - stat.SaveAdd)); } if ((this.baseItem is BaseArmor) || (this.baseItem is BaseWeapon)) { stat = BaseStat.Get(StatType.MaxDurability); num2 = br.ReadInt32(stat.SaveBits); this.stats.Add(new SignedStat(stat, num2)); if (num2 > 0) { stat = BaseStat.Get(StatType.Durability); this.stats.Add(new SignedStat(stat, br.ReadInt32(stat.SaveBits))); } } if ((this.Flags & (ItemFlags.None | ItemFlags.Socketed)) == (ItemFlags.None | ItemFlags.Socketed)) { stat = BaseStat.Get(StatType.Sockets); this.stats.Add(new SignedStat(stat, br.ReadInt32(stat.SaveBits))); } if (this.baseItem.Stackable) { if (this.baseItem.Useable) { this.use = br.ReadByte(5); } this.stats.Add(new SignedStat(BaseStat.Get(StatType.Quantity), br.ReadInt32(9))); } if ((this.Flags & ItemFlags.Identified) == ItemFlags.Identified) { StatBase base2; int num4 = (this.Quality == ItemQuality.Set) ? br.ReadByte(5) : -1; this.mods = new List<StatBase>(); while ((base2 = ReadStat(br)) != null) { this.mods.Add(base2); } if ((this.flags & ItemFlags.Runeword) == ItemFlags.Runeword) { while ((base2 = ReadStat(br)) != null) { this.mods.Add(base2); } } if (num4 > 0) { this.setBonuses = new List<StatBase>[5]; for (int j = 0; j < 5; j++) { if ((num4 & (((int) 1) << j)) != 0) { this.setBonuses[j] = new List<StatBase>(); while ((base2 = ReadStat(br)) != null) { this.setBonuses[j].Add(base2); } } } } } } } } }