Skip to content

Commit 4364f07

Browse files
Adding support deploying managed applications
1 parent 5eb2b21 commit 4364f07

17 files changed

Lines changed: 470 additions & 109 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+

2+
using AtomicEngine;
3+
4+
public class Program
5+
{
6+
public static void Main(string[] args)
7+
{
8+
// Create the Application
9+
var app = NETIPCPlayerApp.Create(args);
10+
11+
// Managed code in charge of main loop
12+
while (app.RunFrame())
13+
{
14+
15+
}
16+
17+
// Shut 'er down
18+
app.Shutdown();
19+
}
20+
}
21+
22+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System;
2+
using System.Reflection;
3+
4+
5+
namespace AtomicEngine
6+
{
7+
public partial class NETAtomicPlayer : PlayerApp
8+
{
9+
10+
/// <summary>
11+
/// AtomicPlayer for NET deployments
12+
/// </summary>
13+
/// <param name="args"></param>
14+
/// <param name="headless"></param>
15+
/// <returns></returns>
16+
public static NETAtomicPlayer Create(string[] args, bool headless = false)
17+
{
18+
DeployedApp = true;
19+
20+
// Initialize AtomicNET
21+
AtomicNET.Initialize();
22+
23+
var app = CreateInternal();
24+
25+
app.Initialize();
26+
27+
RegisterSubsystems();
28+
29+
ExecuteAtomicMain(args);
30+
31+
return app;
32+
}
33+
34+
35+
}
36+
37+
}

‎Script/AtomicNET/AtomicNET/Application/NETIPCPlayerApp.cs‎

Lines changed: 8 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,16 @@
11
using System;
22
using System.Reflection;
33

