-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00b3b62
commit 0036b5d
Showing
82 changed files
with
949 additions
and
458 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using Randomizer.Data.Options; | ||
using Randomizer.Data.Tracking; | ||
using Randomizer.Data.WorldData; | ||
using Randomizer.Data.WorldData.Regions; | ||
using Randomizer.Shared.Enums; | ||
|
||
namespace Randomizer.Abstractions; | ||
|
||
public abstract class GameModeBase | ||
{ | ||
public abstract GameModeType GameModeType { get; } | ||
|
||
public abstract string Name { get; } | ||
|
||
public abstract string Description { get; } | ||
|
||
public virtual void ModifyWorldConfig(Config config) | ||
{ | ||
Console.WriteLine($"Modify world config for{Name}"); | ||
} | ||
|
||
public virtual void ModifyWorldItemPools(WorldItemPools itemPool) | ||
{ | ||
Console.WriteLine($"Modify item pool for {Name}"); | ||
} | ||
|
||
public virtual void PreWorldGeneration() | ||
{ | ||
|
||
} | ||
|
||
public virtual ICollection<RomPatch> GetPatches(World world) | ||
{ | ||
return new List<RomPatch>(); | ||
} | ||
|
||
public virtual void ItemTracked(Item item, Location? location, TrackerBase? tracker) | ||
{ | ||
|
||
} | ||
|
||
public virtual void DungeonCleared(IDungeon dungeon, TrackerBase? tracker) | ||
{ | ||
|
||
} | ||
|
||
public virtual void BossDefeated(Boss boss, TrackerBase? tracker) | ||
{ | ||
|
||
} | ||
|
||
public virtual void ZeldaStateChanged(AutoTrackerZeldaState currentState, AutoTrackerZeldaState? previousState, TrackerBase? tracker) | ||
{ | ||
|
||
} | ||
|
||
public virtual void MetroidStateChanged(AutoTrackerMetroidState currentState, AutoTrackerMetroidState? previousState, TrackerBase? tracker) | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Randomizer.Data.Options; | ||
using Randomizer.Data.Tracking; | ||
using Randomizer.Data.WorldData; | ||
using Randomizer.Data.WorldData.Regions; | ||
|
||
namespace Randomizer.Abstractions; | ||
|
||
public interface IGameModeService | ||
{ | ||
public Dictionary<string, GameModeBase> GameModeTypes { get; } | ||
|
||
public void SetTracker(TrackerBase tracker, GameModeConfigs gameModeConfigs); | ||
|
||
public void ModifyConfig(Config config); | ||
|
||
public void ModifyWorldItemPools(World world); | ||
|
||
public IEnumerable<RomPatch> GetPatches(World world); | ||
|
||
public void ItemTracked(Item item, Location? location); | ||
|
||
public void DungeonCleared(IDungeon dungeon); | ||
|
||
public void BossDefeated(Boss boss); | ||
|
||
public void ZeldaStateChanged(AutoTrackerZeldaState currentState, AutoTrackerZeldaState? previousState); | ||
|
||
public void MetroidStateChanged(AutoTrackerMetroidState currentState, AutoTrackerMetroidState? previousState); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using System.Text; | ||
using Randomizer.SMZ3.FileData; | ||
using Randomizer.SMZ3.FileData.Patches; | ||
|
||
namespace Randomizer.Abstractions; | ||
|
||
/// <summary> | ||
/// Represents one or more changes that can be applied to a generated SMZ3 | ||
/// ROM. | ||
/// </summary> | ||
public abstract class RomPatch | ||
{ | ||
/// <summary> | ||
/// Returns the PC offset for the specified SNES address. | ||
/// </summary> | ||
/// <param name="addr">The SNES address to convert.</param> | ||
/// <returns> | ||
/// The PC offset equivalent to the SNES <paramref name="addr"/>. | ||
/// </returns> | ||
protected static int Snes(int addr) | ||
{ | ||
addr = addr switch | ||
{ | ||
/* Redirect hi bank $30 access into ExHiRom lo bank $40 */ | ||
_ when (addr & 0xFF8000) == 0x308000 => 0x400000 | (addr & 0x7FFF), | ||
/* General case, add ExHi offset for banks < $80, and collapse mirroring */ | ||
_ => (addr < 0x800000 ? 0x400000 : 0) | (addr & 0x3FFFFF), | ||
}; | ||
if (addr > 0x600000) | ||
throw new InvalidOperationException($"Unmapped pc address target ${addr:X}"); | ||
return addr; | ||
} | ||
|
||
/// <summary> | ||
/// Returns a byte array representing the specified 32-bit unsigned | ||
/// integer. | ||
/// </summary> | ||
/// <param name="value">The 32-bit unsigned integer.</param> | ||
/// <returns> | ||
/// A new byte array containing the 32-bit unsigned integer. | ||
/// </returns> | ||
protected static byte[] UintBytes(int value) => BitConverter.GetBytes((uint)value); | ||
|
||
/// <summary> | ||
/// Returns a byte array representing the specified 16-bit unsigned | ||
/// integer. | ||
/// </summary> | ||
/// <param name="value">The 16-bit unsigned integer.</param> | ||
/// <returns> | ||
/// A new byte array containing the 16-bit unsigned integer. | ||
/// </returns> | ||
protected static byte[] UshortBytes(int value) => BitConverter.GetBytes((ushort)value); | ||
|
||
/// <summary> | ||
/// Returns a byte array representing the specified ASCII-encoded text. | ||
/// </summary> | ||
/// <param name="text">The text.</param> | ||
/// <returns> | ||
/// A new byte array containing the ASCII representation of the | ||
/// <paramref name="text"/>. | ||
/// </returns> | ||
protected static byte[] AsAscii(string text) => Encoding.ASCII.GetBytes(text); | ||
|
||
/// <summary> | ||
/// Returns the changes to be applied to an SMZ3 ROM file. | ||
/// </summary> | ||
/// <param name="data">Patcher Data with the world and config information</param> | ||
/// <returns> | ||
/// A collection of changes, represented by the data to overwrite at the | ||
/// specified ROM offset. | ||
/// </returns> | ||
public abstract IEnumerable<GeneratedPatch> GetChanges(GetPatchesRequest data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using Randomizer.Shared.Enums; | ||
|
||
namespace Randomizer.Shared; | ||
|
||
[AttributeUsage(AttributeTargets.Property, | ||
Inherited = false, AllowMultiple = false)] | ||
public class GameModeTypeAttribute : Attribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see | ||
/// cref="GameModeTypeAttribute"/> class with the specified game mode type. | ||
/// </summary> | ||
/// <param name="gameModeType"> | ||
/// The game mode type applicable to the property | ||
/// </param> | ||
public GameModeTypeAttribute(GameModeType gameModeType) | ||
{ | ||
GameModeType = gameModeType; | ||
} | ||
|
||
/// <summary> | ||
/// The game mode of property | ||
/// </summary> | ||
public GameModeType GameModeType { get; } | ||
} |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.