Skip to content
This repository was archived by the owner on Jul 3, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,7 @@ crashlytics-build.properties
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*

.vscode
.vscode

RTBTemp
dump
1 change: 1 addition & 0 deletions Assets/Editor/EcsactSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ MonoBehaviour:
m_Name: EcsactSettings
m_EditorClassIdentifier:
runtimeBuilderOutputPath: Assets/Plugins/EcsactRuntime
runtimeBuilderTempDirectory: RTBTemp
runtimeBuilderDebugBuild: 1
runtimeBuilderPrintSubcommandStdout: 1
runtimeBuilderPrintSubcommandStderr: 1
Expand Down
Binary file modified Assets/Plugins/EcsactRuntime.dll
Binary file not shown.
Binary file added Assets/Plugins/EcsactRuntime.lib
Binary file not shown.
7 changes: 7 additions & 0 deletions Assets/Plugins/EcsactRuntime.lib.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/Resources/Settings/EcsactRuntimeSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ MonoBehaviour:
- scriptEnabled: 1
scriptAssemblyQualifiedName: SyncMove, Assembly-CSharp, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
systemImplSource: 0
systemImplSource: 1
defaultCsharpSystemImplsAssemblyName: ExampleAssembly
runtimeLibraryPaths:
- Assets/Plugins/EcsactRuntime
48 changes: 16 additions & 32 deletions Assets/Resources/Settings/EcsactWasmRuntimeSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,23 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 61f6048043c761b47b4e0be2b0a0e30e, type: 3}
m_Name: EcsactWasmRuntimeSettings
m_EditorClassIdentifier:
useDefaultLoader: 0
autoFindSystemImpls: 1
wasmSystemEntries:
- systemId: 13
wasmAsset: {fileID: 0}
wasmExportName:
- systemId: 14
wasmAsset: {fileID: 0}
wasmExportName:
- systemId: 10
wasmAsset: {fileID: 8505064800252710765, guid: 31649f2d7b0ad8c418d73f15f5ea95b9, type: 3}
wasmExportName: example__Move
- systemId: 15
wasmAsset: {fileID: 0}
wasmExportName:
- systemId: 16
wasmAsset: {fileID: 0}
wasmExportName:
- systemId: 22
wasmAsset: {fileID: 0}
wasmExportName:
wasmAsset: {fileID: 8505064800252710765, guid: 31649f2d7b0ad8c418d73f15f5ea95b9, type: 3}
wasmExportName: example__PerformGenerateBlock
- systemId: 3
wasmAsset: {fileID: 0}
wasmExportName:
- systemId: 17
wasmAsset: {fileID: 0}
wasmExportName:
- systemId: 18
wasmAsset: {fileID: 0}
wasmExportName:
- systemId: 20
wasmAsset: {fileID: 0}
wasmExportName:
- systemId: 21
wasmAsset: {fileID: 0}
wasmExportName:
- systemId: 23
wasmAsset: {fileID: 0}
wasmExportName:
wasmAsset: {fileID: 8505064800252710765, guid: 31649f2d7b0ad8c418d73f15f5ea95b9, type: 3}
wasmExportName: example__AddToExample
- systemId: 13
wasmAsset: {fileID: 8505064800252710765, guid: 31649f2d7b0ad8c418d73f15f5ea95b9, type: 3}
wasmExportName: example__ApplyVelocity
- systemId: 16
wasmAsset: {fileID: 8505064800252710765, guid: 31649f2d7b0ad8c418d73f15f5ea95b9, type: 3}
wasmExportName: example__GenerateBlock
- systemId: 12
wasmAsset: {fileID: 8505064800252710765, guid: 31649f2d7b0ad8c418d73f15f5ea95b9, type: 3}
wasmExportName: example__CollisionComparer__CheckCollision
Binary file added Assets/Scripts/Systems/UnityExamples.wasm
Binary file not shown.
7 changes: 7 additions & 0 deletions Assets/Scripts/Systems/UnityExamples.wasm.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Packages/manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"dependencies": {
"com.seaube.unity-wasm": "https://github.com/seaube/unity-wasm.git",
"com.unity.collab-proxy": "1.17.2",
"com.unity.feature.2d": "1.0.0",
"com.unity.ide.rider": "3.0.15",
Expand All @@ -12,7 +13,7 @@
"com.unity.timeline": "1.6.4",
"com.unity.ugui": "1.0.0",
"com.unity.visualscripting": "1.7.8",
"dev.ecsact.unity": "https://github.com/ecsact-dev/ecsact_unity.git",
"dev.ecsact.unity": "file:C:/programming/ecsact-unity",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0",
Expand Down
14 changes: 10 additions & 4 deletions Packages/packages-lock.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"dependencies": {
"com.seaube.unity-wasm": {
"version": "https://github.com/seaube/unity-wasm.git",
"depth": 0,
"source": "git",
"dependencies": {},
"hash": "38ebddd90e653bf3cc3cf03aac2a569f059e935d"
},
"com.unity.2d.animation": {
"version": "7.0.7",
"depth": 1,
Expand Down Expand Up @@ -279,14 +286,13 @@
"url": "https://packages.unity.com"
},
"dev.ecsact.unity": {
"version": "https://github.com/ecsact-dev/ecsact_unity.git",
"version": "file:C:/programming/ecsact-unity",
"depth": 0,
"source": "git",
"source": "local",
"dependencies": {
"com.unity.editorcoroutines": "1.0.0",
"com.unity.visualscripting": "1.7.8"
},
"hash": "bf5e4211504bcfcdc29c42ad94e28835c3c6863d"
}
},
"com.unity.modules.ai": {
"version": "1.0.0",
Expand Down
11 changes: 11 additions & 0 deletions SystemImpls/WasmExample.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$EcsactInc = (ecsact config include_dir)
emcc -O2 -std=c++20 --no-entry -I"$EcsactInc" `
-sEXPORTED_FUNCTIONS="_example__PerformGenerateBlock,_example__GenerateBlock,_example__AddToExample,_example__Move,_example__ApplyVelocity,_example__CollisionComparer__CheckCollision" `
-sERROR_ON_UNDEFINED_SYMBOLS=0 `
-Wno-js-compiler `
-o ../Assets/Scripts/Systems/UnityExamples.wasm `
generate_block_system.cc `
basic_example.cc `
move.cc `
collision.cc `
example.ecsact.systems.cc
17 changes: 17 additions & 0 deletions SystemImpls/basic_example.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "example.ecsact.hh"
#include "example.ecsact.systems.hh"

// The system implement of our AddToExample system
void example::AddToExample::impl(context& ctx) {
// Get a component from the context
auto value = ctx.get<Example>();

// Modify and update its value
value.example_value +=1;
ctx.update<Example>(value);

if(value.example_value >= 100) {
// Remove the component from the context
ctx.remove<ToBeRemoved>();
}
}
35 changes: 35 additions & 0 deletions SystemImpls/collision.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "example.ecsact.hh"
#include "example.ecsact.systems.hh"

void example::CollisionComparer::CheckCollision::impl(context& ctx) {
if(ctx._ctx.same(ctx._ctx.parent())) return;

auto position = ctx.get<Position>();
auto velocity = ctx.get<Velocity>();

auto otherPos = ctx._ctx.parent().get<Position>();
auto other_collider = ctx._ctx.parent().get<Collider>();

auto xDiff = std::abs(position.x - otherPos.x);
auto yDiff = std::abs(position.y - otherPos.y);

if(xDiff <= other_collider.x_radius && yDiff <= other_collider.y_radius) {
position.x = position.prev_x;
position.y = position.prev_y;

if(position.x < otherPos.x) {
velocity.x_value = -0.5f;
} else {
velocity.x_value = 0.5f;
}

if(position.y < otherPos.y) {
velocity.y_value = -0.5f;
} else {
velocity.y_value = 0.5f;
}

ctx.update<Velocity>(velocity);
ctx.update<Position>(position);
}
}
114 changes: 114 additions & 0 deletions SystemImpls/example.ecsact.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// GENERATED FILE - DO NOT EDIT
#pragma once

#include <cstdint>
#include <compare>
#include "ecsact/runtime/common.h"

namespace example {

struct Example {
static constexpr bool transient = false;
static constexpr auto id = static_cast<ecsact_component_id>(1);
int32_t example_value;
auto operator<=>(const example::Example&) const = default;
};
struct ToBeRemoved {
static constexpr bool transient = false;
static constexpr auto id = static_cast<ecsact_component_id>(2);
auto operator<=>(const example::ToBeRemoved&) const = default;
};
struct CanMove {
static constexpr bool transient = false;
static constexpr auto id = static_cast<ecsact_component_id>(4);
auto operator<=>(const example::CanMove&) const = default;
};
struct Velocity {
static constexpr bool transient = false;
static constexpr auto id = static_cast<ecsact_component_id>(5);
float x_value;
float y_value;
float speed;
auto operator<=>(const example::Velocity&) const = default;
};
struct Position {
static constexpr bool transient = false;
static constexpr auto id = static_cast<ecsact_component_id>(6);
float x;
float y;
float prev_x;
float prev_y;
auto operator<=>(const example::Position&) const = default;
};
struct Collider {
static constexpr bool transient = false;
static constexpr auto id = static_cast<ecsact_component_id>(7);
int32_t x_radius;
int32_t y_radius;
auto operator<=>(const example::Collider&) const = default;
};
struct Block {
static constexpr bool transient = false;
static constexpr auto id = static_cast<ecsact_component_id>(8);
auto operator<=>(const example::Block&) const = default;
};
struct BlockGenerator {
static constexpr bool transient = false;
static constexpr auto id = static_cast<ecsact_component_id>(9);
auto operator<=>(const example::BlockGenerator&) const = default;
};
struct QueueBlock {
static constexpr bool transient = false;
static constexpr auto id = static_cast<ecsact_component_id>(14);
int32_t pos_x;
int32_t pos_y;
auto operator<=>(const example::QueueBlock&) const = default;
};
struct Move {
static constexpr auto id = static_cast<ecsact_action_id>(10);
struct context;
static void impl(context&);
float dir_x;
float dir_y;
auto operator<=>(const example::Move&) const = default;
};
struct PerformGenerateBlock {
static constexpr auto id = static_cast<ecsact_action_id>(15);
struct context;
static void impl(context&);
int32_t pos_x;
int32_t pos_y;
auto operator<=>(const example::PerformGenerateBlock&) const = default;
};
struct AddToExample {
static constexpr auto id = static_cast<ecsact_system_id>(3);
struct context;
static void impl(context&);
};
struct CollisionComparer {
static constexpr auto id = static_cast<ecsact_system_id>(11);
struct CheckCollision {
static constexpr auto id = static_cast<ecsact_system_id>(12);
struct context;
static void impl(context&);
};
struct context;
static void impl(context&);
};
struct ApplyVelocity {
static constexpr auto id = static_cast<ecsact_system_id>(13);
struct context;
static void impl(context&);
};
struct GenerateBlock {
static constexpr auto id = static_cast<ecsact_system_id>(16);
struct context;
static void impl(context&);
};
struct RemoveQueueBlock {
static constexpr auto id = static_cast<ecsact_system_id>(18);
struct context;
static void impl(context&);
};

}// namespace example
34 changes: 34 additions & 0 deletions SystemImpls/example.ecsact.systems.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// GENERATED FILE - DO NOT EDIT
#include "example.ecsact.systems.hh"
void example__AddToExample(struct ecsact_system_execution_context* cctx) {
example::AddToExample::context ctx{cctx};
example::AddToExample::impl(ctx);
}
void example__CollisionComparer(struct ecsact_system_execution_context* cctx) {
example::CollisionComparer::context ctx{cctx};
example::CollisionComparer::impl(ctx);
}
void example__CollisionComparer__CheckCollision(struct ecsact_system_execution_context* cctx) {
example::CollisionComparer::CheckCollision::context ctx{cctx};
example::CollisionComparer::CheckCollision::impl(ctx);
}
void example__ApplyVelocity(struct ecsact_system_execution_context* cctx) {
example::ApplyVelocity::context ctx{cctx};
example::ApplyVelocity::impl(ctx);
}
void example__GenerateBlock(struct ecsact_system_execution_context* cctx) {
example::GenerateBlock::context ctx{cctx};
example::GenerateBlock::impl(ctx);
}
void example__RemoveQueueBlock(struct ecsact_system_execution_context* cctx) {
example::RemoveQueueBlock::context ctx{cctx};
example::RemoveQueueBlock::impl(ctx);
}
void example__Move(struct ecsact_system_execution_context* cctx) {
example::Move::context ctx{cctx};
example::Move::impl(ctx);
}
void example__PerformGenerateBlock(struct ecsact_system_execution_context* cctx) {
example::PerformGenerateBlock::context ctx{cctx};
example::PerformGenerateBlock::impl(ctx);
}
21 changes: 21 additions & 0 deletions SystemImpls/example.ecsact.systems.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// GENERATED FILE - DO NOT EDIT
#ifndef EXAMPLE_H
#define EXAMPLE_H

#ifdef __cplusplus
# define ECSACT_SYSTEM_EXTERN extern "C"
#else
# define ECSACT_SYSTEM_EXTERN extern
#endif

ECSACT_SYSTEM_EXTERN void example__Move(struct ecsact_system_execution_context*);
ECSACT_SYSTEM_EXTERN void example__PerformGenerateBlock(struct ecsact_system_execution_context*);
ECSACT_SYSTEM_EXTERN void example__AddToExample(struct ecsact_system_execution_context*);
ECSACT_SYSTEM_EXTERN void example__CollisionComparer(struct ecsact_system_execution_context*);
ECSACT_SYSTEM_EXTERN void example__CollisionComparer__CheckCollision(struct ecsact_system_execution_context*);
ECSACT_SYSTEM_EXTERN void example__ApplyVelocity(struct ecsact_system_execution_context*);
ECSACT_SYSTEM_EXTERN void example__GenerateBlock(struct ecsact_system_execution_context*);
ECSACT_SYSTEM_EXTERN void example__RemoveQueueBlock(struct ecsact_system_execution_context*);

#undef ECSACT_SYSTEM_EXTERN
#endif//EXAMPLE_H
Loading