├── .github └── ISSUE_TEMPLATE.md ├── .gitignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── Deps └── Unity │ ├── UnityEditor.dll │ └── UnityEngine.dll ├── LICENSE ├── README.md ├── Samples ├── SandboxProject │ ├── App.config │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── SandboxProject.csproj ├── TinyECSUnity3DTemplate │ ├── .gitignore │ ├── Assets │ │ ├── Editor │ │ │ └── TinyECSUnityIntegrationEditor.dll │ │ ├── Plugins │ │ │ └── TinyECS │ │ │ │ ├── TinyECS.dll │ │ │ │ └── TinyECSUnityIntegration.dll │ │ ├── Scenes │ │ │ └── SampleScene.unity │ │ └── Scripts │ │ │ └── Controller.cs │ └── ProjectSettings │ │ ├── AudioManager.asset │ │ ├── ClusterInputManager.asset │ │ ├── DynamicsManager.asset │ │ ├── EditorBuildSettings.asset │ │ ├── EditorSettings.asset │ │ ├── GraphicsSettings.asset │ │ ├── InputManager.asset │ │ ├── NavMeshAreas.asset │ │ ├── NetworkManager.asset │ │ ├── Physics2DSettings.asset │ │ ├── PresetManager.asset │ │ ├── ProjectSettings.asset │ │ ├── ProjectVersion.txt │ │ ├── QualitySettings.asset │ │ ├── TagManager.asset │ │ ├── TimeManager.asset │ │ ├── UnityConnectSettings.asset │ │ └── VFXManager.asset ├── Tutorial01_HelloWorld │ ├── App.config │ ├── Components.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Systems.cs │ └── Tutorial01_HelloWorld.csproj └── Tutorial02_TinyECSIntegrationWithUnity3D │ ├── .gitignore │ ├── Assets │ ├── Editor │ │ └── TinyECSUnityIntegrationEditor.dll │ ├── Materials │ │ └── StaticCubeMat0.mat │ ├── Plugins │ │ └── TinyECS │ │ │ ├── TinyECS.dll │ │ │ └── TinyECSUnityIntegration.dll │ ├── Prefabs │ │ ├── Cube.prefab │ │ ├── CubeView.prefab │ │ └── StaticCubeView.prefab │ ├── Scenes │ │ └── SampleScene.unity │ └── Scripts │ │ ├── Components │ │ └── Components.cs │ │ ├── Controller.cs │ │ ├── Systems │ │ ├── ImprovedSpawnSystem.cs │ │ ├── InputSystem.cs │ │ ├── RotatingCubesSystem.cs │ │ └── SpawnSystem.cs │ │ └── Views │ │ ├── CubeView.cs │ │ └── StaticCubeView.cs │ └── ProjectSettings │ ├── AudioManager.asset │ ├── ClusterInputManager.asset │ ├── DynamicsManager.asset │ ├── EditorBuildSettings.asset │ ├── EditorSettings.asset │ ├── GraphicsSettings.asset │ ├── InputManager.asset │ ├── NavMeshAreas.asset │ ├── NetworkManager.asset │ ├── Physics2DSettings.asset │ ├── PresetManager.asset │ ├── ProjectSettings.asset │ ├── ProjectVersion.txt │ ├── QualitySettings.asset │ ├── TagManager.asset │ ├── TimeManager.asset │ ├── UnityConnectSettings.asset │ └── VFXManager.asset ├── TinyECS.sln ├── TinyECS ├── Impls │ ├── BaseReactiveSystem.cs │ ├── BuiltinComponents.cs │ ├── BuiltinSystems.cs │ ├── ComponentManager.cs │ ├── Entity.cs │ ├── EntityManager.cs │ ├── EntityManagerExtensions.cs │ ├── EventManager.cs │ ├── Events.cs │ ├── Exceptions.cs │ ├── PureSystemsAdapters.cs │ ├── SystemManager.cs │ ├── SystemsPackage.cs │ ├── WorldContext.cs │ └── WorldContextFactory.cs ├── Interfaces │ ├── IComponent.cs │ ├── IComponentManager.cs │ ├── IEntity.cs │ ├── IEntityManager.cs │ ├── IEvent.cs │ ├── IEventManager.cs │ ├── ISystem.cs │ ├── ISystemManager.cs │ ├── ISystemsGroup.cs │ ├── IWorldContext.cs │ └── IWorldContextFactory.cs ├── Properties │ └── AssemblyInfo.cs └── TinyECS.csproj ├── TinyECSTests ├── ComponentManager │ ├── ComponentIteratorTests.cs │ └── ComponentManagerTests.cs ├── EntityManager │ └── EntityManagerTests.cs ├── EventManager │ ├── BrokenEventListenerMock.cs │ └── EventManagerTests.cs ├── Properties │ └── AssemblyInfo.cs ├── SystemManager │ ├── BuiltinSystemsTests.cs │ └── SystemManagerTests.cs ├── TinyECSTests.csproj ├── TinyECSUnityIntegrationTests │ └── RegisterViewSystemTests.cs ├── WorldContext │ └── WorldContextTests.cs ├── app.config └── packages.config ├── TinyECSUnityIntegration ├── Impls │ ├── BaseDynamicView.cs │ ├── BaseStaticView.cs │ ├── BaseView.cs │ ├── DependencyInjector.cs │ ├── EntityObserver.cs │ ├── GameObjectFactory.cs │ ├── RegisterViewSystem.cs │ ├── SystemManagerObserver.cs │ └── WorldContextsManager.cs ├── Interfaces │ ├── IDependencyInjector.cs │ ├── IGameObjectFactory.cs │ └── IView.cs ├── Properties │ └── AssemblyInfo.cs └── TinyECSUnityIntegration.csproj ├── TinyECSUnityIntegrationEditor ├── Inspectors │ ├── EntityObserverEditor.cs │ ├── SystemManagerObserverEditor.cs │ └── WorldContextsManagerEditor.cs ├── Properties │ └── AssemblyInfo.cs └── TinyECSUnityIntegrationEditor.csproj ├── TinyECSUnityIntegrationTests ├── .gitignore ├── Assets │ ├── Editor │ │ └── TinyECSUnityIntegrationEditor.dll │ ├── InitTestScene637339713282938596.unity │ ├── Prefabs │ │ └── TestStaticView.prefab │ ├── Scenes │ │ └── SampleScene.unity │ ├── Tests │ │ ├── DependencyInjectorTests.cs │ │ ├── StaticViewsTests.cs │ │ ├── TestController.cs │ │ ├── TestStaticView.cs │ │ └── Tests.asmdef │ └── TinyECS │ │ ├── TinyECS.dll │ │ └── TinyECSUnityIntegration.dll └── ProjectSettings │ ├── AudioManager.asset │ ├── ClusterInputManager.asset │ ├── DynamicsManager.asset │ ├── EditorBuildSettings.asset │ ├── EditorSettings.asset │ ├── GraphicsSettings.asset │ ├── InputManager.asset │ ├── NavMeshAreas.asset │ ├── NetworkManager.asset │ ├── Physics2DSettings.asset │ ├── PresetManager.asset │ ├── ProjectSettings.asset │ ├── ProjectVersion.txt │ ├── QualitySettings.asset │ ├── TagManager.asset │ ├── TimeManager.asset │ ├── UnityConnectSettings.asset │ ├── VFXManager.asset │ └── XRSettings.asset └── appveyor.yml /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | #### Bug report 2 | 3 | #### Environment 4 | 5 | * Platform 6 | 7 | * Compiler 8 | 9 | * Hardware 10 | 11 | * etc... 12 | 13 | #### Steps to reproduce the issue 14 | 15 | 16 | #### What's the expected result? 17 | 18 | - 19 | 20 | #### What's the actual result? 21 | 22 | - 23 | 24 | #### Additional details / screenshot 25 | 26 | - ![Screenshot]() 27 | 28 | - -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Foreword 2 | 3 | First of all, thank you for you patience and attention for this project. We glad to see any new developer here. Hope that you've found out the project is useful for you. So if you want to contribute and support it, please, read this guide first before your hands get dirty. 4 | 5 | As I wrote above we glad to work with any developer with different skills level. If you have no enough experience in C# development you can work on documentation (e.g. write tutorials), write bug reports, etc. **good first issue** label in Issues tab will be the best entry point for all newcomers. 6 | 7 | ## Typical workflow 8 | 9 | *** 10 | 11 | * Design a feature. 12 | 13 | * Decompose it into a list of tasks. 14 | 15 | * Write code. 16 | 17 | * Cover written code with bunch of unit tests 18 | 19 | * Commit the result to the repository of the project. 20 | 21 | When we decide that the feature is ready for integration into the main build we firstly merge it into test-build. After successfull build of the branch later it can be merged into master. Usually master branch contains only final releases of the project. 22 | 23 | ## Styleguides 24 | 25 | *** 26 | 27 | ### Git commit messages styleguide 28 | 29 | In the project we try to stick to notation which was described at [this](https://chris.beams.io/posts/git-commit/) great article. 30 | 31 | We also use some kind of notation for names of branches. All branches that introduce a new feature should start from _**feature/branch-name**_. The following rules are used for other types of branches: 32 | 33 | * _**fix/branch-name**_ - fix some issue. 34 | 35 | * _**refactoring[/branch-name]**_ - the code in this branch refactors, optimize some part of the project. 36 | 37 | * _**test-build**_ - before the changes all the developers have introduced will appear in **master** branch they should be tested. We use this branch for this purpose. 38 | 39 | ### C\# Styleguide 40 | 41 | * Be sure you use 4 spaces for indentation. 42 | 43 | * All interfaces names should start from **I** prefix (e.g. **IManager**). Classes don't need any prefix (e.g. **Manager**). Structures identifiers starts from **T** prefix (e.g. **TVector2**). Names of classes, interfaces and structures should stick to camel case (e.g. **ComplexNameOfSomeClass**). 44 | 45 | * Enumerations' names start from **E_** prefix and stick to snake case. For instance, **E_MESSAGE_TYPE**. 46 | 47 | * Names of global variables and constants should start from Upper case, for instance **SingletonInstance**. 48 | 49 | * All local variables should start from lower case (**someLocalVariable**). Be sure choose some proper and clear names for them. But remember there is no special notation for names except described above. 50 | 51 | * Members of classes should start from *m* prefix (e.g. "mIsEnabled") including static variables. All public methods names should start from Upper case and stick to camel case. Protected and private methods start from **_** prefix (e.g. **_somePrivateMethod**). The same rules are applicable for properties both public, private (protected). Names of public events start from **On** prefix. **Is** prefix are appreciated for methods that are logical predicates that tell to a user whether some variable is true or false. 52 | 53 | * Stick to Allman style of indentation. For instance 54 | ```csharp 55 | //... 56 | while (true) 57 | { 58 | DoSomething1(); 59 | //... 60 | DoSomething2(); 61 | } 62 | //... 63 | ``` 64 | * Single-statement block should be wrapped in braces too. Also add extra space after operators like **if**, **for**, **switch** and etc. The extra space isn't used in case of method's invocation. 65 | ```csharp 66 | // Wrong (DoSomething() call should be wrapped with braces) 67 | while (true) 68 | DoSomething(); 69 | 70 | // Wrong (needs extra space after while) 71 | while(true) 72 | { 73 | DoSomething(); 74 | } 75 | 76 | // Wrong (function call doesn't need extra space) 77 | while (true) 78 | { 79 | DoSomething (); 80 | } 81 | 82 | // Right! 83 | while (true) 84 | { 85 | DoSomething(); 86 | } 87 | ``` 88 | 89 | These are the main rules of the notation that's used within the project. Hope that nothing important wasn't missed) If you have some questions that aren't mentioned here either write [e-mail](mailto:ildar2571@yandex.ru) or send message into our [gitter](https://gitter.im/bnoazx005/TinyECS). -------------------------------------------------------------------------------- /Deps/Unity/UnityEditor.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bnoazx005/TinyECS/e37e5e07a1871471ef3b7020791f53b6ec5041bc/Deps/Unity/UnityEditor.dll -------------------------------------------------------------------------------- /Deps/Unity/UnityEngine.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bnoazx005/TinyECS/e37e5e07a1871471ef3b7020791f53b6ec5041bc/Deps/Unity/UnityEngine.dll -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![TinyECS](https://i.imgur.com/gLWNmrM.png) 2 | 3 | [![Release](https://img.shields.io/github/release/bnoazx005/TinyECS.svg)](https://github.com/bnoazx005/TinyECS/releases/latest) 4 | [![Build status](https://ci.appveyor.com/api/projects/status/5a0gh17yl6gsva9m?svg=true)](https://ci.appveyor.com/project/bnoazx005/tinyecs) 5 | [![Coverage Status](https://coveralls.io/repos/github/bnoazx005/TinyECS/badge.svg?branch=master)](https://coveralls.io/github/bnoazx005/TinyECS?branch=master) 6 | [![Gitter](https://badges.gitter.im/bnoazx005/TinyECS.svg)](https://gitter.im/bnoazx005/TinyECS?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) 7 | 8 | Tiny ECS is a easy to use Entity-Component-System framework that's designed specially for Unity3D. 9 | 10 | ## Table of contents 11 | 12 | 1. ### [Features](#features) 13 | 2. ### [Requirements](#requirements) 14 | 3. ### [Installation](#installation) 15 | 4. ### [Documentation](#documentation) 16 | 5. ### [Contact](#contact) 17 | 18 | *** 19 | 20 | ### Features 21 | 22 | * Easy to use. 23 | 24 | * Designed especially for integration with Unity3D. 25 | 26 | * Zero dependencies. 27 | 28 | *** 29 | 30 | ### Requirements 31 | 32 | * Visual Studio 2017. 33 | 34 | * At least 2017.1 version of Unity3D. 35 | 36 | * The option '.NET 4.x scripting runtime version' should be enabled in the editor (From Unity3D 2018.1 and newer **"ProjectSettings/Player/Other Settings"**). 37 | 38 | *** 39 | 40 | ### Installation 41 | 42 | To start to use the library just copy its *.dll and *.pdb files somewhere into **Assets/** directory of your Unity3D's project. 43 | 44 | **NOTE.** Also don't forget to specify path to UnityEngine.dll file before the building of the library. 45 | 46 | *** 47 | 48 | ### Documentation 49 | 50 | The project's documentation can be found [here](https://github.com/bnoazx005/TinyECS/wiki). You will find a bunch of tutorials there to understand how to use TinyECS library. 51 | 52 | *** 53 | 54 | ### Contact 55 | 56 | e-mail: ildar.kasimov94@gmail.com 57 | 58 | Pull requests are appreciated ! -------------------------------------------------------------------------------- /Samples/SandboxProject/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Samples/SandboxProject/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using TinyECS.Impls; 4 | using TinyECS.Interfaces; 5 | 6 | 7 | namespace SandboxProject 8 | { 9 | public class Program 10 | { 11 | public struct TestComponent: IComponent { } 12 | public struct AnotherComponent: IComponent { } 13 | 14 | public static void Main(string[] args) 15 | { 16 | IWorldContext worldContext = new WorldContextFactory().CreateNewWorldInstance(); 17 | 18 | ISystemManager systemManager = new SystemManager(worldContext); 19 | 20 | systemManager.RegisterSystem(new PureInitSystemAdapter(worldContext, (world) => 21 | { 22 | // worldContext's variable is available here 23 | Console.WriteLine("call Init()"); 24 | 25 | var e = worldContext.GetEntityById(worldContext.CreateEntity()); 26 | 27 | e.AddComponent(); 28 | })); 29 | 30 | systemManager.RegisterSystem(new PureUpdateSystemAdapter(worldContext, (world, dt) => 31 | { 32 | var entitiesArray = worldContext.GetEntitiesWithAll(typeof(TestComponent)); 33 | 34 | // worldContext's variable is available here 35 | Console.WriteLine("call Update(float)"); 36 | 37 | })); 38 | 39 | systemManager.RegisterSystem(new PureReactiveSystemAdapter(worldContext, entity => 40 | { 41 | return entity.HasComponent(); 42 | } 43 | , (world, entities, dt) => 44 | { 45 | worldContext.CreateDisposableEntity("TestDisposableEntity"); 46 | // worldContext's variable is available here 47 | Console.WriteLine("call ReactiveUpdate(entities, float)"); 48 | })); 49 | 50 | systemManager.Init(); 51 | 52 | for (int i = 0; i < 5; ++i) 53 | { 54 | IEntity entity = worldContext.GetEntityById(worldContext.CreateEntity()); 55 | Debug.Assert(entity != null); 56 | 57 | entity.AddComponent(); 58 | } 59 | 60 | worldContext.GetEntityById(worldContext.CreateEntity()).AddComponent(); 61 | 62 | for (int i = 0; i < 10; ++i) 63 | { 64 | systemManager.Update(0.0f); 65 | } 66 | 67 | Console.WriteLine("Finished"); 68 | Console.ReadKey(); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Samples/SandboxProject/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SandboxProject")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("SandboxProject")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("c2f4c946-e6a2-4ed6-beb8-ac6eb56d411f")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Samples/SandboxProject/SandboxProject.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {C2F4C946-E6A2-4ED6-BEB8-AC6EB56D411F} 8 | Exe 9 | SandboxProject 10 | SandboxProject 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | {5f068059-fcfc-4a07-8430-c58431b39795} 51 | TinyECS 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /Samples/TinyECSUnity3DTemplate/.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]uild/ 5 | [Bb]uilds/ 6 | [Ll]ogs/ 7 | 8 | # Visual Studio cache directory 9 | .vs/ 10 | 11 | # Gradle cache directory 12 | .gradle/ 13 | 14 | # Autogenerated VS/MD/Consulo solution and project files 15 | ExportedObj/ 16 | .consulo/ 17 | *.csproj 18 | *.unityproj 19 | *.sln 20 | *.suo 21 | *.tmp 22 | *.user 23 | *.userprefs 24 | *.pidb 25 | *.booproj 26 | *.svd 27 | *.pdb 28 | *.mdb 29 | *.opendb 30 | *.VC.db 31 | 32 | # Unity3D generated meta files 33 | *.pidb.meta 34 | *.pdb.meta 35 | *.mdb.meta 36 | 37 | # Unity3D generated file on crash reports 38 | sysinfo.txt 39 | 40 | # Builds 41 | *.apk 42 | *.unitypackage 43 | 44 | # Crashlytics generated file 45 | crashlytics-build.properties 46 | 47 | TODO -------------------------------------------------------------------------------- /Samples/TinyECSUnity3DTemplate/Assets/Editor/TinyECSUnityIntegrationEditor.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bnoazx005/TinyECS/e37e5e07a1871471ef3b7020791f53b6ec5041bc/Samples/TinyECSUnity3DTemplate/Assets/Editor/TinyECSUnityIntegrationEditor.dll -------------------------------------------------------------------------------- /Samples/TinyECSUnity3DTemplate/Assets/Plugins/TinyECS/TinyECS.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bnoazx005/TinyECS/e37e5e07a1871471ef3b7020791f53b6ec5041bc/Samples/TinyECSUnity3DTemplate/Assets/Plugins/TinyECS/TinyECS.dll -------------------------------------------------------------------------------- /Samples/TinyECSUnity3DTemplate/Assets/Plugins/TinyECS/TinyECSUnityIntegration.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bnoazx005/TinyECS/e37e5e07a1871471ef3b7020791f53b6ec5041bc/Samples/TinyECSUnity3DTemplate/Assets/Plugins/TinyECS/TinyECSUnityIntegration.dll -------------------------------------------------------------------------------- /Samples/TinyECSUnity3DTemplate/Assets/Scripts/Controller.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using TinyECS.Impls; 3 | using TinyECS.Interfaces; 4 | using TinyECSUnityIntegration.Impls; 5 | 6 | 7 | public class Controller: MonoBehaviour 8 | { 9 | protected IWorldContext mWorldContext; 10 | 11 | protected ISystemManager mSystemManager; 12 | 13 | private void Awake() 14 | { 15 | mWorldContext = new WorldContextFactory().CreateNewWorldInstance(); 16 | 17 | mSystemManager = new SystemManager(mWorldContext); 18 | 19 | WorldContextsManagerUtils.CreateWorldContextManager(mWorldContext, "WorldContextManager_System"); 20 | SystemManagerObserverUtils.CreateSystemManagerObserver(mSystemManager, "SystemManagerObserver_System"); 21 | 22 | mSystemManager.Init(); 23 | } 24 | 25 | private void Update() 26 | { 27 | mSystemManager.Update(Time.deltaTime); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Samples/TinyECSUnity3DTemplate/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | m_Volume: 1 7 | Rolloff Scale: 1 8 | Doppler Factor: 1 9 | Default Speaker Mode: 2 10 | m_SampleRate: 0 11 | m_DSPBufferSize: 1024 12 | m_VirtualVoiceCount: 512 13 | m_RealVoiceCount: 32 14 | m_SpatializerPlugin: 15 | m_AmbisonicDecoderPlugin: 16 | m_DisableAudio: 0 17 | m_VirtualizeEffects: 1 18 | -------------------------------------------------------------------------------- /Samples/TinyECSUnity3DTemplate/ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /Samples/TinyECSUnity3DTemplate/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 8 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 0 23 | m_ReuseCollisionCallbacks: 1 24 | m_ClothInterCollisionSettingsToggle: 0 25 | m_ContactPairsMode: 0 26 | m_BroadphaseType: 0 27 | m_WorldBounds: 28 | m_Center: {x: 0, y: 0, z: 0} 29 | m_Extent: {x: 250, y: 250, z: 250} 30 | m_WorldSubdivisions: 8 31 | -------------------------------------------------------------------------------- /Samples/TinyECSUnity3DTemplate/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: 8 | - enabled: 1 9 | path: Assets/Scenes/SampleScene.unity 10 | guid: 99c9720ab356a0642a771bea13969a05 11 | m_configObjects: {} 12 | -------------------------------------------------------------------------------- /Samples/TinyECSUnity3DTemplate/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 7 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_LineEndingsForNewScripts: 2 10 | m_DefaultBehaviorMode: 0 11 | m_SpritePackerMode: 0 12 | m_SpritePackerPaddingPower: 1 13 | m_EtcTextureCompressorBehavior: 1 14 | m_EtcTextureFastCompressor: 1 15 | m_EtcTextureNormalCompressor: 2 16 | m_EtcTextureBestCompressor: 4 17 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd 18 | m_ProjectGenerationRootNamespace: 19 | m_UserGeneratedProjectSuffix: 20 | m_CollabEditorSettings: 21 | inProgressEnabled: 1 22 | -------------------------------------------------------------------------------- /Samples/TinyECSUnity3DTemplate/ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 12 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 38 | - {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0} 39 | m_PreloadedShaders: [] 40 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 41 | type: 0} 42 | m_CustomRenderPipeline: {fileID: 0} 43 | m_TransparencySortMode: 0 44 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 45 | m_DefaultRenderingPath: 1 46 | m_DefaultMobileRenderingPath: 1 47 | m_TierSettings: [] 48 | m_LightmapStripping: 0 49 | m_FogStripping: 0 50 | m_InstancingStripping: 0 51 | m_LightmapKeepPlain: 1 52 | m_LightmapKeepDirCombined: 1 53 | m_LightmapKeepDynamicPlain: 1 54 | m_LightmapKeepDynamicDirCombined: 1 55 | m_LightmapKeepShadowMask: 1 56 | m_LightmapKeepSubtractive: 1 57 | m_FogKeepLinear: 1 58 | m_FogKeepExp: 1 59 | m_FogKeepExp2: 1 60 | m_AlbedoSwatchInfos: [] 61 | m_LightsUseLinearIntensity: 0 62 | m_LightsUseColorTemperature: 0 63 | -------------------------------------------------------------------------------- /Samples/TinyECSUnity3DTemplate/ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /Samples/TinyECSUnity3DTemplate/ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /Samples/TinyECSUnity3DTemplate/ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_AutoSimulation: 1 23 | m_QueriesHitTriggers: 1 24 | m_QueriesStartInColliders: 1 25 | m_ChangeStopsCallbacks: 0 26 | m_CallbacksOnDisable: 1 27 | m_ReuseCollisionCallbacks: 1 28 | m_AutoSyncTransforms: 0 29 | m_AlwaysShowColliders: 0 30 | m_ShowColliderSleep: 1 31 | m_ShowColliderContacts: 0 32 | m_ShowColliderAABB: 0 33 | m_ContactArrowScale: 0.2 34 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 35 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 36 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 37 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 38 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 39 | -------------------------------------------------------------------------------- /Samples/TinyECSUnity3DTemplate/ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | m_DefaultList: 7 | - type: 8 | m_NativeTypeID: 108 9 | m_ManagedTypePPtr: {fileID: 0} 10 | m_ManagedTypeFallback: 11 | defaultPresets: 12 | - m_Preset: {fileID: 2655988077585873504, guid: c1cf8506f04ef2c4a88b64b6c4202eea, 13 | type: 2} 14 | - type: 15 | m_NativeTypeID: 1020 16 | m_ManagedTypePPtr: {fileID: 0} 17 | m_ManagedTypeFallback: 18 | defaultPresets: 19 | - m_Preset: {fileID: 2655988077585873504, guid: 0cd792cc87e492d43b4e95b205fc5cc6, 20 | type: 2} 21 | - type: 22 | m_NativeTypeID: 1006 23 | m_ManagedTypePPtr: {fileID: 0} 24 | m_ManagedTypeFallback: 25 | defaultPresets: 26 | - m_Preset: {fileID: 2655988077585873504, guid: 7a99f8aa944efe94cb9bd74562b7d5f9, 27 | type: 2} 28 | -------------------------------------------------------------------------------- /Samples/TinyECSUnity3DTemplate/ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2018.3.0f2 2 | -------------------------------------------------------------------------------- /Samples/TinyECSUnity3DTemplate/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - PostProcessing 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /Samples/TinyECSUnity3DTemplate/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.1 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /Samples/TinyECSUnity3DTemplate/ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_TestInitMode: 0 13 | CrashReportingSettings: 14 | m_EventUrl: https://perf-events.cloud.unity3d.com 15 | m_Enabled: 0 16 | m_LogBufferSize: 10 17 | m_CaptureEditorExceptions: 1 18 | UnityPurchasingSettings: 19 | m_Enabled: 0 20 | m_TestMode: 0 21 | UnityAnalyticsSettings: 22 | m_Enabled: 0 23 | m_TestMode: 0 24 | m_InitializeOnStartup: 1 25 | UnityAdsSettings: 26 | m_Enabled: 0 27 | m_InitializeOnStartup: 1 28 | m_TestMode: 0 29 | m_IosGameId: 30 | m_AndroidGameId: 31 | m_GameIds: {} 32 | m_GameId: 33 | PerformanceReportingSettings: 34 | m_Enabled: 0 35 | -------------------------------------------------------------------------------- /Samples/TinyECSUnity3DTemplate/ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_RenderPipeSettingsPath: 10 | m_FixedTimeStep: 0.016666668 11 | m_MaxDeltaTime: 0.05 12 | -------------------------------------------------------------------------------- /Samples/Tutorial01_HelloWorld/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Samples/Tutorial01_HelloWorld/Components.cs: -------------------------------------------------------------------------------- 1 | using TinyECS.Interfaces; 2 | 3 | 4 | public struct THelloWorldComponent: IComponent 5 | { 6 | } -------------------------------------------------------------------------------- /Samples/Tutorial01_HelloWorld/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TinyECS.Impls; 3 | using TinyECS.Interfaces; 4 | 5 | 6 | namespace Tutorial01_HelloWorld 7 | { 8 | public class Program 9 | { 10 | public static void Main(string[] args) 11 | { 12 | IWorldContext worldContext = new WorldContextFactory().CreateNewWorldInstance(); 13 | 14 | ISystemManager systemManager = new SystemManager(worldContext); 15 | 16 | // register our classes that implement systems 17 | systemManager.RegisterSystem(new PrintHelloWorldSystem()); 18 | systemManager.RegisterSystem(new ReactivePrintHelloWorldSystem()); 19 | 20 | // another way of doing the same things is to use adapters and lambdas instead of classes 21 | systemManager.RegisterSystem(new PureInitSystemAdapter(worldContext, (world) => 22 | { 23 | // worldContext's variable is available here 24 | Console.WriteLine("PureInitSystem: Hello, World!"); 25 | })); 26 | 27 | systemManager.RegisterSystem(new PureReactiveSystemAdapter(worldContext, 28 | entity => entity.HasComponent(), 29 | (world, entities, dt) => 30 | { 31 | // worldContext's variable is available here 32 | Console.WriteLine("PureReactiveSystem: Hello, World!"); 33 | })); 34 | 35 | systemManager.Init(); 36 | 37 | bool isRunning = true; 38 | 39 | while (isRunning) 40 | { 41 | if (Console.ReadLine() != string.Empty) 42 | { 43 | EntityId entityId = worldContext.CreateEntity(); 44 | 45 | IEntity entity = worldContext.GetEntityById(entityId); 46 | 47 | entity.AddComponent(); 48 | 49 | isRunning = false; 50 | } 51 | 52 | systemManager.Update(0.0f); 53 | } 54 | 55 | Console.ReadKey(); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Samples/Tutorial01_HelloWorld/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Tutorial01_HelloWorld")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Tutorial01_HelloWorld")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("c64863c9-cdc4-41af-ab9e-1320a320625b")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Samples/Tutorial01_HelloWorld/Systems.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using TinyECS.Impls; 4 | using TinyECS.Interfaces; 5 | 6 | 7 | public class PrintHelloWorldSystem : IInitSystem 8 | { 9 | public void RegisterItself(ISystemManager systemManager) 10 | { 11 | systemManager?.RegisterSystem(this); 12 | } 13 | 14 | public void Init() 15 | { 16 | Console.WriteLine("PrintHelloWorldSystem: Hello, World!"); 17 | } 18 | } 19 | 20 | 21 | public class ReactivePrintHelloWorldSystem : BaseReactiveSystem 22 | { 23 | public override bool Filter(IEntity entity) 24 | { 25 | return entity.HasComponent(); 26 | } 27 | 28 | public override void Update(List entities, float deltaTime) 29 | { 30 | Console.WriteLine("ReactivePrintHelloWorldSystem: Hello, World!"); 31 | } 32 | } -------------------------------------------------------------------------------- /Samples/Tutorial01_HelloWorld/Tutorial01_HelloWorld.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {C64863C9-CDC4-41AF-AB9E-1320A320625B} 8 | Exe 9 | Tutorial01_HelloWorld 10 | Tutorial01_HelloWorld 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | {5f068059-fcfc-4a07-8430-c58431b39795} 57 | TinyECS 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]uild/ 5 | [Bb]uilds/ 6 | [Ll]ogs/ 7 | 8 | # Visual Studio cache directory 9 | .vs/ 10 | 11 | # Gradle cache directory 12 | .gradle/ 13 | 14 | # Autogenerated VS/MD/Consulo solution and project files 15 | ExportedObj/ 16 | .consulo/ 17 | *.csproj 18 | *.unityproj 19 | *.sln 20 | *.suo 21 | *.tmp 22 | *.user 23 | *.userprefs 24 | *.pidb 25 | *.booproj 26 | *.svd 27 | *.pdb 28 | *.mdb 29 | *.opendb 30 | *.VC.db 31 | 32 | # Unity3D generated meta files 33 | *.pidb.meta 34 | *.pdb.meta 35 | *.mdb.meta 36 | 37 | # Unity3D generated file on crash reports 38 | sysinfo.txt 39 | 40 | # Builds 41 | *.apk 42 | *.unitypackage 43 | 44 | # Crashlytics generated file 45 | crashlytics-build.properties 46 | 47 | TODO -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/Assets/Editor/TinyECSUnityIntegrationEditor.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bnoazx005/TinyECS/e37e5e07a1871471ef3b7020791f53b6ec5041bc/Samples/Tutorial02_TinyECSIntegrationWithUnity3D/Assets/Editor/TinyECSUnityIntegrationEditor.dll -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/Assets/Materials/StaticCubeMat0.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: StaticCubeMat0 11 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 1, g: 0, b: 0, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/Assets/Plugins/TinyECS/TinyECS.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bnoazx005/TinyECS/e37e5e07a1871471ef3b7020791f53b6ec5041bc/Samples/Tutorial02_TinyECSIntegrationWithUnity3D/Assets/Plugins/TinyECS/TinyECS.dll -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/Assets/Plugins/TinyECS/TinyECSUnityIntegration.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bnoazx005/TinyECS/e37e5e07a1871471ef3b7020791f53b6ec5041bc/Samples/Tutorial02_TinyECSIntegrationWithUnity3D/Assets/Plugins/TinyECS/TinyECSUnityIntegration.dll -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/Assets/Prefabs/Cube.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &2362603000077499499 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 77180633044416614} 12 | - component: {fileID: 1528382071689942732} 13 | - component: {fileID: 1206468390342099746} 14 | - component: {fileID: 7287063247869289204} 15 | m_Layer: 0 16 | m_Name: Cube 17 | m_TagString: Untagged 18 | m_Icon: {fileID: 0} 19 | m_NavMeshLayer: 0 20 | m_StaticEditorFlags: 0 21 | m_IsActive: 1 22 | --- !u!4 &77180633044416614 23 | Transform: 24 | m_ObjectHideFlags: 0 25 | m_CorrespondingSourceObject: {fileID: 0} 26 | m_PrefabInstance: {fileID: 0} 27 | m_PrefabAsset: {fileID: 0} 28 | m_GameObject: {fileID: 2362603000077499499} 29 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 30 | m_LocalPosition: {x: 0, y: 0, z: 0} 31 | m_LocalScale: {x: 1, y: 1, z: 1} 32 | m_Children: [] 33 | m_Father: {fileID: 0} 34 | m_RootOrder: 0 35 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 36 | --- !u!33 &1528382071689942732 37 | MeshFilter: 38 | m_ObjectHideFlags: 0 39 | m_CorrespondingSourceObject: {fileID: 0} 40 | m_PrefabInstance: {fileID: 0} 41 | m_PrefabAsset: {fileID: 0} 42 | m_GameObject: {fileID: 2362603000077499499} 43 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} 44 | --- !u!23 &1206468390342099746 45 | MeshRenderer: 46 | m_ObjectHideFlags: 0 47 | m_CorrespondingSourceObject: {fileID: 0} 48 | m_PrefabInstance: {fileID: 0} 49 | m_PrefabAsset: {fileID: 0} 50 | m_GameObject: {fileID: 2362603000077499499} 51 | m_Enabled: 1 52 | m_CastShadows: 1 53 | m_ReceiveShadows: 1 54 | m_DynamicOccludee: 1 55 | m_MotionVectors: 1 56 | m_LightProbeUsage: 1 57 | m_ReflectionProbeUsage: 1 58 | m_RenderingLayerMask: 1 59 | m_RendererPriority: 0 60 | m_Materials: 61 | - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} 62 | m_StaticBatchInfo: 63 | firstSubMesh: 0 64 | subMeshCount: 0 65 | m_StaticBatchRoot: {fileID: 0} 66 | m_ProbeAnchor: {fileID: 0} 67 | m_LightProbeVolumeOverride: {fileID: 0} 68 | m_ScaleInLightmap: 1 69 | m_PreserveUVs: 0 70 | m_IgnoreNormalsForChartDetection: 0 71 | m_ImportantGI: 0 72 | m_StitchLightmapSeams: 0 73 | m_SelectedEditorRenderState: 3 74 | m_MinimumChartSize: 4 75 | m_AutoUVMaxDistance: 0.5 76 | m_AutoUVMaxAngle: 89 77 | m_LightmapParameters: {fileID: 0} 78 | m_SortingLayerID: 0 79 | m_SortingLayer: 0 80 | m_SortingOrder: 0 81 | --- !u!65 &7287063247869289204 82 | BoxCollider: 83 | m_ObjectHideFlags: 0 84 | m_CorrespondingSourceObject: {fileID: 0} 85 | m_PrefabInstance: {fileID: 0} 86 | m_PrefabAsset: {fileID: 0} 87 | m_GameObject: {fileID: 2362603000077499499} 88 | m_Material: {fileID: 0} 89 | m_IsTrigger: 0 90 | m_Enabled: 1 91 | serializedVersion: 2 92 | m_Size: {x: 1, y: 1, z: 1} 93 | m_Center: {x: 0, y: 0, z: 0} 94 | -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/Assets/Prefabs/CubeView.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &244725410744987301 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 1692515751727476189} 12 | - component: {fileID: 8554042841673353873} 13 | - component: {fileID: 6114564728054519226} 14 | - component: {fileID: 983930230630506803} 15 | - component: {fileID: 7371199077547766967} 16 | m_Layer: 0 17 | m_Name: CubeView 18 | m_TagString: Untagged 19 | m_Icon: {fileID: 0} 20 | m_NavMeshLayer: 0 21 | m_StaticEditorFlags: 0 22 | m_IsActive: 1 23 | --- !u!4 &1692515751727476189 24 | Transform: 25 | m_ObjectHideFlags: 0 26 | m_CorrespondingSourceObject: {fileID: 0} 27 | m_PrefabInstance: {fileID: 0} 28 | m_PrefabAsset: {fileID: 0} 29 | m_GameObject: {fileID: 244725410744987301} 30 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 31 | m_LocalPosition: {x: 17.696983, y: 22.205055, z: -33.85285} 32 | m_LocalScale: {x: 1, y: 1, z: 1} 33 | m_Children: [] 34 | m_Father: {fileID: 0} 35 | m_RootOrder: 0 36 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 37 | --- !u!33 &8554042841673353873 38 | MeshFilter: 39 | m_ObjectHideFlags: 0 40 | m_CorrespondingSourceObject: {fileID: 0} 41 | m_PrefabInstance: {fileID: 0} 42 | m_PrefabAsset: {fileID: 0} 43 | m_GameObject: {fileID: 244725410744987301} 44 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} 45 | --- !u!23 &6114564728054519226 46 | MeshRenderer: 47 | m_ObjectHideFlags: 0 48 | m_CorrespondingSourceObject: {fileID: 0} 49 | m_PrefabInstance: {fileID: 0} 50 | m_PrefabAsset: {fileID: 0} 51 | m_GameObject: {fileID: 244725410744987301} 52 | m_Enabled: 1 53 | m_CastShadows: 1 54 | m_ReceiveShadows: 1 55 | m_DynamicOccludee: 1 56 | m_MotionVectors: 1 57 | m_LightProbeUsage: 1 58 | m_ReflectionProbeUsage: 1 59 | m_RenderingLayerMask: 1 60 | m_RendererPriority: 0 61 | m_Materials: 62 | - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} 63 | m_StaticBatchInfo: 64 | firstSubMesh: 0 65 | subMeshCount: 0 66 | m_StaticBatchRoot: {fileID: 0} 67 | m_ProbeAnchor: {fileID: 0} 68 | m_LightProbeVolumeOverride: {fileID: 0} 69 | m_ScaleInLightmap: 1 70 | m_PreserveUVs: 0 71 | m_IgnoreNormalsForChartDetection: 0 72 | m_ImportantGI: 0 73 | m_StitchLightmapSeams: 0 74 | m_SelectedEditorRenderState: 3 75 | m_MinimumChartSize: 4 76 | m_AutoUVMaxDistance: 0.5 77 | m_AutoUVMaxAngle: 89 78 | m_LightmapParameters: {fileID: 0} 79 | m_SortingLayerID: 0 80 | m_SortingLayer: 0 81 | m_SortingOrder: 0 82 | --- !u!65 &983930230630506803 83 | BoxCollider: 84 | m_ObjectHideFlags: 0 85 | m_CorrespondingSourceObject: {fileID: 0} 86 | m_PrefabInstance: {fileID: 0} 87 | m_PrefabAsset: {fileID: 0} 88 | m_GameObject: {fileID: 244725410744987301} 89 | m_Material: {fileID: 0} 90 | m_IsTrigger: 0 91 | m_Enabled: 1 92 | serializedVersion: 2 93 | m_Size: {x: 1, y: 1, z: 1} 94 | m_Center: {x: 0, y: 0, z: 0} 95 | --- !u!114 &7371199077547766967 96 | MonoBehaviour: 97 | m_ObjectHideFlags: 0 98 | m_CorrespondingSourceObject: {fileID: 0} 99 | m_PrefabInstance: {fileID: 0} 100 | m_PrefabAsset: {fileID: 0} 101 | m_GameObject: {fileID: 244725410744987301} 102 | m_Enabled: 1 103 | m_EditorHideFlags: 0 104 | m_Script: {fileID: 11500000, guid: 4db516923d66bc84dbd36946d22c83d1, type: 3} 105 | m_Name: 106 | m_EditorClassIdentifier: 107 | -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/Assets/Prefabs/StaticCubeView.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &9119247876856425973 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 8865727207368875561} 12 | - component: {fileID: 2927861261307409961} 13 | - component: {fileID: 5727730167446580845} 14 | - component: {fileID: 3000802993724931791} 15 | - component: {fileID: 3013655656203183819} 16 | - component: {fileID: 2418339348558047595} 17 | m_Layer: 0 18 | m_Name: StaticCubeView 19 | m_TagString: Untagged 20 | m_Icon: {fileID: 0} 21 | m_NavMeshLayer: 0 22 | m_StaticEditorFlags: 0 23 | m_IsActive: 1 24 | --- !u!4 &8865727207368875561 25 | Transform: 26 | m_ObjectHideFlags: 0 27 | m_CorrespondingSourceObject: {fileID: 0} 28 | m_PrefabInstance: {fileID: 0} 29 | m_PrefabAsset: {fileID: 0} 30 | m_GameObject: {fileID: 9119247876856425973} 31 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 32 | m_LocalPosition: {x: 0, y: 0, z: 0} 33 | m_LocalScale: {x: 1, y: 1, z: 1} 34 | m_Children: [] 35 | m_Father: {fileID: 0} 36 | m_RootOrder: 0 37 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 38 | --- !u!33 &2927861261307409961 39 | MeshFilter: 40 | m_ObjectHideFlags: 0 41 | m_CorrespondingSourceObject: {fileID: 0} 42 | m_PrefabInstance: {fileID: 0} 43 | m_PrefabAsset: {fileID: 0} 44 | m_GameObject: {fileID: 9119247876856425973} 45 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} 46 | --- !u!23 &5727730167446580845 47 | MeshRenderer: 48 | m_ObjectHideFlags: 0 49 | m_CorrespondingSourceObject: {fileID: 0} 50 | m_PrefabInstance: {fileID: 0} 51 | m_PrefabAsset: {fileID: 0} 52 | m_GameObject: {fileID: 9119247876856425973} 53 | m_Enabled: 1 54 | m_CastShadows: 1 55 | m_ReceiveShadows: 1 56 | m_DynamicOccludee: 1 57 | m_MotionVectors: 1 58 | m_LightProbeUsage: 1 59 | m_ReflectionProbeUsage: 1 60 | m_RenderingLayerMask: 1 61 | m_RendererPriority: 0 62 | m_Materials: 63 | - {fileID: 2100000, guid: b3bf4b15624cb02448f91924286eb659, type: 2} 64 | m_StaticBatchInfo: 65 | firstSubMesh: 0 66 | subMeshCount: 0 67 | m_StaticBatchRoot: {fileID: 0} 68 | m_ProbeAnchor: {fileID: 0} 69 | m_LightProbeVolumeOverride: {fileID: 0} 70 | m_ScaleInLightmap: 1 71 | m_PreserveUVs: 0 72 | m_IgnoreNormalsForChartDetection: 0 73 | m_ImportantGI: 0 74 | m_StitchLightmapSeams: 0 75 | m_SelectedEditorRenderState: 3 76 | m_MinimumChartSize: 4 77 | m_AutoUVMaxDistance: 0.5 78 | m_AutoUVMaxAngle: 89 79 | m_LightmapParameters: {fileID: 0} 80 | m_SortingLayerID: 0 81 | m_SortingLayer: 0 82 | m_SortingOrder: 0 83 | --- !u!65 &3000802993724931791 84 | BoxCollider: 85 | m_ObjectHideFlags: 0 86 | m_CorrespondingSourceObject: {fileID: 0} 87 | m_PrefabInstance: {fileID: 0} 88 | m_PrefabAsset: {fileID: 0} 89 | m_GameObject: {fileID: 9119247876856425973} 90 | m_Material: {fileID: 0} 91 | m_IsTrigger: 0 92 | m_Enabled: 1 93 | serializedVersion: 2 94 | m_Size: {x: 1, y: 1, z: 1} 95 | m_Center: {x: 0, y: 0, z: 0} 96 | --- !u!114 &3013655656203183819 97 | MonoBehaviour: 98 | m_ObjectHideFlags: 0 99 | m_CorrespondingSourceObject: {fileID: 0} 100 | m_PrefabInstance: {fileID: 0} 101 | m_PrefabAsset: {fileID: 0} 102 | m_GameObject: {fileID: 9119247876856425973} 103 | m_Enabled: 1 104 | m_EditorHideFlags: 0 105 | m_Script: {fileID: -520381238, guid: b4a20bd5c502f89418bed874a42ef6fc, type: 3} 106 | m_Name: 107 | m_EditorClassIdentifier: 108 | --- !u!114 &2418339348558047595 109 | MonoBehaviour: 110 | m_ObjectHideFlags: 0 111 | m_CorrespondingSourceObject: {fileID: 0} 112 | m_PrefabInstance: {fileID: 0} 113 | m_PrefabAsset: {fileID: 0} 114 | m_GameObject: {fileID: 9119247876856425973} 115 | m_Enabled: 1 116 | m_EditorHideFlags: 0 117 | m_Script: {fileID: 11500000, guid: 3842938b029b7474cb19d3f87fd5e2f5, type: 3} 118 | m_Name: 119 | m_EditorClassIdentifier: 120 | -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/Assets/Scripts/Components/Components.cs: -------------------------------------------------------------------------------- 1 | using TinyECS.Interfaces; 2 | using UnityEngine; 3 | 4 | /// 5 | /// This type defines a flag-component, because it doesn't store 6 | /// some internal data 7 | /// 8 | 9 | public struct TClickComponent : IComponent 10 | { 11 | } 12 | 13 | /// 14 | /// This type contains an information about user's input. You can store 15 | /// any type of information you want. 16 | /// 17 | 18 | public struct TClickedComponent : IComponent 19 | { 20 | public Vector2 mWorldPosition; 21 | } 22 | 23 | 24 | public struct TRotatingCubeComponent: IComponent 25 | { 26 | public float mSpeed; 27 | } 28 | 29 | 30 | public struct TRotationComponent: IComponent 31 | { 32 | public Quaternion mRotation; 33 | } -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/Assets/Scripts/Controller.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using TinyECS.Impls; 3 | using TinyECS.Interfaces; 4 | using TinyECSUnityIntegration.Impls; 5 | 6 | 7 | public class Controller: MonoBehaviour 8 | { 9 | public GameObject mPrefab; 10 | 11 | protected IWorldContext mWorldContext; 12 | 13 | protected ISystemManager mSystemManager; 14 | 15 | private void Awake() 16 | { 17 | mWorldContext = new WorldContextFactory().CreateNewWorldInstance(); 18 | 19 | mSystemManager = new SystemManager(mWorldContext); 20 | 21 | WorldContextsManagerUtils.CreateWorldContextManager(mWorldContext, "WorldContextManager_System"); 22 | SystemManagerObserverUtils.CreateSystemManagerObserver(mSystemManager, "SystemManagerObserver_System"); 23 | 24 | // register our systems here 25 | mSystemManager.RegisterUpdateSystem(new InputSystem(mWorldContext, Camera.main)); 26 | mSystemManager.RegisterReactiveSystem(new ImprovedSpawnSystem(mWorldContext, mPrefab, new GameObjectFactory(mWorldContext))); 27 | mSystemManager.RegisterReactiveSystem(new RegisterViewSystem(mWorldContext)); 28 | mSystemManager.RegisterUpdateSystem(new RotatingCubesSystem(mWorldContext)); 29 | 30 | mSystemManager.Init(); 31 | } 32 | 33 | private void Update() 34 | { 35 | mSystemManager.Update(Time.deltaTime); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/Assets/Scripts/Systems/ImprovedSpawnSystem.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using TinyECS.Impls; 3 | using TinyECS.Interfaces; 4 | using TinyECSUnityIntegration.Interfaces; 5 | using UnityEngine; 6 | 7 | /// 8 | /// This class will use all the power that TinyECS provides 9 | /// 10 | 11 | public class ImprovedSpawnSystem : BaseReactiveSystem 12 | { 13 | protected IWorldContext mWorldContext; 14 | 15 | protected GameObject mPrefab; 16 | 17 | protected IGameObjectFactory mFactory; 18 | 19 | public ImprovedSpawnSystem(IWorldContext worldContext, GameObject prefab, IGameObjectFactory factory) 20 | { 21 | mWorldContext = worldContext; 22 | 23 | mPrefab = prefab; 24 | 25 | mFactory = factory; 26 | } 27 | 28 | /// 29 | /// This method filters entities that were updated by someone. If method returns true 30 | /// the entity has passed the test, otherwise it's failed and will be skipped 31 | /// 32 | /// 33 | /// 34 | 35 | public override bool Filter(IEntity entity) 36 | { 37 | return entity.HasComponent() && entity.HasComponent(); 38 | } 39 | 40 | public override void Update(List entities, float deltaTime) 41 | { 42 | for (int i = 0; i < entities.Count; ++i) 43 | { 44 | mFactory.Spawn(mPrefab, entities[i].GetComponent().mWorldPosition, 45 | Quaternion.identity, null); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/Assets/Scripts/Systems/InputSystem.cs: -------------------------------------------------------------------------------- 1 | using TinyECS.Interfaces; 2 | using UnityEngine; 3 | 4 | 5 | /// 6 | /// This is our first system which processes user's input. All systems 7 | /// which implements IUpdateSystem are executed every frame 8 | /// 9 | 10 | public class InputSystem: IUpdateSystem 11 | { 12 | protected IWorldContext mWorldContext; 13 | 14 | protected IEntity mClickInfoEntity; 15 | 16 | protected Camera mMainCamera; 17 | 18 | public InputSystem(IWorldContext worldContext, Camera mainCamera) 19 | { 20 | mWorldContext = worldContext; 21 | 22 | // We create a new entity which will be unique and store information about user's clicks 23 | // 24 | // For the sake of safety methods of the framework were designed in way when they return handles not references. 25 | // So when you need to get some it's better to seek for the instance via its handle 26 | mClickInfoEntity = mWorldContext.GetEntityById(mWorldContext.CreateEntity("ClickInfoEntity")); 27 | 28 | mClickInfoEntity.AddComponent(/* You can also set some initial values for the component here*/); 29 | 30 | mMainCamera = mainCamera; 31 | } 32 | 33 | /// 34 | /// The method is a main part of the system and it's called every frame 35 | /// 36 | /// 37 | 38 | public void Update(float deltaTime) 39 | { 40 | if (Input.GetKeyDown(KeyCode.Mouse0)) 41 | { 42 | Debug.Log(mMainCamera.ScreenToWorldPoint(Input.mousePosition)); 43 | 44 | // All later invocations of AddComponent will change the current component's value 45 | mClickInfoEntity.AddComponent(new TClickedComponent 46 | { 47 | mWorldPosition = mMainCamera.ScreenToWorldPoint(Input.mousePosition) 48 | }); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/Assets/Scripts/Systems/RotatingCubesSystem.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using TinyECS.Interfaces; 3 | using TinyECSUnityIntegration.Impls; 4 | using UnityEngine; 5 | 6 | 7 | public class RotatingCubesSystem: IUpdateSystem 8 | { 9 | protected IWorldContext mWorldContext; 10 | 11 | public RotatingCubesSystem(IWorldContext worldContext) 12 | { 13 | mWorldContext = worldContext; 14 | } 15 | 16 | public void Update(float deltaTime) 17 | { 18 | // get all entities with TRotatingCubeComponent component 19 | List entities = mWorldContext.GetEntitiesWithAll(typeof(TRotatingCubeComponent)); 20 | 21 | IEntity currEntity = null; 22 | 23 | for (int i = 0; i < entities.Count; ++i) 24 | { 25 | currEntity = mWorldContext.GetEntityById(entities[i]); 26 | 27 | // now we have two ways: strongly coupled code or use TinyECS approach 28 | // first version: 29 | /* 30 | * uncomment to test this version 31 | * 32 | TViewComponent viewComponent = currEntity.GetComponent(); 33 | 34 | TRotatingCubeComponent rotatingCubeComponent = currEntity.GetComponent(); 35 | 36 | viewComponent.mView.transform.Rotate(Vector3.up, rotatingCubeComponent.mSpeed); 37 | */ 38 | 39 | // second version (TinyECS approach) 40 | /* 41 | */ 42 | TRotatingCubeComponent rotatingCubeComponent = currEntity.GetComponent(); 43 | 44 | TRotationComponent rotationComponent = currEntity.GetComponent(); 45 | 46 | currEntity.AddComponent(new TRotationComponent { mRotation = rotationComponent.mRotation * Quaternion.Euler(0.0f, rotatingCubeComponent.mSpeed, 0.0f) }); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/Assets/Scripts/Systems/SpawnSystem.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using TinyECS.Impls; 3 | using TinyECS.Interfaces; 4 | using UnityEngine; 5 | 6 | /// 7 | /// This class is a type of a reactive system. 8 | /// Reactive systems are executed when something within world's context has changed 9 | /// and this update passes system's filter 10 | /// 11 | 12 | public class SpawnSystem : BaseReactiveSystem 13 | { 14 | protected IWorldContext mWorldContext; 15 | 16 | protected GameObject mPrefab; 17 | 18 | public SpawnSystem(IWorldContext worldContext, GameObject prefab) 19 | { 20 | mWorldContext = worldContext; 21 | 22 | mPrefab = prefab; 23 | } 24 | 25 | /// 26 | /// This method filters entities that were updated by someone. If method returns true 27 | /// the entity has passed the test, otherwise it's failed and will be skipped 28 | /// 29 | /// 30 | /// 31 | 32 | public override bool Filter(IEntity entity) 33 | { 34 | return entity.HasComponent() && entity.HasComponent(); 35 | } 36 | 37 | public override void Update(List entities, float deltaTime) 38 | { 39 | for (int i = 0; i < entities.Count; ++i) 40 | { 41 | GameObject.Instantiate(mPrefab, entities[i].GetComponent().mWorldPosition, 42 | Quaternion.identity, null); 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/Assets/Scripts/Views/CubeView.cs: -------------------------------------------------------------------------------- 1 | using TinyECS.Impls; 2 | using TinyECS.Interfaces; 3 | using TinyECSUnityIntegration.Impls; 4 | 5 | 6 | public class CubeView : BaseDynamicView, IEventListener> 7 | { 8 | public override void RegisterSubscriptions(IEventManager eventManager, uint entityId) 9 | { 10 | IEntity linkedEntity = mWorldContext.GetEntityById(entityId); 11 | 12 | linkedEntity.AddComponent(new TRotatingCubeComponent { mSpeed = 5.0f }); 13 | linkedEntity.AddComponent(new TRotationComponent { mRotation = transform.rotation }); 14 | 15 | eventManager.Subscribe>(this); 16 | } 17 | 18 | public void OnEvent(TComponentChangedEvent eventData) 19 | { 20 | transform.rotation = eventData.mValue.mRotation; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/Assets/Scripts/Views/StaticCubeView.cs: -------------------------------------------------------------------------------- 1 | using TinyECS.Impls; 2 | using TinyECS.Interfaces; 3 | using TinyECSUnityIntegration.Impls; 4 | using UnityEngine; 5 | 6 | 7 | public class StaticCubeView: BaseStaticView, IEventListener> 8 | { 9 | public override void RegisterSubscriptions(IEventManager eventManager, uint entityId) 10 | { 11 | IEntity linkedEntity = mWorldContext.GetEntityById(entityId); 12 | 13 | linkedEntity.AddComponent(new TRotatingCubeComponent { mSpeed = 5.0f }); 14 | linkedEntity.AddComponent(new TRotationComponent { mRotation = transform.rotation }); 15 | 16 | eventManager.Subscribe>(this); 17 | } 18 | 19 | public void OnEvent(TComponentChangedEvent eventData) 20 | { 21 | transform.rotation = eventData.mValue.mRotation; 22 | } 23 | } -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | m_Volume: 1 7 | Rolloff Scale: 1 8 | Doppler Factor: 1 9 | Default Speaker Mode: 2 10 | m_SampleRate: 0 11 | m_DSPBufferSize: 1024 12 | m_VirtualVoiceCount: 512 13 | m_RealVoiceCount: 32 14 | m_SpatializerPlugin: 15 | m_AmbisonicDecoderPlugin: 16 | m_DisableAudio: 0 17 | m_VirtualizeEffects: 1 18 | -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 8 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 0 23 | m_ReuseCollisionCallbacks: 1 24 | m_ClothInterCollisionSettingsToggle: 0 25 | m_ContactPairsMode: 0 26 | m_BroadphaseType: 0 27 | m_WorldBounds: 28 | m_Center: {x: 0, y: 0, z: 0} 29 | m_Extent: {x: 250, y: 250, z: 250} 30 | m_WorldSubdivisions: 8 31 | -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: 8 | - enabled: 1 9 | path: Assets/Scenes/SampleScene.unity 10 | guid: 99c9720ab356a0642a771bea13969a05 11 | m_configObjects: {} 12 | -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 7 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_LineEndingsForNewScripts: 2 10 | m_DefaultBehaviorMode: 0 11 | m_SpritePackerMode: 0 12 | m_SpritePackerPaddingPower: 1 13 | m_EtcTextureCompressorBehavior: 1 14 | m_EtcTextureFastCompressor: 1 15 | m_EtcTextureNormalCompressor: 2 16 | m_EtcTextureBestCompressor: 4 17 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd 18 | m_ProjectGenerationRootNamespace: 19 | m_UserGeneratedProjectSuffix: 20 | m_CollabEditorSettings: 21 | inProgressEnabled: 1 22 | -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 12 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 38 | - {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0} 39 | m_PreloadedShaders: [] 40 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 41 | type: 0} 42 | m_CustomRenderPipeline: {fileID: 0} 43 | m_TransparencySortMode: 0 44 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 45 | m_DefaultRenderingPath: 1 46 | m_DefaultMobileRenderingPath: 1 47 | m_TierSettings: [] 48 | m_LightmapStripping: 0 49 | m_FogStripping: 0 50 | m_InstancingStripping: 0 51 | m_LightmapKeepPlain: 1 52 | m_LightmapKeepDirCombined: 1 53 | m_LightmapKeepDynamicPlain: 1 54 | m_LightmapKeepDynamicDirCombined: 1 55 | m_LightmapKeepShadowMask: 1 56 | m_LightmapKeepSubtractive: 1 57 | m_FogKeepLinear: 1 58 | m_FogKeepExp: 1 59 | m_FogKeepExp2: 1 60 | m_AlbedoSwatchInfos: [] 61 | m_LightsUseLinearIntensity: 0 62 | m_LightsUseColorTemperature: 0 63 | -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_AutoSimulation: 1 23 | m_QueriesHitTriggers: 1 24 | m_QueriesStartInColliders: 1 25 | m_ChangeStopsCallbacks: 0 26 | m_CallbacksOnDisable: 1 27 | m_ReuseCollisionCallbacks: 1 28 | m_AutoSyncTransforms: 0 29 | m_AlwaysShowColliders: 0 30 | m_ShowColliderSleep: 1 31 | m_ShowColliderContacts: 0 32 | m_ShowColliderAABB: 0 33 | m_ContactArrowScale: 0.2 34 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 35 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 36 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 37 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 38 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 39 | -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | m_DefaultList: 7 | - type: 8 | m_NativeTypeID: 108 9 | m_ManagedTypePPtr: {fileID: 0} 10 | m_ManagedTypeFallback: 11 | defaultPresets: 12 | - m_Preset: {fileID: 2655988077585873504, guid: c1cf8506f04ef2c4a88b64b6c4202eea, 13 | type: 2} 14 | - type: 15 | m_NativeTypeID: 1020 16 | m_ManagedTypePPtr: {fileID: 0} 17 | m_ManagedTypeFallback: 18 | defaultPresets: 19 | - m_Preset: {fileID: 2655988077585873504, guid: 0cd792cc87e492d43b4e95b205fc5cc6, 20 | type: 2} 21 | - type: 22 | m_NativeTypeID: 1006 23 | m_ManagedTypePPtr: {fileID: 0} 24 | m_ManagedTypeFallback: 25 | defaultPresets: 26 | - m_Preset: {fileID: 2655988077585873504, guid: 7a99f8aa944efe94cb9bd74562b7d5f9, 27 | type: 2} 28 | -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2018.3.0f2 2 | -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - PostProcessing 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.1 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_TestInitMode: 0 13 | CrashReportingSettings: 14 | m_EventUrl: https://perf-events.cloud.unity3d.com 15 | m_Enabled: 0 16 | m_LogBufferSize: 10 17 | m_CaptureEditorExceptions: 1 18 | UnityPurchasingSettings: 19 | m_Enabled: 0 20 | m_TestMode: 0 21 | UnityAnalyticsSettings: 22 | m_Enabled: 0 23 | m_TestMode: 0 24 | m_InitializeOnStartup: 1 25 | UnityAdsSettings: 26 | m_Enabled: 0 27 | m_InitializeOnStartup: 1 28 | m_TestMode: 0 29 | m_IosGameId: 30 | m_AndroidGameId: 31 | m_GameIds: {} 32 | m_GameId: 33 | PerformanceReportingSettings: 34 | m_Enabled: 0 35 | -------------------------------------------------------------------------------- /Samples/Tutorial02_TinyECSIntegrationWithUnity3D/ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_RenderPipeSettingsPath: 10 | m_FixedTimeStep: 0.016666668 11 | m_MaxDeltaTime: 0.05 12 | -------------------------------------------------------------------------------- /TinyECS.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.421 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TinyECS", "TinyECS\TinyECS.csproj", "{5F068059-FCFC-4A07-8430-C58431B39795}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TinyECSTests", "TinyECSTests\TinyECSTests.csproj", "{41C5CFFE-D320-4D54-9F8A-167E08EB9B84}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{208A6D50-AA5A-48E0-B21C-A64A6983020B}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SandboxProject", "Samples\SandboxProject\SandboxProject.csproj", "{C2F4C946-E6A2-4ED6-BEB8-AC6EB56D411F}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tutorial01_HelloWorld", "Samples\Tutorial01_HelloWorld\Tutorial01_HelloWorld.csproj", "{C64863C9-CDC4-41AF-AB9E-1320A320625B}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TinyECSUnityIntegration", "TinyECSUnityIntegration\TinyECSUnityIntegration.csproj", "{7FF156DA-3333-49B6-B082-FF86B458724E}" 17 | EndProject 18 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TinyECSUnityIntegrationEditor", "TinyECSUnityIntegrationEditor\TinyECSUnityIntegrationEditor.csproj", "{CA57669C-A319-4473-A6C6-02829BBD749D}" 19 | EndProject 20 | Global 21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 22 | Debug|Any CPU = Debug|Any CPU 23 | Release|Any CPU = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 26 | {5F068059-FCFC-4A07-8430-C58431B39795}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {5F068059-FCFC-4A07-8430-C58431B39795}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {5F068059-FCFC-4A07-8430-C58431B39795}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {5F068059-FCFC-4A07-8430-C58431B39795}.Release|Any CPU.Build.0 = Release|Any CPU 30 | {41C5CFFE-D320-4D54-9F8A-167E08EB9B84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 31 | {41C5CFFE-D320-4D54-9F8A-167E08EB9B84}.Debug|Any CPU.Build.0 = Debug|Any CPU 32 | {41C5CFFE-D320-4D54-9F8A-167E08EB9B84}.Release|Any CPU.ActiveCfg = Release|Any CPU 33 | {41C5CFFE-D320-4D54-9F8A-167E08EB9B84}.Release|Any CPU.Build.0 = Release|Any CPU 34 | {C2F4C946-E6A2-4ED6-BEB8-AC6EB56D411F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 35 | {C2F4C946-E6A2-4ED6-BEB8-AC6EB56D411F}.Debug|Any CPU.Build.0 = Debug|Any CPU 36 | {C2F4C946-E6A2-4ED6-BEB8-AC6EB56D411F}.Release|Any CPU.ActiveCfg = Release|Any CPU 37 | {C2F4C946-E6A2-4ED6-BEB8-AC6EB56D411F}.Release|Any CPU.Build.0 = Release|Any CPU 38 | {C64863C9-CDC4-41AF-AB9E-1320A320625B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 39 | {C64863C9-CDC4-41AF-AB9E-1320A320625B}.Debug|Any CPU.Build.0 = Debug|Any CPU 40 | {C64863C9-CDC4-41AF-AB9E-1320A320625B}.Release|Any CPU.ActiveCfg = Release|Any CPU 41 | {C64863C9-CDC4-41AF-AB9E-1320A320625B}.Release|Any CPU.Build.0 = Release|Any CPU 42 | {7FF156DA-3333-49B6-B082-FF86B458724E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 43 | {7FF156DA-3333-49B6-B082-FF86B458724E}.Debug|Any CPU.Build.0 = Debug|Any CPU 44 | {7FF156DA-3333-49B6-B082-FF86B458724E}.Release|Any CPU.ActiveCfg = Release|Any CPU 45 | {7FF156DA-3333-49B6-B082-FF86B458724E}.Release|Any CPU.Build.0 = Release|Any CPU 46 | {CA57669C-A319-4473-A6C6-02829BBD749D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 47 | {CA57669C-A319-4473-A6C6-02829BBD749D}.Debug|Any CPU.Build.0 = Debug|Any CPU 48 | {CA57669C-A319-4473-A6C6-02829BBD749D}.Release|Any CPU.ActiveCfg = Release|Any CPU 49 | {CA57669C-A319-4473-A6C6-02829BBD749D}.Release|Any CPU.Build.0 = Release|Any CPU 50 | EndGlobalSection 51 | GlobalSection(SolutionProperties) = preSolution 52 | HideSolutionNode = FALSE 53 | EndGlobalSection 54 | GlobalSection(NestedProjects) = preSolution 55 | {C2F4C946-E6A2-4ED6-BEB8-AC6EB56D411F} = {208A6D50-AA5A-48E0-B21C-A64A6983020B} 56 | {C64863C9-CDC4-41AF-AB9E-1320A320625B} = {208A6D50-AA5A-48E0-B21C-A64A6983020B} 57 | EndGlobalSection 58 | GlobalSection(ExtensibilityGlobals) = postSolution 59 | SolutionGuid = {DBEB9C11-5243-4290-88C6-A6D9420A56E1} 60 | EndGlobalSection 61 | EndGlobal 62 | -------------------------------------------------------------------------------- /TinyECS/Impls/BaseReactiveSystem.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using TinyECS.Interfaces; 3 | 4 | 5 | namespace TinyECS.Impls 6 | { 7 | /// 8 | /// abstract class BaseReactiveSystem 9 | /// 10 | /// The class is a common implementation for all reactive systems that are used within 11 | /// the framework. If you need to implement one just derive it from this class. 12 | /// 13 | 14 | public abstract class BaseReactiveSystem: IReactiveSystem 15 | { 16 | public BaseReactiveSystem() 17 | { 18 | } 19 | 20 | /// 21 | /// The method register the system within the given system manager based on the type 22 | /// 23 | /// A reference to ISystemManager implementation 24 | 25 | public void RegisterItself(ISystemManager systemManager) 26 | { 27 | systemManager?.RegisterSystem(this); 28 | } 29 | 30 | /// 31 | /// The method filters input list of entities based on its internal predicate's implementation 32 | /// 33 | /// An input entity 34 | /// The method should return true to pass the entity, false in other cases 35 | 36 | public abstract bool Filter(IEntity entity); 37 | 38 | /// 39 | /// The method is called if some entity was changed and passed a filter of the system 40 | /// 41 | /// A list of entities that are passed a filter of the system 42 | /// A time which is elapsed from the previous frame 43 | 44 | public abstract void Update(List entities, float deltaTime); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /TinyECS/Impls/BuiltinComponents.cs: -------------------------------------------------------------------------------- 1 | using TinyECS.Interfaces; 2 | 3 | 4 | namespace TinyECS.Impls 5 | { 6 | /// 7 | /// struct TDisposableComponent 8 | /// 9 | /// The structure is a component-flag that makes an entity on to which it is assigned disposable one 10 | /// 11 | 12 | public struct TDisposableComponent: IComponent { } 13 | 14 | 15 | /// 16 | /// struct TEntityLifetimeComponent 17 | /// 18 | /// This structure should be used in tie with TDisposableComponent to keep entity for a few extra frames 19 | /// 20 | 21 | public struct TEntityLifetimeComponent: IComponent 22 | { 23 | public uint mCounter; ///< A number of frames to live 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /TinyECS/Impls/BuiltinSystems.cs: -------------------------------------------------------------------------------- 1 | using TinyECS.Interfaces; 2 | 3 | 4 | namespace TinyECS.Impls 5 | { 6 | /// 7 | /// static class BuiltinSystems 8 | /// 9 | /// The static class contains a bunch of builtin systems that are represented as static functions 10 | /// 11 | 12 | public static class BuiltinSystems 13 | { 14 | /// 15 | /// The system is an update one that destroys all disposable entities at an end of a frame 16 | /// 17 | /// 18 | /// 19 | 20 | public static void DisposableEntitiesCollectorSystem(IWorldContext worldContext, float dt) 21 | { 22 | var disposableEntities = worldContext.GetEntitiesWithAll(typeof(TDisposableComponent)); 23 | 24 | for (int i = 0; i < disposableEntities.Count; ++i) 25 | { 26 | IEntity currEntity = worldContext.GetEntityById(disposableEntities[i]); 27 | if (currEntity.HasComponent()) 28 | { 29 | TEntityLifetimeComponent lifetimeData = currEntity.GetComponent(); 30 | currEntity.AddComponent(new TEntityLifetimeComponent { mCounter = lifetimeData.mCounter - 1 }); 31 | 32 | if (lifetimeData.mCounter > 0) 33 | { 34 | continue; 35 | } 36 | } 37 | 38 | worldContext.DestroyEntity(disposableEntities[i]); 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /TinyECS/Impls/Entity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TinyECS.Interfaces; 3 | 4 | 5 | namespace TinyECS.Impls 6 | { 7 | /// 8 | /// class Entity 9 | /// 10 | /// The class represents an entity. An entity is one of atomic elements of 11 | /// entity-component-system paradigm. The class is used to simplify an access 12 | /// to components of an entity, but actually it's just an integer not a container 13 | /// 14 | 15 | public class Entity: IEntity 16 | { 17 | protected EntityId mId; 18 | 19 | protected string mName; 20 | 21 | protected IEntityManager mEntityManager; 22 | 23 | /// 24 | /// The main constructor with parameters 25 | /// 26 | /// A reference to IEntityManager's implementation 27 | /// An identifier of a entity (unique) 28 | /// A name of an entity (two or more entities can have same name) 29 | 30 | public Entity(IEntityManager entityManager, EntityId id, string name = null) 31 | { 32 | mEntityManager = entityManager ?? throw new ArgumentNullException("entityManager"); 33 | 34 | mId = id; 35 | 36 | mName = name; 37 | } 38 | 39 | /// 40 | /// The default constructor is prohibited 41 | /// 42 | 43 | protected Entity() 44 | { 45 | } 46 | 47 | /// 48 | /// The method attaches a new component to the entity 49 | /// 50 | /// A type of a component that should be attached 51 | /// A type's value that is used to initialize fields of a new component 52 | 53 | public void AddComponent(T componentInitializer = default(T)) where T : struct, IComponent 54 | { 55 | mEntityManager.AddComponent(mId, componentInitializer); 56 | } 57 | 58 | /// 59 | /// The method removes a component of a specified type 60 | /// 61 | /// A type of a component that should be removed 62 | 63 | public void RemoveComponent() where T : struct, IComponent 64 | { 65 | mEntityManager.RemoveComponent(mId); 66 | } 67 | 68 | /// 69 | /// The method removes all components that are attached to the entity 70 | /// 71 | 72 | public void RemoveAllComponents() 73 | { 74 | mEntityManager.RemoveAllComponents(mId); 75 | } 76 | 77 | /// 78 | /// The method returns a component of a given type if it belongs to 79 | /// the specified entity 80 | /// 81 | /// A type of a component that should be retrieved 82 | /// The method returns a component of a given type if it belongs to 83 | /// the specified entity 84 | 85 | public T GetComponent() 86 | where T : struct, IComponent 87 | { 88 | return mEntityManager.GetComponent(mId); 89 | } 90 | 91 | /// 92 | /// The method checks up whether a given entity has specified component or not 93 | /// 94 | /// A type of a component 95 | /// The method returns true if the entity has the given component, false in other cases 96 | 97 | public bool HasComponent() 98 | where T : struct, IComponent 99 | { 100 | return mEntityManager.HasComponent(mId); 101 | } 102 | 103 | /// 104 | /// The method checks up whether a given entity has specified component or not 105 | /// 106 | /// A type of a component 107 | /// The method returns true if the entity has the given component, false in other cases 108 | 109 | public bool HasComponent(Type componentType) 110 | { 111 | return mEntityManager.HasComponent(mId, componentType); 112 | } 113 | 114 | /// 115 | /// The method creates a new iterator which provides an ability to enumerate all components of the entity 116 | /// 117 | /// The method returns a reference to IComponentIterator that implements some iterative mechanism 118 | 119 | public IComponentIterator GetComponentsIterator() 120 | { 121 | return mEntityManager.GetComponentsIterator(mId); 122 | } 123 | 124 | public override string ToString() 125 | { 126 | return $"Entity_{mId} {(mName != null ? $"({mName})" : string.Empty)}"; 127 | } 128 | 129 | /// 130 | /// The property returns an identifier of an entity 131 | /// 132 | 133 | public EntityId Id => mId; 134 | 135 | /// 136 | /// The property returns a name of an entity 137 | /// 138 | 139 | public string Name => mName; 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /TinyECS/Impls/EntityManagerExtensions.cs: -------------------------------------------------------------------------------- 1 | using TinyECS.Interfaces; 2 | 3 | 4 | namespace TinyECS.Impls 5 | { 6 | /// 7 | /// static class EntityManagerExtensions 8 | /// 9 | /// The class contains helper methods for EntityManager 10 | /// 11 | 12 | public static class EntityManagerExtensions 13 | { 14 | /// 15 | /// The method creates a new entity with the only component that's already attached to it. 16 | /// The component is TDisposableComponent. All entities that have that component are destroyed 17 | /// at an end of a frame with a special system. 18 | /// 19 | /// A reference to IEntityManager implementation 20 | /// A name of an entity (optional) 21 | /// The method returns an identifier of created entity 22 | 23 | public static EntityId CreateDisposableEntity(this IEntityManager entityManager, string name = null) 24 | { 25 | IEntity entity = entityManager.CreateEntity(name); 26 | 27 | entity.AddComponent(); 28 | 29 | return entity.Id; 30 | } 31 | 32 | /// 33 | /// The method creates a new entity with the only component that's already attached to it. 34 | /// The component is TDisposableComponent. All entities that have that component are destroyed 35 | /// at an end of a frame with a special system. 36 | /// 37 | /// A reference to IWorldContext implementation 38 | /// A name of an entity (optional) 39 | /// The method returns an identifier of created entity 40 | 41 | public static EntityId CreateDisposableEntity(this IWorldContext worldContext, string name = null) 42 | { 43 | IEntity entity = worldContext.GetEntityById(worldContext.CreateEntity(name)); 44 | 45 | entity.AddComponent(); 46 | 47 | return entity.Id; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /TinyECS/Impls/EventManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using TinyECS.Interfaces; 4 | 5 | 6 | namespace TinyECS.Impls 7 | { 8 | /// 9 | /// class EventManager 10 | /// 11 | /// The class is an implementation of internal events manager which is used to process 12 | /// reactive systems and provide a communications with Unity's GameObjects 13 | /// 14 | 15 | public class EventManager: IEventManager 16 | { 17 | protected struct TListenerEntry 18 | { 19 | public Type mEventType; 20 | 21 | public IEventListener mListener; 22 | } 23 | 24 | protected List mListeners; 25 | 26 | protected Stack mFreeEntriesRegistry; 27 | 28 | public EventManager() 29 | { 30 | mListeners = new List(); 31 | 32 | mFreeEntriesRegistry = new Stack(); 33 | } 34 | 35 | /// 36 | /// The method subscribes a listener to the manager 37 | /// 38 | /// A reference to IEventListener implementation 39 | /// A type of an event 40 | /// 41 | 42 | public uint Subscribe(IEventListener eventListener) 43 | where T : struct 44 | { 45 | if (eventListener == null) 46 | { 47 | throw new ArgumentNullException("eventListener"); 48 | } 49 | 50 | int firstFreeEntryIndex = mFreeEntriesRegistry.Count > 0 ? mFreeEntriesRegistry.Pop() : mListeners.Count; 51 | 52 | if (firstFreeEntryIndex >= mListeners.Count) 53 | { 54 | mListeners.Add(new TListenerEntry { }); 55 | } 56 | 57 | mListeners[firstFreeEntryIndex] = new TListenerEntry() 58 | { 59 | mEventType = typeof(T), 60 | mListener = eventListener 61 | }; 62 | 63 | return (uint)firstFreeEntryIndex; 64 | } 65 | 66 | /// 67 | /// The method unsubscribes specified listener with a given identifier 68 | /// 69 | /// An identifier of a listener 70 | 71 | public void Unsubscribe(uint listenerId) 72 | { 73 | if (listenerId >= mListeners.Count) 74 | { 75 | throw new ListenerDoesntExistException(listenerId); 76 | } 77 | 78 | mListeners[(int)listenerId] = new TListenerEntry() { }; 79 | 80 | mFreeEntriesRegistry.Push((int)listenerId); 81 | } 82 | 83 | /// 84 | /// The method notifies all listeners of the manager that an event of type T has occurred 85 | /// 86 | /// A type of an event 87 | /// An event's data 88 | /// An identifier of destination listener. If the value equals to uint.MaxValue 89 | /// the broadcasting will be executed 90 | 91 | public void Notify(T eventData, uint destListenerId = uint.MaxValue) 92 | where T : struct 93 | { 94 | Type currEventType = typeof(T); 95 | 96 | TListenerEntry currListenerEntry; 97 | 98 | if (destListenerId != uint.MaxValue) 99 | { 100 | if (destListenerId >= mListeners.Count) 101 | { 102 | throw new ArgumentOutOfRangeException("destListenerId"); 103 | } 104 | 105 | currListenerEntry = mListeners[(int)destListenerId]; 106 | 107 | try 108 | { 109 | if (currListenerEntry.mEventType == currEventType) 110 | { 111 | (currListenerEntry.mListener as IEventListener)?.OnEvent(eventData); 112 | } 113 | } 114 | finally 115 | { 116 | } 117 | 118 | 119 | return; 120 | } 121 | 122 | // execute broadcasting 123 | List catchedExceptions = new List(); 124 | 125 | for (int i = 0; i < mListeners.Count; ++i) 126 | { 127 | currListenerEntry = mListeners[i]; 128 | 129 | if (currListenerEntry.mEventType == null || 130 | currListenerEntry.mEventType != currEventType || 131 | currListenerEntry.mListener == null) 132 | { 133 | continue; 134 | } 135 | 136 | try 137 | { 138 | (currListenerEntry.mListener as IEventListener)?.OnEvent(eventData); 139 | } 140 | catch(Exception exception) 141 | { 142 | catchedExceptions.Add(exception); 143 | } 144 | } 145 | 146 | if (catchedExceptions.Count > 0) 147 | { 148 | throw new AggregateException(catchedExceptions); 149 | } 150 | } 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /TinyECS/Impls/Events.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TinyECS.Interfaces; 3 | 4 | 5 | namespace TinyECS.Impls 6 | { 7 | public struct TNewEntityCreatedEvent: IEvent 8 | { 9 | public EntityId mEntityId; 10 | } 11 | 12 | public struct TEntityDestroyedEvent: IEvent 13 | { 14 | public EntityId mEntityId; 15 | 16 | public string mEntityName; 17 | } 18 | 19 | public struct TNewComponentAddedEvent: IEvent 20 | { 21 | public EntityId mOwnerId; 22 | 23 | public Type mComponentType; 24 | } 25 | 26 | 27 | public struct TComponentChangedEvent: IEvent 28 | { 29 | public EntityId mOwnerId; 30 | 31 | public T mValue; 32 | } 33 | 34 | 35 | public struct TComponentRemovedEvent: IEvent 36 | { 37 | public EntityId mOwnerId; 38 | 39 | public Type mComponentType; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /TinyECS/Impls/Exceptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TinyECS.Interfaces; 3 | 4 | namespace TinyECS.Impls 5 | { 6 | /// 7 | /// class ComponentDoesntExistException 8 | /// 9 | /// The class is an exception type which occurs when someone 10 | /// tries to get a component that an entity doesn't have 11 | /// 12 | 13 | public class ComponentDoesntExistException: Exception 14 | { 15 | public ComponentDoesntExistException(Type type, EntityId entityId): 16 | base($"A component of [{type}] doesn't belong to entity with id [{(uint)entityId}]") 17 | { 18 | } 19 | } 20 | 21 | 22 | /// 23 | /// class ComponentAlreadyExistException 24 | /// 25 | /// The class is an exception type which occurs when someone 26 | /// tries to add unique component to another entity 27 | /// 28 | 29 | public class ComponentAlreadyExistException : Exception 30 | { 31 | public ComponentAlreadyExistException(Type type, EntityId entityId) : 32 | base($"A component of [{type}] already exists on entity [{(uint)entityId}]") 33 | { 34 | } 35 | } 36 | 37 | 38 | /// 39 | /// class EntityDoesntExistException 40 | /// 41 | /// The class is an exception's type which occurs when someone 42 | /// ask for an entity which doesn't exist 43 | /// 44 | 45 | public class EntityDoesntExistException: Exception 46 | { 47 | public EntityDoesntExistException(EntityId entityId): 48 | base($"An entity with the specified identifier [{(uint)entityId}] doesn't exist") 49 | { 50 | } 51 | } 52 | 53 | 54 | /// 55 | /// class InvalidIdentifierException 56 | /// 57 | /// The class is an exception's type which occurs when someone pass an invalid identifier 58 | /// as an argument 59 | /// 60 | 61 | public class InvalidIdentifierException: Exception 62 | { 63 | public InvalidIdentifierException(uint id): 64 | base($"The given identifier [{id}] is not valid") 65 | { 66 | } 67 | } 68 | 69 | 70 | /// 71 | /// class ListenerDoesntExistException 72 | /// 73 | /// The class is an exception's type which occurs when someone pass an invalid identifier as an argument 74 | /// 75 | 76 | public class ListenerDoesntExistException: Exception 77 | { 78 | public ListenerDoesntExistException(uint id) : 79 | base($"The given identifier [{id}] is not valid") 80 | { 81 | } 82 | } 83 | 84 | 85 | /// 86 | /// class InvalidIteratorException 87 | /// 88 | /// The class is an exception's type which occurs when someone tries to access to a component that doesn't exist 89 | /// 90 | 91 | public class InvalidIteratorException: Exception 92 | { 93 | public InvalidIteratorException() : 94 | base("Iterator to a particular component is invalid") 95 | { 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /TinyECS/Impls/SystemsPackage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using TinyECS.Interfaces; 4 | 5 | 6 | namespace TinyECS.Impls 7 | { 8 | public class SystemsPackage: ISystemsPackage 9 | { 10 | private ISystemManager mSystemManager = null; 11 | 12 | private List mSystems = null; 13 | 14 | private List mSystemsIds = null; 15 | 16 | private bool mIsRegistered = false; 17 | 18 | public SystemsPackage(ISystemManager systemManager, List systems) 19 | { 20 | mSystemManager = systemManager ?? throw new ArgumentNullException("systemManager"); 21 | mSystems = systems ?? throw new ArgumentNullException("systems"); 22 | } 23 | 24 | public void Register() 25 | { 26 | if (mIsRegistered) 27 | { 28 | return; 29 | } 30 | 31 | mSystemsIds = new List(); 32 | 33 | SystemId systemId = (SystemId)0x0; 34 | 35 | for (int i = 0; i < mSystems.Count; ++i) 36 | { 37 | switch (mSystems[i]) 38 | { 39 | case IInitSystem initSystem: 40 | systemId = mSystemManager.RegisterSystem(initSystem); 41 | break; 42 | case IUpdateSystem updateSystem: 43 | systemId = mSystemManager.RegisterSystem(updateSystem); 44 | break; 45 | case IReactiveSystem reactiveSystem: 46 | systemId = mSystemManager.RegisterSystem(reactiveSystem); 47 | break; 48 | } 49 | 50 | mSystemsIds.Add(systemId); 51 | } 52 | 53 | mIsRegistered = true; 54 | } 55 | 56 | public void Unregister() 57 | { 58 | if (!mIsRegistered) 59 | { 60 | return; 61 | } 62 | 63 | for (int i = 0; i < mSystemsIds.Count; ++i) 64 | { 65 | mSystemManager.UnregisterSystem(mSystemsIds[i]); 66 | } 67 | 68 | mIsRegistered = false; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /TinyECS/Impls/WorldContextFactory.cs: -------------------------------------------------------------------------------- 1 | using TinyECS.Interfaces; 2 | 3 | namespace TinyECS.Impls 4 | { 5 | /// 6 | /// class WorldContextFactory 7 | /// 8 | /// The class provides a default implementation of IWorldContext's factory which should be 9 | /// used instead of manual context's creation 10 | /// 11 | 12 | public class WorldContextFactory: IWorldContextFactory 13 | { 14 | /// 15 | /// The method creates a new instance of IWorldContext type 16 | /// 17 | /// The method returns a reference to a new instance of IWorldContext type 18 | 19 | public IWorldContext CreateNewWorldInstance() 20 | { 21 | return new WorldContext(new EntityManager(new ComponentManager(new EventManager()))); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /TinyECS/Interfaces/IComponent.cs: -------------------------------------------------------------------------------- 1 | namespace TinyECS.Interfaces 2 | { 3 | /// 4 | /// class IComponent 5 | /// 6 | /// The class describes a functionality of a component 7 | /// that can store the data 8 | /// 9 | 10 | public interface IComponent 11 | { 12 | } 13 | 14 | 15 | /// 16 | /// interface IComponent 17 | /// 18 | /// All the components that should be unique among entities should implement this one 19 | /// 20 | 21 | public interface IUniqueComponent: IComponent 22 | { 23 | } 24 | 25 | 26 | /// 27 | /// class IComponentIterator 28 | /// 29 | /// The interface describes a functionality of an iterator that enumerates all components 30 | /// of particular entity 31 | /// 32 | 33 | public interface IComponentIterator 34 | { 35 | /// 36 | /// The method returns component's value which the iterator points to 37 | /// 38 | /// A specific type to which current component will be casted 39 | /// The method returns component's value which the iterator points to 40 | 41 | T Get() where T: struct, IComponent; 42 | 43 | /// 44 | /// The method returns a reference to IComponent which the iterator points to 45 | /// 46 | /// The method returns a reference to IComponent which the iterator points to 47 | 48 | IComponent Get(); 49 | 50 | /// 51 | /// The method moves iterator to next available component if the latter exists 52 | /// 53 | /// The method returns true if there is a component at next position, false in other cases 54 | 55 | bool MoveNext(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /TinyECS/Interfaces/IComponentManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TinyECS.Interfaces 4 | { 5 | /// 6 | /// interface IComponentManager 7 | /// 8 | /// The interface describes a functionality that a component manager should 9 | /// provide to a end-user 10 | /// 11 | 12 | public interface IComponentManager 13 | { 14 | /// 15 | /// The method is used to register the given entity within the internal data structure, but 16 | /// withou actual allocating memory for components 17 | /// 18 | /// Entity's identifier 19 | 20 | void RegisterEntity(EntityId entityId); 21 | 22 | /// 23 | /// The method attaches a new component to the entity 24 | /// 25 | /// Entity's identifier 26 | /// A type's value that is used to initialize fields of a new component 27 | /// A type of a component that should be attached 28 | 29 | void AddComponent(EntityId entityId, T componentInitializer = default(T)) where T : struct, IComponent; 30 | 31 | /// 32 | /// The method returns a component of a given type if it belongs to 33 | /// the specified entity 34 | /// 35 | /// A type of a component that should be retrieved 36 | /// Entity's identifier 37 | /// The method returns a component of a given type if it belongs to 38 | /// the specified entity 39 | 40 | T GetComponent(EntityId entityId) where T : struct, IComponent; 41 | 42 | /// 43 | /// The method removes a component of a specified type 44 | /// 45 | /// Entity's identifier 46 | /// A type of a component that should be removed 47 | 48 | void RemoveComponent(EntityId entityId) where T : struct, IComponent; 49 | 50 | /// 51 | /// The method removes all components that are attached to the entity with the specified identifier 52 | /// Entity's identifier 53 | /// 54 | 55 | void RemoveAllComponents(EntityId entityId); 56 | 57 | /// 58 | /// The method checks up whether a given entity has specified component or not 59 | /// 60 | /// A type of a component 61 | /// Entity's identifier 62 | /// The method returns true if the entity has the given component, false in other cases 63 | 64 | bool HasComponent(EntityId entityId) where T : struct, IComponent; 65 | 66 | /// 67 | /// The method checks up whether a given entity has specified component or not 68 | /// 69 | /// A type of a component 70 | /// Entity's identifier 71 | /// The method returns true if the entity has the given component, false in other cases 72 | 73 | bool HasComponent(EntityId entityId, Type componentType); 74 | 75 | /// 76 | /// The method creates a new iterator which provides an ability to enumerate all components of a given entity 77 | /// 78 | /// Entity's identifier 79 | /// The method returns a reference to IComponentIterator that implements some iterative mechanism 80 | 81 | IComponentIterator GetComponentsIterator(EntityId entityId); 82 | 83 | /// 84 | /// The method returns a reference to IEventManager implementation 85 | /// 86 | 87 | IEventManager EventManager { get; } 88 | 89 | /// 90 | /// The property returns a number of all active components that are used by entities 91 | /// 92 | 93 | uint NumOfActiveComponents { get; } 94 | 95 | /// 96 | /// The property returns an average number of components per entity. The value shows up 97 | /// an average entity's complexity, the higher the value, the worse performance 98 | /// 99 | 100 | uint AverageNumOfComponentsPerEntity { get; } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /TinyECS/Interfaces/IEntity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace TinyECS.Interfaces 4 | { 5 | public struct EntityId 6 | { 7 | public static EntityId Invalid = new EntityId(uint.MaxValue); 8 | 9 | private uint mInternalID; 10 | 11 | public EntityId(uint value) 12 | { 13 | mInternalID = value; 14 | } 15 | 16 | public static explicit operator EntityId(uint id) => new EntityId(id); 17 | public static explicit operator uint(EntityId id) => id.mInternalID; 18 | 19 | public static bool operator== (EntityId left, EntityId right) => left.mInternalID == right.mInternalID; 20 | public static bool operator!= (EntityId left, EntityId right) => left.mInternalID != right.mInternalID; 21 | 22 | public override bool Equals(object obj) => mInternalID == ((EntityId)obj).mInternalID; 23 | public override int GetHashCode() => mInternalID.GetHashCode(); 24 | public override string ToString() => $"EntityId: {mInternalID}"; 25 | } 26 | 27 | 28 | /// 29 | /// interface IEntity 30 | /// 31 | /// The interface describes a functionality of an entity, which is a container 32 | /// of components. Actually it doesn't contain them 33 | /// 34 | 35 | public interface IEntity 36 | { 37 | /// 38 | /// The method attaches a new component to the entity 39 | /// 40 | /// A type of a component that should be attached 41 | /// A type's value that is used to initialize fields of a new component 42 | 43 | void AddComponent(T componentInitializer = default(T)) where T : struct, IComponent; 44 | 45 | /// 46 | /// The method removes a component of a specified type 47 | /// 48 | /// A type of a component that should be removed 49 | 50 | void RemoveComponent() where T : struct, IComponent; 51 | 52 | /// 53 | /// The method removes all components that are attached to the entity 54 | /// 55 | 56 | void RemoveAllComponents(); 57 | 58 | /// 59 | /// The method returns a component of a given type if it belongs to 60 | /// the specified entity 61 | /// 62 | /// A type of a component that should be retrieved 63 | /// The method returns a component of a given type if it belongs to 64 | /// the specified entity 65 | 66 | T GetComponent() where T : struct, IComponent; 67 | 68 | /// 69 | /// The method checks up whether a given entity has specified component or not 70 | /// 71 | /// A type of a component 72 | /// The method returns true if the entity has the given component, false in other cases 73 | 74 | bool HasComponent() where T : struct, IComponent; 75 | 76 | /// 77 | /// The method checks up whether a given entity has specified component or not 78 | /// 79 | /// A type of a component 80 | /// The method returns true if the entity has the given component, false in other cases 81 | 82 | bool HasComponent(Type componentType); 83 | 84 | /// 85 | /// The method creates a new iterator which provides an ability to enumerate all components of the entity 86 | /// 87 | /// The method returns a reference to IComponentIterator that implements some iterative mechanism 88 | 89 | IComponentIterator GetComponentsIterator(); 90 | 91 | /// 92 | /// The property returns an identifier of an entity 93 | /// 94 | 95 | EntityId Id { get; } 96 | 97 | /// 98 | /// The property returns a name of an entity 99 | /// 100 | 101 | string Name { get; } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /TinyECS/Interfaces/IEvent.cs: -------------------------------------------------------------------------------- 1 | namespace TinyECS.Interfaces 2 | { 3 | /// 4 | /// interface IEvent 5 | /// 6 | /// The interface describes a functionality of internal events 7 | /// 8 | 9 | public interface IEvent 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /TinyECS/Interfaces/IEventManager.cs: -------------------------------------------------------------------------------- 1 | namespace TinyECS.Interfaces 2 | { 3 | /// 4 | /// interface IEventListener 5 | /// 6 | /// The interface represents a listener of events of specific type 7 | /// 8 | 9 | public interface IEventListener 10 | { 11 | } 12 | 13 | 14 | /// 15 | /// interface IEventListener 16 | /// 17 | /// The interface represents a listener of events of specific type 18 | /// 19 | /// 20 | 21 | public interface IEventListener: IEventListener 22 | where T: struct 23 | { 24 | /// 25 | /// The method should be implemented by all listeners which want to retrieve events of T type 26 | /// 27 | /// An event's data 28 | 29 | void OnEvent(T eventData); 30 | } 31 | 32 | 33 | /// 34 | /// interface IEventManager 35 | /// 36 | /// The interface describes a functionality of an internal event manager which is used by the framework 37 | /// 38 | 39 | public interface IEventManager 40 | { 41 | /// 42 | /// The method subscribes a listener to the manager 43 | /// 44 | /// A reference to IEventListener implementation 45 | /// A type of an event 46 | /// An identifier of a listener 47 | 48 | uint Subscribe(IEventListener eventListener) 49 | where T : struct; 50 | 51 | /// 52 | /// The method unsubscribes specified listener with a given identifier 53 | /// 54 | /// An identifier of a listener 55 | 56 | void Unsubscribe(uint listenerId); 57 | 58 | /// 59 | /// The method notifies all listeners of the manager that an event of type T has occurred 60 | /// 61 | /// A type of an event 62 | /// An event's data 63 | /// An identifier of destination listener. If the value equals to uint.MaxValue 64 | /// the broadcasting will be executed 65 | 66 | void Notify(T eventData, uint destListenerId = uint.MaxValue) 67 | where T: struct; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /TinyECS/Interfaces/ISystemManager.cs: -------------------------------------------------------------------------------- 1 | namespace TinyECS.Interfaces 2 | { 3 | /// 4 | /// interface ISystemManager 5 | /// 6 | /// The interface represents a functionality that every system manager in the project 7 | /// should provide 8 | /// 9 | 10 | public interface ISystemManager 11 | { 12 | /// 13 | /// The method registers specialized system type which is IInitSystem. The systems of this type 14 | /// is executed only once at start of an application. Please DON'T use this method use Register 15 | /// method instead. 16 | /// 17 | /// A reference to ISystem implementation 18 | /// An identifier of a system within the manager 19 | 20 | SystemId RegisterSystem(IInitSystem system); 21 | 22 | /// 23 | /// The method registers specialized system type which is IUpdateSystem. The systems of this type 24 | /// is executed every frame when the initialization's step is passed. Please DON'T use this method use Register 25 | /// method instead. 26 | /// 27 | /// A reference to ISystem implementation 28 | /// An identifier of a system within the manager 29 | 30 | SystemId RegisterSystem(IUpdateSystem system); 31 | 32 | /// 33 | /// The method registers a given reactive system within the manager. Please DON'T use this method use Register 34 | /// method instead. 35 | /// 36 | /// A reference to IReactiveSystem implementation 37 | /// An identifier of a system within the manager 38 | 39 | SystemId RegisterSystem(IReactiveSystem system); 40 | 41 | /// 42 | /// The method excludes a system with the given systemId from the manager if it exists 43 | /// 44 | /// An identifier of a system which was retrieved from RegisterSystem's call 45 | 46 | void UnregisterSystem(SystemId systemId); 47 | 48 | /// 49 | /// The method activates a system with the given systemId if it registered within the manager 50 | /// 51 | /// An identifier of a system which was retrieved from RegisterSystem's call 52 | /// An identifier of a system within the manager 53 | 54 | SystemId ActivateSystem(SystemId systemId); 55 | 56 | /// 57 | /// The method deactivates a system with the given systemId if it registered within the manager 58 | /// 59 | /// An identifier of a system which was retrieved from RegisterSystem's call 60 | /// An identifier of a system within the manager 61 | 62 | SystemId DeactivateSystem(SystemId systemId); 63 | 64 | /// 65 | /// The method initializes all active systems that implements IInitSystem interface 66 | /// 67 | 68 | void Init(); 69 | 70 | /// 71 | /// The method executes all active systems. The method should be invoked within a main loop of a game 72 | /// 73 | /// The value in milliseconds which tells how much time elapsed from the previous frame 74 | 75 | void Update(float dt); 76 | 77 | /// 78 | /// The method creates a new iterator which provides an ability to enumerate all systems of a given manager 79 | /// 80 | /// The method returns a reference to ISystemIterator that implements some iterative mechanism 81 | 82 | ISystemIterator GetSystemIterator(); 83 | } 84 | } -------------------------------------------------------------------------------- /TinyECS/Interfaces/ISystemsGroup.cs: -------------------------------------------------------------------------------- 1 | namespace TinyECS.Interfaces 2 | { 3 | /// 4 | /// interface ISystemsGroup 5 | /// 6 | /// The interface describes a functionality of a group of systems that can be unified by some criteria 7 | /// 8 | 9 | public interface ISystemsGroup 10 | { 11 | /// 12 | /// The method adds a new system into the group 13 | /// 14 | /// A reference to ISystem implementation 15 | 16 | void Add(ISystem system); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /TinyECS/Interfaces/IWorldContext.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | 5 | namespace TinyECS.Interfaces 6 | { 7 | /// 8 | /// structure TWorldContextStats 9 | /// 10 | /// The structure contains statistics about a particular world's context 11 | /// 12 | 13 | public struct TWorldContextStats 14 | { 15 | public uint mNumOfActiveEntities; 16 | 17 | public uint mNumOfReservedEntities; 18 | 19 | public uint mNumOfActiveComponents; 20 | 21 | public uint mAverageNumOfComponentsPerEntity; 22 | } 23 | 24 | 25 | /// 26 | /// class IWorldContext 27 | /// 28 | /// The interface describes a functionality of a world's context which is a main hub 29 | /// that combines all parts of the architecture 30 | /// 31 | 32 | public interface IWorldContext 33 | { 34 | /// 35 | /// The method creates a new entity within the context 36 | /// 37 | /// An optional parameter that specifies a name of the entity 38 | /// An integer index that is an entity's identifier 39 | 40 | EntityId CreateEntity(string name = null); 41 | 42 | /// 43 | /// The method destroy an entity with a given identifier 44 | /// 45 | /// An entity's identifier 46 | /// The method returns true if the entity was successfully destroyed and false in other cases 47 | 48 | bool DestroyEntity(EntityId entityId); 49 | 50 | /// 51 | /// The method returns a reference to an entity by its identifier 52 | /// 53 | /// An entity's identifier 54 | /// A reference to IEntity's implementation 55 | 56 | IEntity GetEntityById(EntityId entityId); 57 | 58 | /// 59 | /// The method returns single entity which corresponds to given list of components 60 | /// 61 | /// A list of components that every entity should have 62 | /// Returns a reference to an entity or null if it doesn't exist 63 | 64 | IEntity GetSingleEntityWithAll(params Type[] components); 65 | 66 | /// 67 | /// The method returns single entity which have any from given list of components 68 | /// 69 | /// A list of components that every entity should have 70 | /// Returns a reference to an entity or null if it doesn't exist 71 | 72 | IEntity GetSingleEntityWithAny(params Type[] components); 73 | 74 | /// 75 | /// The method returns an array of entities that have all specified components attached to them 76 | /// 77 | /// A list of components that every entity should have 78 | /// The method returns an array of entities that have all specified components attached to them 79 | 80 | List GetEntitiesWithAll(params Type[] components); 81 | 82 | /// 83 | /// The method returns an array of entities that have any of specified components 84 | /// 85 | /// A list of components that every entity should have 86 | /// The method returns an array of entities that have any of specified components 87 | 88 | List GetEntitiesWithAny(params Type[] components); 89 | 90 | /// 91 | /// The method returns an entity with specified component. Note that the component should be unique 92 | /// 93 | /// A type of a component that should be retrieved 94 | /// The method returns an entity with specified component. Note that the component should be unique 95 | 96 | IEntity GetUniqueEntity() where T: struct, IUniqueComponent; 97 | 98 | /// 99 | /// The method returns a reference to IEventManager implementation 100 | /// 101 | 102 | IEventManager EventManager { get; } 103 | 104 | /// 105 | /// The property returns statistics of current world's context 106 | /// 107 | 108 | TWorldContextStats Statistics { get; } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /TinyECS/Interfaces/IWorldContextFactory.cs: -------------------------------------------------------------------------------- 1 | namespace TinyECS.Interfaces 2 | { 3 | /// 4 | /// interface IWorldContextFactory 5 | /// 6 | /// The interface describes a functionality of a world context's factory 7 | /// 8 | 9 | public interface IWorldContextFactory 10 | { 11 | /// 12 | /// The method creates a new instance of IWorldContext type 13 | /// 14 | /// The method returns a reference to a new instance of IWorldContext type 15 | 16 | IWorldContext CreateNewWorldInstance(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /TinyECS/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("TinyECS")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("TinyECS")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("5f068059-fcfc-4a07-8430-c58431b39795")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /TinyECS/TinyECS.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {5F068059-FCFC-4A07-8430-C58431B39795} 8 | Library 9 | Properties 10 | TinyECS 11 | TinyECS 12 | v4.6.1 13 | 512 14 | true 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 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 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /TinyECSTests/ComponentManager/ComponentIteratorTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using System; 3 | using System.Collections.Generic; 4 | using TinyECS.Impls; 5 | using TinyECS.Interfaces; 6 | 7 | 8 | namespace TinyECSTests 9 | { 10 | [TestFixture] 11 | public class ComponentIteratorTests 12 | { 13 | protected struct TComponentA: IComponent 14 | { 15 | public int mValue; 16 | } 17 | 18 | protected struct TComponentB: IComponent 19 | { 20 | } 21 | 22 | protected struct TComponentC: IComponent 23 | { 24 | } 25 | 26 | 27 | [Test] 28 | public void TestConstructor_PassCorrectInputData_CreatesCorrectIterator() 29 | { 30 | var entityComponentsTable = new Dictionary(); 31 | 32 | var componentsHashesTable = new Dictionary(); 33 | 34 | var components = new List>(); 35 | 36 | Assert.DoesNotThrow(() => 37 | { 38 | IComponentIterator iter = new ComponentManager.ComponentIterator(entityComponentsTable, componentsHashesTable, components); 39 | 40 | Assert.IsNotNull(iter); 41 | }); 42 | } 43 | 44 | [Test] 45 | public void TestGet_InvokedOnEmptyComponentsMatrix_ThrowsException() 46 | { 47 | var entityComponentsTable = new Dictionary(); 48 | 49 | var componentsHashesTable = new Dictionary(); 50 | 51 | var components = new List>(); 52 | 53 | Assert.Throws(() => 54 | { 55 | IComponentIterator iter = new ComponentManager.ComponentIterator(entityComponentsTable, componentsHashesTable, components); 56 | 57 | Assert.IsNotNull(iter); 58 | 59 | iter.Get(); 60 | }); 61 | } 62 | 63 | [Test] 64 | public void TestGet_InvokedOnCorrectIterator_ReturnsComponentValue() 65 | { 66 | var entityComponentsTable = new Dictionary 67 | { 68 | { typeof(TComponentA), 0 } 69 | }; 70 | 71 | var componentsHashesTable = new Dictionary 72 | { 73 | { typeof(TComponentA), 0 } 74 | }; 75 | 76 | var components = new List> 77 | { 78 | new List 79 | { 80 | new TComponentA() { mValue = 42 } 81 | } 82 | }; 83 | 84 | Assert.Throws(() => 85 | { 86 | IComponentIterator iter = new ComponentManager.ComponentIterator(entityComponentsTable, componentsHashesTable, components); 87 | 88 | Assert.IsNotNull(iter); 89 | 90 | TComponentA componentValue = iter.Get(); 91 | 92 | Assert.AreEqual(42, componentValue.mValue); 93 | }); 94 | } 95 | 96 | [Test] 97 | public void TestMoveNext_InvokedOnCorrectData_CorrectlyEnumeratesComponents() 98 | { 99 | var componentsPackageList = new List 100 | { 101 | typeof(TComponentA), 102 | typeof(TComponentB), 103 | typeof(TComponentC) 104 | }; 105 | 106 | var entityComponentsTable = new Dictionary(); 107 | 108 | foreach (var componentType in componentsPackageList) 109 | { 110 | entityComponentsTable.Add(componentType, 0); 111 | } 112 | 113 | var componentsHashesTable = new Dictionary(); 114 | 115 | for (int i = 0; i < componentsPackageList.Count; ++i) 116 | { 117 | componentsHashesTable.Add(componentsPackageList[i], i); 118 | } 119 | 120 | var components = new List> 121 | { 122 | new List 123 | { 124 | new TComponentA() { mValue = 42 } 125 | }, 126 | new List 127 | { 128 | new TComponentB() { } 129 | }, 130 | new List 131 | { 132 | new TComponentC() { } 133 | }, 134 | }; 135 | 136 | Assert.DoesNotThrow(() => 137 | { 138 | IComponentIterator iter = new ComponentManager.ComponentIterator(entityComponentsTable, componentsHashesTable, components); 139 | 140 | Assert.IsNotNull(iter); 141 | 142 | int visitedComponentsCount = 0; 143 | 144 | while (iter.MoveNext()) 145 | { 146 | IComponent currComponent = iter.Get(); 147 | 148 | Assert.AreEqual(componentsPackageList[visitedComponentsCount], currComponent.GetType()); 149 | 150 | ++visitedComponentsCount; 151 | } 152 | 153 | Assert.AreEqual(componentsPackageList.Count, visitedComponentsCount); 154 | }); 155 | } 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /TinyECSTests/EventManager/BrokenEventListenerMock.cs: -------------------------------------------------------------------------------- 1 | using TinyECS.Interfaces; 2 | using static TinyECSTests.EventManagerTests; 3 | 4 | 5 | namespace TinyECSTests 6 | { 7 | public class BrokenEventListenerMock : IEventListener 8 | { 9 | public bool IsSimpleOnEventInvoked { get; set; } = false; 10 | 11 | public BrokenEventListenerMock(IEventManager eventManager) 12 | { 13 | eventManager.Subscribe(this); 14 | eventManager.Subscribe(this); 15 | } 16 | 17 | public void OnEvent(TSimpleEvent eventData) 18 | { 19 | IsSimpleOnEventInvoked = true; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /TinyECSTests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("TinyECSTests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("TinyECSTests")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("41c5cffe-d320-4d54-9f8a-167e08eb9b84")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /TinyECSTests/SystemManager/BuiltinSystemsTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using TinyECS.Impls; 3 | using TinyECS.Interfaces; 4 | 5 | 6 | namespace TinyECSTests 7 | { 8 | [TestFixture] 9 | public class BuiltinSystemsTests 10 | { 11 | protected ISystemManager mSystemManager; 12 | 13 | protected IWorldContext mWorldContext; 14 | 15 | [SetUp] 16 | public void Init() 17 | { 18 | mWorldContext = new WorldContextFactory().CreateNewWorldInstance(); 19 | 20 | mSystemManager = new SystemManager(mWorldContext); 21 | } 22 | 23 | [Test] 24 | public void TestDisposableEntitiesCollectorSystem_ThereAreNoDisposableEntitiesAtInput_DoNothing() 25 | { 26 | mSystemManager.RegisterSystem(new PureUpdateSystemAdapter(mWorldContext, BuiltinSystems.DisposableEntitiesCollectorSystem)); 27 | 28 | int expectedNumOfDisposableEntities = 5; 29 | 30 | for (int i = 0; i < expectedNumOfDisposableEntities; ++i) 31 | { 32 | mWorldContext.CreateDisposableEntity(); 33 | } 34 | 35 | Assert.AreEqual(expectedNumOfDisposableEntities, mWorldContext.GetEntitiesWithAll(typeof(TDisposableComponent)).Count); 36 | 37 | mSystemManager.Init(); 38 | mSystemManager.Update(0.0f); 39 | 40 | Assert.AreEqual(0, mWorldContext.GetEntitiesWithAll(typeof(TDisposableComponent)).Count); 41 | } 42 | 43 | [Test] 44 | public void TestDisposableEntitiesCollectorSystem_DisposableEntitiesAreCreatedBeforeEachUpdate_CorrectlyDeleteThem() 45 | { 46 | mSystemManager.RegisterSystem(new PureUpdateSystemAdapter(mWorldContext, BuiltinSystems.DisposableEntitiesCollectorSystem)); 47 | 48 | int expectedNumOfDisposableEntities = 5; 49 | 50 | mSystemManager.Init(); 51 | 52 | for (int i = 0; i < expectedNumOfDisposableEntities; ++i) 53 | { 54 | mWorldContext.CreateDisposableEntity(); 55 | mSystemManager.Update(0.0f); 56 | } 57 | 58 | Assert.AreEqual(0, mWorldContext.GetEntitiesWithAll(typeof(TDisposableComponent)).Count); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /TinyECSTests/TinyECSUnityIntegrationTests/RegisterViewSystemTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using TinyECS.Impls; 3 | using TinyECS.Interfaces; 4 | using TinyECSUnityIntegration.Impls; 5 | 6 | 7 | namespace TinyECSTests 8 | { 9 | [TestFixture] 10 | public class RegisterViewSystemTests 11 | { 12 | protected IWorldContext mWorldContext; 13 | 14 | protected ISystemManager mSystemManager; 15 | 16 | protected IReactiveSystem mRegisterViewsSystem; 17 | 18 | [SetUp] 19 | public void Init() 20 | { 21 | mWorldContext = new WorldContextFactory().CreateNewWorldInstance(); 22 | 23 | mSystemManager = new SystemManager(mWorldContext); 24 | 25 | mRegisterViewsSystem = new RegisterViewSystem(mWorldContext); 26 | 27 | mSystemManager.RegisterSystem(mRegisterViewsSystem); 28 | 29 | mSystemManager.Init(); 30 | } 31 | 32 | [Test] 33 | public void TestUpdateMethodOfSystem_PassCorrectData_SuccessfullyProcessesData() 34 | { 35 | string entityName = "entity01"; 36 | 37 | // prepare data 38 | var e = mWorldContext.GetEntityById(mWorldContext.CreateEntity(entityName)); 39 | 40 | e.AddComponent(); 41 | 42 | Assert.IsNotNull(e); 43 | Assert.AreEqual(e.Name, entityName); 44 | 45 | // execute system 46 | mSystemManager.Update(0.0f); 47 | 48 | // check results 49 | Assert.DoesNotThrow(() => 50 | { 51 | Assert.IsFalse(e.HasComponent()); 52 | Assert.IsTrue(e.HasComponent()); 53 | }); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /TinyECSTests/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /TinyECSTests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /TinyECSUnityIntegration/Impls/BaseDynamicView.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | 4 | namespace TinyECSUnityIntegration.Impls 5 | { 6 | /// 7 | /// class BaseDynamicView 8 | /// 9 | /// The class is a subtype of BaseView which should be used in cases when some view 10 | /// will be created in runtime using GameObject.Instantiate or some factory 11 | /// 12 | 13 | public abstract class BaseDynamicView : BaseView 14 | { 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /TinyECSUnityIntegration/Impls/BaseStaticView.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | 4 | namespace TinyECSUnityIntegration.Impls 5 | { 6 | /// 7 | /// class BaseStaticView 8 | /// 9 | /// The class is a subtype of BaseView which should be used in cases when some view 10 | /// will be created in compile time and never be allocated dynamically in runtime 11 | /// 12 | 13 | [RequireComponent(typeof(DependencyInjector))] 14 | public abstract class BaseStaticView: BaseView 15 | { 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /TinyECSUnityIntegration/Impls/BaseView.cs: -------------------------------------------------------------------------------- 1 | using TinyECS.Interfaces; 2 | using TinyECSUnityIntegration.Interfaces; 3 | using UnityEngine; 4 | 5 | 6 | namespace TinyECSUnityIntegration.Impls 7 | { 8 | /// 9 | /// struct TOnViewWaitForInitEventComponent 10 | /// 11 | /// The structure describes a parameters of an event which is generated with BaseView 12 | /// when some instance of it has awaken and need to be registered 13 | /// 14 | 15 | public struct TOnViewWaitForInitEventComponent: IComponent 16 | { 17 | public BaseView mView; 18 | } 19 | 20 | 21 | /// 22 | /// struct TViewComponent 23 | /// 24 | /// The structure contains a reference to a view which is linked to the entity 25 | /// 26 | 27 | public struct TViewComponent: IComponent 28 | { 29 | public BaseView mView; 30 | } 31 | 32 | 33 | /// 34 | /// class BaseView 35 | /// 36 | /// The class is a base implementation of views for all that will be used to interact with a ECS model 37 | /// 38 | 39 | public abstract class BaseView: MonoBehaviour, IView 40 | { 41 | protected IWorldContext mWorldContext; 42 | 43 | private IEventManager mEventManager; 44 | 45 | protected EntityId mLinkedEntityId = EntityId.Invalid; 46 | 47 | /// 48 | /// The method prepares the view for initialization step 49 | /// 50 | /// A reference to IWorldContext implementation 51 | 52 | public void PreInit(IWorldContext worldContext) 53 | { 54 | WorldContext = worldContext; 55 | 56 | // create a new event which is an entity with attached component to inform system to register this view in the world's context 57 | IEntity registerViewRequestEntity = worldContext.GetEntityById(worldContext.CreateEntity()); 58 | 59 | registerViewRequestEntity.AddComponent(new TOnViewWaitForInitEventComponent { mView = this }); 60 | } 61 | 62 | /// 63 | /// The method links current view's instance with a given entity's identifier 64 | /// 65 | /// An integral identifier which represents some existing entity 66 | 67 | public virtual void Link(EntityId entityId) 68 | { 69 | if (mLinkedEntityId != EntityId.Invalid) 70 | { 71 | return; 72 | } 73 | 74 | mLinkedEntityId = entityId; 75 | 76 | RegisterSubscriptions(_eventManager, entityId); 77 | } 78 | 79 | /// 80 | /// The method is used to provide a single place where all subscriptions are made 81 | /// 82 | /// A reference to IEventManager implementation 83 | /// Entity's identifier 84 | 85 | public abstract void RegisterSubscriptions(IEventManager eventManager, EntityId entityId); 86 | 87 | /// 88 | /// The property returns a reference to IWorldContext which contains the entity that's linked 89 | /// to the view 90 | /// 91 | 92 | public IWorldContext WorldContext { get => mWorldContext; set => mWorldContext = value; } 93 | 94 | /// 95 | /// The property returns an identifier of the linked entity 96 | /// 97 | 98 | public EntityId LinkedEntityId => mLinkedEntityId; 99 | 100 | protected IEventManager _eventManager 101 | { 102 | get 103 | { 104 | if (mEventManager == null) 105 | { 106 | mEventManager = mWorldContext?.EventManager; 107 | } 108 | 109 | return mEventManager; 110 | } 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /TinyECSUnityIntegration/Impls/DependencyInjector.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TinyECSUnityIntegration.Interfaces; 3 | using UnityEngine; 4 | 5 | 6 | namespace TinyECSUnityIntegration.Impls 7 | { 8 | /// 9 | /// class DependencyInjector 10 | /// 11 | /// The class is a utility class that injects reference to IWorldContext 12 | /// 13 | 14 | public class DependencyInjector: MonoBehaviour, IDependencyInjector 15 | { 16 | protected WorldContextsManager mWorldContextsManager; 17 | 18 | protected BaseView[] mParentViews; 19 | 20 | protected bool mIsInitialized = false; 21 | 22 | public void Init() 23 | { 24 | var worldContext = _worldContextsManager?.WorldContext; 25 | 26 | if (mIsInitialized || worldContext == null) 27 | { 28 | return; 29 | } 30 | 31 | Array.ForEach(_parentViews, entity => entity?.PreInit(worldContext)); 32 | 33 | mIsInitialized = true; 34 | } 35 | 36 | protected WorldContextsManager _worldContextsManager 37 | { 38 | get 39 | { 40 | if (mWorldContextsManager == null) 41 | { 42 | mWorldContextsManager = FindObjectOfType(); 43 | } 44 | 45 | return mWorldContextsManager; 46 | } 47 | } 48 | 49 | protected BaseView[] _parentViews 50 | { 51 | get 52 | { 53 | if (mParentViews == null) 54 | { 55 | mParentViews = GetComponentsInChildren(); 56 | } 57 | 58 | return mParentViews; 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /TinyECSUnityIntegration/Impls/EntityObserver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TinyECS.Interfaces; 3 | using UnityEngine; 4 | 5 | 6 | 7 | namespace TinyECSUnityIntegration.Impls 8 | { 9 | /// 10 | /// class EntityObserver 11 | /// 12 | /// The class is used to provide the debug information about some entity within Unity editor 13 | /// 14 | 15 | public class EntityObserver: MonoBehaviour 16 | { 17 | public EntityId mEntityId; 18 | 19 | protected IWorldContext mWorldContext; 20 | 21 | /// 22 | /// The method initializes current state of the observer 23 | /// 24 | /// A reference to a world context from which the entity will be retrieved 25 | /// An identifier of an entity 26 | 27 | public void Init(IWorldContext worldContext, EntityId entityId) 28 | { 29 | mWorldContext = worldContext ?? throw new ArgumentNullException("worldContext"); 30 | 31 | mEntityId = entityId; 32 | } 33 | 34 | public IEntity Entity => mWorldContext?.GetEntityById(mEntityId); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /TinyECSUnityIntegration/Impls/GameObjectFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using TinyECS.Interfaces; 3 | using TinyECSUnityIntegration.Interfaces; 4 | using UnityEngine; 5 | 6 | 7 | namespace TinyECSUnityIntegration.Impls 8 | { 9 | /// 10 | /// class GameObjectFactory 11 | /// 12 | /// The class is an implementation of IGameObjectFactory that should be used 13 | /// as a replacement of GameObject.Instantiate 14 | /// 15 | 16 | public class GameObjectFactory: IGameObjectFactory 17 | { 18 | protected IWorldContext mWorldContext; 19 | 20 | public GameObjectFactory(IWorldContext worldContext) 21 | { 22 | mWorldContext = worldContext ?? throw new ArgumentNullException("worldContext"); 23 | } 24 | 25 | /// 26 | /// The method instantiates a new instance of a given prefab 27 | /// 28 | /// A reference to a prefab that should be created dynamically 29 | /// A position of a new object 30 | /// An orientation of an object in a space 31 | /// A parent of a new created object 32 | /// A reference to a new created entity which is attached to a new created GameObject 33 | 34 | public IEntity Spawn(GameObject prefab, Vector3 position, Quaternion rotation, Transform parent) 35 | { 36 | GameObject gameObjectInstance = GameObject.Instantiate(prefab, position, rotation, parent); 37 | 38 | IView[] views = gameObjectInstance.GetComponentsInChildren(); 39 | for (int i = 0; i < views.Length; ++i) 40 | { 41 | IView viewComponent = views[i]; 42 | 43 | EntityId linkedEntityId = mWorldContext.CreateEntity(/*gameObjectInstance.name*/); 44 | IEntity linkedEntity = mWorldContext.GetEntityById(linkedEntityId); 45 | 46 | viewComponent.WorldContext = mWorldContext; 47 | 48 | linkedEntity.AddComponent(new TViewComponent { mView = viewComponent as BaseView }); 49 | 50 | viewComponent.Link(linkedEntityId); 51 | } 52 | 53 | return views.Length > 0 ? mWorldContext.GetEntityById(views[0].LinkedEntityId) : null; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /TinyECSUnityIntegration/Impls/RegisterViewSystem.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using TinyECS.Impls; 3 | using TinyECS.Interfaces; 4 | 5 | 6 | namespace TinyECSUnityIntegration.Impls 7 | { 8 | /// 9 | /// class RegisterViewSystem 10 | /// 11 | /// The class represents a reactive system that links created entities with their views 12 | /// in Unity3D side 13 | /// 14 | 15 | public class RegisterViewSystem : BaseReactiveSystem 16 | { 17 | protected IWorldContext mWorldContext; 18 | 19 | public RegisterViewSystem(IWorldContext worldContext) 20 | { 21 | mWorldContext = worldContext; 22 | } 23 | 24 | public override bool Filter(IEntity entity) 25 | { 26 | return entity.HasComponent(); 27 | } 28 | 29 | public override void Update(List entities, float deltaTime) 30 | { 31 | IEntity currEntity = null; 32 | 33 | TOnViewWaitForInitEventComponent currRegisterViewRequestComponent; 34 | 35 | IEventManager eventManager = mWorldContext?.EventManager; 36 | 37 | for (int i = 0; i < entities.Count; ++i) 38 | { 39 | currEntity = entities[i]; 40 | 41 | currRegisterViewRequestComponent = currEntity.GetComponent(); 42 | 43 | currRegisterViewRequestComponent.mView?.Link(currEntity.Id); 44 | 45 | currEntity.AddComponent(new TViewComponent { mView = currRegisterViewRequestComponent.mView }); 46 | 47 | currEntity.RemoveComponent(); 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /TinyECSUnityIntegration/Impls/SystemManagerObserver.cs: -------------------------------------------------------------------------------- 1 | using TinyECS.Interfaces; 2 | using UnityEngine; 3 | 4 | 5 | namespace TinyECSUnityIntegration.Impls 6 | { 7 | /// 8 | /// class SystemManagerObserver 9 | /// 10 | /// The class is used for integration of TinyECS with Unity3D and stores a reference to some 11 | /// ISystemManager implementation 12 | /// 13 | 14 | public class SystemManagerObserver: MonoBehaviour 15 | { 16 | protected ISystemManager mSystemManager; 17 | 18 | public ISystemManager SystemManager { get => mSystemManager; set => mSystemManager = value; } 19 | } 20 | 21 | 22 | /// 23 | /// class SystemManagerObserverUtils 24 | /// 25 | /// The static class contains helper methods that are used wih SystemManagerObserver 26 | /// 27 | 28 | public static class SystemManagerObserverUtils 29 | { 30 | /// 31 | /// The method creates a new GameObject which is a representation of ISystemManager within Unity3D's scene 32 | /// 33 | /// 34 | /// A name of a game object that will have SystemManagerObserver component 35 | /// The extension method returns a new allocated observer of ISystemManager type 36 | 37 | public static SystemManagerObserver CreateSystemManagerObserver(this ISystemManager systemManager, string name = null) 38 | { 39 | GameObject systemManagerObserverGO = new GameObject(name); 40 | 41 | SystemManagerObserver systemManagerObserver = systemManagerObserverGO.AddComponent(); 42 | 43 | systemManagerObserver.SystemManager = systemManager; 44 | 45 | return systemManagerObserver; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /TinyECSUnityIntegration/Impls/WorldContextsManager.cs: -------------------------------------------------------------------------------- 1 | using TinyECS.Interfaces; 2 | using TinyECS.Impls; 3 | using UnityEngine; 4 | using TinyECSUnityIntegration.Interfaces; 5 | 6 | 7 | namespace TinyECSUnityIntegration.Impls 8 | { 9 | /// 10 | /// class WorldContextsManager 11 | /// 12 | /// The class represents a manager that provides references to existing worlds contexts. 13 | /// NOTE: For now we support the only world context 14 | /// 15 | 16 | public class WorldContextsManager: MonoBehaviour, IEventListener, IEventListener 17 | { 18 | protected IWorldContext mWorldContext; 19 | 20 | protected uint mNewEntityCreatedListenerId = uint.MaxValue; 21 | 22 | protected uint mEntityRemovedListenerId = uint.MaxValue; 23 | 24 | protected Transform mCachedTransform; 25 | 26 | public void PrepareViews() 27 | { 28 | IDependencyInjector[] viewsInjectors = GameObject.FindObjectsOfType(); 29 | for (int i = 0; i < viewsInjectors.Length; ++i) 30 | { 31 | viewsInjectors[i]?.Init(); 32 | } 33 | } 34 | 35 | public void OnEvent(TNewEntityCreatedEvent eventData) 36 | { 37 | IEntity entity = mWorldContext.GetEntityById(eventData.mEntityId); 38 | 39 | #if false//DEBUG 40 | Debug.Log($"[WorldContextsManager] A new entity ({entity.Name}) was created"); 41 | #endif 42 | 43 | GameObject entityGO = _createEntityGOView(entity, _cachedTransform); 44 | 45 | // initializes the observer of the entity 46 | EntityObserver entityObserver = entityGO.AddComponent(); 47 | 48 | entityObserver.Init(mWorldContext, entity.Id); 49 | } 50 | 51 | public void OnEvent(TEntityDestroyedEvent eventData) 52 | { 53 | #if DEBUG 54 | Debug.Log($"[WorldContextsManager] Entity ({eventData.mEntityName}) was destroyed"); 55 | #endif 56 | 57 | GameObject entityGO = GameObject.Find(eventData.mEntityName); 58 | 59 | GameObject.DestroyImmediate(entityGO); 60 | } 61 | 62 | protected GameObject _createEntityGOView(IEntity entity, Transform parent) 63 | { 64 | GameObject entityGO = new GameObject(entity.Name); 65 | 66 | Transform entityGOTransform = entityGO.GetComponent(); 67 | 68 | entityGOTransform.parent = parent; 69 | 70 | return entityGO; 71 | } 72 | 73 | public IWorldContext WorldContext 74 | { 75 | get 76 | { 77 | return mWorldContext; 78 | } 79 | 80 | set 81 | { 82 | mWorldContext = value; 83 | 84 | var eventManager = mWorldContext.EventManager; 85 | 86 | // unsubscribe previous listeners 87 | if (mNewEntityCreatedListenerId != uint.MaxValue) 88 | { 89 | eventManager.Unsubscribe(mNewEntityCreatedListenerId); 90 | } 91 | 92 | if (mEntityRemovedListenerId != uint.MaxValue) 93 | { 94 | eventManager.Unsubscribe(mEntityRemovedListenerId); 95 | } 96 | 97 | mNewEntityCreatedListenerId = eventManager.Subscribe(this); 98 | mEntityRemovedListenerId = eventManager.Subscribe(this); 99 | } 100 | } 101 | 102 | protected Transform _cachedTransform 103 | { 104 | get 105 | { 106 | if (mCachedTransform == null) 107 | { 108 | mCachedTransform = GetComponent(); 109 | } 110 | 111 | return mCachedTransform; 112 | } 113 | } 114 | } 115 | 116 | 117 | /// 118 | /// class WorldContextsManagerUtils 119 | /// 120 | /// The static class contains helper methods to initialize WorldContextsManager 121 | /// 122 | 123 | public static class WorldContextsManagerUtils 124 | { 125 | /// 126 | /// The extension method returns a new allocated manager of world contexts 127 | /// 128 | /// 129 | /// A name of a game object that will have WorldContextsManager component 130 | /// The extension method returns a new allocated manager of world contexts 131 | 132 | public static WorldContextsManager CreateWorldContextManager(this IWorldContext worldContext, string name = null) 133 | { 134 | GameObject worldContextsManagerGO = new GameObject(name); 135 | 136 | WorldContextsManager worldContextsManager = worldContextsManagerGO.AddComponent(); 137 | 138 | worldContextsManager.WorldContext = worldContext; 139 | 140 | worldContextsManager.PrepareViews(); 141 | 142 | return worldContextsManager; 143 | } 144 | 145 | public static IEntity CreateAndGetEntity(this IWorldContext worldContext, string name = null) 146 | { 147 | return worldContext.GetEntityById(worldContext.CreateEntity(name)); 148 | } 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /TinyECSUnityIntegration/Interfaces/IDependencyInjector.cs: -------------------------------------------------------------------------------- 1 | namespace TinyECSUnityIntegration.Interfaces 2 | { 3 | public interface IDependencyInjector 4 | { 5 | void Init(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /TinyECSUnityIntegration/Interfaces/IGameObjectFactory.cs: -------------------------------------------------------------------------------- 1 | using TinyECS.Interfaces; 2 | using UnityEngine; 3 | 4 | 5 | namespace TinyECSUnityIntegration.Interfaces 6 | { 7 | /// 8 | /// interface IGameObjectFactory 9 | /// 10 | /// The interface represents a factory of objects of GameObject type. Use 11 | /// the implementation of this interface should be used as a replacement 12 | /// for GameObject.Instantiate invocations 13 | /// 14 | 15 | public interface IGameObjectFactory 16 | { 17 | /// 18 | /// The method instantiates a new instance of a given prefab 19 | /// 20 | /// A reference to a prefab that should be created dynamically 21 | /// A position of a new object 22 | /// An orientation of an object in a space 23 | /// A parent of a new created object 24 | /// A reference to a new created entity which is attached to a new created GameObject 25 | 26 | IEntity Spawn(GameObject prefab, Vector3 position, Quaternion rotation, Transform parent); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /TinyECSUnityIntegration/Interfaces/IView.cs: -------------------------------------------------------------------------------- 1 | using TinyECS.Interfaces; 2 | 3 | 4 | namespace TinyECSUnityIntegration.Interfaces 5 | { 6 | /// 7 | /// interface IView 8 | /// 9 | /// The interface describes a basic functionality of views that are used to represent current 10 | /// active state of a world's context using Unity3D engine. Basically, a view is a simple 11 | /// link between an entity and a GameObject's instance 12 | /// 13 | 14 | public interface IView 15 | { 16 | /// 17 | /// The method prepares the view for initialization step 18 | /// 19 | /// A reference to IWorldContext implementation 20 | 21 | void PreInit(IWorldContext worldContext); 22 | 23 | /// 24 | /// The method links current view's instance with a given entity's identifier 25 | /// 26 | /// An integral identifier which represents some existing entity 27 | 28 | void Link(EntityId entityId); 29 | 30 | /// 31 | /// The method is used to provide a single place where all subscriptions are made 32 | /// 33 | /// A reference to IEventManager implementation 34 | /// Entity's identifier 35 | 36 | void RegisterSubscriptions(IEventManager eventManager, EntityId entityId); 37 | 38 | /// 39 | /// The property returns a reference to IWorldContext which contains the entity that's linked 40 | /// to the view 41 | /// 42 | 43 | IWorldContext WorldContext { get; set; } 44 | 45 | /// 46 | /// The property returns an identifier of the linked entity 47 | /// 48 | 49 | EntityId LinkedEntityId { get; } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /TinyECSUnityIntegration/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("TinyECSUnityIntegration")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("TinyECSUnityIntegration")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("7ff156da-3333-49b6-b082-ff86b458724e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /TinyECSUnityIntegration/TinyECSUnityIntegration.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {7FF156DA-3333-49B6-B082-FF86B458724E} 8 | Library 9 | Properties 10 | TinyECSUnityIntegration 11 | TinyECSUnityIntegration 12 | v4.6.1 13 | 512 14 | true 15 | 16 | 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | false 27 | 28 | 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | false 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | False 44 | ..\Deps\Unity\UnityEngine.dll 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | {5f068059-fcfc-4a07-8430-c58431b39795} 65 | TinyECS 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationEditor/Inspectors/EntityObserverEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using TinyECS.Interfaces; 4 | using TinyECSUnityIntegration.Impls; 5 | using UnityEditor; 6 | using UnityEngine; 7 | 8 | 9 | namespace TinyECSUnityIntegrationEditor.Inspectors 10 | { 11 | [CustomEditor(typeof(EntityObserver), true)] 12 | public class EntityObserverEditor: Editor 13 | { 14 | protected static bool[] mComponentsFoldOutInfo = new bool[1000]; 15 | 16 | protected EntityObserver mCurrSelectedEntity = null; 17 | 18 | public override void OnInspectorGUI() 19 | { 20 | EntityObserver entityObserver = target as EntityObserver; 21 | 22 | if (mCurrSelectedEntity != entityObserver) 23 | { 24 | Array.Clear(mComponentsFoldOutInfo, 0, mComponentsFoldOutInfo.Length); 25 | 26 | mCurrSelectedEntity = entityObserver; 27 | } 28 | 29 | IEntity entity = entityObserver.Entity; 30 | 31 | EditorGUILayout.BeginVertical(GUI.skin.box); 32 | 33 | EditorGUILayout.LabelField("Entity Info:", EditorStyles.boldLabel); 34 | 35 | EditorGUILayout.LabelField("Id", entity.Id.ToString()); 36 | EditorGUILayout.LabelField("Name", entity.Name); 37 | 38 | EditorGUILayout.Separator(); 39 | GUILayout.Space(20.0f); 40 | 41 | // display all components that are attached to the entity 42 | IComponentIterator componentIter = entity.GetComponentsIterator(); 43 | 44 | int i = 0; 45 | 46 | while (componentIter.MoveNext()) 47 | { 48 | _displayComponent(componentIter.Get(), i++, ref mComponentsFoldOutInfo); 49 | } 50 | 51 | EditorGUILayout.EndVertical(); 52 | 53 | Repaint(); 54 | } 55 | 56 | protected void _displayComponent(IComponent component, int componentId, ref bool[] componenentsFoldOutInfo) 57 | { 58 | EditorGUILayout.BeginVertical(GUI.skin.box); 59 | 60 | // the method returns true when we should to display detailed information to a user 61 | if (componenentsFoldOutInfo[componentId] = _displayComponentHeader(component, componenentsFoldOutInfo[componentId])) 62 | { 63 | _displayComponentFields(component); 64 | } 65 | 66 | EditorGUILayout.EndVertical(); 67 | } 68 | 69 | protected bool _displayComponentHeader(IComponent component, bool prevState) 70 | { 71 | EditorGUILayout.BeginHorizontal(); 72 | 73 | // implement fold out effect 74 | if (GUILayout.Button(prevState ? "-" : "+", GUILayout.ExpandWidth(false))) 75 | { 76 | return !prevState; 77 | } 78 | 79 | EditorGUILayout.LabelField(component.GetType().Name, EditorStyles.boldLabel); 80 | 81 | EditorGUILayout.EndHorizontal(); 82 | 83 | return prevState; 84 | } 85 | 86 | protected void _displayComponentFields(IComponent component) 87 | { 88 | Type componentType = component.GetType(); 89 | 90 | // display current values of the component (read only) 91 | FieldInfo[] componentFields = componentType.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly); 92 | 93 | FieldInfo currField = null; 94 | 95 | string fieldName = null; 96 | 97 | object fieldValue = null; 98 | 99 | for (int i = 0; i < componentFields.Length; ++i) 100 | { 101 | currField = componentFields[i]; 102 | 103 | fieldName = currField.Name; 104 | fieldValue = currField.GetValue(component); 105 | 106 | // display reference type's value 107 | if (!currField.FieldType.IsValueType) 108 | { 109 | EditorGUILayout.ObjectField(fieldName, fieldValue as UnityEngine.Object, currField.FieldType, false); 110 | 111 | continue; 112 | } 113 | 114 | EditorGUILayout.LabelField(fieldName, $"{fieldValue}"); 115 | } 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationEditor/Inspectors/SystemManagerObserverEditor.cs: -------------------------------------------------------------------------------- 1 | using TinyECS.Interfaces; 2 | using TinyECSUnityIntegration.Impls; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | 7 | namespace TinyECSUnityIntegrationEditor.Inspectors 8 | { 9 | [CustomEditor(typeof(SystemManagerObserver), true)] 10 | public class SystemManagerObserverEditor: Editor 11 | { 12 | public override void OnInspectorGUI() 13 | { 14 | ISystemManager systemManager = (target as SystemManagerObserver)?.SystemManager; 15 | 16 | EditorGUILayout.BeginVertical(GUI.skin.box); 17 | 18 | EditorGUILayout.LabelField("System Manager Statistics", EditorStyles.boldLabel); 19 | 20 | GUILayout.Space(25.0f); 21 | 22 | EditorGUILayout.LabelField("Active Systems List:", EditorStyles.boldLabel); 23 | 24 | ISystemIterator iter = systemManager.GetSystemIterator(); 25 | 26 | EditorGUILayout.BeginVertical(GUI.skin.box); 27 | 28 | EditorGUILayout.LabelField("Name\t\tType"); 29 | 30 | while (iter.MoveNext()) 31 | { 32 | _displaySystemInfo(iter.Get()); 33 | } 34 | 35 | EditorGUILayout.EndVertical(); 36 | 37 | EditorGUILayout.EndVertical(); 38 | } 39 | 40 | protected void _displaySystemInfo(ISystem system) 41 | { 42 | EditorGUILayout.LabelField($"{system.GetType().Name}\t\t{_getSystemTypeMask(system)}"); 43 | } 44 | 45 | protected E_SYSTEM_TYPE _getSystemTypeMask(ISystem system) 46 | { 47 | E_SYSTEM_TYPE systemTypeMask = E_SYSTEM_TYPE.ST_UNKNOWN; 48 | 49 | if (system is IInitSystem) 50 | { 51 | systemTypeMask |= E_SYSTEM_TYPE.ST_INIT; 52 | } 53 | 54 | if (system is IUpdateSystem) 55 | { 56 | systemTypeMask |= E_SYSTEM_TYPE.ST_UPDATE; 57 | } 58 | 59 | if (system is IReactiveSystem) 60 | { 61 | systemTypeMask |= E_SYSTEM_TYPE.ST_REACTIVE; 62 | } 63 | 64 | return systemTypeMask; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationEditor/Inspectors/WorldContextsManagerEditor.cs: -------------------------------------------------------------------------------- 1 | using TinyECS.Interfaces; 2 | using TinyECSUnityIntegration.Impls; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | 7 | namespace TinyECSUnityIntegrationEditor.Inspectors 8 | { 9 | [CustomEditor(typeof(WorldContextsManager), true)] 10 | public class WorldContextsManagerEditor: Editor 11 | { 12 | public override void OnInspectorGUI() 13 | { 14 | IWorldContext worldContext = (target as WorldContextsManager)?.WorldContext; 15 | 16 | TWorldContextStats stats = worldContext.Statistics; 17 | 18 | EditorGUILayout.BeginVertical(GUI.skin.box); 19 | 20 | EditorGUILayout.LabelField("World Context Statistics", EditorStyles.boldLabel); 21 | 22 | EditorGUILayout.LabelField("Active entities:", stats.mNumOfActiveEntities.ToString()); 23 | EditorGUILayout.LabelField("Reserved entities:", stats.mNumOfReservedEntities.ToString()); 24 | EditorGUILayout.LabelField("Total Components Count:", stats.mNumOfActiveComponents.ToString()); 25 | EditorGUILayout.LabelField("Average Components Per Entity:", stats.mAverageNumOfComponentsPerEntity.ToString()); 26 | 27 | EditorGUILayout.EndVertical(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationEditor/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("TinyECSUnityIntegrationEditor")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("TinyECSUnityIntegrationEditor")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("ca57669c-a319-4473-a6c6-02829bbd749d")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationEditor/TinyECSUnityIntegrationEditor.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {CA57669C-A319-4473-A6C6-02829BBD749D} 8 | Library 9 | Properties 10 | TinyECSUnityIntegrationEditor 11 | TinyECSUnityIntegrationEditor 12 | v4.6.1 13 | 512 14 | true 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | False 40 | ..\Deps\Unity\UnityEditor.dll 41 | 42 | 43 | ..\Deps\Unity\UnityEngine.dll 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | {7ff156da-3333-49b6-b082-ff86b458724e} 55 | TinyECSUnityIntegration 56 | 57 | 58 | {5F068059-FCFC-4A07-8430-C58431B39795} 59 | TinyECS 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]uild/ 5 | [Bb]uilds/ 6 | [Ll]ogs/ 7 | 8 | # Visual Studio cache directory 9 | .vs/ 10 | 11 | # Gradle cache directory 12 | .gradle/ 13 | 14 | # Autogenerated VS/MD/Consulo solution and project files 15 | ExportedObj/ 16 | .consulo/ 17 | *.csproj 18 | *.unityproj 19 | *.sln 20 | *.suo 21 | *.tmp 22 | *.user 23 | *.userprefs 24 | *.pidb 25 | *.booproj 26 | *.svd 27 | *.pdb 28 | *.mdb 29 | *.opendb 30 | *.VC.db 31 | 32 | # Unity3D generated meta files 33 | *.pidb.meta 34 | *.pdb.meta 35 | *.mdb.meta 36 | 37 | # Unity3D generated file on crash reports 38 | sysinfo.txt 39 | 40 | # Builds 41 | *.apk 42 | *.unitypackage 43 | 44 | # Crashlytics generated file 45 | crashlytics-build.properties 46 | 47 | TODO -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/Assets/Editor/TinyECSUnityIntegrationEditor.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bnoazx005/TinyECS/e37e5e07a1871471ef3b7020791f53b6ec5041bc/TinyECSUnityIntegrationTests/Assets/Editor/TinyECSUnityIntegrationEditor.dll -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/Assets/Prefabs/TestStaticView.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &6175682493726170773 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 1987259668567278377} 12 | - component: {fileID: 5431176740932584624} 13 | - component: {fileID: 5637006959597989232} 14 | - component: {fileID: 5637006959597989231} 15 | m_Layer: 0 16 | m_Name: TestStaticView 17 | m_TagString: Untagged 18 | m_Icon: {fileID: 0} 19 | m_NavMeshLayer: 0 20 | m_StaticEditorFlags: 0 21 | m_IsActive: 1 22 | --- !u!4 &1987259668567278377 23 | Transform: 24 | m_ObjectHideFlags: 0 25 | m_CorrespondingSourceObject: {fileID: 0} 26 | m_PrefabInstance: {fileID: 0} 27 | m_PrefabAsset: {fileID: 0} 28 | m_GameObject: {fileID: 6175682493726170773} 29 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 30 | m_LocalPosition: {x: 0, y: 0, z: 0} 31 | m_LocalScale: {x: 1, y: 1, z: 1} 32 | m_Children: [] 33 | m_Father: {fileID: 0} 34 | m_RootOrder: 0 35 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 36 | --- !u!212 &5431176740932584624 37 | SpriteRenderer: 38 | m_ObjectHideFlags: 0 39 | m_CorrespondingSourceObject: {fileID: 0} 40 | m_PrefabInstance: {fileID: 0} 41 | m_PrefabAsset: {fileID: 0} 42 | m_GameObject: {fileID: 6175682493726170773} 43 | m_Enabled: 1 44 | m_CastShadows: 0 45 | m_ReceiveShadows: 0 46 | m_DynamicOccludee: 1 47 | m_MotionVectors: 1 48 | m_LightProbeUsage: 1 49 | m_ReflectionProbeUsage: 1 50 | m_RayTracingMode: 0 51 | m_RenderingLayerMask: 1 52 | m_RendererPriority: 0 53 | m_Materials: 54 | - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} 55 | m_StaticBatchInfo: 56 | firstSubMesh: 0 57 | subMeshCount: 0 58 | m_StaticBatchRoot: {fileID: 0} 59 | m_ProbeAnchor: {fileID: 0} 60 | m_LightProbeVolumeOverride: {fileID: 0} 61 | m_ScaleInLightmap: 1 62 | m_ReceiveGI: 1 63 | m_PreserveUVs: 0 64 | m_IgnoreNormalsForChartDetection: 0 65 | m_ImportantGI: 0 66 | m_StitchLightmapSeams: 1 67 | m_SelectedEditorRenderState: 0 68 | m_MinimumChartSize: 4 69 | m_AutoUVMaxDistance: 0.5 70 | m_AutoUVMaxAngle: 89 71 | m_LightmapParameters: {fileID: 0} 72 | m_SortingLayerID: 0 73 | m_SortingLayer: 0 74 | m_SortingOrder: 0 75 | m_Sprite: {fileID: 10913, guid: 0000000000000000f000000000000000, type: 0} 76 | m_Color: {r: 1, g: 1, b: 1, a: 1} 77 | m_FlipX: 0 78 | m_FlipY: 0 79 | m_DrawMode: 0 80 | m_Size: {x: 0.2, y: 0.2} 81 | m_AdaptiveModeThreshold: 0.5 82 | m_SpriteTileMode: 0 83 | m_WasSpriteAssigned: 1 84 | m_MaskInteraction: 0 85 | m_SpriteSortPoint: 0 86 | --- !u!114 &5637006959597989232 87 | MonoBehaviour: 88 | m_ObjectHideFlags: 0 89 | m_CorrespondingSourceObject: {fileID: 0} 90 | m_PrefabInstance: {fileID: 0} 91 | m_PrefabAsset: {fileID: 0} 92 | m_GameObject: {fileID: 6175682493726170773} 93 | m_Enabled: 1 94 | m_EditorHideFlags: 0 95 | m_Script: {fileID: -520381238, guid: d96c16e615664044ea88249c420e3276, type: 3} 96 | m_Name: 97 | m_EditorClassIdentifier: 98 | --- !u!114 &5637006959597989231 99 | MonoBehaviour: 100 | m_ObjectHideFlags: 0 101 | m_CorrespondingSourceObject: {fileID: 0} 102 | m_PrefabInstance: {fileID: 0} 103 | m_PrefabAsset: {fileID: 0} 104 | m_GameObject: {fileID: 6175682493726170773} 105 | m_Enabled: 1 106 | m_EditorHideFlags: 0 107 | m_Script: {fileID: 11500000, guid: eec8f36a35d43bc4e8192e8d097f3441, type: 3} 108 | m_Name: 109 | m_EditorClassIdentifier: 110 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/Assets/Tests/DependencyInjectorTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using System; 3 | using System.Collections; 4 | using TinyECSUnityIntegration.Impls; 5 | using UnityEngine; 6 | using UnityEngine.TestTools; 7 | 8 | 9 | [TestFixture] 10 | public class DependencyInjectorTests 11 | { 12 | [UnityTest] 13 | public IEnumerator TestInit_CreateViewWithPlaneHierarchy_InvokesInit() 14 | { 15 | TestController.Create(); 16 | 17 | yield return new WaitForEndOfFrame(); 18 | 19 | bool isInitialized = false; 20 | 21 | GameObject viewGO = new GameObject("TestStaticView"); 22 | 23 | viewGO.AddComponent().OnRegister = () => 24 | { 25 | isInitialized = true; 26 | }; 27 | 28 | var dependencyInjector = viewGO.AddComponent(); 29 | dependencyInjector.Init(); 30 | 31 | yield return null; 32 | 33 | Assert.IsTrue(isInitialized); 34 | } 35 | 36 | // Test to check issue #30 https://github.com/bnoazx005/TinyECS/issues/30 37 | 38 | [UnityTest] 39 | public IEnumerator TestInit_CreateViewWithNestedSubviews_CorrectlyInitializesAllViews() 40 | { 41 | TestController.Create(); 42 | 43 | yield return new WaitForEndOfFrame(); 44 | 45 | uint actualCounter = 0; 46 | uint expectedCounter = 3; 47 | 48 | Func addView = (parent) => 49 | { 50 | GameObject go = new GameObject(); 51 | 52 | go.AddComponent().OnRegister = () => 53 | { 54 | actualCounter++; 55 | }; 56 | 57 | go.transform.SetParent(parent); 58 | 59 | return go; 60 | }; 61 | 62 | /* 63 | * The code below creates the following tree of GameObjects 64 | * 65 | * View 66 | * |- SubView 67 | * |-NestedView 68 | * ------- 69 | */ 70 | 71 | GameObject go1 = addView(null); 72 | GameObject go2 = addView(go1.transform); 73 | GameObject go3 = addView(go2.transform); 74 | 75 | var dependencyInjector = go1.AddComponent(); 76 | dependencyInjector.Init(); 77 | 78 | yield return new WaitForEndOfFrame(); 79 | 80 | Assert.AreEqual(expectedCounter, actualCounter); 81 | } 82 | 83 | // https://github.com/bnoazx005/TinyECS/issues/31 84 | 85 | [UnityTest] 86 | public IEnumerator TestInit_CreateNewInstanceButWorldContextIsNotInitialized_DoNothing() 87 | { 88 | bool isInitialized = false; 89 | 90 | GameObject viewGO = new GameObject("TestStaticView"); 91 | 92 | viewGO.AddComponent().OnRegister = () => 93 | { 94 | isInitialized = true; 95 | }; 96 | 97 | var dependencyInjector = viewGO.AddComponent(); 98 | dependencyInjector.Init(); 99 | 100 | yield return null; 101 | 102 | Assert.IsFalse(isInitialized); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/Assets/Tests/StaticViewsTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using System.Collections; 3 | using TinyECSUnityIntegration.Impls; 4 | using UnityEngine; 5 | using UnityEngine.TestTools; 6 | 7 | 8 | [TestFixture] 9 | public class StaticViewsTests 10 | { 11 | [UnityTest] 12 | public IEnumerator TestPreInit_CreateNewView_SuccessfullyInvokesPreInitAndCreateRequestEntity() 13 | { 14 | // This execution order imitates scenes loading, for dynamic objects the order doesn't make sense 15 | var view = TestStaticView.Create(); 16 | var controller = TestController.Create(); 17 | 18 | yield return new WaitForEndOfFrame(); 19 | 20 | Assert.IsNotNull(controller); 21 | Assert.IsNotNull(view); 22 | 23 | var worldContext = controller.WorldContext; 24 | 25 | Assert.IsNotNull(worldContext); 26 | 27 | var registerRequestsEntity = worldContext.GetSingleEntityWithAll(typeof(TOnViewWaitForInitEventComponent)); 28 | Assert.IsNotNull(registerRequestsEntity); 29 | 30 | Assert.DoesNotThrow(() => 31 | { 32 | Assert.AreSame(view, registerRequestsEntity.GetComponent().mView); 33 | }); 34 | 35 | yield return new WaitForFixedUpdate(); 36 | yield return new WaitForFixedUpdate(); 37 | 38 | Assert.AreEqual(registerRequestsEntity.Id, view.LinkedEntityId); 39 | } 40 | 41 | [UnityTest] 42 | public IEnumerator TestRegisterSubscriptions_CreateNewView_InvokesRegisterSubscriptions() 43 | { 44 | bool hasRegisterSubscriptionsBeenInvoked = false; 45 | 46 | // This execution order imitates scenes loading, for dynamic objects the order doesn't make sense 47 | var view = TestStaticView.Create(() => 48 | { 49 | hasRegisterSubscriptionsBeenInvoked = true; 50 | }); 51 | var controller = TestController.Create(); 52 | 53 | yield return new WaitForEndOfFrame(); 54 | 55 | Assert.IsNotNull(controller); 56 | Assert.IsNotNull(view); 57 | 58 | yield return new WaitForFixedUpdate(); 59 | yield return new WaitForFixedUpdate(); 60 | 61 | Assert.IsTrue(hasRegisterSubscriptionsBeenInvoked); 62 | } 63 | 64 | [UnityTest] 65 | public IEnumerator TestRegisterViewSystem_CreateNewView_SystemRegistersItAndRemoveRequestEntity() 66 | { 67 | // This execution order imitates scenes loading, for dynamic objects the order doesn't make sense 68 | var view = TestStaticView.Create(); 69 | var controller = TestController.Create(); 70 | 71 | yield return new WaitForEndOfFrame(); 72 | 73 | Assert.IsNotNull(controller); 74 | Assert.IsNotNull(view); 75 | 76 | var worldContext = controller.WorldContext; 77 | 78 | Assert.IsNotNull(worldContext); 79 | Assert.IsNotNull(worldContext.GetSingleEntityWithAll(typeof(TOnViewWaitForInitEventComponent))); 80 | 81 | yield return new WaitForFixedUpdate(); 82 | yield return new WaitForFixedUpdate(); 83 | 84 | Assert.IsNull(worldContext.GetSingleEntityWithAll(typeof(TOnViewWaitForInitEventComponent))); 85 | 86 | var viewEntity = worldContext.GetSingleEntityWithAll(typeof(TViewComponent)); 87 | Assert.IsNotNull(viewEntity); 88 | Assert.AreEqual(viewEntity.Id, view.LinkedEntityId); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/Assets/Tests/TestController.cs: -------------------------------------------------------------------------------- 1 | using TinyECS.Impls; 2 | using TinyECS.Interfaces; 3 | using TinyECSUnityIntegration.Impls; 4 | using UnityEngine; 5 | 6 | 7 | public class TestController : MonoBehaviour 8 | { 9 | protected IWorldContext mWorldContext; 10 | 11 | protected ISystemManager mSystemManager; 12 | 13 | protected void Awake() 14 | { 15 | mWorldContext = new WorldContextFactory().CreateNewWorldInstance(); 16 | 17 | mSystemManager = new SystemManager(mWorldContext); 18 | 19 | WorldContextsManagerUtils.CreateWorldContextManager(mWorldContext, "WorldsContextsManager_System"); 20 | SystemManagerObserverUtils.CreateSystemManagerObserver(mSystemManager, "SystemManagerObserver_System"); 21 | 22 | mSystemManager.RegisterSystem(new RegisterViewSystem(mWorldContext)); 23 | 24 | mSystemManager.Init(); 25 | 26 | } 27 | 28 | protected void Update() => mSystemManager.Update(Time.deltaTime); 29 | 30 | public IWorldContext WorldContext => mWorldContext; 31 | 32 | public static TestController Create() 33 | { 34 | GameObject controllerObject = new GameObject("Controller"); 35 | controllerObject.AddComponent(); 36 | 37 | return controllerObject.GetComponent(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/Assets/Tests/TestStaticView.cs: -------------------------------------------------------------------------------- 1 | using TinyECS.Interfaces; 2 | using TinyECSUnityIntegration.Impls; 3 | using UnityEngine; 4 | using UnityEngine.Events; 5 | 6 | 7 | public class TestStaticView : BaseStaticView 8 | { 9 | public UnityAction OnRegister; 10 | 11 | public override void RegisterSubscriptions(IEventManager eventManager, EntityId entityId) 12 | { 13 | OnRegister?.Invoke(); 14 | } 15 | 16 | public static BaseView Create(UnityAction action = null) 17 | { 18 | GameObject go = new GameObject("TestStaticView"); 19 | go.AddComponent(); 20 | 21 | TestStaticView view = go.AddComponent(); 22 | view.OnRegister = action; 23 | 24 | return view; 25 | } 26 | } -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/Assets/Tests/Tests.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Tests", 3 | "references": [ 4 | "UnityEngine.TestRunner", 5 | "UnityEditor.TestRunner" 6 | ], 7 | "includePlatforms": [], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": true, 11 | "precompiledReferences": [ 12 | "nunit.framework.dll", 13 | "TinyECS.dll", 14 | "TinyECSUnityIntegration.dll" 15 | ], 16 | "autoReferenced": false, 17 | "defineConstraints": [ 18 | "UNITY_INCLUDE_TESTS" 19 | ], 20 | "versionDefines": [], 21 | "noEngineReferences": false 22 | } -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/Assets/TinyECS/TinyECS.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bnoazx005/TinyECS/e37e5e07a1871471ef3b7020791f53b6ec5041bc/TinyECSUnityIntegrationTests/Assets/TinyECS/TinyECS.dll -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/Assets/TinyECS/TinyECSUnityIntegration.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bnoazx005/TinyECS/e37e5e07a1871471ef3b7020791f53b6ec5041bc/TinyECSUnityIntegrationTests/Assets/TinyECS/TinyECSUnityIntegration.dll -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Volume: 1 8 | Rolloff Scale: 1 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_SampleRate: 0 12 | m_DSPBufferSize: 1024 13 | m_VirtualVoiceCount: 512 14 | m_RealVoiceCount: 32 15 | m_SpatializerPlugin: 16 | m_AmbisonicDecoderPlugin: 17 | m_DisableAudio: 0 18 | m_VirtualizeEffects: 1 19 | m_RequestedDSPBufferSize: 1024 20 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 11 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 0 23 | m_ReuseCollisionCallbacks: 1 24 | m_ClothInterCollisionSettingsToggle: 0 25 | m_ContactPairsMode: 0 26 | m_BroadphaseType: 0 27 | m_WorldBounds: 28 | m_Center: {x: 0, y: 0, z: 0} 29 | m_Extent: {x: 250, y: 250, z: 250} 30 | m_WorldSubdivisions: 8 31 | m_FrictionType: 0 32 | m_EnableEnhancedDeterminism: 0 33 | m_EnableUnifiedHeightmaps: 1 34 | m_DefaultMaxAngluarSpeed: 7 35 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: [] 8 | m_configObjects: {} 9 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 9 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_LineEndingsForNewScripts: 0 10 | m_DefaultBehaviorMode: 1 11 | m_PrefabRegularEnvironment: {fileID: 0} 12 | m_PrefabUIEnvironment: {fileID: 0} 13 | m_SpritePackerMode: 4 14 | m_SpritePackerPaddingPower: 1 15 | m_EtcTextureCompressorBehavior: 1 16 | m_EtcTextureFastCompressor: 1 17 | m_EtcTextureNormalCompressor: 2 18 | m_EtcTextureBestCompressor: 4 19 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref 20 | m_ProjectGenerationRootNamespace: 21 | m_CollabEditorSettings: 22 | inProgressEnabled: 1 23 | m_EnableTextureStreamingInEditMode: 1 24 | m_EnableTextureStreamingInPlayMode: 1 25 | m_AsyncShaderCompilation: 1 26 | m_EnterPlayModeOptionsEnabled: 0 27 | m_EnterPlayModeOptions: 3 28 | m_ShowLightmapResolutionOverlay: 1 29 | m_UseLegacyProbeSampleCount: 1 30 | m_AssetPipelineMode: 1 31 | m_CacheServerMode: 0 32 | m_CacheServerEndpoint: 33 | m_CacheServerNamespacePrefix: default 34 | m_CacheServerEnableDownload: 1 35 | m_CacheServerEnableUpload: 1 36 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 12 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 34 | m_PreloadedShaders: [] 35 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 36 | type: 0} 37 | m_CustomRenderPipeline: {fileID: 0} 38 | m_TransparencySortMode: 0 39 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 40 | m_DefaultRenderingPath: 1 41 | m_DefaultMobileRenderingPath: 1 42 | m_TierSettings: [] 43 | m_LightmapStripping: 0 44 | m_FogStripping: 0 45 | m_InstancingStripping: 0 46 | m_LightmapKeepPlain: 1 47 | m_LightmapKeepDirCombined: 1 48 | m_LightmapKeepDynamicPlain: 1 49 | m_LightmapKeepDynamicDirCombined: 1 50 | m_LightmapKeepShadowMask: 1 51 | m_LightmapKeepSubtractive: 1 52 | m_FogKeepLinear: 1 53 | m_FogKeepExp: 1 54 | m_FogKeepExp2: 1 55 | m_AlbedoSwatchInfos: [] 56 | m_LightsUseLinearIntensity: 0 57 | m_LightsUseColorTemperature: 0 58 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_JobOptions: 23 | serializedVersion: 2 24 | useMultithreading: 0 25 | useConsistencySorting: 0 26 | m_InterpolationPosesPerJob: 100 27 | m_NewContactsPerJob: 30 28 | m_CollideContactsPerJob: 100 29 | m_ClearFlagsPerJob: 200 30 | m_ClearBodyForcesPerJob: 200 31 | m_SyncDiscreteFixturesPerJob: 50 32 | m_SyncContinuousFixturesPerJob: 50 33 | m_FindNearestContactsPerJob: 100 34 | m_UpdateTriggerContactsPerJob: 100 35 | m_IslandSolverCostThreshold: 100 36 | m_IslandSolverBodyCostScale: 1 37 | m_IslandSolverContactCostScale: 10 38 | m_IslandSolverJointCostScale: 10 39 | m_IslandSolverBodiesPerJob: 50 40 | m_IslandSolverContactsPerJob: 50 41 | m_AutoSimulation: 1 42 | m_QueriesHitTriggers: 1 43 | m_QueriesStartInColliders: 1 44 | m_CallbacksOnDisable: 1 45 | m_ReuseCollisionCallbacks: 1 46 | m_AutoSyncTransforms: 0 47 | m_AlwaysShowColliders: 0 48 | m_ShowColliderSleep: 1 49 | m_ShowColliderContacts: 0 50 | m_ShowColliderAABB: 0 51 | m_ContactArrowScale: 0.2 52 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 53 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 54 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 55 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 56 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 57 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_DefaultPresets: {} 8 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 2019.4.0f1 2 | m_EditorVersionWithRevision: 2019.4.0f1 (0af376155913) 3 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 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 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.1 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_TestInitMode: 0 13 | CrashReportingSettings: 14 | m_EventUrl: https://perf-events.cloud.unity3d.com 15 | m_Enabled: 0 16 | m_LogBufferSize: 10 17 | m_CaptureEditorExceptions: 1 18 | UnityPurchasingSettings: 19 | m_Enabled: 0 20 | m_TestMode: 0 21 | UnityAnalyticsSettings: 22 | m_Enabled: 0 23 | m_TestMode: 0 24 | m_InitializeOnStartup: 1 25 | UnityAdsSettings: 26 | m_Enabled: 0 27 | m_InitializeOnStartup: 1 28 | m_TestMode: 0 29 | m_IosGameId: 30 | m_AndroidGameId: 31 | m_GameIds: {} 32 | m_GameId: 33 | PerformanceReportingSettings: 34 | m_Enabled: 0 35 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_StripUpdateShader: {fileID: 0} 10 | m_RenderPipeSettingsPath: 11 | m_FixedTimeStep: 0.016666668 12 | m_MaxDeltaTime: 0.05 13 | -------------------------------------------------------------------------------- /TinyECSUnityIntegrationTests/ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_SettingKeys": [ 3 | "VR Device Disabled", 4 | "VR Device User Alert" 5 | ], 6 | "m_SettingValues": [ 7 | "False", 8 | "False" 9 | ] 10 | } -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | image: Visual Studio 2017 2 | 3 | version: 0.4.{build} 4 | 5 | platform: 6 | - 'Any CPU' 7 | 8 | configuration: Release 9 | 10 | branches: 11 | # whitelist 12 | only: 13 | - master 14 | - test-build 15 | 16 | clone_depth: 1 17 | 18 | before_build: 19 | - nuget restore 20 | 21 | environment: 22 | COVERALLS_REPO_TOKEN: 23 | secure: y9Xai/mlfKfPkl5U1cpMgfbMD9pcqkiVNMa4jQLX0o0aa//5yiqHbys5Gn4Hofvj 24 | CODECOV_TOKEN: 25 | secure: adhiK/xX7bRpxvUgWD/4IBEGyoKcaRYB0XQeEureIcj4ufrixfQAFtSzWpdPJ3Td 26 | 27 | test: 28 | assemblies: 29 | - '**\bin\$(configuration)\TinyECSTests.dll' 30 | 31 | artifacts: 32 | - path: TinyECS.zip 33 | 34 | after_test: 35 | - cmd: packages\OpenCover.4.7.922\tools\OpenCover.Console.exe -register:user -filter:"+[*]* -[nunit.framework]*" -target:"packages\NUnit.ConsoleRunner.3.10.0\tools\nunit3-console.exe" -targetargs:"/domain:single TinyECSTests\bin\%CONFIGURATION%\TinyECSTests.dll" -output:coverage.xml 36 | - cmd: packages\coveralls.io.1.4.2\tools\coveralls.net.exe --opencover coverage.xml -r %COVERALLS_REPO_TOKEN% 37 | 38 | after_build: 39 | #create zip archive with all the binaries and documentation 40 | 7z a TinyECS.zip %APPVEYOR_BUILD_FOLDER%\TinyECS\bin\%CONFIGURATION%\*.dll %APPVEYOR_BUILD_FOLDER%\README.md %APPVEYOR_BUILD_FOLDER%\LICENSE %APPVEYOR_BUILD_FOLDER%\CHANGELOG.md %APPVEYOR_BUILD_FOLDER%\TinyECSUnityIntegration\bin\%CONFIGURATION%\TinyECSUnityIntegration.dll %APPVEYOR_BUILD_FOLDER%\TinyECSUnityIntegrationEditor\bin\%CONFIGURATION%\TinyECSUnityIntegrationEditor.dll 41 | 42 | skip_tags: true 43 | 44 | deploy: 45 | release: TinyECS-v$(appveyor_build_version) 46 | description: '' 47 | provider: GitHub 48 | auth_token: 49 | secure: 1xPR+/5vbL2PEPkG/LtjPXkZqAfB6vZWxVrUCdr6afKZ9utwUA7n6mzDv7//N2gk 50 | artifact: /.*\.zip/ 51 | draft: false 52 | prerelease: false 53 | on: 54 | branch: master # release from master branch only --------------------------------------------------------------------------------