Git Product home page Git Product logo

empyrionprime's Introduction

EmpyrionPrime

Empyrion Piggybacked Remote Independent Modification Environment is a utility to host Empyrion mods remotely using EPM which is bundled with the game server.

Dependency Injection Support

Plugins can access the following interfaces in their constructor.

Feature Plugin ModFramework
Event Handling IBasicEmpyrionApi.GameEvent
IExtendedEmpyrionApi.ChatMessage
IApiEvents
Event Requests IBasicEmpyrionApi.SendEvent
IExtendedEmpyrionApi.SendChatMessage
IApiRequests
IRequestBroker
Empyrion Configuration N/A IEmpyrionEnvironment
IEmpyrionServerConfig
IEmpyrionGameConfig
IEmpyrionAdminConfig
Plugin Configuration N/A IPluginOptionsFactory<TSettings>

Note: ModFramework can use everything in the Plugin section as well.

Projects

Launcher

Used to host mod outside of the game server. By default it will connect to the game server via EPM (the mod EAH uses to connect to the server).

Plugins should be assemblies with a class that implements

  • IEmpyrionPlugin (EmpyrionPrime.Plugin): preferred method due to more flexibility in plugin creation. This also supports dependency injection in the plugin's constructor.
    Plugins can also make use of EmpyrionPrime.ModFramework for more APIs and utilities.

  • ModInterface (Eleon.Modding): legacy Empyrion mod framework from Eleon, this is supported but not guaranteed to work with existing mods.

Plugin

Simple plugin interface as well as some Eleon mod API extensions and types.

Basic Plugin Example

For more examples see the ExamplePlugins folder

public class BasicPlugin : IEmpyrionPlugin
{
   public string Name => "Basic Plugin";
   public string Author => "NotOats";
   public Version Version => new(1, 0);

   public ModInterface ModInterface { get; }

   public BasicPlugin(ILogger logger, IBasicEmpyrionApi basicEmpyrionApi)
   {
       // Use a Eleon legacy style ModInterface
       ModInterface = new ExampleModInterface();

       // Or use the Plugin API interfaces
       basicEmpyrionApi.GameEvent += (eventId, seqNum, data) =>
       {
           logger.LogDebug("GameEvent(id: {EventId}, Seq: {SequenceNumber}, Data: {DataType})",
               eventId, seqNum, data?.GetType());

           // Do something
       };
   }
}

ModFramework

Framework for working with Plugins.

Framework Plugin Example

For more examples see the FrameworkPlugins project in ExamplePlugins.

public class BasicFrameworkExample : IEmpyrionPlugin
{
    public string Name => "Basic Framework Example";
    public string Author => "NotOats";
    public Version Version => new("1.0");
    public ModInterface? ModInterface => null;

    public BasicFrameworkExample(ILogger logger, IApiEvents apiEvents, IApiRequests apiRequests)
    {
        apiEvents.PlayerConnected += async id =>
        {
            // Welcome the player
            var player = await apiRequests.PlayerInfo(id);
            
            await apiRequests.InGameMessageSinglePlayer(new IdMsgPrio
            {
                id = player.entityId,
                msg = $"Welcome {player.playerName}",
                prio = (byte)MessagePriority.Alert,
                time = 10
            });

            // Log the player and playfield
            var playfield = await apiRequests.PlayfieldStats(player.playfield.ToPString());

            logger.LogInformation("{Player} connected to {Playfield} (pid: {ProcessId}, uptime: {Uptime})",
                player.playerName, playfield.playfield, playfield.processId, playfield.uptime);
        };
    }
}

empyrionprime's People

Contributors

notoats avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.