public static EleGraphicalData ReadFromStream(int id, EleInstance instance, BigEndianReader reader) { var type = (EleGraphicalElementTypes)reader.ReadByte(); switch (type) { case EleGraphicalElementTypes.ANIMATED: return(AnimatedGraphicalElementData.ReadFromStream(instance, id, reader)); case EleGraphicalElementTypes.BLENDED: return(BlendedGraphicalElementData.ReadFromStream(instance, id, reader)); case EleGraphicalElementTypes.BOUNDING_BOX: return(BoundingBoxGraphicalElementData.ReadFromStream(instance, id, reader)); case EleGraphicalElementTypes.ENTITY: return(EntityGraphicalElementData.ReadFromStream(instance, id, reader)); case EleGraphicalElementTypes.NORMAL: return(NormalGraphicalElementData.ReadFromStream(instance, id, reader)); case EleGraphicalElementTypes.PARTICLES: return(ParticlesGraphicalElementData.ReadFromStream(instance, id, reader)); default: throw new Exception("Unknown graphical data of type " + type); } }
public static void GetElements(DlmMap map, Elements elements, out List <MapInteractiveElement> interactiveElements) { interactiveElements = new List <MapInteractiveElement>(); foreach (var layer in map.Layers) { foreach (var cell in layer.Cells) { foreach (var element in cell.Elements) { if (element is DlmGraphicalElement) { DlmGraphicalElement graphicalElement = element as DlmGraphicalElement; if (graphicalElement.Identifier != 0) { var gfxElement = elements.ReadElement((int)graphicalElement.ElementId); if (gfxElement.Type != EleGraphicalElementTypes.ENTITY) { NormalGraphicalElementData normalElement = gfxElement as NormalGraphicalElementData; MapInteractiveElement interactiveTable = new MapInteractiveElement(); interactiveTable.ElementId = (int)graphicalElement.Identifier; interactiveTable.MapId = map.Id; interactiveTable.CellId = (ushort)cell.Id; if (normalElement != null) { interactiveTable.GfxId = normalElement.Gfx; } interactiveTable.GfxBonesId = -1; interactiveElements.Add(interactiveTable); } else { EntityGraphicalElementData entityElement = gfxElement as EntityGraphicalElementData; MapInteractiveElement interactiveTable = new MapInteractiveElement(); interactiveTable.ElementId = (int)graphicalElement.Identifier; interactiveTable.MapId = map.Id; interactiveTable.CellId = (ushort)cell.Id; interactiveTable.GfxBonesId = ushort.Parse(entityElement.EntityLook.Replace("{", "").Replace("}", "")); interactiveTable.GfxId = -1; interactiveElements.Add(interactiveTable); } } } } } } }
public static EleGraphicalData readElement(Elements instance, BigEndianReader reader, int id) { EleGraphicalElementTypes type = (EleGraphicalElementTypes)reader.ReadByte(); EleGraphicalData result; switch (type) { case EleGraphicalElementTypes.NORMAL: result = NormalGraphicalElementData.ReadFromStream(instance, id, reader); break; case EleGraphicalElementTypes.BOUNDING_BOX: result = BoundingBoxGraphicalElementData.ReadFromStream(instance, id, reader); break; case EleGraphicalElementTypes.ANIMATED: result = AnimatedGraphicalElementData.ReadFromStream(instance, id, reader); break; case EleGraphicalElementTypes.ENTITY: result = EntityGraphicalElementData.ReadFromStream(instance, id, reader); break; case EleGraphicalElementTypes.PARTICLES: result = ParticlesGraphicalElementData.ReadFromStream(instance, id, reader); break; case EleGraphicalElementTypes.BLENDED: result = BlendedGraphicalElementData.ReadFromStream(instance, id, reader); break; default: throw new Exception("Unknown graphical data of type " + type); } return(result); }