internal override Event ReadEntry(BinaryReaderEx br) { EventType type = br.GetEnum8 <EventType>(br.Position + br.VarintSize + 4); switch (type) { case EventType.Light: return(Lights.EchoAdd(new Event.Light(br))); case EventType.Shadow: return(Shadows.EchoAdd(new Event.Shadow(br))); case EventType.Fog: return(Fogs.EchoAdd(new Event.Fog(br))); case EventType.BGColor: return(BGColors.EchoAdd(new Event.BGColor(br))); case EventType.MapOffset: return(MapOffsets.EchoAdd(new Event.MapOffset(br))); case EventType.Warp: return(Warps.EchoAdd(new Event.Warp(br))); case EventType.CheapMode: return(CheapModes.EchoAdd(new Event.CheapMode(br))); default: throw new NotImplementedException($"Unimplemented event type: {type}"); } }
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); } } }
IEnumerator DoFade() { Warps warpScript = new Warps(); warpScript.FadeIn(); yield return(new WaitForSeconds(0.5f)); warpScript.FadeOut(); narrative.SetActive(false); }
public GuideEditor(Warps.Trackers.GuideCombTracker tracker) { InitializeComponent(); //InitializeNsPlot(); //Comb = comb; InitializeGrid(); if (tracker != null) { m_nsPlot.MouseDown += tracker.OnDown; m_nsPlot.MouseMove += tracker.OnMove; m_nsPlot.MouseUp += tracker.OnUp; } //InitializePlotterComponents(); }
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); }
public void Serialize(string path) { BinaryWriter Binary = new BinaryWriter(File.Open(path, FileMode.OpenOrCreate)); Binary.Write((uint)(Interactable.Size * Interactables.Count + NPC.Size * NPCs.Count + Warp.Size * Warps.Count + Trigger.Size * Triggers.Count + 0x4)); Binary.Write((byte)Interactables.Count); Binary.Write((byte)NPCs.Count); Binary.Write((byte)Warps.Count); Binary.Write((byte)Triggers.Count); // Because BinaryFormatter is "unsafe"... Interactables.ForEach(x => { Binary.Write(x.Script); Binary.Write(x.Condition); Binary.Write(x.Interactibility); Binary.Write(x.RailIndex); Binary.Write(x.X); Binary.Write(x.Y); Binary.Write(x.Z * 0x10); }); NPCs.ForEach(x => { Binary.Write(x.ID); Binary.Write(x.ModelID); Binary.Write(x.MovementPermission); Binary.Write(x.Type); Binary.Write(x.SpawnFlag); Binary.Write(x.ScriptID); Binary.Write(x.FaceDirection); Binary.Write(x.SightRange); Binary.Write(x.Unknown); Binary.Write(x.Unknown2); Binary.Write(x.TraversalWidth); Binary.Write(x.TraversalHeight); Binary.Write(x.StartingX); Binary.Write(x.StartingY); Binary.Write(x.X); Binary.Write(x.Y); Binary.Write(x.Unknown3); Binary.Write(x.Z); }); Warps.ForEach(x => { Binary.Write(x.TargetZone); Binary.Write(x.TargetWarp); Binary.Write(x.ContactDirection); Binary.Write(x.TransitionType); Binary.Write(x.CoordinateType); Binary.Write(x.X); Binary.Write(x.Z); Binary.Write(x.Y); Binary.Write(x.W); Binary.Write(x.H); Binary.Write(x.Rail); }); Triggers.ForEach(x => { Binary.Write(x.Script); Binary.Write(x.ValueNeededForExecution); Binary.Write(x.Variable); Binary.Write(x.Unknown); Binary.Write(x.Unknown2); Binary.Write(x.X); Binary.Write(x.Y); Binary.Write(x.Z); Binary.Write(x.W); Binary.Write(x.H); Binary.Write(x.Unknown3); }); int SectionOffset = 0; LevelScripts.ForEach(x => { Binary.Write(x.Unknown); Binary.Write(x.Unknown2); Binary.Write(x.Unknown3); SectionOffset += 0x6; }); while (SectionOffset % 4 != 0) { Binary.Write((ushort)0x0); SectionOffset += 0x2; } LevelScripts.ForEach(x => { if (x.Data != null) { Binary.Write(x.Data.Unknown); Binary.Write(x.Data.Unknown2); Binary.Write(x.Data.Unknown3); SectionOffset += 0x6; } }); while (SectionOffset % 4 != 0) { Binary.Write((ushort)0x0); SectionOffset += 0x2; } Binary.Close(); }
private GameMapData LoadCollisionDataDungeon(int map, bool magnifyGlass) { GameMapData mapData = new GameMapData(); mapData.map = map; mapData.specialFlag = magnifyGlass; //Sets the buffer address LAGame.gbROM.BufferLocation = getCollisionDataDungeonOffset(mapData); mapData.animation = LAGame.gbROM.ReadByte(); mapData.tilePreset = LAGame.gbROM.ReadByte(); byte b; while ((b = LAGame.gbROM.ReadByte()) != 0xFE) //0xFE = End of room { //There is free space for room 0xFF (dungeon >=6) but there is no room ending byte if (LAGame.dungeon == 0xFF && LAGame.gbROM.BufferLocation >= 0x2BF43) { break; } else if ((LAGame.dungeon >= 6 && LAGame.dungeon < 0x1A) && LAGame.gbROM.BufferLocation >= 0x2FFFF && LAGame.dungeon != 0xFF) { break; } else if ((LAGame.dungeon < 6 || LAGame.dungeon >= 0x1A) && LAGame.gbROM.BufferLocation >= 0x2BB77 && LAGame.dungeon != 0xFF) { break; } //Check to see if we are reading empty space /*if (b == 0) * { * //We need a 00 00 00 pair for it to be empty space. Otherwise it could just be an object in XY position 0. * byte x = LAGame.gbROM.ReadByte(); * if (x == 0) * { * x = LAGame.gbROM.ReadByte(); * if (x == 0 && x != 0xFE) * { * LAGame.gbROM.BufferLocation--; * continue; * } * if (x == 0xFE) * break; * else * LAGame.gbROM.BufferLocation -= 2; * } * }*/ if (b >> 4 == 0xE) { if (LAGame.dungeon == 0xFF && LAGame.gbROM.BufferLocation + 4 >= 0x2BF43) { break; } else if ((LAGame.dungeon >= 6 && LAGame.dungeon < 0x1A) && LAGame.gbROM.BufferLocation + 4 >= 0x2FFFF && LAGame.dungeon != 0xFF) { break; } else if ((LAGame.dungeon < 6 || LAGame.dungeon >= 0x1A) && LAGame.gbROM.BufferLocation + 4 >= 0x2BB77 && LAGame.dungeon != 0xFF) { break; } Warps w = new Warps(); w.type = (byte)(b & 0x0F); w.region = LAGame.gbROM.ReadByte(); w.map = LAGame.gbROM.ReadByte(); w.x = LAGame.gbROM.ReadByte(); w.y = LAGame.gbROM.ReadByte(); mapData.warpObjects.Add(w); continue; } if (b >> 4 == 8 || b >> 4 == 0xC) //3-Byte objects { if (LAGame.dungeon == 0xFF && LAGame.gbROM.BufferLocation + 2 >= 0x2BF43) { break; } else if ((LAGame.dungeon >= 6 && LAGame.dungeon < 0x1A) && LAGame.gbROM.BufferLocation + 2 >= 0x2FFFF && LAGame.dungeon != 0xFF) { break; } else if ((LAGame.dungeon < 6 || LAGame.dungeon >= 0x1A) && LAGame.gbROM.BufferLocation + 2 >= 0x2BB77 && LAGame.dungeon != 0xFF) { break; } CollisionObject o = new CollisionObject(); o.is3Byte = true; o.length = (byte)(b & 0xF); o.direction = (byte)(b >> 4); byte b2 = LAGame.gbROM.ReadByte(); o.yPos = (byte)(b2 >> 4); o.xPos = (byte)(b2 & 0xF); o.id = LAGame.gbROM.ReadByte(); if (o.id >= 0xEC && o.id <= 0xFD)// Door tiles { int bufferloc = LAGame.gbROM.BufferLocation; o.dungeonDoors(LAGame, o); LAGame.gbROM.BufferLocation = bufferloc; foreach (CollisionObject obj in o.objectIDs) { mapData.collisionObjects.Add(obj); } } else { mapData.collisionObjects.Add(o); } continue; } else { if (LAGame.dungeon == 0xFF && LAGame.gbROM.BufferLocation + 1 >= 0x2BF43) { break; } else if ((LAGame.dungeon >= 6 && LAGame.dungeon < 0x1A) && LAGame.gbROM.BufferLocation + 1 >= 0x2FFFF && LAGame.dungeon != 0xFF) { break; } else if ((LAGame.dungeon < 6 || LAGame.dungeon >= 0x1A) && LAGame.gbROM.BufferLocation + 1 >= 0x2BB77 && LAGame.dungeon != 0xFF) { break; } CollisionObject ob = new CollisionObject(); // 2-Byte tiles ob.yPos = (byte)(b >> 4); ob.xPos = (byte)(b & 0xF); ob.id = LAGame.gbROM.ReadByte(); if (ob.id >= 0xEC && ob.id <= 0xFD)// Door tiles { int bufferloc = LAGame.gbROM.BufferLocation; ob.dungeonDoors(LAGame, ob); LAGame.gbROM.BufferLocation = bufferloc; foreach (CollisionObject obj in ob.objectIDs) { mapData.collisionObjects.Add(obj); } } else { mapData.collisionObjects.Add(ob); } } } return(mapData); }
private GameMapData LoadCollisionDataOverworld(int map, bool specialFlag) { CollisionObject overworldObjects = new CollisionObject(); GameMapData mapData = new GameMapData(); mapData.map = map; mapData.specialFlag = specialFlag; //Sets the buffer address LAGame.gbROM.BufferLocation = getCollisionDataOverworldOffset(mapData); mapData.animation = LAGame.gbROM.ReadByte(); mapData.tilePreset = LAGame.gbROM.ReadByte(); byte b; while ((b = LAGame.gbROM.ReadByte()) != 0xFE) //0xFE = End of room { if (map < 0x80 && LAGame.gbROM.BufferLocation >= 0x2668D) { break; } if (map > 0x7F && LAGame.gbROM.BufferLocation >= 0x69E75) { break; } //Check to see if we are reading empty space if (b == 0) { //We need a 00 00 pair for it to be empty space. Otherwise it could just be an object in XY position 0. byte x = LAGame.gbROM.ReadByte(); if (x == 0) { continue; } else { LAGame.gbROM.BufferLocation--; } } if (b >> 4 == 0xE) { if (map < 0x80 && LAGame.gbROM.BufferLocation + 4 > 0x2668D) { continue; } if (map > 0x7F && LAGame.gbROM.BufferLocation + 4 > 0x69E75) { continue; } Warps w = new Warps(); w.type = (byte)(b & 0x0F); w.region = LAGame.gbROM.ReadByte(); w.map = LAGame.gbROM.ReadByte(); w.x = LAGame.gbROM.ReadByte(); w.y = LAGame.gbROM.ReadByte(); mapData.warpObjects.Add(w); continue; } if (b >> 4 == 8 || b >> 4 == 0xC) //3-Byte objects { if (map < 0x80 && LAGame.gbROM.BufferLocation + 2 > 0x2668D) { continue; } if (map > 0x7F && LAGame.gbROM.BufferLocation + 2 > 0x69E75) { continue; } CollisionObject o = new CollisionObject(); o.is3Byte = true; o.length = (byte)(b & 0xF); o.direction = (byte)(b >> 4); byte b2 = LAGame.gbROM.ReadByte(); o.yPos = (byte)(b2 >> 4); o.xPos = (byte)(b2 & 0xF); o.id = LAGame.gbROM.ReadByte(); overworldObjects.getOverworldObjs(o); //mapData.collisionObjects.Add(o); continue; } else { if (map < 0x80 && LAGame.gbROM.BufferLocation + 1 > 0x2668D) { continue; } if (map > 0x7F && LAGame.gbROM.BufferLocation + 1 > 0x69E75) { continue; } CollisionObject o = new CollisionObject(); // 2-Byte objects o.yPos = (byte)(b >> 4); o.xPos = (byte)(b & 0xF); o.id = LAGame.gbROM.ReadByte(); overworldObjects.getOverworldObjs(o); //mapData.collisionObjects.Add(o); continue; } } foreach (CollisionObject obj in overworldObjects.objectIDs) { mapData.collisionObjects.Add(obj); } return(mapData); }
public Warps.Controls.VariableEditor WriteEditor(Warps.Controls.VariableEditor edit) { if (edit == null) edit = new Warps.Controls.VariableEditor(Label, EquationText); Warps.Controls.VariableEditor ee = edit as Warps.Controls.VariableEditor; if (ee == null) ee = new Warps.Controls.VariableEditor(Label, EquationText); //ee.sail = sail; //if(sail!=null) // ee.AutoFillData = sail.GetAutoFillData(this).ToArray(); ee.Tag = GetType(); //ee.Label = GetType().Name; return edit; }
public void ReadEditor(Warps.Controls.VariableEditor edit) { if (edit == null) throw new ArgumentException("Invalid Editor in CurvePoint"); Label = edit.Label; EquationText = edit.EquationText; Evaluate(edit.sail); }