4-
54
namespace AtomicEngine
65
{
7-
public partial class PlayerApp : AppBase
8-
{
9-
protected static void ExecuteAtomicMain(string[] args)
10-
{
11-
var file = AtomicNET.Cache.GetFile("AtomicProject.dll");
12-
13-
if (file == null)
14-
return;
15-
16-
Assembly assembly = Assembly.LoadFrom(file.FullPath);
17-
18-
if (assembly == null)
19-
return;
20-
21-
Type atomicMainType = null;
22-
Type[] assemblyTypes = assembly.GetTypes();
23-
24-
for (int j = 0; j < assemblyTypes.Length; j++)
25-
{
26-
if (assemblyTypes[j].Name == "AtomicMain")
27-
{
28-
atomicMainType = assemblyTypes[j];
29-
break;
30-
}
31-
}
32-
33-
if (atomicMainType == null)
34-
return;
35-
36-
Type[] mainParms = new Type[1] { typeof(string[]) };
37-
38-
var method = atomicMainType.GetMethod("Main", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, Type.DefaultBinder, mainParms, null);
39-
40-
if (method == null)
41-
return;
42-
43-
Object[] parms = new Object[1] { args };
44-
method.Invoke(null, parms);
45-
46-
}
47-
48-
}
49-
506
public partial class NETIPCPlayerApp : IPCPlayerApp
517
{
52-
8+
/// <summary>
9+
/// IPC Player App used with the Atomic Editor
10+
/// </summary>
11+
/// <param name="args"></param>
12+
/// <param name="headless"></param>
13+
/// <returns></returns>
5314
public static NETIPCPlayerApp Create(string[] args, bool headless = false)
5415
{
5516
// Initialize AtomicNET
@@ -59,18 +20,8 @@ public static NETIPCPlayerApp Create(string[] args, bool headless = false)
5920

6021
app.Initialize();
6122

62-
// TODO: Refactor these registrations
63-
AtomicNET.RegisterSubsystem("FileSystem");
64-
65-
AtomicNET.RegisterSubsystem("Graphics");
66-
AtomicNET.RegisterSubsystem("Player");
67-
68-
AtomicNET.RegisterSubsystem("Input");
69-
AtomicNET.RegisterSubsystem("Renderer");
70-
71-
AtomicNET.RegisterSubsystem("ResourceCache");
72-
AtomicNET.Cache = AtomicNET.GetSubsystem<ResourceCache>();
73-
23+
RegisterSubsystems();
24+
7425
ExecuteAtomicMain(args);
7526

7627
return app;
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
using System;
2+
using System.IO;
3+
using System.Reflection;
4+
5+
namespace AtomicEngine
6+
{
7+
8+
9+
public partial class PlayerApp : AppBase
10+
{
11+
public static bool DeployedApp = false;
12+
13+
static protected void RegisterSubsystems()
14+
{
15+
// TODO: Refactor these registrations
16+
AtomicNET.RegisterSubsystem("FileSystem");
17+
18+
AtomicNET.RegisterSubsystem("Graphics");
19+
AtomicNET.RegisterSubsystem("Player");
20+
21+
AtomicNET.RegisterSubsystem("Input");
22+
AtomicNET.RegisterSubsystem("Renderer");
23+
24+
AtomicNET.RegisterSubsystem("ResourceCache");
25+
AtomicNET.Cache = AtomicNET.GetSubsystem<ResourceCache>();
26+
}
27+
28+
protected static void ExecuteAtomicMain(string[] args)
29+
{
30+
String projectAssemblyPath;
31+
32+
if (!DeployedApp)
33+
{
34+
var file = AtomicNET.Cache.GetFile("AtomicProject.dll");
35+
projectAssemblyPath = file.FullPath;
36+
}
37+
else
38+
{
39+
projectAssemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/AtomicProject.dll";
40+
}
41+
42+
Assembly assembly = Assembly.LoadFrom(projectAssemblyPath);
43+
44+
if (assembly == null)
45+
return;
46+
47+
Type atomicMainType = null;
48+
Type[] assemblyTypes = assembly.GetTypes();
49+
50+
for (int j = 0; j < assemblyTypes.Length; j++)
51+
{
52+
if (assemblyTypes[j].Name == "AtomicMain")
53+
{
54+
atomicMainType = assemblyTypes[j];
55+
break;
56+
}
57+
}
58+
59+
if (atomicMainType == null)
60+
return;
61+
62+
Type[] mainParms = new Type[1] { typeof(string[]) };
63+
64+
var method = atomicMainType.GetMethod("Main", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, Type.DefaultBinder, mainParms, null);
65+
66+
if (method == null)
67+
return;
68+
69+
Object[] parms = new Object[1] { args };
70+
method.Invoke(null, parms);
71+
72+
}
73+
74+
}
75+
76+
77+
}

‎Script/AtomicNET/AtomicNET/Scene/CSComponentCore.cs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.IO;
23
using System.Collections.Generic;
34
using System.Reflection;
45
using System.Linq;
@@ -247,6 +248,12 @@ void HandleComponentAssemblyReference(uint eventType, ScriptVariantMap eventData
247248
componentCache[assemblyPath] = assemblyTypes = new Dictionary<string, CSComponentInfo>();
248249
}
249250

251+
// HACK!
252+
if (PlayerApp.DeployedApp)
253+
{
254+
assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/AtomicProject.dll";
255+
}
256+
250257
Assembly assembly = Assembly.LoadFrom(assemblyPath);
251258

252259
Type[] types = assembly.GetTypes();

‎Script/AtomicNET/AtomicNETProject.json‎

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@
6464
]
6565
},
6666
{
67-
"name": "AtomicPlayer",
67+
"name": "AtomicIPCPlayer",
6868
"outputType" : "Exe",
69-
"rootNamespace" : "AtomicPlayer",
70-
"assemblyName" : "AtomicPlayer",
69+
"rootNamespace" : "AtomicIPCPlayer",
70+
"assemblyName" : "AtomicIPCPlayer",
7171
"assemblyOutputPath" : "..\\..\\",
7272
"references" : [
7373
"System",
@@ -77,8 +77,26 @@
7777
"AtomicNET"
7878
],
7979
"sources" : [
80-
"$ATOMIC_ROOT$/Script/AtomicNET/AtomicPlayer/"
80+
"$ATOMIC_ROOT$/Script/AtomicNET/AtomicIPCPlayer/"
8181
]
82-
}
82+
},
83+
{
84+
"name": "AtomicPlayer",
85+
"outputType" : "Exe",
86+
"rootNamespace" : "AtomicPlayer",
87+
"assemblyName" : "AtomicPlayer",
88+
"assemblyOutputPath" : "..\\..\\",
89+
"references" : [
90+
"System",
91+
"System.Core" ,
92+
"System.Xml.Linq",
93+
"System.XML",
94+
"AtomicNET"
95+
],
96+
"sources" : [
97+
"$ATOMIC_ROOT$/Script/AtomicNET/AtomicPlayer/"
98+
]
99+
}
100+
83101
]
84102
}

‎Script/AtomicNET/AtomicPlayer/Program.cs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
public class Program
55
{
66
public static void Main(string[] args)
7-
{
7+
{
88
// Create the Application
9-
var app = NETIPCPlayerApp.Create(args);
9+
var app = NETAtomicPlayer.Create(args);
1010

1111
// Managed code in charge of main loop
1212
while (app.RunFrame())
@@ -18,5 +18,3 @@ public static void Main(string[] args)
1818
app.Shutdown();
1919
}
2020
}
21-
22-

‎Script/AtomicNET/AtomicPlayer/project.json‎

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name" : "AtomicNETNative",
33
"sources" : ["Source/AtomicNET/NETNative"],
4-
"classes" : ["NETCore", "NETIPCPlayerApp", "NETServiceApplication"]
4+
"classes" : ["NETCore", "NETIPCPlayerApp", "NETServiceApplication", "NETAtomicPlayer"]
55
}

‎Source/AtomicEditor/EditorMode/AEEditorMode.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ bool EditorMode::PlayProject(String addArgs, bool debug)
143143
if (fileSystem->FileExists(project->GetResourcePath() + "AtomicProject.dll"))
144144
{
145145
managed = true;
146-
playerBinary = env->GetAtomicNETManagedPlayerBinary();
146+
playerBinary = env->GetAtomicNETManagedIPCPlayerBinary();
147147
}
148148

149149

0 commit comments

Comments
 (0)