~ruther/NosSmooth

ref: 2d0fe0a749c4e7587d3e06cb59759707f34e499e NosSmooth/Samples/ExternalBrowser/Program.cs -rw-r--r-- 1.8 KiB
2d0fe0a7 — František Boháček feat(localbinding): split obtaining objects from hooking completely 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//
//  Program.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 System.Diagnostics;
using NosSmooth.LocalBinding;
using NosSmooth.LocalBinding.Options;

namespace ExternalBrowser;

/// <summary>
/// The entrypoint class for ExternalBrowser.
/// </summary>
public class Program
{
    /// <summary>
    /// The entrypoint method for ExternalBrowser.
    /// </summary>
    /// <param name="arguments">The arguments.</param>
    public static void Main(string[] arguments)
    {
        var playerManagerOptions = new CharacterBindingOptions();
        var sceneManagerOptions = new SceneManagerBindingOptions();

        foreach (var argument in arguments)
        {
            Process[] processes;

            if (int.TryParse(argument, out var processId))
            {
                processes = new Process[] { Process.GetProcessById(processId) };
            }
            else
            {
                processes = Process
                    .GetProcesses()
                    .Where(x => x.ProcessName.Contains(argument))
                    .ToArray();
            }

            foreach (var process in processes)
            {
                var externalBrowser = new ExternalNosBrowser(process, playerManagerOptions, sceneManagerOptions);
                var playerManager = externalBrowser.GetPlayerManager();
                if (!playerManager.IsSuccess)
                {
                    Console.Error.WriteLine($"Could not get the player manager: {playerManager.Error.Message}");
                    continue;
                }

                Console.WriteLine($"Player in process {process.Id} is named {playerManager.Entity.Player.Name}");
            }
        }
    }
}
Do not follow this link