public static void PlotColiObj(ColiObject c, GameObject parent, string labelStart = "") { switch (c.ShapeId) { case 1: { var coli = (ColiType1)c; PlotAsQuads(coli.Coordinates, Color.blue, $"{labelStart} 01", parent); break; } case 2: { var coli = (ColiType2)c; PlotAsQuads(coli.Coordinates, Color.red, $"{labelStart} 02", parent); break; } case 3: { var coli = (ColiType3)c; var name = BitConverter.ToString(BitConverter.GetBytes(coli.Data[0])); PlotAsPoint(coli.Coordinate, Color.cyan, $"{labelStart} 03 {name}", parent); break; } case 5: { var coli = (ColiType5)c; var name = BitConverter.ToString(BitConverter.GetBytes(coli.Data[0])); PlotAsPoint(coli.Coordinate, Color.yellow, $"{labelStart} 05 {name}", parent); break; } } }
public void ReadColiObjects(Coli coli) { this.BaseStream.Seek(coli.ContentOffset, SeekOrigin.Begin); while (this.BaseStream.Position < (coli.ContentOffset + coli.Size)) { ColiObject newColiObj; uint coliLayer = this.ReadUInt32(); uint coliShape = this.ReadUInt32(); switch (coliShape) { case 0x01: newColiObj = new ColiType1(coliLayer, this); break; case 0x02: newColiObj = new ColiType2(coliLayer, this); break; case 0x03: newColiObj = new ColiType3(coliLayer, this); break; case 0x05: newColiObj = new ColiType5(coliLayer, this); break; default: newColiObj = new ColiObject(coliLayer, coliShape); break; } coli.ColiDatas.Add(newColiObj); // skip the terminator this.BaseStream.Seek(4, SeekOrigin.Current); } }
public void ReadColiObjsNew(Stream s) { using (BinaryReader r = new BinaryReader(s)) { while (r.BaseStream.Position < this.ContentOffset + this.Size) { ColiObject coli; uint coliLayer = r.ReadUInt32(); uint coliShape = r.ReadUInt32(); // Console.WriteLine($"Creating coli with layer {coliLayer.ToString("X2")} shape: {coliShape.ToString("X2")}"); switch (coliShape) { case 0x01: coli = new ColiType1(coliLayer, r); break; case 0x02: coli = new ColiType2(coliLayer, r); break; case 0x03: coli = new ColiType3(coliLayer, r); break; case 0x05: coli = new ColiType5(coliLayer, r); break; default: coli = new ColiObject(coliLayer, coliShape); break; //throw new Exception($"Got an unexpected coli type: 0x{coliShape.ToString("X2")}"); } this.ColiDatas.Add(coli); // skip the terminator r.BaseStream.Seek(4, SeekOrigin.Current); } } }