Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Intersect.Client.General;
- using Intersect.Client.Plugins;
- using Intersect.Client.Plugins.Interfaces;
- using Intersect.Plugins;
- /// <summary>
- /// **Make sure to change this namespace to match yours!**
- /// </summary>
- namespace Client.Plugins
- {
- /// <summary>
- /// Client plugin entry class template.
- /// Change the class name to match yours or just copy the contents.
- /// </summary>
- public class ClientPluginEntryTemplate : ClientPluginEntry
- {
- /// <summary>
- /// Called during application bootstrap, before OnStart is called.
- /// <para></para>Useful for registering custom packets and handlers using context.Network,
- /// and initializing command line options using context.CommandLine.
- /// </summary>
- /// <param name="context"></param>The current plugin context for the client.
- public override void OnBootstrap(IPluginBootstrapContext context)
- {
- RegisterPackets(context);
- RegisterPacketHandlers(context);
- }
- /// <summary>
- /// Registers custom packets.
- /// </summary>
- /// <param name="context"></param>
- private void RegisterPackets(IPluginBootstrapContext context)
- {
- // Example packet registration
- //if (!context.Packet.TryRegisterPacketType<YourServerPacket>())
- //{
- // context.Logging.Plugin.Error($"Failed to register {nameof(YourServerPacket)} packet.");
- // Environment.Exit(-3);
- //}
- }
- /// <summary>
- /// Registers packet handlers for custom packets.
- /// </summary>
- /// <param name="context"></param>
- private void RegisterPacketHandlers(IPluginBootstrapContext context)
- {
- // Example packet handler registration
- //if (!context.Packet.TryRegisterPacketHandler<YourServerPacketHandler, YourServerPacket>(out _))
- //{
- // context.Logging.Plugin.Error($"Failed to register {nameof(YourServerPacketHandler)} packet handler.");
- // Environment.Exit(-4);
- //}
- }
- /// <summary>
- /// Invoked on application start after bootstrapping and other basic initialization.
- /// <para></para>Useful for subscribing to lifecycle events using context.Lifecycle,
- /// and loading assets using context.ContentManager.
- /// </summary>
- /// <param name="context"></param>
- public override void OnStart(IClientPluginContext context)
- {
- // Subscribe to lifecycle event callbacks
- context.Lifecycle.LifecycleChangeState += Lifecycle_LifecycleChangeState;
- context.Lifecycle.GameUpdate += Lifecycle_GameUpdate;
- }
- /// <summary>
- /// Invoked once when the client lifecycle changes state.
- /// </summary>
- /// <param name="context"></param>The client plugin context.
- /// <param name="lifecycleChangeStateArgs"></param>The args invoked when GameState changes. Includes the new GameState.
- private void Lifecycle_LifecycleChangeState(IClientPluginContext context,
- LifecycleChangeStateArgs lifecycleChangeStateArgs)
- {
- switch (lifecycleChangeStateArgs.State)
- {
- // Called when the intro images begin playing.
- case GameStates.Intro:
- break;
- // Called when the main menu is loaded.
- case GameStates.Menu:
- break;
- // Called when logging in and the main menu transitions to the game.
- case GameStates.Loading:
- break;
- // Called when the game is done loading.
- case GameStates.InGame:
- break;
- // Internal use.
- case GameStates.Error:
- break;
- default:
- break;
- }
- }
- /// <summary>
- /// Invoked once per frame during the given GameState.
- /// Useful for things that require immediate updates such as capturing inputs.
- /// </summary>
- /// <param name="context"></param>
- /// <param name="gameUpdateArgs"></param>
- private void Lifecycle_GameUpdate(IClientPluginContext context,
- GameUpdateArgs gameUpdateArgs)
- {
- switch (gameUpdateArgs.State)
- {
- // Called when the intro images are playing.
- case GameStates.Intro:
- break;
- // Called while in the main menu.
- case GameStates.Menu:
- break;
- // Called while logging in, while the main menu transitions to the game.
- case GameStates.Loading:
- break;
- // Called while in game.
- case GameStates.InGame:
- break;
- // Internal use.
- case GameStates.Error:
- break;
- default:
- break;
- }
- }
- /// <summary>
- /// Invoked when the application is shutting down.
- /// <para></para>
- /// Useful for cleaning up and saving data.
- /// </summary>
- /// <param name="context"></param>
- public override void OnStop(IClientPluginContext context)
- {
- // Unsubscribe from event callbacks when app stops.
- context.Lifecycle.LifecycleChangeState -= Lifecycle_LifecycleChangeState;
- context.Lifecycle.GameUpdate -= Lifecycle_GameUpdate;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment