Skip to content

Commit b0dbc95

Browse files
authored
Merge pull request #12 from starbounded-dev/csharp
feature: CSharp Scripting
2 parents e4b5123 + 8a74991 commit b0dbc95

File tree

644 files changed

+47853
-119
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

644 files changed

+47853
-119
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ jobs:
6262
run: premake5 vs2022
6363

6464
- name: Build project with MSBuild
65-
run: MSBuild /m /p:Configuration=Dist StarEngine.sln
65+
run: MSBuild /m /p:Configuration=Release StarEngine.sln
6666

6767
- name: Upload executable
6868
uses: actions/upload-artifact@v4
6969
with:
7070
name: StarEngine-Windows
7171
path: |
72-
bin/Dist-windows-x86_64/StarEditor/StarEditor.exe
73-
bin/Dist-windows-x86_64/StarEditor/assets
74-
bin/Dist-windows-x86_64/StarEditor/Resources
75-
bin/Dist-windows-x86_64/StarEditor/imgui.ini
72+
bin/Release-windows-x86_64/StarEditor/StarEditor.exe
73+
bin/Release-windows-x86_64/StarEditor/assets
74+
bin/Release-windows-x86_64/StarEditor/Resources
75+
bin/Release-windows-x86_64/StarEditor/imgui.ini

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Binaries
22
**/bin/
33
bin-int/
4+
Intermediates/
45

56
# StarEngine files
67
*.log
@@ -14,6 +15,7 @@ bin-int/
1415
**.vcxproj
1516
**.vcxproj.filters
1617
**.vcxproj.user
18+
**.csproj
1719

1820
# Directories
1921
StarEngine/vendor/VulkanSDK
@@ -22,3 +24,6 @@ scripts/__pycache__
2224

2325
StarEngine/vendor/VulkanSDK/VulkanSDK-1.2.170.0-Installer.exe
2426
vendor/premake/bin/
27+
StarEditor/Resources/Scripts/StarEngine-ScriptCore.dll
28+
StarEditor/Resources/Scripts/StarEngine-ScriptCore.pdb
29+
StarEditor/SandboxProject/Assets/Scripts/Binaries

Dependencies.lua

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,20 @@ IncludeDir["GLAD"] = "%{wks.location}/StarEngine/vendor/GLAD/include"
1111
IncludeDir["ImGui"] = "%{wks.location}/StarEngine/vendor/imgui"
1212
IncludeDir["ImGuizmo"] = "%{wks.location}/StarEngine/vendor/imguizmo"
1313
IncludeDir["glm"] = "%{wks.location}/StarEngine/vendor/glm"
14+
IncludeDir["filewatch"] = "%{wks.location}/StarEngine/vendor/filewatch"
1415
IncludeDir["entt"] = "%{wks.location}/StarEngine/vendor/entt/include"
16+
IncludeDir["mono"] = "%{wks.location}/StarEngine/vendor/mono/include"
1517
IncludeDir["shaderc"] = "%{wks.location}/StarEngine/vendor/shaderc/include"
1618
IncludeDir["SPIRV_Cross"] = "%{wks.location}/StarEngine/vendor/SPIRV-Cross"
1719
IncludeDir["VulkanSDK"] = "%{VULKAN_SDK}/Include"
1820

1921
LibraryDir = {}
2022

2123
LibraryDir["VulkanSDK"] = "%{VULKAN_SDK}/Lib"
24+
LibraryDir["Mono"] = "%{wks.location}/StarEngine/vendor/mono/lib/%{cfg.buildcfg}"
2225

2326
Library = {}
27+
Library["mono"] = "%{LibraryDir.Mono}/libmono-static-sgen.lib"
2428
Library["Vulkan"] = "%{LibraryDir.VulkanSDK}/vulkan-1.lib"
2529
Library["VulkanUtils"] = "%{LibraryDir.VulkanSDK}/VkLayer_utils.lib"
2630

@@ -31,4 +35,11 @@ Library["SPIRV_Tools_Debug"] = "%{LibraryDir.VulkanSDK}/SPIRV-Toolsd.lib"
3135

3236
Library["ShaderC_Release"] = "%{LibraryDir.VulkanSDK}/shaderc_shared.lib"
3337
Library["SPIRV_Cross_Release"] = "%{LibraryDir.VulkanSDK}/spirv-cross-core.lib"
34-
Library["SPIRV_Cross_GLSL_Release"] = "%{LibraryDir.VulkanSDK}/spirv-cross-glsl.lib"
38+
Library["SPIRV_Cross_GLSL_Release"] = "%{LibraryDir.VulkanSDK}/spirv-cross-glsl.lib"
39+
40+
41+
-- Windows
42+
Library["WinSock"] = "Ws2_32.lib"
43+
Library["WinMM"] = "Winmm.lib"
44+
Library["WinVersion"] = "Version.lib"
45+
Library["BCrypt"] = "Bcrypt.lib"
119 Bytes
438 Bytes
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
using StarEngine;
8+
9+
namespace Sandbox
10+
{
11+
public class Camera : Entity
12+
{
13+
public Entity OtherEntity;
14+
15+
public float DistanceFromPlayer = 5.0f;
16+
17+
private Entity m_Player;
18+
19+
void OnCreate()
20+
{
21+
m_Player = FindEntityByName("Player");
22+
}
23+
24+
void OnUpdate(float ts)
25+
{
26+
if (m_Player != null)
27+
Translation = new Vector3(m_Player.Translation.XY, DistanceFromPlayer);
28+
29+
float speed = 1.0f;
30+
Vector3 velocity = Vector3.Zero;
31+
32+
if (Input.IsKeyDown(KeyCode.Up))
33+
velocity.Y = 1.0f;
34+
else if (Input.IsKeyDown(KeyCode.Down))
35+
velocity.Y = -1.0f;
36+
37+
if (Input.IsKeyDown(KeyCode.Left))
38+
velocity.X = -1.0f;
39+
else if (Input.IsKeyDown(KeyCode.Right))
40+
velocity.X = 1.0f;
41+
42+
velocity *= speed;
43+
44+
Vector3 translation = Translation;
45+
translation += velocity * ts;
46+
Translation = translation;
47+
}
48+
49+
}
50+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
using StarEngine;
8+
9+
namespace Sandbox
10+
{
11+
public class Player : Entity
12+
{
13+
private TransformComponent m_Transform;
14+
private RigidBody2DComponent m_RigidBody;
15+
16+
public float Speed = 1.0f;
17+
public float Time = 0.0f;
18+
19+
void OnCreate()
20+
{
21+
Console.WriteLine($"Player.OnCreate - {ID}");
22+
23+
m_Transform = GetComponent<TransformComponent>();
24+
m_RigidBody = GetComponent<RigidBody2DComponent>();
25+
}
26+
27+
void OnUpdate(float ts)
28+
{
29+
Time += ts;
30+
// Console.WriteLine($"Player.OnUpdate: {ts}");
31+
32+
float speed = Speed;
33+
Vector3 velocity = Vector3.Zero;
34+
35+
if (Input.IsKeyDown(KeyCode.W))
36+
velocity.Y = 1.0f;
37+
else if (Input.IsKeyDown(KeyCode.S))
38+
velocity.Y = -1.0f;
39+
40+
if (Input.IsKeyDown(KeyCode.A))
41+
velocity.X = -1.0f;
42+
else if (Input.IsKeyDown(KeyCode.D))
43+
velocity.X = 1.0f;
44+
45+
Entity cameraEntity = FindEntityByName("Camera");
46+
if (cameraEntity != null)
47+
{
48+
Camera camera = cameraEntity.As<Camera>();
49+
50+
if (Input.IsKeyDown(KeyCode.Q))
51+
camera.DistanceFromPlayer += speed * 2.0f * ts;
52+
else if (Input.IsKeyDown(KeyCode.E))
53+
camera.DistanceFromPlayer -= speed * 2.0f * ts;
54+
}
55+
56+
velocity *= speed * ts;
57+
58+
m_RigidBody.ApplyLinearImpulse(velocity.XY, true);
59+
60+
//Vector3 translation = m_Transform.Translation;
61+
//translation += velocity * ts;
62+
//m_Transform.Translation = translation;
63+
}
64+
65+
}
66+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
call ..\..\..\..\vendor\premake\bin\premake5.exe vs2022
3+
PAUSE
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
local StarEngineRootDir = '../../../..'
2+
include (StarEngineRootDir .. "/vendor/premake/premake_customization/solution_items.lua")
3+
4+
workspace "Sandbox"
5+
architecture "x86_64"
6+
startproject "Sandbox"
7+
8+
configurations
9+
{
10+
"Debug",
11+
"Release",
12+
"Dist"
13+
}
14+
15+
flags
16+
{
17+
"MultiProcessorCompile"
18+
}
19+
20+
outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"
21+
22+
project "Sandbox"
23+
kind "SharedLib"
24+
language "C#"
25+
dotnetframework "4.7.2"
26+
27+
targetdir ("Binaries")
28+
objdir ("Intermediates")
29+
30+
files
31+
{
32+
"Source/**.cs",
33+
"Properties/**.cs"
34+
}
35+
36+
links
37+
{
38+
"StarEngine-ScriptCore"
39+
}
40+
41+
filter "configurations:Debug"
42+
optimize "Off"
43+
symbols "Default"
44+
45+
filter "configurations:Release"
46+
optimize "On"
47+
symbols "Default"
48+
49+
filter "configurations:Dist"
50+
optimize "Full"
51+
symbols "Off"
52+
53+
group "StarEngine"
54+
include (StarEngineRootDir .. "/StarEngine-ScriptCore")
55+
group ""

StarEditor/assets/scene/Physics2D.starscene

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
Scene: Untitled
22
Entities:
3+
- Entity: 14040563719264005740
4+
TagComponent:
5+
Tag: Player
6+
TransformComponent:
7+
Translation: [0, 5, 0]
8+
Rotation: [0, 0, 0]
9+
Scale: [1, 1, 1]
10+
SpriteRendererComponent:
11+
Color: [1, 1, 1, 1]
12+
TilingFactor: 1
13+
RigidBody2DComponent:
14+
BodyType: Dynamic
15+
FixedRotation: false
16+
BoxCollider2DComponent:
17+
Offset: [0, 0]
18+
Size: [0.5, 0.5]
19+
Density: 1
20+
Friction: 0.5
21+
Restitution: 0
22+
RestitutionThreshold: 0.5
323
- Entity: 16241606122818465121
424
TagComponent:
525
Tag: Camera
@@ -27,7 +47,8 @@ Entities:
2747
Scale: [1, 1, 1]
2848
SpriteRendererComponent:
2949
Color: [1, 1, 1, 1]
30-
Rigidbody2DComponent:
50+
TilingFactor: 1
51+
RigidBody2DComponent:
3152
BodyType: Dynamic
3253
FixedRotation: false
3354
BoxCollider2DComponent:
@@ -46,9 +67,10 @@ Entities:
4667
Scale: [10, 1, 1]
4768
SpriteRendererComponent:
4869
Color: [1, 1, 1, 1]
49-
Rigidbody2DComponent:
70+
TilingFactor: 1
71+
RigidBody2DComponent:
5072
BodyType: Static
51-
FixedRotation: false
73+
FixedRotation: true
5274
BoxCollider2DComponent:
5375
Offset: [0, 0]
5476
Size: [0.5, 0.5]
@@ -67,7 +89,7 @@ Entities:
6789
Color: [0.934362948, 0.497845858, 0, 1]
6890
Thickness: 1
6991
Fade: 0.00499999989
70-
Rigidbody2DComponent:
92+
RigidBody2DComponent:
7193
BodyType: Dynamic
7294
FixedRotation: false
7395
CircleCollider2DComponent:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
664 KB
Binary file not shown.
31.5 KB
Binary file not shown.
35.5 KB
Binary file not shown.
189 KB
Binary file not shown.
71 KB
Binary file not shown.

StarEditor/mono/lib/mono/4.5/I18N.dll

38.5 KB
Binary file not shown.
70.5 KB
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)