Skip to content

Conversion of the slippi-js SDK to C# targeting .NET

Notifications You must be signed in to change notification settings

asundheim/Slippi.NET

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NuGet version (Slippi.NET)

Slippi.NET

This project is a port of slippi-js to modern .NET while maintaining more or less the same API surface.

Internally an attempt is made to use stack-allocated System.Span<byte> wherever possible, which significantly improves performance over GC-allocated byte[].

Download

This package is available on nuget.org and can be referenced by simply adding a <PackageReference> to your project like:

<ItemGroup>
    <PackageReference Include="Slippi.NET" Version="0.1.0" />
</ItemGroup>

Usage

Just as in slippi-js, the main entrypoint is SlippiGame, taking either a filepath or a byte buffer.

SlippiGame game = new SlippiGame('./game.slp');
// do things with game

Utils

Utility functions are scattered, to name a few:

Slippi.NET.Melee

namespace Slippi.NET.Melee;

static class StageUtils
{
    static StageInfo GetStageInfo(int stageId);
    // etc.
}

static class MoveUtils
{
    static Move GetMoveInfo(int moveId);
    // etc.
}

static class CharacterUtils
{
    static CharacterInfo GetCharacterInfo(int characterId);
    static List<CharacterInfo> GetAllCharacters();
    // etc.
}

Slippi.NET.Stats

namespace Slipp.NET.Stats;

static class ActionUtils
{
    static bool IsMissGroundTech(State animation);
    // etc.
}

static class InputUtils
{
    static JoystickRegion GetJoystickRegion(float x, float y);
    // etc.
}

Slippi.NET.Utils

namespace Slippi.NET.Utils;

static class WinnerCalculator
{
    static IList<Placement> GetWinners(
        GameEnd gameEnd,
        GameStart settings,
        IList<PostFrameUpdate> finalPostFrameUpdates);
}

Connection

ConsoleConnection is implemented but currently untested.

Using DolphinConnection is very straightforward, create a new DolphinConnection and call Connect with an IP address and port. You can listen to the events defined on the base Connection class for updates and information on the Dolphin instance.

If Dolphin is local, you can use 127.0.0.1. The Ports enumeration provides common values for ports, with Default (51441) being the standard one that Dolphin uses.

You can find an example in src/DolphinConnectionTestApp/.

Development

Restore and build Slippi.NET.sln from the root of the project.

Currently all projects target .NET 9 to make use of the latest Span improvements to the standard library.

Tests

The Slippi.NET.Tests contains all unit tests for the project. All tests have been ported from slippi-js.

About

Conversion of the slippi-js SDK to C# targeting .NET

Resources

Stars

Watchers

Forks

Packages

No packages published