// // ServiceCollectionExtensions.cs // // Copyright (c) František Boháček. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using Microsoft.Extensions.DependencyInjection; using NosSmooth.LocalBinding.Hooks; using NosSmooth.LocalBinding.Hooks.Implementations; using NosSmooth.LocalBinding.Objects; using NosSmooth.LocalBinding.Options; using NosSmooth.LocalBinding.Structs; namespace NosSmooth.LocalBinding.Extensions; /// /// Contains extension methods for . /// public static class ServiceCollectionExtensions { /// /// Adds bindings to Nostale objects along with to initialize those. /// /// /// This adds , , /// and their siblings. /// You have to initialize the bindings using /// prior to requesting them from the provider, otherwise an exception /// will be thrown. /// /// The service collection. /// The collection. public static IServiceCollection AddNostaleBindings(this IServiceCollection serviceCollection) { return serviceCollection .AddSingleton() .AddSingleton() .AddSingleton() .AddSingleton() .AddSingleton(p => p.GetRequiredService().PacketReceive) .AddSingleton(p => p.GetRequiredService().PacketSend) .AddSingleton(p => p.GetRequiredService().EntityFollow) .AddSingleton(p => p.GetRequiredService().EntityUnfollow) .AddSingleton(p => p.GetRequiredService().EntityFocus) .AddSingleton(p => p.GetRequiredService().PlayerWalk) .AddSingleton(p => p.GetRequiredService().PetWalk) .AddSingleton(p => p.GetRequiredService().Periodic) .AddSingleton(p => p.GetRequiredService().PacketReceive.Get()) .AddSingleton(p => p.GetRequiredService().PacketSend.Get()) .AddSingleton(p => p.GetRequiredService().EntityFollow.Get()) .AddSingleton(p => p.GetRequiredService().EntityUnfollow.Get()) .AddSingleton(p => p.GetRequiredService().EntityFocus.Get()) .AddSingleton(p => p.GetRequiredService().PlayerWalk.Get()) .AddSingleton(p => p.GetRequiredService().PetWalk.Get()) .AddSingleton(p => p.GetRequiredService().Periodic.Get()) .AddSingleton(p => p.GetRequiredService().PlayerManager) .AddSingleton(p => p.GetRequiredService().SceneManager) .AddSingleton(p => p.GetRequiredService().PetManagerList) .AddSingleton(p => p.GetRequiredService().SceneManager) .AddSingleton(p => p.GetRequiredService().PetManagerList) .AddSingleton(p => p.GetRequiredService().PlayerManager) .AddSingleton(p => p.GetRequiredService().NetworkManager) .AddSingleton(p => p.GetRequiredService().UnitManager) .AddSingleton(p => p.GetRequiredService().NtClient) .AddSingleton(p => p.GetRequiredService().PacketReceive) .AddSingleton(p => p.GetRequiredService().PacketSend) .AddSingleton(p => p.GetRequiredService().PlayerWalk) .AddSingleton(p => p.GetRequiredService().PetWalk) .AddSingleton(p => p.GetRequiredService().EntityFocus) .AddSingleton(p => p.GetRequiredService().EntityFollow) .AddSingleton(p => p.GetRequiredService().EntityUnfollow) .AddSingleton(p => p.GetRequiredService().Periodic) .AddSingleton(p => p.GetRequiredService().PlayerManager.Get()) .AddSingleton(p => p.GetRequiredService().SceneManager.Get()) .AddSingleton(p => p.GetRequiredService().PetManagerList.Get()) .AddSingleton(p => p.GetRequiredService().SceneManager.Get()) .AddSingleton(p => p.GetRequiredService().PetManagerList.Get()) .AddSingleton(p => p.GetRequiredService().PlayerManager.Get()) .AddSingleton(p => p.GetRequiredService().NetworkManager.Get()) .AddSingleton(p => p.GetRequiredService().UnitManager.Get()) .AddSingleton(p => p.GetRequiredService().NtClient.Get()) .AddSingleton(p => p.GetRequiredService().PacketReceive.Get()) .AddSingleton(p => p.GetRequiredService().PacketSend.Get()) .AddSingleton(p => p.GetRequiredService().PlayerWalk.Get()) .AddSingleton(p => p.GetRequiredService().PetWalk.Get()) .AddSingleton(p => p.GetRequiredService().EntityFocus.Get()) .AddSingleton(p => p.GetRequiredService().EntityFollow.Get()) .AddSingleton(p => p.GetRequiredService().EntityUnfollow.Get()) .AddSingleton(p => p.GetRequiredService().Periodic.Get()); } /// /// Configures what functions to hook and allows the user to make pattern, offset changes. /// /// The service collection. /// Function for configuring the hook config. /// The collection. public static IServiceCollection ConfigureHooks(this IServiceCollection serviceCollection, Action configure) { var builder = new HooksConfigBuilder(new HookManagerOptions()); configure(builder); builder.Apply(serviceCollection); return serviceCollection; } }