public WorldItemPrototype(IBaseItemPrototype item) { ServerID = item.ServerID; ClientID = item.ClientID; Name = item.Name; Article = item.Article; Plural = item.Plural; CanUse = item.CanUse; ItemComponent = item.ItemComponent; DecayInfo = item.DecayInfo; WriteInfo = item.WriteInfo; }
private static bool ParseContainerComponent(ref IBaseItemPrototype item) { bool modified = false; byte size = (byte)TryGetUShort("containerSize", ref modified); if (modified) { item.ItemComponent = new ContainerComponent(size); } return(modified); }
private static bool ParseItem(ref IBaseItemPrototype item) { bool modified = false; int weight = TryGetInt("weight", ref modified); if (modified) { item = new ItemPrototype(item, weight); } return(modified); }
private static bool ParseMeeleWeaponComponent(ref IBaseItemPrototype item) { bool modified = false; uint attack = TryGetUInt("attack", ref modified); if (modified) { var equip = item.ItemComponent as EquipableComponent; item.ItemComponent = new MeleeWeaponComponent(equip, 1, 1, attack); } return(modified); }
private static bool ParseEquipableComponent(ref IBaseItemPrototype item) { bool modified = false; uint level = TryGetUInt("requiredLevel", ref modified); ushort defense = TryGetUShort("defense", ref modified); if (modified) { item.ItemComponent = new EquipableComponent(defense: defense, minLevel: level); } return(modified); }
private static bool ParseWorldItem(ref IBaseItemPrototype item) { bool modified = false; ushort destroyTo = TryGetUShort("destroyTo", ref modified); ushort rotateTo = TryGetUShort("rotateTo", ref modified); ushort transformTo = TryGetUShort("transformTo", ref modified); bool blockprojectile = TryGetBool("blockProjectile", ref modified); if (modified) { item = new WorldItemPrototype(item, destroyTo, rotateTo, transformTo, blockprojectile); } return(modified); }
private static void ParseBasic(ref IBaseItemPrototype item) { bool modified = false; string description = TryGetValue("description", ref modified); uint duration = TryGetUInt("duration", ref modified); ushort toId = TryGetUShort("decayTo", ref modified); ushort maxTextLen = TryGetUShort("maxTextLen", ref modified); ushort writeOnceId = TryGetUShort("writeOnceItemId", ref modified); if (modified) { item.Description = description; item.DecayInfo = new DecayInfo(toId != 0 && duration != 0, toId, duration); item.WriteInfo = new WriteInfo(maxTextLen > 0, writeOnceId, maxTextLen); } }
private static void LoadItemsFromOTB(string path) { var data = FileManager.ReadFileToByteArray(path); var tree = new OTBTreeBuilder(data).BuildTree(); // SKIP to nodes _items = new List <IBaseItemPrototype>(30000); foreach (var itemNode in tree.Children) { var itemStream = new ReadOnlyMemoryStream(itemNode.Data.Span); var flags = itemStream.ReadUInt32(); ushort serverId = 0; ushort clientId = 0; ushort wareId = 0; ushort speed = 0; byte lightLevel = 0; byte lightColor = 0; byte topOrder = 0; var toSkip = 0; bool escaped = false; while (!itemStream.IsOver) { var attr = itemStream.ReadByte(); var isEscape = (OTBMarkupByte)attr == OTBMarkupByte.Escape; if (toSkip > 0) { if (isEscape) { if (escaped) { toSkip++; escaped = false; } else { toSkip--; escaped = true; } } else { toSkip--; } if (toSkip == 0) { break; } continue; } var dataSize = itemStream.ReadUInt16(); switch (attr) { case 0x10: // ServerID 0x10 = 16 serverId = itemStream.ReadUInt16(); break; case 0x11: // ClientID 0x11 = 17 clientId = itemStream.ReadUInt16(); break; case 0x14: // Speed 0x14 = 20 speed = itemStream.ReadUInt16(); break; case 0x2A: // LightBlock 0x2A = 42 lightLevel = (byte)itemStream.ReadUInt16(); lightColor = (byte)itemStream.ReadUInt16(); break; case 0x2B: // TopOrder 0x2B = 43 topOrder = itemStream.ReadByte(); break; case 0x2D: // WareID 0x2D = 45 wareId = (byte)itemStream.ReadUInt16(); break; default: toSkip = dataSize; break; } } var blockSolid = HasFlag(flags, 1 << 0); var blockProjectile = HasFlag(flags, 1 << 1); var blockPathFind = HasFlag(flags, 1 << 2); //var hasElevation = HasFlag(flags, 1 << 3); // Irrelevant var isUsable = HasFlag(flags, 1 << 4); var isPickupable = HasFlag(flags, 1 << 5); var isMoveable = HasFlag(flags, 1 << 6); //var isStackable = HasFlag(flags, 1 << 7); var alwaysOnTop = HasFlag(flags, 1 << 13); // Maybe irrelevant var isReadable = HasFlag(flags, 1 << 14); var isRotatable = HasFlag(flags, 1 << 15); var isHangable = HasFlag(flags, 1 << 16); var isVertical = HasFlag(flags, 1 << 17); var isHorizontal = HasFlag(flags, 1 << 18); var allowDistRead = HasFlag(flags, 1 << 20); var lookTrough = HasFlag(flags, 1 << 21); var isAnimation = HasFlag(flags, 1 << 22); // Maybe irrelevant too? IBaseItemPrototype item = null; if (!isPickupable) // A world item { item = new WorldItemPrototype(serverId, clientId, isUsable, isMoveable, blockSolid, lookTrough, blockPathFind, blockProjectile); } else // An item { item = new ItemPrototype(serverId, clientId, isUsable); } if (item != null) { _items.Add(item); } } _items.TrimExcess(); }
public ItemPrototype(IBaseItemPrototype item, int weight = 0, byte maxStackSize = 100) : this(item) { Weight = weight; MaxStackSize = maxStackSize; }
public WorldItemPrototype(IBaseItemPrototype item, ushort destroyTo, ushort rotateTo, ushort transformTo, bool blockprojectile) : this(item) { DestroyTo = destroyTo; RotateTo = rotateTo; TransformTo = transformTo; BlockInfo = new BlockInfo(projectile: blockprojectile); }