protected LevelArea(byte AreaID, byte LevelID, bool AddWarps, bool AddObjects) { Geolayout = new Geolayout.Geolayout(SM64Lib.Geolayout.Geolayout.NewScriptCreationMode.Level); this.AreaID = AreaID; { var withBlock = Levelscript; withBlock.Add(new LevelscriptCommand(new byte[] { 0x1F, 0x8, AreaID, 0x0, 0x0, 0x0, 0x0, 0x0 })); withBlock.Add(new LevelscriptCommand(new byte[] { 0x2E, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 })); withBlock.Add(new LevelscriptCommand(new byte[] { 0x36, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 })); withBlock.Add(new LevelscriptCommand(new byte[] { 0x31, 0x4, 0x0, 0x2 })); withBlock.Add(new LevelscriptCommand(new byte[] { 0x20, 0x4, 0x0, 0x0 })); } if (AddWarps) { Objects.Add(new LevelscriptCommand(new byte[] { 0x24, 0x18, 0x1F, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xA, 0x0, 0x0, 0x13, 0x0, 0x2F, 0x74 })); Warps.Add(new LevelscriptCommand(new byte[] { 0x26, 0x8, 0xA, LevelID, AreaID, 0x0, 0x0, 0x0 })); WarpsForGame.Add(new LevelscriptCommand(new byte[] { 0x26, 0x8, 0xF0, 0x6, 0x1, 0x32, 0x0, 0x0 })); WarpsForGame.Add(new LevelscriptCommand(new byte[] { 0x26, 0x8, 0xF1, 0x6, 0x1, 0x64, 0x0, 0x0 })); } if (AddObjects) { for (int i = 1; i <= 15; i++) { var newObj = new LevelscriptCommand(DefaultNormal3DObject); Objects.Add(newObj); } } }
public void ParseOverworld(BinaryReader b) { uint fileSize = b.ReadUInt32(); if (fileSize < 0x4) { b.Close(); throw new Exception("Invalid overworld container."); } byte interactableCount = b.ReadByte(); byte npcCount = b.ReadByte(); byte warpCount = b.ReadByte(); byte triggerCount = b.ReadByte(); for (int i = 0; i < interactableCount; ++i) { Interactables.Add(new Interactable(b)); } for (int i = 0; i < npcCount; ++i) { NPCs.Add(new NPC(b)); } for (int i = 0; i < warpCount; ++i) { Warps.Add(new Warp(b)); } for (int i = 0; i < triggerCount; ++i) { Triggers.Add(new Trigger(b)); } while (b.PeekChar() != 0) { LevelScripts.Add(new LevelScriptDeclaration(b)); } b.BaseStream.Position += 0x2; int index = 0; while (b.PeekChar() != 0 && b.PeekChar() != -1 && index < LevelScripts.Count) { LevelScripts[index++].Data = new LevelScriptData(b); } }
internal override Event ReadEntry(BinaryReaderEx br) { EventType type = br.GetEnum16 <EventType>(br.Position + 0xC); switch (type) { case EventType.Light: var light = new Event.Light(br); Lights.Add(light); return(light); case EventType.Shadow: var shadow = new Event.Shadow(br); Shadows.Add(shadow); return(shadow); case EventType.Fog: var fog = new Event.Fog(br); Fogs.Add(fog); return(fog); case EventType.BGColor: var bgColor = new Event.BGColor(br); BGColors.Add(bgColor); return(bgColor); case EventType.MapOffset: var mapOffset = new Event.MapOffset(br); MapOffsets.Add(mapOffset); return(mapOffset); case EventType.Warp: var warp = new Event.Warp(br); Warps.Add(warp); return(warp); case EventType.CheapMode: var cheapMode = new Event.CheapMode(br); CheapModes.Add(cheapMode); return(cheapMode); default: throw new NotImplementedException($"Unimplemented event type: {type}"); } }
public void Add(IMsbEvent item) { switch (item) { case Event.Light e: Lights.Add(e); break; case Event.Shadow e: Shadows.Add(e); break; case Event.Fog e: Fogs.Add(e); break; case Event.BGColor e: BGColors.Add(e); break; case Event.MapOffset e: MapOffsets.Add(e); break; case Event.Warp e: Warps.Add(e); break; case Event.CheapMode e: CheapModes.Add(e); break; default: throw new ArgumentException( message: "Item is not recognized", paramName: nameof(item)); } }
/// <summary> /// Adds an event to the appropriate list for its type; returns the event. /// </summary> public Event Add(Event evnt) { switch (evnt) { case Event.Light e: Lights.Add(e); break; case Event.Shadow e: Shadows.Add(e); break; case Event.Fog e: Fogs.Add(e); break; case Event.BGColor e: BGColors.Add(e); break; case Event.MapOffset e: MapOffsets.Add(e); break; case Event.Warp e: Warps.Add(e); break; case Event.CheapMode e: CheapModes.Add(e); break; default: throw new ArgumentException($"Unrecognized type {evnt.GetType()}.", nameof(evnt)); } return(evnt); }