Table of Contents

Interface IUpdateable

Namespace
Anvil.Services
Assembly
NWN.Anvil.dll

Implement this interface in your service to get a callback each server loop.

public interface IUpdateable
Extension Methods

Examples

/*
 * Report the current tick rate every server loop.
 */

using Anvil.API;
using Anvil.Services;
using NLog;

namespace NWN.Anvil.Samples.Services
{
  [ServiceBinding(typeof(IUpdateable))]
  [ServiceBinding(typeof(PerformanceReportService))]
  public class PerformanceReportService : IUpdateable
  {
    // Gets the server log. By default, this reports to "anvil.log"
    private static readonly Logger Log = LogManager.GetCurrentClassLogger();

    public void Update()
    {
      Log.Info($"Current tick rate: {1 / Time.DeltaTime.TotalSeconds}");
    }
  }
}

Methods

Update()

Called once every main loop frame. You may safely use any of the NWN API in this callback, but it is recommended to keep the processing in this function to a minimum, as it may have adverse effect on server performance.