├── .gitattributes
├── Archetype.cs
├── Archetype.cs.meta
├── CHANGELOG.md
├── CHANGELOG.md.meta
├── ComponentIndex.cs
├── ComponentIndex.cs.meta
├── DataAccessor.cs
├── DataAccessor.cs.meta
├── DataComponentPool.cs
├── DataComponentPool.cs.meta
├── DataPoolAccessor.cs
├── DataPoolAccessor.cs.meta
├── DataTaxonSlice.cs
├── DataTaxonSlice.cs.meta
├── ECS_Serializer.cs
├── ECS_Serializer.cs.meta
├── Editor.meta
├── Editor
├── EntityDrawer.cs
├── EntityDrawer.cs.meta
├── EntityView.cs
├── EntityView.cs.meta
├── ScriptableWrapper.cs
├── ScriptableWrapper.cs.meta
├── VodeoECS.editor.asmdef
└── VodeoECS.editor.asmdef.meta
├── Entity.cs
├── Entity.cs.meta
├── EntityTaxonSlice.cs
├── EntityTaxonSlice.cs.meta
├── EventEmitter.cs
├── EventEmitter.cs.meta
├── EventListener.cs
├── EventListener.cs.meta
├── EventManager.cs
├── EventManager.cs.meta
├── Events.meta
├── Events
├── ComponentCreationEvent.cs
├── ComponentCreationEvent.cs.meta
├── ComponentDestructionEvent.cs
├── ComponentDestructionEvent.cs.meta
├── DestroyEntityEvent.cs
├── DestroyEntityEvent.cs.meta
├── PrototypeLoadedEvent.cs
├── PrototypeLoadedEvent.cs.meta
├── WorldLoadedEvent.cs
└── WorldLoadedEvent.cs.meta
├── FilterComponentPool.cs
├── FilterComponentPool.cs.meta
├── FilterPoolReader.cs
├── FilterPoolReader.cs.meta
├── FilterTaxonSlice.cs
├── FilterTaxonSlice.cs.meta
├── FrameSystemECS.cs
├── FrameSystemECS.cs.meta
├── IComponent.cs
├── IComponent.cs.meta
├── IComponentPool.cs
├── IComponentPool.cs.meta
├── IDataComponent.cs
├── IDataComponent.cs.meta
├── IElementComponent.cs
├── IElementComponent.cs.meta
├── IEventECS.cs
├── IEventECS.cs.meta
├── IFilterComponent.cs
├── IFilterComponent.cs.meta
├── IFilterComponentPool.cs
├── IFilterComponentPool.cs.meta
├── IRegistryLoader.cs
├── IRegistryLoader.cs.meta
├── Internal.meta
├── Internal
├── ArchetypeData.cs
├── ArchetypeData.cs.meta
├── EventPool.cs
├── EventPool.cs.meta
├── FieldsOnlyResolver.cs
├── FieldsOnlyResolver.cs.meta
├── FilterCombination.cs
├── FilterCombination.cs.meta
├── IEventPool.cs
├── IEventPool.cs.meta
├── NativeNested.cs
├── NativeNested.cs.meta
├── SerializedPoolData.cs
├── SerializedPoolData.cs.meta
├── SerializedWorldData.cs
├── SerializedWorldData.cs.meta
├── SystemManager.cs
└── SystemManager.cs.meta
├── LICENSE
├── ListAccessor.cs
├── ListAccessor.cs.meta
├── ListComponentPool.cs
├── ListComponentPool.cs.meta
├── ListPoolAccessor.cs
├── ListPoolAccessor.cs.meta
├── ListTaxonSlice.cs
├── ListTaxonSlice.cs.meta
├── NamedRegistry.cs
├── NamedRegistry.cs.meta
├── NamedRegistryConverter.cs
├── NamedRegistryConverter.cs.meta
├── NativePriorityQueue.cs
├── NativePriorityQueue.cs.meta
├── PassiveSystemECS.cs
├── PassiveSystemECS.cs.meta
├── PrototypesManager.cs
├── PrototypesManager.cs.meta
├── Query.cs
├── Query.cs.meta
├── README.md
├── README.md.meta
├── Registry.cs
├── Registry.cs.meta
├── RegistryIndex.cs
├── RegistryIndex.cs.meta
├── Samples~
├── Example.meta
└── Example
│ ├── AISystem.cs
│ ├── AISystem.cs.meta
│ ├── AgentSystem.cs
│ ├── AgentSystem.cs.meta
│ ├── Components.meta
│ ├── Components
│ ├── AIFilter.cs
│ ├── AIFilter.cs.meta
│ ├── FlyingComponent.cs
│ ├── FlyingComponent.cs.meta
│ ├── HomeComponent.cs
│ ├── HomeComponent.cs.meta
│ ├── PathComponent.cs
│ ├── PathComponent.cs.meta
│ ├── PathNodeElement.cs
│ ├── PathNodeElement.cs.meta
│ ├── PhysicsComponent.cs
│ ├── PhysicsComponent.cs.meta
│ ├── PlayerFilter.cs
│ ├── PlayerFilter.cs.meta
│ ├── RoadComponent.cs
│ ├── RoadComponent.cs.meta
│ ├── RoadConnectionElement.cs
│ ├── RoadConnectionElement.cs.meta
│ ├── SpawnerComponent.cs
│ ├── SpawnerComponent.cs.meta
│ ├── TravelStateComponent.cs
│ └── TravelStateComponent.cs.meta
│ ├── Events.meta
│ ├── Events
│ ├── ChangeHomeEvent.cs
│ ├── ChangeHomeEvent.cs.meta
│ ├── InitializeFlyerEvent.cs
│ ├── InitializeFlyerEvent.cs.meta
│ ├── InputEvent.cs
│ ├── InputEvent.cs.meta
│ ├── NewPhysicalEvent.cs
│ ├── NewPhysicalEvent.cs.meta
│ ├── NewSpawnerEvent.cs
│ ├── NewSpawnerEvent.cs.meta
│ ├── PathCompleteEvent.cs
│ └── PathCompleteEvent.cs.meta
│ ├── FlyingSystem.cs
│ ├── FlyingSystem.cs.meta
│ ├── LevelGeneratorSystem.cs
│ ├── LevelGeneratorSystem.cs.meta
│ ├── Main.cs
│ ├── Main.cs.meta
│ ├── PathfindingSystem.cs
│ ├── PathfindingSystem.cs.meta
│ ├── PhysicsSystem.cs
│ ├── PhysicsSystem.cs.meta
│ ├── PlayerInputs.cs
│ ├── PlayerInputs.cs.meta
│ ├── PlayerSystem.cs
│ ├── PlayerSystem.cs.meta
│ ├── Resources.meta
│ ├── Resources
│ ├── Materials.meta
│ ├── Materials
│ │ ├── AgentMaterial.mat
│ │ ├── AgentMaterial.mat.meta
│ │ ├── AgentMaterial2.mat
│ │ ├── AgentMaterial2.mat.meta
│ │ ├── BasicMaterial.mat
│ │ ├── BasicMaterial.mat.meta
│ │ ├── CapsuleMaterial.mat
│ │ ├── CapsuleMaterial.mat.meta
│ │ ├── PrefabMaterial.mat
│ │ └── PrefabMaterial.mat.meta
│ ├── Meshes.meta
│ ├── Meshes
│ │ ├── cube.obj
│ │ └── cube.obj.meta
│ ├── Prefabs.meta
│ └── Prefabs
│ │ ├── Capsule.prefab
│ │ ├── Capsule.prefab.meta
│ │ ├── Cylinder.prefab
│ │ ├── Cylinder.prefab.meta
│ │ ├── Sphere.prefab
│ │ └── Sphere.prefab.meta
│ ├── Scenes.meta
│ ├── Scenes
│ ├── Scene.unity
│ └── Scene.unity.meta
│ ├── SpawnerSystem.cs
│ ├── SpawnerSystem.cs.meta
│ ├── StreamingAssets.meta
│ └── StreamingAssets
│ ├── ComponentFormats.meta
│ ├── ComponentFormats
│ ├── AIFilter.json
│ ├── AIFilter.json.meta
│ ├── FlyingComponent.json
│ ├── FlyingComponent.json.meta
│ ├── HomeComponent.json
│ ├── HomeComponent.json.meta
│ ├── MaterialFilter.json
│ ├── MaterialFilter.json.meta
│ ├── MeshRenderFilter.json
│ ├── MeshRenderFilter.json.meta
│ ├── ObjectRendererComponent.json
│ ├── ObjectRendererComponent.json.meta
│ ├── PathComponent.json
│ ├── PathComponent.json.meta
│ ├── PathNodeElement.json
│ ├── PathNodeElement.json.meta
│ ├── PhysicsComponent.json
│ ├── PhysicsComponent.json.meta
│ ├── PlayerFilter.json
│ ├── PlayerFilter.json.meta
│ ├── RenderLayerFilter.json
│ ├── RenderLayerFilter.json.meta
│ ├── RenderParentComponent.json
│ ├── RenderParentComponent.json.meta
│ ├── RoadComponent.json
│ ├── RoadComponent.json.meta
│ ├── RoadConnectionElement.json
│ ├── RoadConnectionElement.json.meta
│ ├── RotationComponent.json
│ ├── RotationComponent.json.meta
│ ├── ScaleComponent.json
│ ├── ScaleComponent.json.meta
│ ├── SpawnerComponent.json
│ ├── SpawnerComponent.json.meta
│ ├── StaticPositionComponent.json
│ ├── StaticPositionComponent.json.meta
│ ├── TrajectoryComponent.json
│ ├── TrajectoryComponent.json.meta
│ ├── TravelStateComponent.json
│ └── TravelStateComponent.json.meta
│ ├── Prototypes.meta
│ └── Prototypes
│ ├── AICapsule.json
│ ├── AICapsule.json.meta
│ ├── Agent.json
│ ├── Agent.json.meta
│ ├── Capsule.json
│ ├── Capsule.json.meta
│ ├── Cylinder.json
│ ├── Cylinder.json.meta
│ ├── Home.json
│ ├── Home.json.meta
│ ├── PlayerCapsule.json
│ ├── PlayerCapsule.json.meta
│ ├── ReturningAgent.json
│ ├── ReturningAgent.json.meta
│ ├── Road.json
│ ├── Road.json.meta
│ ├── RoadNode.json
│ ├── RoadNode.json.meta
│ ├── Spawner.json
│ └── Spawner.json.meta
├── ScheduleQueue.cs
├── ScheduleQueue.cs.meta
├── ScheduleQueueManager.cs
├── ScheduleQueueManager.cs.meta
├── ScheduledSystemECS.cs
├── ScheduledSystemECS.cs.meta
├── Standard.meta
├── Standard
├── Components.meta
├── Components
│ ├── MaterialFilter.cs
│ ├── MaterialFilter.cs.meta
│ ├── MeshRenderFilter.cs
│ ├── MeshRenderFilter.cs.meta
│ ├── ObjectRendererComponent.cs
│ ├── ObjectRendererComponent.cs.meta
│ ├── RenderLayerFilter.cs
│ ├── RenderLayerFilter.cs.meta
│ ├── RenderParentComponent.cs
│ ├── RenderParentComponent.cs.meta
│ ├── RotationComponent.cs
│ ├── RotationComponent.cs.meta
│ ├── ScaleComponent.cs
│ ├── ScaleComponent.cs.meta
│ ├── StaticPositionComponent.cs
│ ├── StaticPositionComponent.cs.meta
│ ├── TrajectoryComponent.cs
│ └── TrajectoryComponent.cs.meta
├── Events.meta
├── Events
│ ├── UpdateStaticMeshesEvent.cs
│ └── UpdateStaticMeshesEvent.cs.meta
├── MeshRenderSystem.cs
├── MeshRenderSystem.cs.meta
├── ObjectRenderSystem.cs
├── ObjectRenderSystem.cs.meta
├── PrefabPool.cs
├── PrefabPool.cs.meta
├── RegistryLoaders.meta
└── RegistryLoaders
│ ├── MaterialLoader.cs
│ ├── MaterialLoader.cs.meta
│ ├── MeshLoader.cs
│ ├── MeshLoader.cs.meta
│ ├── PrefabLoader.cs
│ └── PrefabLoader.cs.meta
├── StringRegistryConverter.cs
├── StringRegistryConverter.cs.meta
├── SystemECS.cs
├── SystemECS.cs.meta
├── Taxon.cs
├── Taxon.cs.meta
├── VodeoECS.asmdef
├── VodeoECS.asmdef.meta
├── World.cs
├── World.cs.meta
├── package.json
└── package.json.meta
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/Archetype.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using VodeoECS.Internal;
3 |
4 | namespace VodeoECS
5 | {
6 | ///
7 | /// Identifier for an Archetype. This doesn't contain any data, it's just a unique identifier.
8 | /// Archetypes represent sets of Component Types and are matched by Entities which contain the same components.
9 | /// They are used with the World class to make queries matching the Archetype.
10 | ///
11 | public readonly struct Archetype : IEquatable
12 | {
13 | ///
14 | /// The unique Registry Index of the Archetype.
15 | ///
16 | public RegistryIndex index { get; }
17 | ///
18 | /// For Internal use by the World class. Use the appropriate World class methods to register new Archetypes.
19 | ///
20 | /// Unique Registry Index.
21 | public Archetype ( RegistryIndex index )
22 | {
23 | this.index = index;
24 | }
25 | public bool Equals ( Archetype other )
26 | {
27 | return this.index.Equals( other.index );
28 | }
29 | public static bool operator == ( Archetype x, Archetype y ) { return x.Equals( y ); }
30 | public static bool operator != ( Archetype x, Archetype y ) { return !( x.Equals( y ) ); }
31 | public override bool Equals ( object o )
32 | {
33 | if ( o == null ) return false;
34 | else return this == ( Archetype )o;
35 | }
36 | public override int GetHashCode ( )
37 | {
38 | return ( index ).GetHashCode( );
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/Archetype.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0f0dcb563bbb63648940727bd651fa76
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/VodeoGames/VodeoECS/3eee1cdc9d845da160ca0bef69b08afb62f27031/CHANGELOG.md
--------------------------------------------------------------------------------
/CHANGELOG.md.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: df8879d451f164846940be6e8f8efdca
3 | TextScriptImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/ComponentIndex.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace VodeoECS
5 | {
6 | ///
7 | /// Index for accessing a specific Component in Component Pools. Components within an Archetype share the same ComponentIndex if their Entities implement the Archetype!
8 | /// Component Indices should not be stored permanently as they are invalidated by Component removal, and Archetype or Filter changes. Accessing a Component through a Component Index is more efficient than through an Entity.
9 | ///
10 | public readonly struct ComponentIndex : IEquatable
11 | {
12 | ///
13 | /// The Null Component Index.
14 | ///
15 | public static ComponentIndex Null { get { return new ComponentIndex( 0 ); } }
16 | ///
17 | /// The integer indexing the specific Component entry within its Taxon. (20 bits max).
18 | ///
19 | public int entry { get { return ( int )( value & ( ( 1 << 20 ) - 1 ) ); } } // 20 bits for entry
20 | ///
21 | /// The integer indexing the Taxon the Component is in. (12 bits max).
22 | ///
23 | public int taxonID { get { return ( int )( value >> 20 ); } } // 12 bits for taxon
24 |
25 | private readonly uint value;
26 |
27 | ///
28 | /// For internal use by Component Pools. Constructor for a Component Index.
29 | ///
30 | /// The integer indexing the specific Component entry within its Taxon. (20 bits max).
31 | /// The integer indexing the Taxon the Component is in. (12 bits max).
32 | public ComponentIndex ( int entry, int taxonID )
33 | {
34 | this.value = ( ( uint )taxonID << 20 ) | ( uint )entry;
35 | }
36 | public bool Equals ( ComponentIndex other ) { return ( this.value == other.value ); }
37 | public override int GetHashCode ( ) { return ( value ).GetHashCode( ); }
38 | public static bool operator == ( ComponentIndex x, ComponentIndex y ) { return x.Equals( y ); }
39 | public static bool operator != ( ComponentIndex x, ComponentIndex y ) { return !( x.Equals( y ) ); }
40 | public override bool Equals ( object o )
41 | {
42 | if ( o == null ) return false;
43 | else return this == ( ComponentIndex )o;
44 | }
45 | private ComponentIndex ( uint value ) { this.value = value; }
46 | }
47 | }
--------------------------------------------------------------------------------
/ComponentIndex.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: edc0d00441efbd44b9cbbd12f26c228d
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/DataAccessor.cs:
--------------------------------------------------------------------------------
1 | using Unity.Collections;
2 |
3 | namespace VodeoECS
4 | {
5 | ///
6 | /// Accessor for reading and writing to a single Data Component.
7 | /// Can be passed to Burst Compiled jobs.
8 | ///
9 | /// The type of Data Component.
10 | public struct DataAccessor where T : unmanaged, IDataComponent
11 | {
12 | //Disabled because it discourages accessor re-use
13 | ///
14 | /// Implicit cast to value.
15 | ///
16 | /// The data accessor to cast.
17 | //public static implicit operator T ( DataAccessor a ) => a.Value;
18 |
19 | ///
20 | /// The value of the Data Component.
21 | ///
22 | public T Value { get { return slice[0]; } }
23 |
24 | ///
25 | /// For internal use by the Data Component Pool class. Constructs a Data Accessor.
26 | ///
27 | /// The length 1 slice pointing to the Data Component.
28 | public DataAccessor ( NativeSlice slice )
29 | {
30 | this.slice = slice;
31 | }
32 | ///
33 | /// Write to the Data Component.
34 | ///
35 | /// The value to write to the Data Component.
36 | public void Write ( T value ) { slice[0] = value; }
37 |
38 | private NativeSlice slice;
39 | }
40 | }
--------------------------------------------------------------------------------
/DataAccessor.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 99b6e70d0f4514e439c0580abdd0307f
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/DataComponentPool.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a76a4815943eb2342a33c70e35d7f5d0
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/DataPoolAccessor.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7ffaeb8a0bd43df48a40b2c6a377860d
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/DataTaxonSlice.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using Unity.Collections;
5 | using Unity.Collections.LowLevel.Unsafe;
6 |
7 | namespace VodeoECS
8 | {
9 | ///
10 | /// A slice into the Data Components associated with a single Taxon.
11 | /// The order of Entities associated with each Component in a Taxon Slice is preserved across all Component Pools sharing the Taxon.
12 | /// Can be passed to Burst Compiled jobs.
13 | ///
14 | /// The type of the Data Components accessed by this Taxon Slice.
15 | public struct DataTaxonSlice : IEnumerable where T : unmanaged, IDataComponent
16 | {
17 | ///
18 | /// Number of Data Components in this Slice.
19 | ///
20 | public int Length { get { return slice.Length; } }
21 | private NativeSlice slice;
22 |
23 | ///
24 | /// For internal use by the Data Component Pool class. Constructs a Data Taxon Slice.
25 | ///
26 | /// A NativeSlice into the Data Components for a single Taxon.
27 | public DataTaxonSlice ( NativeSlice slice )
28 | {
29 | this.slice = slice;
30 | }
31 |
32 | ///
33 | /// The Data Component at a specific position in the Taxon Slice.
34 | /// The order of Entities associated with each Component in a Taxon Slice is preserved across all Component Pools sharing the Taxon.
35 | ///
36 | /// The position of the Data Component in the Taxon Slice.
37 | /// The value of the Data Component at the given position.
38 | public T this[int i]
39 | {
40 | get
41 | {
42 | return slice[i];
43 | }
44 | set
45 | {
46 | this.slice[i] = value;
47 | }
48 | }
49 | ///
50 | /// Enumerates through all Data Component values in this Taxon Slice.
51 | /// The order of Entities associated with each Component in a Taxon Slice is preserved across all Component Pools sharing the Taxon.
52 | ///
53 | /// Each Data Component value in the Taxon Slice.
54 | public IEnumerator GetEnumerator ( )
55 | {
56 | for ( int i = 0; i < this.Length; i++ )
57 | {
58 | yield return slice[i];
59 | }
60 | }
61 | IEnumerator IEnumerable.GetEnumerator ( )
62 | {
63 | return GetEnumerator( );
64 | }
65 | }
66 | }
--------------------------------------------------------------------------------
/DataTaxonSlice.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ce6d0e987c8c1bc40bb895eb1060e1f9
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/ECS_Serializer.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 884e7f85f4af8584db52f95bf98c7d57
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Editor.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7e5060dfb30dc7545884a23f5242708a
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Editor/EntityDrawer.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 | using System;
5 | using UnityEditor;
6 |
7 |
8 | namespace VodeoECS.Editor
9 | {
10 | [CustomPropertyDrawer( typeof( Entity ) )]
11 | public class EntityDrawer : PropertyDrawer
12 | {
13 | // Draw the property inside the given rect
14 | public override void OnGUI ( Rect position, SerializedProperty property, GUIContent label )
15 | {
16 | // Using BeginProperty / EndProperty on the parent property means that
17 | // prefab override logic works on the entire property.
18 | EditorGUI.BeginProperty( position, label, property );
19 |
20 | // Draw label
21 | position = EditorGUI.PrefixLabel( position, GUIUtility.GetControlID( FocusType.Passive ), label );
22 |
23 | // Don't make child fields be indented
24 | var indent = EditorGUI.indentLevel;
25 | EditorGUI.indentLevel = 0;
26 |
27 | // Calculate rects
28 | var idRect = new Rect( position.x, position.y, 200, position.height );
29 | var protoRect = new Rect( position.x + 35, position.y, 200, position.height );
30 |
31 | // Draw fields - passs GUIContent.none to each so they are drawn without labels
32 | Entity entity = (Entity)EntityView.GetTargetObjectOfProperty(property);
33 | EditorGUI.IntField( idRect, entity.ID);
34 | if ( entity.prototype ) EditorGUI.LabelField( protoRect, "(Prototype)");
35 |
36 | // Set indent back to what it was
37 | EditorGUI.indentLevel = indent;
38 |
39 | EditorGUI.EndProperty( );
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Editor/EntityDrawer.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 32fde5a7b9c93d6489b0bf448c4be6d3
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Editor/EntityView.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: df8601098f3b4b6409a86a934bd0c36b
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Editor/ScriptableWrapper.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 |
5 | namespace VodeoECS.Editor
6 | {
7 | public class ScriptableWrapper : ScriptableObject
8 | {
9 | [SerializeReference]
10 | public IComponent data;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Editor/ScriptableWrapper.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1ac11eec16eb6e14a9d89331827f8145
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Editor/VodeoECS.editor.asmdef:
--------------------------------------------------------------------------------
1 | {
2 | "name": "VodeoECS.editor",
3 | "rootNamespace": "",
4 | "references": [
5 | "GUID:d2f772b09a8235b4d88b3956a8365dd9"
6 | ],
7 | "includePlatforms": [
8 | "Editor"
9 | ],
10 | "excludePlatforms": [],
11 | "allowUnsafeCode": false,
12 | "overrideReferences": false,
13 | "precompiledReferences": [],
14 | "autoReferenced": true,
15 | "defineConstraints": [],
16 | "versionDefines": [],
17 | "noEngineReferences": false
18 | }
--------------------------------------------------------------------------------
/Editor/VodeoECS.editor.asmdef.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1191ec205a1560e44ba8e2983fea06e1
3 | AssemblyDefinitionImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Entity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace VodeoECS
4 | {
5 | ///
6 | /// Entity struct: this is simply an identifier and doesn't contain any component data.
7 | ///
8 | [Serializable]
9 | public readonly struct Entity : IEquatable
10 | {
11 | ///
12 | /// The Null Entity identifier.
13 | ///
14 | public static Entity Null { get { return new Entity( 0 ); } }
15 | ///
16 | /// The unique integer identifying this Entity.
17 | ///
18 | public int ID { get { return ( int )( value & ( ( ( uint )1 << 31 ) - 1 ) ); } } // 31 bits for ID
19 | ///
20 | /// Is the Entity a prototype?
21 | ///
22 | public bool prototype { get { return ( value >> 31 ) > 0; } } // 1 prototype bit
23 |
24 | private readonly uint value;
25 |
26 | ///
27 | /// Entity Constructor. For internal use only, entities should normally be created from the World class.
28 | ///
29 | /// The unique integer identifying this Entity.
30 | /// Is the Entity a prototype?
31 | public Entity ( int ID, bool prototype )
32 | {
33 | this.value = ( ( uint )ID ) | ( uint )( prototype ? 1 : 0 ) << 31;
34 | }
35 | public bool Equals ( Entity other ) { return this.value == other.value; }
36 | public override int GetHashCode ( ) { return ( value ).GetHashCode( ); }
37 | public static bool operator == ( Entity x, Entity y ) { return x.Equals( y ); }
38 | public static bool operator != ( Entity x, Entity y ) { return !( x.Equals( y ) ); }
39 | public override bool Equals ( object o )
40 | {
41 | if ( o == null ) return false;
42 | else return this == ( Entity )o;
43 | }
44 | private Entity ( uint value ) { this.value = value; }
45 | }
46 | }
--------------------------------------------------------------------------------
/Entity.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0c0569dc28cfc6c43883ee22e72ede84
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/EntityTaxonSlice.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using System.Collections.Generic;
3 | using Unity.Collections;
4 |
5 | namespace VodeoECS
6 | {
7 | ///
8 | /// A slice into the Entities associated with a single Taxon from a Component Pool. The order of Entities associated with each Component is preserved across all Taxa from the same Query.
9 | /// Can be passed to Burst Compiled jobs.
10 | ///
11 | public readonly struct EntityTaxonSlice : IEnumerable
12 | {
13 | ///
14 | /// The Entity at a specific position in the Taxon Slice.
15 | /// The order of Entities in a Taxon Slice is preserved across all Component Pools sharing the Taxon, and correspond to the order of Components in other types of Taxon Slice.
16 | ///
17 | /// The position of the Entity in the Taxon Slice.
18 | /// The Entity at the given position.
19 | public Entity this[int i] { get { return slice[i]; } }
20 | ///
21 | /// Number of Data Components in this Slice.
22 | ///
23 | public int Length { get { return slice.Length; } }
24 | private readonly NativeSlice slice;
25 | ///
26 | /// For internal use by the Component Pool classes. Constructs an Entity Taxon Slice.
27 | ///
28 | /// A NativeSlice into the Entities for a single Taxon.
29 | public EntityTaxonSlice ( NativeSlice slice )
30 | {
31 | this.slice = slice;
32 | }
33 | ///
34 | /// Enumerates through all Data Component values in this Taxon Slice.
35 | /// The order of Entities in a Taxon Slice is preserved across all Component Pools sharing the Taxon, and correspond to the order of Components in other types of Taxon Slice.
36 | ///
37 | /// Each Entity in the Taxon Slice.
38 | public IEnumerator GetEnumerator ( )
39 | {
40 | for ( int i = 0; i < this.Length; i++ )
41 | yield return slice[i];
42 | }
43 | IEnumerator IEnumerable.GetEnumerator ( )
44 | {
45 | return GetEnumerator( );
46 | }
47 | }
48 | }
--------------------------------------------------------------------------------
/EntityTaxonSlice.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5c3488a9df731324aa2ab6afa9116549
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/EventEmitter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Runtime.InteropServices;
5 | using Unity.Collections;
6 |
7 | namespace VodeoECS
8 | {
9 | ///
10 | /// Event Emitters are used to create new Events of a given type.
11 | ///
12 | /// The type of Events this Emitter creates.
13 | public struct EventEmitter where T : unmanaged, IEventECS
14 | {
15 | private NativeList eventQueue;
16 |
17 | ///
18 | /// Constructor. For internal use by Event pool.
19 | ///
20 | ///
21 | public EventEmitter( NativeList eventQueue )
22 | {
23 | this.eventQueue = eventQueue;
24 | }
25 |
26 | ///
27 | /// Create a new Event of type T.
28 | ///
29 | /// The Event to create.
30 | public void CreateEvent ( T theEvent )
31 | {
32 | this.eventQueue.Add( theEvent );
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/EventEmitter.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 64800ffdafd277944a1cb99666745f96
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/EventListener.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Runtime.InteropServices;
5 | using Unity.Collections;
6 |
7 | namespace VodeoECS
8 | {
9 | ///
10 | /// Event Listeners are used to listen to Events of a given type.
11 | ///
12 | /// The type of Events this Listener listens to.
13 | public struct EventListener : IEnumerable where T : unmanaged, IEventECS
14 | {
15 | private NativeList eventList;
16 |
17 | ///
18 | /// The number of Events of type T currently buffered.
19 | ///
20 | public int Count { get { return eventList.Length; } }
21 | ///
22 | /// Constructor. For internal use by Event Pool.
23 | ///
24 | ///
25 | public EventListener ( NativeList eventList )
26 | {
27 | this.eventList = eventList;
28 | }
29 |
30 | ///
31 | /// Enumerates through access to all Events of type T.
32 | ///
33 | /// The value of each Event.
34 | public IEnumerator GetEnumerator ( )
35 | {
36 | foreach ( T e in this.eventList )
37 | {
38 | yield return e;
39 | }
40 | }
41 | IEnumerator IEnumerable.GetEnumerator ( )
42 | {
43 | return GetEnumerator( );
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/EventListener.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 77e493d123bc52f4bbea599e13d3c77a
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/EventManager.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 465c5e67d642be34c8e6c6fb050885c6
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Events.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e2c8e8ca33351e84386c8fb2c4c4c1a2
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Events/ComponentCreationEvent.cs:
--------------------------------------------------------------------------------
1 | namespace VodeoECS
2 | {
3 | ///
4 | /// Generic event for signaling the creation of a component of type T.
5 | ///
6 | /// The type of the component that was created.
7 | public struct ComponentCreationEvent : IEventECS
8 | {
9 | public Entity entity;
10 | }
11 | }
--------------------------------------------------------------------------------
/Events/ComponentCreationEvent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0d6140b999fccca4bb88d40252eb4ded
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Events/ComponentDestructionEvent.cs:
--------------------------------------------------------------------------------
1 | namespace VodeoECS
2 | {
3 | ///
4 | /// Generic event for signaling the destruction of a component of type T.
5 | ///
6 | /// The type of the component that was destroyed.
7 | public struct ComponentDestructionEvent : IEventECS
8 | {
9 | public Entity entity;
10 | public T component;
11 | }
12 | }
--------------------------------------------------------------------------------
/Events/ComponentDestructionEvent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ca84536c3ccd57042903e977cd2ff267
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Events/DestroyEntityEvent.cs:
--------------------------------------------------------------------------------
1 | namespace VodeoECS
2 | {
3 | ///
4 | /// Event emitted to destroy an Entity. Listen to this event to perform system-specific cleanup.
5 | ///
6 | public struct DestroyEntityEvent : IEventECS
7 | {
8 | public Entity entity;
9 | }
10 | }
--------------------------------------------------------------------------------
/Events/DestroyEntityEvent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 22ece53331427aa4bb04bcf55532796c
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Events/PrototypeLoadedEvent.cs:
--------------------------------------------------------------------------------
1 | namespace VodeoECS
2 | {
3 | ///
4 | /// This event is emitted whenever a new Prototype is loaded.
5 | ///
6 | public struct PrototypeLoadedEvent : IEventECS
7 | {
8 | public Entity prototype;
9 | }
10 | }
--------------------------------------------------------------------------------
/Events/PrototypeLoadedEvent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b0225f7d5c1fad342bfba533d345007f
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Events/WorldLoadedEvent.cs:
--------------------------------------------------------------------------------
1 | namespace VodeoECS
2 | {
3 | ///
4 | /// An event that is emitted when the world is deserialized.
5 | ///
6 | public struct WorldLoadedEvent : IEventECS { }
7 | }
--------------------------------------------------------------------------------
/Events/WorldLoadedEvent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 24c6a10f1ef1af442a75b5da052fd6bf
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/FilterComponentPool.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c7a1336360ec08a46a081a77ef215b65
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/FilterPoolReader.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f1f9b1648f392384eaa94c2703afd501
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/FilterTaxonSlice.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using Unity.Collections;
5 | using Unity.Collections.LowLevel.Unsafe;
6 |
7 | namespace VodeoECS
8 | {
9 | ///
10 | /// A slice into the Filter Components associated with a single Taxon.
11 | /// The order of Entities associated with each Component in a Taxon Slice is preserved across all Component Pools sharing the Taxon.
12 | /// Can be passed to Burst Compiled jobs.
13 | ///
14 | /// The type of the Filter Components accessed by this Taxon Slice.
15 | public struct FilterTaxonSlice : IEnumerable where T : unmanaged, IFilterComponent
16 | {
17 | ///
18 | /// Number of Filter Components in this Slice.
19 | ///
20 | public int Length { get { return IDs.Length; } }
21 | private NativeSlice IDs;
22 | private NativeSlice filtersByID;
23 |
24 | ///
25 | /// For internal use by the Filter Component Pool class. Constructs a Filter Taxon Slice.
26 | ///
27 | /// A slice into all unique Filter Components in the Filter Pool.
28 | /// A slice into the Filter indices for a single Taxon in the Filter Pool.
29 | public FilterTaxonSlice ( NativeSlice filter_slice, NativeSlice id_slice )
30 | {
31 | this.IDs = id_slice;
32 | this.filtersByID = filter_slice;
33 | }
34 |
35 | ///
36 | /// The value of the Filter Component at a specific position in the Taxon Slice.
37 | /// The order of Entities associated with each Component in a Taxon Slice is preserved across all Component Pools sharing the Taxon.
38 | ///
39 | /// The position of the Filter Component in the Taxon Slice.
40 | /// The value of the Filter Component at the given position.
41 | public T this[int i]
42 | {
43 | get
44 | {
45 | return filtersByID[IDs[i]];
46 | }
47 | }
48 | ///
49 | /// Enumerates through all Filter Component values in this Taxon Slice.
50 | /// The order of Entities associated with each Component in a Taxon Slice is preserved across all Component Pools sharing the Taxon.
51 | ///
52 | /// Each Filter Component value in the Taxon Slice.
53 | public IEnumerator GetEnumerator ( )
54 | {
55 | for ( int i = 0; i < this.Length; i++ )
56 | {
57 | yield return filtersByID[IDs[i]];
58 | }
59 | }
60 | IEnumerator IEnumerable.GetEnumerator ( )
61 | {
62 | return GetEnumerator( );
63 | }
64 | }
65 | }
--------------------------------------------------------------------------------
/FilterTaxonSlice.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3749450425e1543489259dc00d7f8663
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/FrameSystemECS.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 |
5 | namespace VodeoECS
6 | {
7 | ///
8 | /// FrameSystems are updated everytime a graphical frame needs to be rendered.
9 | ///
10 | public abstract class FrameSystemECS : SystemECS
11 | {
12 | ///
13 | /// Construct a Frame System.
14 | ///
15 | /// The World object.
16 | public FrameSystemECS ( World world )
17 | {
18 | world.Systems.RegisterSystem( this );
19 | }
20 | ///
21 | /// Prepare frame for rendering.
22 | ///
23 | /// The time at which the frame is to be rendered.
24 | public abstract void UpdateFrame ( float t );
25 | ///
26 | /// Complete frame rendering.
27 | ///
28 | public abstract void CompleteUpdate ( );
29 | }
30 | }
--------------------------------------------------------------------------------
/FrameSystemECS.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3a99b4b4724120c43be4e697f1088519
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/IComponent.cs:
--------------------------------------------------------------------------------
1 | namespace VodeoECS
2 | {
3 | ///
4 | /// Interface for ECS Components. All Component Types must implement this.
5 | ///
6 | public interface IComponent { }
7 | }
--------------------------------------------------------------------------------
/IComponent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: af9ea8f09e1d45e4086c996a2852ca6b
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/IComponentPool.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 9095a67ca0432b04fa7bce6fe6873272
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/IDataComponent.cs:
--------------------------------------------------------------------------------
1 | namespace VodeoECS
2 | {
3 | ///
4 | /// Interface for ECS Data Components. All Data Component Types must implement this.
5 | ///
6 | public interface IDataComponent : IComponent { }
7 | }
--------------------------------------------------------------------------------
/IDataComponent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4de465e01707a164db25c1aac54256cc
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/IElementComponent.cs:
--------------------------------------------------------------------------------
1 | using VodeoECS.Internal;
2 | using System;
3 | using System.Collections;
4 | using System.Collections.Generic;
5 | using System.Runtime.InteropServices;
6 | using Unity.Collections;
7 |
8 | namespace VodeoECS
9 | {
10 | ///
11 | /// Interface for List Components. All List Component Element Types must implement this.
12 | ///
13 | public interface IElementComponent : IComponent { }
14 | }
--------------------------------------------------------------------------------
/IElementComponent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 20a0222ba282bf94b8173c3b8d3c21a5
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/IEventECS.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Runtime.InteropServices;
5 | using Unity.Collections;
6 | using Unity.Collections.LowLevel.Unsafe;
7 | using UnityEngine;
8 |
9 | namespace VodeoECS
10 | {
11 | ///
12 | /// Interface for ECS Events. All ECS Event Types must implement this.
13 | ///
14 | public interface IEventECS { }
15 | }
--------------------------------------------------------------------------------
/IEventECS.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ac0b80fd575c7504fbe9d81cc357687d
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/IFilterComponent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Runtime.InteropServices;
5 | using Unity.Collections;
6 |
7 | namespace VodeoECS
8 | {
9 | ///
10 | /// Interface for Filter Components. All IFilterComponent interfaces implement this.
11 | ///
12 | public interface IFilterComponent : IComponent { }
13 |
14 | ///
15 | /// Interface for Filter Components of a specific type. All Filter Component Types must implement this.
16 | ///
17 | ///
18 | public interface IFilterComponent : IFilterComponent, IEquatable where T : IFilterComponent { }
19 | }
--------------------------------------------------------------------------------
/IFilterComponent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4321f918c0d96eb4996133b22bcc1b30
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/IFilterComponentPool.cs:
--------------------------------------------------------------------------------
1 | namespace VodeoECS
2 | {
3 | ///
4 | /// Interface for Filter Component Pools.
5 | ///
6 | public interface IFilterComponentPool : IComponentPool
7 | {
8 | ///
9 | /// Reads a Filter Component from this pool, as an IFilterComponent.
10 | ///
11 | /// The Entity associated with the Filter Component in this pool.
12 | /// The Filter Component as an IFilterComponent.
13 | public IFilterComponent ReadBoxedFilterComponent ( Entity entity );
14 | }
15 | }
--------------------------------------------------------------------------------
/IFilterComponentPool.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b117417697a298f4497b3511d77be8ad
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/IRegistryLoader.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections;
4 | using System.Collections.Generic;
5 |
6 | namespace VodeoECS
7 | {
8 | ///
9 | /// An interface for loader classes that can be used as a fallback loader in a Registry class.
10 | ///
11 | /// The type loaded by the loader.
12 | public interface IRegistryLoader
13 | {
14 | public T Load ( string name );
15 | }
16 | }
--------------------------------------------------------------------------------
/IRegistryLoader.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 618b8c3d7e777384c95429d241b00443
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Internal.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c1da7f6272f829c44b7b1944a3d34882
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Internal/ArchetypeData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 |
5 | namespace VodeoECS.Internal
6 | {
7 | ///
8 | /// For Internal use by the World class. Implementation Data for Archetypes.
9 | ///
10 | public readonly struct ArchetypeData : IEquatable
11 | {
12 | public static ArchetypeData Null { get { return new ArchetypeData( ); } }
13 |
14 | private static IEqualityComparer>> hashComparer = HashSet>.CreateSetComparer( );
15 |
16 | public readonly HashSet> components;
17 | public readonly HashSet> filters;
18 | public ArchetypeData ( IEnumerable> components, IEnumerable> filters )
19 | {
20 | this.components = new HashSet>( components );
21 | this.filters = new HashSet>( filters );
22 | }
23 |
24 | public bool Equals ( ArchetypeData other )
25 | {
26 | return this.components.SetEquals( other.components ) && this.filters.SetEquals( other.filters );
27 | }
28 | public static bool operator == ( ArchetypeData x, ArchetypeData y ) { return x.Equals( y ); }
29 | public static bool operator != ( ArchetypeData x, ArchetypeData y ) { return !( x.Equals( y ) ); }
30 | public override bool Equals ( object o )
31 | {
32 | if ( o == null ) return false;
33 | else return this == ( ArchetypeData )o;
34 | }
35 | public override int GetHashCode ( )
36 | {
37 | return hashComparer.GetHashCode( components ) + hashComparer.GetHashCode( filters );
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/Internal/ArchetypeData.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b082b4fe51ce5214d9f2648c71f13dcd
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Internal/EventPool.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Runtime.InteropServices;
4 | using Unity.Collections;
5 |
6 | namespace VodeoECS.Internal
7 | {
8 | ///
9 | /// Event Pools manage events of a given Event type. For internal use by the Event Manager.
10 | ///
11 | /// The Event type implementing IEventECS.
12 | public class EventPool : IEventPool where T : unmanaged, IEventECS
13 | {
14 | ///
15 | /// The Set of all Systems registered as Emitters for this pool.
16 | ///
17 | public HashSet Emitters { get; }
18 | ///
19 | /// The Set of all Systems registered as Listeners for this pool.
20 | ///
21 | public HashSet Listeners { get; }
22 | ///
23 | /// Number of Events buffered.
24 | ///
25 | public int Count { get { return eventQueue.Length; } }
26 |
27 | private NativeList eventQueue;
28 | private NativeList eventList;
29 |
30 | ///
31 | /// For internal use by the Event Pool Manager class. Event pools are normally created by requesting them from the World.
32 | ///
33 | ///
34 | public EventPool ( bool construct = true )
35 | {
36 | this.eventQueue = new NativeList( Allocator.Persistent );
37 | this.eventList = new NativeList( Allocator.Persistent );
38 | this.Emitters = new HashSet( );
39 | this.Listeners = new HashSet( );
40 | }
41 |
42 | ///
43 | /// Swap Event buffers, clearing the previous buffered Events and replacing them by the currently queued up Events.
44 | ///
45 | public void SwapBuffers( )
46 | {
47 | this.eventList.Clear( );
48 | this.eventList.CopyFrom( eventQueue.AsArray() );
49 | this.eventQueue.Clear( );
50 | }
51 |
52 | ///
53 | /// Get an accessor to read currently buffered Events.
54 | ///
55 | /// An accessor to read currently buffered Events.
56 | public EventListener GetListenBuffer( )
57 | {
58 | return new EventListener( this.eventList );
59 | }
60 |
61 | ///
62 | /// Get an accessor to wite Events to the queue.
63 | ///
64 | /// An accessor to wite Events to the queue.
65 | public EventEmitter GetEmitQueue ( )
66 | {
67 | return new EventEmitter( this.eventQueue );
68 | }
69 |
70 | ///
71 | /// For use by the ECS Serializer. Serializes this Pool.
72 | ///
73 | /// The serialized data for this pool.
74 | public SerializedPoolData SerializeToBytes ( )
75 | {
76 | int eventSize = Marshal.SizeOf( default( T ) );
77 | byte[] eventBytes = new byte[( this.eventQueue.Length ) * eventSize];
78 | this.eventQueue.AsArray().Reinterpret( eventSize ).CopyTo( eventBytes );
79 |
80 | return new SerializedPoolData( ) { components = eventBytes };
81 | }
82 |
83 | ///
84 | /// For use by the ECS Serialized. Deserializes pool data into this Pool.
85 | ///
86 | /// The serialized data to deserialize.
87 | public void DeserializeFromBytes ( SerializedPoolData data )
88 | {
89 | eventQueue.Clear( );
90 |
91 | int eventSize = Marshal.SizeOf( default( T ) );
92 |
93 | T[] events = new T[data.components.Length / eventSize];
94 | NativeArray eventBytes = new NativeArray( data.components, Allocator.Temp );
95 | eventBytes.Reinterpret( sizeof( byte ) ).CopyTo( events );
96 |
97 | for ( int i = 0; i < events.Length; i++ )
98 | {
99 | this.eventQueue.Add( events[i] );
100 | }
101 |
102 | eventBytes.Dispose( );
103 | }
104 |
105 | ///
106 | /// Dispose the native memory reserved by this Pool.
107 | ///
108 | public void Dispose ( )
109 | {
110 | this.eventQueue.Dispose( );
111 | this.eventList.Dispose( );
112 | }
113 | }
114 | }
--------------------------------------------------------------------------------
/Internal/EventPool.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: dd4ec33172a404a4fa6a5020e71628a2
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Internal/FieldsOnlyResolver.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using Newtonsoft.Json.Serialization;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Reflection;
6 |
7 | namespace VodeoECS.Internal
8 | {
9 | ///
10 | /// For internal use by the PrototypeManager class.
11 | ///
12 | class FieldsOnlyResolver : DefaultContractResolver
13 | {
14 | protected override IList CreateProperties ( Type type, MemberSerialization memberSerialization )
15 | {
16 | IList props = base.CreateProperties( type, memberSerialization );
17 | List newprops = new List( );
18 | IEnumerable fields = type.GetRuntimeFields( );
19 | foreach ( JsonProperty prop in props )
20 | {
21 | foreach ( FieldInfo field in fields )
22 | {
23 | if ( prop.PropertyName == field.Name )
24 | {
25 | newprops.Add( prop );
26 | }
27 | }
28 | }
29 | return newprops;
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/Internal/FieldsOnlyResolver.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b0f8174c8aad518458f2fedc779659b4
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Internal/FilterCombination.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace VodeoECS.Internal
5 | {
6 | ///
7 | /// For internal use by the World class. Represents a combination of filter values.
8 | ///
9 | public readonly struct FilterCombination : IEquatable
10 | {
11 | public static FilterCombination Null { get { return new FilterCombination( ); } }
12 | public static FilterCombination Default { get { return new FilterCombination( empty ); } }
13 | public static FilterCombination NewEmpty { get { return new FilterCombination( new RegistryIndex[0] ); } }
14 |
15 | private static IEqualityComparer>> hashComparer = HashSet>.CreateSetComparer( );
16 |
17 | public readonly HashSet> filterComponentInstances;
18 |
19 | public FilterCombination ( params RegistryIndex[] components )
20 | {
21 | this.filterComponentInstances = new HashSet>( components );
22 | }
23 | public bool Equals ( FilterCombination other )
24 | {
25 | if ( this.filterComponentInstances == null && other.filterComponentInstances == null )
26 | return true;
27 | if ( this.filterComponentInstances == null || other.filterComponentInstances == null )
28 | return false;
29 | return this.filterComponentInstances.SetEquals( other.filterComponentInstances );
30 | }
31 | public static bool operator == ( FilterCombination x, FilterCombination y ) { return x.Equals( y ); }
32 | public static bool operator != ( FilterCombination x, FilterCombination y ) { return !( x.Equals( y ) ); }
33 | public override bool Equals ( object o )
34 | {
35 | if ( o == null ) return false;
36 | else return this == ( FilterCombination )o;
37 | }
38 | public override int GetHashCode ( )
39 | {
40 | return hashComparer.GetHashCode( filterComponentInstances );
41 | }
42 | private static RegistryIndex[] empty = new RegistryIndex[0];
43 | }
44 | }
--------------------------------------------------------------------------------
/Internal/FilterCombination.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 68d1f5efc1834d24f974f493ce426e7b
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Internal/IEventPool.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 |
5 | namespace VodeoECS.Internal
6 | {
7 | ///
8 | /// Event Pools manage events. For internal use by the Event Manager.
9 | ///
10 | public interface IEventPool : IDisposable
11 | {
12 | ///
13 | /// Swap Event buffers, clearing the previous buffered Events and replacing them by the currently queued up Events.
14 | ///
15 | public void SwapBuffers ( );
16 | ///
17 | /// The Set of all Systems registered as Emitters for this pool.
18 | ///
19 | public HashSet Emitters { get; }
20 | ///
21 | /// The Set of all Systems registered as Listeners for this pool.
22 | ///
23 | public HashSet Listeners { get; }
24 | }
25 | }
--------------------------------------------------------------------------------
/Internal/IEventPool.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e07f85922f84e4d478465351482d5807
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Internal/NativeNested.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: bc06daf752793184b80489561256dae7
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Internal/SerializedPoolData.cs:
--------------------------------------------------------------------------------
1 | namespace VodeoECS.Internal
2 | {
3 | ///
4 | /// For internal use with the ECS Serializer. Data structure for storing serialized Component Pool data.
5 | /// Depending on the Pool type, some byte arrays will be null.
6 | ///
7 | public struct SerializedPoolData
8 | {
9 | public byte[] filterIndices;
10 | public byte[] elementCounts;
11 | public byte[] entities;
12 | public byte[] components;
13 | }
14 | }
--------------------------------------------------------------------------------
/Internal/SerializedPoolData.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c79ab1c103f72ec49b01d01cfa0790b1
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Internal/SerializedWorldData.cs:
--------------------------------------------------------------------------------
1 | namespace VodeoECS.Internal
2 | {
3 | ///
4 | /// For internal use with the ECS Serializer. Data structure for storing World Data unrelated to individual Component Pools.
5 | ///
6 | public struct SerializedWorldData
7 | {
8 | public byte[] entities;
9 | public int recyclenext;
10 | public int nextfree;
11 | }
12 | }
--------------------------------------------------------------------------------
/Internal/SerializedWorldData.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e94cf780a03b1a24aa07bfbd65b53473
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Internal/SystemManager.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 348ed37cf7fe6084a8b490bff1dccfac
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/ListAccessor.cs:
--------------------------------------------------------------------------------
1 | using VodeoECS.Internal;
2 | using System;
3 | using System.Collections;
4 | using System.Collections.Generic;
5 | using Unity.Collections;
6 | using Unity.Collections.LowLevel.Unsafe;
7 |
8 | namespace VodeoECS
9 | {
10 | ///
11 | /// Accessor for reading and writing to a single List Component.
12 | /// Can be passed to Burst Compiled jobs.
13 | ///
14 | ///
15 | public struct ListAccessor : IEnumerable where T : unmanaged, IElementComponent
16 | {
17 | ///
18 | /// Number of Elements in the List Component accessed.
19 | ///
20 | public int Length { get { return nested[entry].Length; } }
21 | private NativeSlice> nested;
22 | int entry;
23 |
24 | ///
25 | /// For internal use by the List Component Pool class. Constructs a List Accessor.
26 | ///
27 | /// A slice into the Pool's NativeNested container.
28 | /// The index of the specific List Component to access in the slice.
29 | public ListAccessor ( NativeSlice> nested, int entry )
30 | {
31 | this.nested = nested;
32 | this.entry = entry;
33 | }
34 |
35 | ///
36 | /// The Element at a specific position in the accessed List Component.
37 | ///
38 | /// The position of the Element in the List Component.
39 | /// The value of the Element accessed.
40 | public unsafe T this[int i]
41 | {
42 | get
43 | {
44 | return UnsafeUtility.ReadArrayElement( this.nested[entry].Ptr, i );
45 | }
46 | set
47 | {
48 | UnsafeUtility.WriteArrayElement( this.nested[entry].Ptr, i, value );
49 | }
50 | }
51 | ///
52 | /// Read the value of a specific Element in the List Component.
53 | ///
54 | /// The position of the Element to read in the List Component.
55 | /// The value of the Element read.
56 | public unsafe T ReadElement ( int i )
57 | {
58 | return this[i];
59 | }
60 | ///
61 | /// Write to a specific Element in the List Component.
62 | ///
63 | /// The position of the Element to write to in the List Component.
64 | /// The new value to write to the Element.
65 | public unsafe void WriteElement ( int i, T value )
66 | {
67 | this[i] = value;
68 | }
69 | ///
70 | /// Append a new Element to the List Component.
71 | ///
72 | /// The value of the new Element to append.
73 | public unsafe void AppendElement ( T value )
74 | {
75 | UnsafeUtility.ArrayElementAsRef>( this.nested.GetUnsafePtr( ), entry ).Add( value );
76 | }
77 | ///
78 | /// Remove an Element from the List Component, and swap back to maintain close packing.
79 | ///
80 | /// The position of the Element to remove.
81 | public unsafe void RemoveElement ( int i )
82 | {
83 | UnsafeUtility.ArrayElementAsRef>( this.nested.GetUnsafePtr( ), entry ).RemoveAtSwapBack( i );
84 | }
85 | ///
86 | /// Clear the List Component of all its Elements.
87 | ///
88 | public unsafe void ClearList ( )
89 | {
90 | UnsafeUtility.ArrayElementAsRef>( this.nested.GetUnsafePtr( ), entry ).Clear( );
91 | }
92 |
93 | ///
94 | /// Enumerates through all Element values in the accessed List Component.
95 | ///
96 | /// Each Element value in the List Component.
97 | public IEnumerator GetEnumerator ( )
98 | {
99 | for ( int i = 0; i < this.Length; i++ )
100 | {
101 | yield return this[i];
102 | }
103 | }
104 | IEnumerator IEnumerable.GetEnumerator ( )
105 | {
106 | return GetEnumerator( );
107 | }
108 |
109 | }
110 | }
--------------------------------------------------------------------------------
/ListAccessor.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e433ed034dc949d408ebc3886a3073a3
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/ListComponentPool.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e6257f31b26322a4cbbdf4878c882d44
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/ListPoolAccessor.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 363ea72dfb579544ca6d715c5176f71f
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/ListTaxonSlice.cs:
--------------------------------------------------------------------------------
1 | using VodeoECS.Internal;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 |
5 | namespace VodeoECS
6 | {
7 | ///
8 | /// A slice into the List Components associated with a single Taxon.
9 | /// The order of Entities associated with each Component in a Taxon Slice is preserved across all Component Pools sharing the Taxon.
10 | /// Can be passed to Burst Compiled jobs.
11 | ///
12 | /// The type of the List Component Elements accessed by this Taxon Slice.
13 | public struct ListTaxonSlice : IEnumerable> where T : unmanaged, IElementComponent
14 | {
15 | ///
16 | /// Number of List Components in this Slice.
17 | ///
18 | public int Length { get { return nested.Length; } }
19 | private NativeNested nested;
20 |
21 | ///
22 | /// For internal use by the List Component Pool class. Constructs a List Taxon Slice.
23 | ///
24 | /// The Native Nested container of List Components for a single Taxon.
25 | public ListTaxonSlice ( NativeNested nested )
26 | {
27 | this.nested = nested;
28 | }
29 |
30 | ///
31 | /// Access the List Component at a specific position in the Taxon Slice.
32 | /// The order of Entities associated with each Component in a Taxon Slice is preserved across all Component Pools sharing the Taxon.
33 | ///
34 | /// The position of the List Component in the Taxon Slice.
35 | /// An accessor for the List Component at the given position.
36 | public ListAccessor this[int i]
37 | {
38 | get
39 | {
40 | return new ListAccessor( this.nested.GetNestedSlice( ), i );
41 | }
42 | }
43 | ///
44 | /// Enumerates access to all List Component values in this Taxon Slice.
45 | ///
46 | /// Accessor to each List Component in the Taxon Slice.
47 | public IEnumerator> GetEnumerator ( )
48 | {
49 | for ( int i = 0; i < this.Length; i++ )
50 | {
51 | yield return this[i];
52 | }
53 | }
54 | IEnumerator IEnumerable.GetEnumerator ( )
55 | {
56 | return GetEnumerator( );
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/ListTaxonSlice.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4cb2c58e04d09b64e9bca7e41e3fa9d9
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/NamedRegistry.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections;
4 | using System.Collections.Generic;
5 |
6 | namespace VodeoECS
7 | {
8 | ///
9 | /// A registry class associating a set of unique items with a name and RegistryIndex for each one.
10 | ///
11 | /// The type registered in this NamedRegistry.
12 | public class NamedRegistry : Registry
13 | {
14 | private readonly Dictionary> nameLookup;
15 | private readonly List names;
16 | private readonly IRegistryLoader fallback;
17 |
18 | ///
19 | /// Constructs a NamedRegistry.
20 | ///
21 | /// A loader implementing the IRegistryLoader class. If no item under a requested name is registered, it will be loaded through this loader as fallback.
22 | public NamedRegistry ( IRegistryLoader fallback = null ) : base( )
23 | {
24 | this.nameLookup = new Dictionary>( );
25 | this.names = new List( );
26 | this.fallback = fallback;
27 | }
28 |
29 | ///
30 | /// Register the given item into the Registry.
31 | ///
32 | /// The item to register.
33 | /// The index of the registered item.
34 | public new RegistryIndex Register ( T item ) { return this.Register( item, "Null" ); }
35 |
36 | ///
37 | /// Register the given item into the Registry, under the given name.
38 | ///
39 | /// The item to register.
40 | /// The name to register the item under.
41 | /// The index of the registered item.
42 | public RegistryIndex Register ( T item, string name )
43 | {
44 | RegistryIndex index = new RegistryIndex( ( ushort )this.Count );
45 | if ( nameLookup.ContainsKey( name ) ) throw new ArgumentException( typeof( T ).ToString( ) + " already registered under name " + name.ToString( ) );
46 | if ( base.indexLookup.ContainsKey( item ) ) throw new ArgumentException( item.GetType( ).ToString( ) + " " + name.ToString( ) + " is already registered under a different name" );
47 |
48 | this.registered.Add( item );
49 | this.names.Add( name );
50 | base.indexLookup.Add( item, index );
51 | this.nameLookup.Add( name, index );
52 |
53 | return index;
54 | }
55 |
56 | ///
57 | /// Get the name of a registered item.
58 | ///
59 | /// The RegistryIndex of the registered item.
60 | /// The name of the registered item.
61 | public string GetName ( RegistryIndex index )
62 | {
63 | return this.names[index.ID];
64 | }
65 |
66 | ///
67 | /// Get the RegistryIndex of an item by its name.
68 | /// If no item is registered under this name and this Registry has a fallback loader, load the item by name.
69 | ///
70 | /// The name of the requested item.
71 | /// The RegistryIndex of the requested item.
72 | public RegistryIndex GetIndexByName ( string name )
73 | {
74 | RegistryIndex index;
75 | if ( this.nameLookup.TryGetValue( name, out index ) )
76 | {
77 | return index;
78 | }
79 | else if ( fallback != null )
80 | {
81 | return this.Register( fallback.Load( name ), name );
82 | }
83 | else
84 | {
85 | throw new FormatException( "No " + typeof( T ).Name + " registered under the name " + name );
86 | }
87 | }
88 | }
89 | }
--------------------------------------------------------------------------------
/NamedRegistry.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ccef2c93597b6a3459f944db9fa8e1b3
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/NamedRegistryConverter.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections;
4 | using System.Collections.Generic;
5 |
6 | namespace VodeoECS
7 | {
8 | ///
9 | /// JsonConverter for serializing and deserializing NamedRegistry indices by name.
10 | ///
11 | /// The type stored in the NamedRegistry to support serializing and deserializing by name.
12 | public class NamedRegistryConverter : JsonConverter>
13 | {
14 | protected NamedRegistry registry;
15 | public NamedRegistryConverter ( NamedRegistry registry )
16 | {
17 | this.registry = registry;
18 | }
19 |
20 | public override void WriteJson ( JsonWriter writer, RegistryIndex value, JsonSerializer serializer )
21 | {
22 | if ( registry.Count > 0 )
23 | writer.WriteValue( registry.GetName( value ) );
24 | else
25 | writer.WriteValue( "Registry of type " + registry.GetType() + " is empty" );
26 | }
27 |
28 | public override RegistryIndex ReadJson ( JsonReader reader, Type objectType, RegistryIndex existingValue, bool hasExistingValue, JsonSerializer serializer )
29 | {
30 | return registry.GetIndexByName( ( string )reader.Value );
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/NamedRegistryConverter.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b3c6c75a8197b944d86c171baf5b075a
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/NativePriorityQueue.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2e28d2aa15752394eb65acd4a3544d27
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/PassiveSystemECS.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 |
5 | namespace VodeoECS
6 | {
7 | ///
8 | /// Passive Systems only respond to Events and are not updated otherwise.
9 | ///
10 | public abstract class PassiveSystemECS : SystemECS
11 | {
12 | ///
13 | /// Construct a Passive System.
14 | ///
15 | /// The World object.
16 | public PassiveSystemECS ( World world )
17 | {
18 | world.Systems.RegisterSystem( this );
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/PassiveSystemECS.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 325283f007ed0cc429b93348d5e28af7
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/PrototypesManager.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: bca6a4c2c486af0439216a0dd4fc3ff2
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Query.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 |
5 | namespace VodeoECS
6 | {
7 | ///
8 | /// Queries are made by calling the appropriate Methods on the World class.
9 | /// They represent a set of Entities and Components matching a specific Archetype and set of Filters.
10 | /// Queries are divided into multiple Taxa, each Taxon representing a specific set of Archetypes and set of Filters matching the Query.
11 | ///
12 | public readonly struct Query : IEnumerable
13 | {
14 | ///
15 | /// The Null Query.
16 | ///
17 | public static Query Null { get { return new Query( new List( ) ); } }
18 | ///
19 | /// The number of Taxa matching the Query.
20 | ///
21 | public int Count { get { return this.taxa.Count; } }
22 | ///
23 | /// Get a Taxon in the Query.
24 | /// A Taxon is a category of Entities and Components matching a specific set of Archetypes and set of Filters.
25 | /// They are mainly used for accessing Component Pools in Burst-compiled code.
26 | ///
27 | /// The index of the Taxon within the Query.
28 | /// The Taxon requested. This doesn't contain any data, it's just an index.
29 | public Taxon this[int i] { get { return this.taxa[i]; } }
30 | private readonly List taxa;
31 |
32 | ///
33 | /// For internal use by the World class. Queries are normally made by calling the appropriate Methods on the World class.
34 | ///
35 | /// The taxa to be included in the Query.
36 | public Query ( List taxa ) { this.taxa = taxa; }
37 |
38 | ///
39 | /// Enumerate through all the Taxa in a given Query.
40 | ///
41 | /// A Taxon Enumerator.
42 | public IEnumerator GetEnumerator ( )
43 | {
44 | return ( ( IEnumerable )taxa ).GetEnumerator( );
45 | }
46 | IEnumerator IEnumerable.GetEnumerator ( )
47 | {
48 | return ( ( IEnumerable )taxa ).GetEnumerator( );
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/Query.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 31686b0fba85f5e4fb55cadcfc66cea8
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Vodeo ECS Framework for Unity
2 |
3 | Full documentation here: https://github.com/VodeoGames/VodeoECS/wiki
4 |
5 | Showcase video:
6 |
7 | [](https://youtu.be/3U-p9YQCnPw "Vodeo ECS")
8 |
9 | ## What is this for?
10 |
11 | The Vodeo ECS framework is an "Entity Component System" framework for game development with the Unity game engine.
12 |
13 | ECS architecture is specialized for high-performance real-time processing of large quantities of dynamic entities. It takes a modular, data-driven approach by defining all "Entities" as sets of simple and modular data-only "Components", which are then processed by various "Systems", each System having a specific and encapsulated function.
14 |
15 | As of this writing Unity is developing its own official ECS framework as part of the "DOTS" project, which is likely to continue undergoing significant changes in the near future. The Vodeo ECS is a separate project which was created as a custom-built and more stable alternative to the Unity ECS, while still taking advantage of Burst compilation and the Jobs system.
16 |
17 | ## What are the main features of the Vodeo ECS framework?
18 |
19 | * Supports Burst compilation and the DOTS job system, but can also be used without any knowledge of these features.
20 |
21 | * Moddability out of the box through runtime loading of .json files defining all basic Entity "prototypes", which are instantiated by the game.
22 |
23 | * Saving and loading system supporting serialization and deserialization of the entire game state automatically including any user-defined data.
24 |
25 | * A custom Unity editor view for inspecting and modifying Component data in play mode.
26 |
27 | * The Vodeo ECS architecture is based on a unique "best-of-both worlds" solution to the problem of choosing between the "Archetypal" and "Sparse sets" approaches to component storage.
28 |
29 | ## How to install the framework?
30 |
31 |
32 |
33 | 1. Create a new Unity project
34 |
35 | 2. In the Package Manager click on the "+" button then "Add package from git URL" and copy-paste this URL: https://github.com/VodeoGames/VodeoECS.git
36 |
37 | 3. If you'd like to check out the sample demonstration (recommended if you're new to the framework!) Open the "Samples" dropdown and import the sample. Then load up the imported scene in your Samples folder!
38 |
39 | 4. Check out the Wiki for documentation! (https://github.com/VodeoGames/VodeoECS/wiki)
40 |
41 |
42 |
--------------------------------------------------------------------------------
/README.md.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d56a838fa1c3c194d9dbeace4228b439
3 | TextScriptImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Registry.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections;
4 | using System.Collections.Generic;
5 |
6 | namespace VodeoECS
7 | {
8 | ///
9 | /// A registry class associating a set of unique items with a RegistryIndex for each one.
10 | ///
11 | /// The type registered in this Registry.
12 | public class Registry : IEnumerable
13 | {
14 | protected readonly List registered;
15 | protected readonly Dictionary> indexLookup;
16 |
17 | ///
18 | /// The number of unique items registered in this Registry.
19 | ///
20 | public int Count { get { return registered.Count; } }
21 |
22 | ///
23 | /// Registry Constructor.
24 | ///
25 | public Registry ( )
26 | {
27 | this.registered = new List( );
28 | this.indexLookup = new Dictionary>( );
29 | }
30 |
31 | ///
32 | /// Register the given item into the Registry.
33 | ///
34 | /// The item to register.
35 | /// The index of the registered item.
36 | public RegistryIndex Register ( T item )
37 | {
38 | RegistryIndex index = new RegistryIndex( ( ushort )this.Count );
39 | if ( indexLookup.ContainsKey( item ) ) throw new ArgumentException( item.GetType( ).ToString( ) + " is already registered" );
40 |
41 | this.registered.Add( item );
42 | this.indexLookup.Add( item, index );
43 |
44 | return index;
45 | }
46 |
47 | ///
48 | /// Read the item with the given index.
49 | ///
50 | /// The index of the item to read.
51 | /// The requested item.
52 | public T this[RegistryIndex index]
53 | {
54 | get => registered[index.ID];
55 | }
56 |
57 | ///
58 | /// Get the RegistryIndex of a registered item.
59 | ///
60 | /// The registered item.
61 | /// The index associated with the registered item.
62 | public RegistryIndex GetIndex ( T registered )
63 | {
64 | RegistryIndex index;
65 | if ( this.indexLookup.TryGetValue( registered, out index ) )
66 | {
67 | return index;
68 | }
69 | else
70 | {
71 | throw new FormatException( "No such " + typeof( T ).Name + " registered" );
72 | }
73 |
74 | }
75 |
76 | ///
77 | /// Get the RegistryIndex of a registered item if present, otherwise return false.
78 | ///
79 | /// The registered item.
80 | /// Variable to output the index associated with the registered item to.
81 | /// Returns true if the item was present, false if not.
82 | public bool TryGetIndex ( T registered, out RegistryIndex index )
83 | {
84 | return this.indexLookup.TryGetValue( registered, out index );
85 | }
86 |
87 | ///
88 | /// Enumerates through all the items registered in this registry.
89 | ///
90 | /// Each individual item registered into the registry.
91 | public IEnumerator GetEnumerator ( )
92 | {
93 | foreach ( T i in this.registered )
94 | {
95 | yield return i;
96 | }
97 | }
98 |
99 | ///
100 | /// Enumerates through the indices of all items registered in this registry.
101 | ///
102 | public IEnumerable> ByIndex
103 | {
104 | get
105 | {
106 | for ( ushort i = 0; i < this.registered.Count; i++ )
107 | {
108 | yield return new RegistryIndex( i );
109 | }
110 | }
111 | }
112 |
113 | IEnumerator IEnumerable.GetEnumerator ( )
114 | {
115 | return this.GetEnumerator( );
116 | }
117 | }
118 | }
--------------------------------------------------------------------------------
/Registry.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6d45a3c3638c6594593582efa2627b73
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/RegistryIndex.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections;
4 | using System.Collections.Generic;
5 | using UnityEngine;
6 |
7 | namespace VodeoECS
8 | {
9 | ///
10 | /// Index into a Registry.
11 | ///
12 | /// The type associated with the registry that this index is an index into.
13 | [Serializable]
14 | public readonly struct RegistryIndex : IEquatable>
15 | {
16 | private readonly ushort value;
17 | ///
18 | /// Constructs a new RegistryIndex with the given numerical index. For internal use by Registry classes.
19 | ///
20 | /// The numerical index.
21 | public RegistryIndex ( ushort ID )
22 | {
23 | this.value = ID;
24 | }
25 | ///
26 | /// The numerical index of the RegistryIndex.
27 | ///
28 | public ushort ID { get { return this.value; } }
29 | public bool Equals ( RegistryIndex other ) { return this.value == other.value; }
30 | public override int GetHashCode ( ) { return (typeof( T ), value).GetHashCode( ); }
31 | public static bool operator == ( RegistryIndex x, RegistryIndex y ) { return x.Equals( y ); }
32 | public static bool operator != ( RegistryIndex x, RegistryIndex y ) { return !( x.Equals( y ) ); }
33 | public override bool Equals ( object o )
34 | {
35 | if ( o == null ) return false;
36 | else return this == ( RegistryIndex )o;
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/RegistryIndex.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: be45d7af690e20747b64a4373e8bba9b
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 942872b06df95da428b6ad3bd6f5ee79
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Samples~/Example/AISystem.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using VodeoECS;
3 | using VodeoECS.Standard;
4 |
5 | public class AISystem : ScheduledSystemECS
6 | {
7 | private float deltaT;
8 | private Unity.Mathematics.Random random;
9 |
10 | private EventListener listener;
11 |
12 | private FilterComponentPool aiPool;
13 | private DataComponentPool flyerPool;
14 | private DataComponentPool trajectories;
15 | public AISystem ( World world, float deltaT = 1.0f ) : base( world, "AI" )
16 | {
17 | this.random = new Unity.Mathematics.Random( 931028 );
18 | this.deltaT = deltaT;
19 |
20 | this.flyerPool = world.GetDataComponentPool( );
21 | this.trajectories = world.GetDataComponentPool( );
22 | this.aiPool = world.GetFilterComponentPool( );
23 |
24 | this.listener = world.Events.GetListener( this );
25 | }
26 |
27 | public override void Dispose ( ) { }
28 |
29 | public override void Initialize ( ) { }
30 |
31 | public override void ProcessEvents ( )
32 | {
33 | foreach ( InitializeFlyerEvent e in listener )
34 | {
35 | if ( aiPool.HasComponent(e.flyer))
36 | {
37 | this.ScheduleQueue.Schedule( e.flyer, e.time );
38 | }
39 | }
40 | }
41 |
42 | public override void UpdateEntity ( Entity entity, float time )
43 | {
44 | TrajectoryComponent trajectory = trajectories[entity].Value;
45 | Vector3 vector = new Vector3( trajectory.end.x - trajectory.start.x, trajectory.end.y - trajectory.start.y, trajectory.end.z - trajectory.start.z);
46 | Vector3 position = new Vector3( trajectory.end.x, trajectory.end.y, trajectory.end.z );
47 |
48 | DataAccessor flyingAccessor = flyerPool[entity];
49 | FlyingComponent component = flyingAccessor.Value;
50 | if ( Vector3.Dot(vector, position) >= 0 || random.NextFloat() < 0.1f)
51 | {
52 | component.pitchAxis = random.NextFloat( ) - random.NextFloat( );
53 | component.rollAxis = random.NextFloat( ) - random.NextFloat( );
54 | component.yawAxis = random.NextFloat( ) - random.NextFloat( );
55 | if (random.NextFloat() > 0.33f ) component.throttle = random.NextFloat( );
56 | else component.throttle = 0;
57 | }
58 | else
59 | {
60 | component.pitchAxis = ( random.NextFloat( ) - random.NextFloat( ) )*0.1f;
61 | component.rollAxis = random.NextFloat( ) - random.NextFloat( );
62 | component.yawAxis = ( random.NextFloat( ) - random.NextFloat( ) ) * 0.1f;
63 | component.throttle = random.NextFloat( );
64 | }
65 | flyingAccessor.Write( component );
66 | this.ScheduleQueue.Schedule( entity, random.NextFloat( ) * deltaT + random.NextFloat( ) * deltaT + time );
67 | }
68 | }
--------------------------------------------------------------------------------
/Samples~/Example/AISystem.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: eea79b345d8cfb442a7e25b26fb016d0
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/AgentSystem.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: fd10bab16124e9b4aa9053e62a020ef9
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/Components.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2437200ed142474409902b62fc2f1e92
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Samples~/Example/Components/AIFilter.cs:
--------------------------------------------------------------------------------
1 | using VodeoECS;
2 |
3 | public struct AIFilter : IFilterComponent
4 | {
5 | public ushort AI;
6 | public bool Equals ( AIFilter other )
7 | {
8 | return this.AI == other.AI;
9 | }
10 | public override int GetHashCode ( ) { return (this.AI ).GetHashCode( ); }
11 | }
--------------------------------------------------------------------------------
/Samples~/Example/Components/AIFilter.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 56a33d0f7b77b0f448f8d9e00b48d222
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/Components/FlyingComponent.cs:
--------------------------------------------------------------------------------
1 | using VodeoECS;
2 |
3 | public struct FlyingComponent : IDataComponent
4 | {
5 | public float pitchAxis;
6 | public float yawAxis;
7 | public float rollAxis;
8 | public float throttle;
9 |
10 | public float maxSpeed;
11 | public float turnspeed;
12 | public float acceleration;
13 |
14 | public float velocity;
15 | }
--------------------------------------------------------------------------------
/Samples~/Example/Components/FlyingComponent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: dd081f0c786bddd488c76ec8b17151a8
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/Components/HomeComponent.cs:
--------------------------------------------------------------------------------
1 | using VodeoECS;
2 |
3 | public struct HomeComponent : IDataComponent
4 | {
5 | public Entity homeNode;
6 | }
7 |
--------------------------------------------------------------------------------
/Samples~/Example/Components/HomeComponent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c1d22172a0e191d468bc8b271400ad4f
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/Components/PathComponent.cs:
--------------------------------------------------------------------------------
1 | using VodeoECS;
2 |
3 | public struct PathComponent : IDataComponent
4 | {
5 | public Entity destination; //final destination of path
6 | public ushort step; //current step in path
7 | public float range; //range within which to pathfind
8 | public float invertedSpeed;
9 | }
--------------------------------------------------------------------------------
/Samples~/Example/Components/PathComponent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3419581034a75cb42aaa1aaadee0a47f
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/Components/PathNodeElement.cs:
--------------------------------------------------------------------------------
1 | using VodeoECS;
2 |
3 | public struct PathNodeElement : IElementComponent
4 | {
5 | public Entity node;
6 | }
--------------------------------------------------------------------------------
/Samples~/Example/Components/PathNodeElement.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4d0d92248c526124a9cb82ea810ce99f
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/Components/PhysicsComponent.cs:
--------------------------------------------------------------------------------
1 | using Unity.Mathematics;
2 | using VodeoECS;
3 |
4 | public struct PhysicsComponent : IDataComponent
5 | {
6 | public float3 velocity;
7 | public float deathTime;
8 | }
--------------------------------------------------------------------------------
/Samples~/Example/Components/PhysicsComponent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: bedaeef6bf42995428c41446044d953b
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/Components/PlayerFilter.cs:
--------------------------------------------------------------------------------
1 | using VodeoECS;
2 |
3 | public struct PlayerFilter : IFilterComponent
4 | {
5 | public ushort player;
6 | public bool Equals ( PlayerFilter other )
7 | {
8 | return this.player == other.player;
9 | }
10 | public override int GetHashCode ( ) { return (this.player).GetHashCode( ); }
11 | }
--------------------------------------------------------------------------------
/Samples~/Example/Components/PlayerFilter.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 80a62670bf285414594905c467b81bf3
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/Components/RoadComponent.cs:
--------------------------------------------------------------------------------
1 | using VodeoECS;
2 | public struct RoadComponent : IDataComponent
3 | {
4 | public Entity nodeA;
5 | public Entity nodeB;
6 | }
--------------------------------------------------------------------------------
/Samples~/Example/Components/RoadComponent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e3b1596c49b605a46b4eb6c850dff621
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/Components/RoadConnectionElement.cs:
--------------------------------------------------------------------------------
1 | using VodeoECS;
2 |
3 | public struct RoadConnectionElement : IElementComponent
4 | {
5 | public Entity road;
6 | }
--------------------------------------------------------------------------------
/Samples~/Example/Components/RoadConnectionElement.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5814270115adc87428610ed5d4e28879
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/Components/SpawnerComponent.cs:
--------------------------------------------------------------------------------
1 | using Unity.Mathematics;
2 | using VodeoECS;
3 |
4 | public struct SpawnerComponent : IDataComponent
5 | {
6 | public float outputRate;
7 | public float outputVelocity;
8 | public float lifeTime;
9 | public float3 position;
10 | public Entity prototype;
11 | }
--------------------------------------------------------------------------------
/Samples~/Example/Components/SpawnerComponent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4c5cd5cfb30c1e948b47de8e47fdb359
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/Components/TravelStateComponent.cs:
--------------------------------------------------------------------------------
1 | using VodeoECS;
2 |
3 | public struct TravelStateComponent : IDataComponent
4 | {
5 | public byte returning;
6 | public Entity home;
7 | }
8 |
--------------------------------------------------------------------------------
/Samples~/Example/Components/TravelStateComponent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0c3bd6e08a9e7514bbcace603c27c846
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/Events.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e1b7cdc21e0e94c4ab6b3d4fa95b38d1
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Samples~/Example/Events/ChangeHomeEvent.cs:
--------------------------------------------------------------------------------
1 | using VodeoECS;
2 |
3 | public struct ChangeHomeEvent : IEventECS {}
--------------------------------------------------------------------------------
/Samples~/Example/Events/ChangeHomeEvent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 51870f5f10dcd964baa583a878a2cdd4
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/Events/InitializeFlyerEvent.cs:
--------------------------------------------------------------------------------
1 | using VodeoECS;
2 |
3 | public struct InitializeFlyerEvent : IEventECS
4 | {
5 | public Entity flyer;
6 | public float time;
7 | }
--------------------------------------------------------------------------------
/Samples~/Example/Events/InitializeFlyerEvent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 78d6df5532b831e489c1942d5a068a9c
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/Events/InputEvent.cs:
--------------------------------------------------------------------------------
1 | using VodeoECS;
2 | public struct InputEvent : IEventECS
3 | {
4 | public float yawAxis;
5 | public float pitchAxis;
6 | public float rollAxis;
7 | public float throttle;
8 | }
9 |
--------------------------------------------------------------------------------
/Samples~/Example/Events/InputEvent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b0a828215ae7dfb4b8f518fd84431ad0
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/Events/NewPhysicalEvent.cs:
--------------------------------------------------------------------------------
1 | using Unity.Mathematics;
2 | using VodeoECS;
3 |
4 | public struct NewPhysicalEvent :IEventECS
5 | {
6 | public Entity entity;
7 | public float4 moment;
8 | public float3 velocity;
9 | public float deathTime;
10 | }
--------------------------------------------------------------------------------
/Samples~/Example/Events/NewPhysicalEvent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 484c0f78fc7ce2d46ae1db22f22d8583
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/Events/NewSpawnerEvent.cs:
--------------------------------------------------------------------------------
1 | using Unity.Mathematics;
2 | using VodeoECS;
3 |
4 | public struct NewSpawnerEvent : IEventECS
5 | {
6 | public SpawnerComponent spawner;
7 | public float4 moment;
8 | }
--------------------------------------------------------------------------------
/Samples~/Example/Events/NewSpawnerEvent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ce50f254f01876142bf1bc7b88f64430
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/Events/PathCompleteEvent.cs:
--------------------------------------------------------------------------------
1 | using VodeoECS;
2 |
3 | public struct PathCompleteEvent : IEventECS
4 | {
5 | public Entity entity;
6 | public float time;
7 | }
--------------------------------------------------------------------------------
/Samples~/Example/Events/PathCompleteEvent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: bd726aa0e077eed4e919da2c42f44579
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/FlyingSystem.cs:
--------------------------------------------------------------------------------
1 | using Unity.Mathematics;
2 | using UnityEngine;
3 | using VodeoECS;
4 | using VodeoECS.Standard;
5 |
6 | public class FlyingSystem : ScheduledSystemECS
7 | {
8 | private EventListener listener;
9 |
10 | private DataComponentPool flyingPool;
11 | private DataComponentPool rotations;
12 | private DataComponentPool trajectories;
13 |
14 | private float deltaT;
15 |
16 | public FlyingSystem (World world, float deltaT = 0.0166f ) : base( world, "Flying" )
17 | {
18 | this.deltaT = deltaT;
19 | this.flyingPool = world.GetDataComponentPool( );
20 | this.rotations = world.GetDataComponentPool( );
21 | this.trajectories = world.GetDataComponentPool( );
22 |
23 | world.DefineArchetype( flyingPool, rotations, trajectories );
24 |
25 | this.listener = world.Events.GetListener( this );
26 | }
27 |
28 | public override void Dispose ( ) { }
29 |
30 | public override void Initialize ( ) { }
31 |
32 | public override void ProcessEvents ( )
33 | {
34 | foreach (InitializeFlyerEvent e in listener)
35 | {
36 | this.ScheduleQueue.Schedule( e.flyer, e.time );
37 | }
38 | }
39 |
40 | public override void UpdateEntity ( Entity entity, float time )
41 | {
42 | ComponentIndex index = flyingPool.GetIndex( entity );
43 |
44 | DataAccessor flyingAccessor = flyingPool[index];
45 | DataAccessor rotationAccessor = rotations[index];
46 | DataAccessor trajectoryAccessor = trajectories[index];
47 | FlyingComponent flyingComponent = flyingAccessor.Value;
48 | RotationComponent rotation = rotationAccessor.Value;
49 | TrajectoryComponent trajectory = trajectoryAccessor.Value;
50 |
51 | float lastDelta = trajectory.end.w - trajectory.start.w;
52 |
53 | Quaternion quaternion = new Quaternion( rotation.quaternion.x, rotation.quaternion.y, rotation.quaternion.z, rotation.quaternion.w);
54 | Quaternion rotationchange = Quaternion.Euler( lastDelta * flyingComponent.pitchAxis * flyingComponent.turnspeed, lastDelta * flyingComponent.yawAxis * flyingComponent.turnspeed, lastDelta * flyingComponent.rollAxis * flyingComponent.turnspeed );
55 | quaternion *= rotationchange;
56 |
57 | if ( flyingComponent.throttle == 0)
58 | {
59 | if (flyingComponent.velocity >= 0)
60 | {
61 | flyingComponent.velocity = math.clamp( flyingComponent.velocity + flyingComponent.acceleration * ( -0.5f ) * lastDelta, 0, flyingComponent.maxSpeed );
62 | }
63 | else
64 | {
65 | flyingComponent.velocity = math.clamp( flyingComponent.velocity + flyingComponent.acceleration * ( 0.5f ) * lastDelta, -flyingComponent.maxSpeed, 0 );
66 | }
67 | }
68 | else
69 | {
70 | flyingComponent.velocity = math.clamp( flyingComponent.velocity + flyingComponent.acceleration * ( flyingComponent.throttle ) * lastDelta, -flyingComponent.maxSpeed * 0.5f, flyingComponent.maxSpeed );
71 | }
72 |
73 | Vector3 vector = quaternion * Vector3.forward * flyingComponent.velocity;
74 |
75 | trajectory = new TrajectoryComponent( )
76 | {
77 | start = trajectory.end,
78 | end = trajectory.end + new float4( )
79 | {
80 | x = vector.x * this.deltaT,
81 | y = vector.y * this.deltaT,
82 | z = vector.z * this.deltaT,
83 | w = this.deltaT
84 | }
85 | };
86 |
87 | rotation.quaternion = new float4( quaternion.x, quaternion.y, quaternion.z, quaternion.w );
88 |
89 | flyingAccessor.Write( flyingComponent );
90 | rotationAccessor.Write( rotation );
91 | trajectoryAccessor.Write( trajectory );
92 |
93 | this.ScheduleQueue.Schedule( entity, trajectory.start.w + this.deltaT );
94 | }
95 | }
--------------------------------------------------------------------------------
/Samples~/Example/FlyingSystem.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e2db1420c5e9d9f4680173d74e0b1dce
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/LevelGeneratorSystem.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f1189869e43ce194b87bf8046cf9aec7
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/Main.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using UnityEngine;
3 | using UnityEditor;
4 | using VodeoECS;
5 | using VodeoECS.Standard;
6 |
7 | public class Main : MonoBehaviour
8 | {
9 | public World world; //Our ECS World
10 | private ECS_Serializer serializer;
11 |
12 | private ObjectRenderSystem objectRenderer;
13 |
14 | private string saveDirectory;
15 | private string saveName = "demoSave";
16 |
17 | //Initialization
18 | public void Awake ( )
19 | {
20 | #if UNITY_EDITOR
21 | //Copy StreamingAssets folder from sample if not present
22 | DirectoryInfo directoryInfo = new DirectoryInfo( Application.streamingAssetsPath );
23 | if ( !directoryInfo.Exists )
24 | {
25 | FileUtil.CopyFileOrDirectory( "Assets/Samples/Vodeo ECS/0.1.0/Example/StreamingAssets/", "Assets/StreamingAssets/" );
26 | }
27 | #endif
28 |
29 | //Create World
30 | world = new World( );
31 |
32 | //Create our Systems
33 | new LevelGeneratorSystem( world );
34 | new MeshRenderSystem( world );
35 | new AgentSystem( world );
36 | new PathFindingSystem( world );
37 | new PhysicsSystem( world );
38 | new SpawnerSystem( world );
39 | new FlyingSystem( world );
40 | new PlayerSystem( world );
41 | new AISystem( world );
42 | objectRenderer = new ObjectRenderSystem( world );
43 |
44 | //Our serializer to save/load the world
45 | serializer = new ECS_Serializer( world );
46 | }
47 |
48 | // Start is called before the first frame update
49 | void Start ()
50 | {
51 | //Initialize all Systems
52 | world.InitializeSystems( );
53 | //Path where save files are stored
54 | saveDirectory = Application.persistentDataPath + "/Saves/";
55 | }
56 |
57 | // Update is called once per frame
58 | void Update()
59 | {
60 | this.GetComponent( ).AttachCamera( objectRenderer );
61 | world.Systems.FrameUpdate( );
62 | }
63 |
64 | private void LateUpdate ( )
65 | {
66 | world.Systems.CompleteUpdate( );
67 |
68 | if ( Input.GetKeyDown( KeyCode.Alpha5 ) )
69 | {
70 | Directory.CreateDirectory( saveDirectory );
71 | string path = saveDirectory + saveName + ".json";
72 | StreamWriter writer = new StreamWriter( path, false );
73 | writer.WriteLine( serializer.SerializeWorld( ) );
74 | Debug.Log( "State saved to " + path );
75 | writer.Dispose( );
76 | }
77 | else if ( Input.GetKeyDown( KeyCode.Alpha9 ) )
78 | {
79 | string path = saveDirectory + saveName + ".json";
80 | StreamReader reader = new StreamReader( path, false );
81 | serializer.DeserializeWorld( reader.ReadToEnd( ) );
82 | Debug.Log( "State loaded from " + path );
83 | reader.Dispose( );
84 | }
85 | }
86 |
87 | public void OnDestroy ( )
88 | {
89 | world.Dispose( );
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/Samples~/Example/Main.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 21c63b297335da942bb59d73f32200f3
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/PathfindingSystem.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8e1f9168378fbcf4cbff8aa5be37caa6
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/PhysicsSystem.cs:
--------------------------------------------------------------------------------
1 | using Unity.Mathematics;
2 | using VodeoECS.Standard;
3 | using VodeoECS;
4 |
5 | public class PhysicsSystem : ScheduledSystemECS
6 | {
7 | private EventListener newPhysicalEvent;
8 | private EventEmitter destroyEvents;
9 |
10 | private DataComponentPool physicsPool;
11 | private DataComponentPool trajectoryPool;
12 |
13 | private float gravity;
14 | private float deltaT;
15 |
16 | public PhysicsSystem ( World world, float gravity = -90f, float deltaT = 0.1f ) : base( world, "Physics" )
17 | {
18 | newPhysicalEvent = world.Events.GetListener( this );
19 | destroyEvents = world.Events.GetEmitter( this );
20 | physicsPool = world.GetDataComponentPool( );
21 | trajectoryPool = world.GetDataComponentPool( );
22 |
23 | this.gravity = gravity;
24 | this.deltaT = deltaT;
25 | }
26 |
27 | public override void Initialize ( ) { }
28 |
29 | public override void ProcessEvents ( )
30 | {
31 | foreach ( NewPhysicalEvent e in newPhysicalEvent )
32 | {
33 | DataAccessor physicsAccessor = physicsPool[e.entity];
34 | PhysicsComponent physics = physicsAccessor.Value;
35 | DataAccessor trajectoryAccessor = trajectoryPool[e.entity];
36 |
37 | physics.velocity = e.velocity;
38 | physics.deathTime = e.deathTime;
39 | TrajectoryComponent trajectory = new TrajectoryComponent( )
40 | {
41 | start = e.moment,
42 | end = e.moment + new float4( )
43 | {
44 | x = physics.velocity.x * this.deltaT,
45 | y = physics.velocity.y * this.deltaT,
46 | z = physics.velocity.z * this.deltaT,
47 | w = this.deltaT
48 | }
49 | };
50 |
51 | physicsAccessor.Write( physics );
52 | trajectoryAccessor.Write( trajectory );
53 |
54 | this.ScheduleQueue.Schedule( e.entity, e.moment.w );
55 | }
56 | }
57 |
58 | public override void UpdateEntity ( Entity entity, float time )
59 | {
60 | DataAccessor physicsAccessor = physicsPool[entity];
61 | PhysicsComponent physics = physicsAccessor.Value;
62 | DataAccessor trajectoryAccessor = trajectoryPool[entity];
63 | TrajectoryComponent trajectory = trajectoryAccessor.Value;
64 |
65 | float lastDelta = trajectory.end.w - trajectory.start.w;
66 | physics.velocity = physics.velocity + new float3( ) { x = 0, y = this.gravity * lastDelta, z = 0 };
67 | trajectory = new TrajectoryComponent( )
68 | {
69 | start = trajectory.end,
70 | end = trajectory.end + new float4( )
71 | {
72 | x = physics.velocity.x * this.deltaT,
73 | y = physics.velocity.y * this.deltaT,
74 | z = physics.velocity.z * this.deltaT,
75 | w = this.deltaT
76 | }
77 | };
78 |
79 | physicsAccessor.Write( physics );
80 | trajectoryAccessor.Write( trajectory );
81 |
82 | if (physics.deathTime > time)
83 | {
84 | this.ScheduleQueue.Schedule( entity, trajectory.start.w + this.deltaT );
85 | }
86 | else
87 | {
88 | this.destroyEvents.CreateEvent( new DestroyEntityEvent( ) { entity = entity } );
89 | }
90 | }
91 |
92 | public override void Dispose ( ) { }
93 | }
94 |
--------------------------------------------------------------------------------
/Samples~/Example/PhysicsSystem.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a3bd9162a17e0094982c44ddfb4607b1
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/PlayerInputs.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using VodeoECS;
3 | using VodeoECS.Standard;
4 |
5 | public class PlayerInputs : MonoBehaviour
6 | {
7 | private EventEmitter inputEmitter;
8 | private EventEmitter homeEmitter;
9 | private Archetype playerArchetype;
10 |
11 | public void AttachCamera( ObjectRenderSystem system )
12 | {
13 | Entity player = this.GetComponent( ).world.GetRandomEntityOfArchetype( this.GetComponent( ).world.GetDataComponentPool( ), this.GetComponent( ).world.MakeQuery( playerArchetype, new PlayerFilter( )) );
14 |
15 | //set camera
16 | Camera.main.transform.SetParent( system.GetTransform( player ) );
17 | Camera.main.transform.localPosition = new Vector3( 0, 1.0f, -3.0f );
18 | Camera.main.transform.localRotation = Quaternion.identity;
19 | }
20 |
21 | private void Awake ( )
22 | {
23 | this.playerArchetype = this.GetComponent( ).world.DefineArchetype( this.GetComponent( ).world.GetDataComponentPool( ), this.GetComponent( ).world.GetFilterComponentPool( ) );
24 | }
25 |
26 | // Start is called before the first frame update
27 | void Start()
28 | {
29 | this.inputEmitter = this.GetComponent( ).world.Events.GetEmitter( null );
30 | this.homeEmitter = this.GetComponent( ).world.Events.GetEmitter( null );
31 |
32 | Cursor.visible = false;
33 | }
34 |
35 | // Update is called once per frame
36 | void Update ( )
37 | {
38 | InputEvent e = new InputEvent( );
39 | e.yawAxis = Mathf.Clamp( Input.GetAxis( "Mouse X" ), -0.5f, 0.5f ) * 2.0f;
40 | e.pitchAxis = Mathf.Clamp( Input.GetAxis( "Mouse Y" ), -0.5f, 0.5f ) * 2.0f;
41 | e.rollAxis = ( Input.GetKey( KeyCode.A ) ? 1 : 0 ) - ( Input.GetKey( KeyCode.D ) ? 1 : 0 );
42 | e.throttle = ( Input.GetKey( KeyCode.W ) ? 1 : 0 ) - ( Input.GetKey( KeyCode.S ) ? 1 : 0 );
43 |
44 | inputEmitter.CreateEvent( e );
45 |
46 | if (Input.GetKeyDown(KeyCode.Space))
47 | {
48 | this.homeEmitter.CreateEvent( new ChangeHomeEvent( ) );
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Samples~/Example/PlayerInputs.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 73d3eb3e912141344a6941aeec19219b
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/PlayerSystem.cs:
--------------------------------------------------------------------------------
1 | using VodeoECS;
2 |
3 | public class PlayerSystem : PassiveSystemECS
4 | {
5 | private World world;
6 | private EventListener listener;
7 | private Archetype playerFlyer;
8 |
9 | private FilterComponentPool playerPool;
10 | private DataComponentPool flyerPool;
11 | public PlayerSystem ( World world ) : base( world )
12 | {
13 | this.world = world;
14 | this.listener = world.Events.GetListener(this);
15 |
16 | this.playerPool = world.GetFilterComponentPool( );
17 | this.flyerPool = world.GetDataComponentPool( );
18 |
19 | this.playerFlyer = world.DefineArchetype( flyerPool, playerPool );
20 | }
21 |
22 | public override void Dispose ( ) { }
23 |
24 | public override void Initialize ( ) { }
25 |
26 | public override void ProcessEvents ( )
27 | {
28 | foreach (InputEvent e in listener)
29 | {
30 | PlayerFilter filter = new PlayerFilter( );
31 | Query query = world.MakeQuery( playerFlyer, filter );
32 |
33 | foreach ( DataAccessor accessor in flyerPool.Matching(query))
34 | {
35 | FlyingComponent component = accessor.Value;
36 | component.pitchAxis = e.pitchAxis;
37 | component.rollAxis = e.rollAxis;
38 | component.yawAxis = e.yawAxis;
39 | component.throttle = e.throttle;
40 | accessor.Write(component);
41 | }
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/Samples~/Example/PlayerSystem.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: daaa79d4bdf115d4193c0180ddbaf791
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/Resources.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4b6e65ffb00b07a42a88d108890a0bb5
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Samples~/Example/Resources/Materials.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e1c0c94a908f35647afe14ff9366939b
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Samples~/Example/Resources/Materials/AgentMaterial.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: AgentMaterial
11 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
12 | m_ShaderKeywords:
13 | m_LightmapFlags: 4
14 | m_EnableInstancingVariants: 1
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
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 | m_BuildTextureStacks: []
79 |
--------------------------------------------------------------------------------
/Samples~/Example/Resources/Materials/AgentMaterial.mat.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 716d09a2e9f6cd64da5a5cf540ec7aa8
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 2100000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Samples~/Example/Resources/Materials/AgentMaterial2.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: AgentMaterial2
11 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
12 | m_ShaderKeywords:
13 | m_LightmapFlags: 4
14 | m_EnableInstancingVariants: 1
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
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.91099846, b: 0, a: 1}
77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
78 | m_BuildTextureStacks: []
79 |
--------------------------------------------------------------------------------
/Samples~/Example/Resources/Materials/AgentMaterial2.mat.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 12f4b86153290e646a0bb9acf3ba4fea
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 2100000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Samples~/Example/Resources/Materials/BasicMaterial.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: BasicMaterial
11 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
12 | m_ShaderKeywords:
13 | m_LightmapFlags: 4
14 | m_EnableInstancingVariants: 1
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.199
65 | - _GlossyReflections: 1
66 | - _Metallic: 0.541
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: 1, b: 1, a: 1}
77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
78 | m_BuildTextureStacks: []
79 |
--------------------------------------------------------------------------------
/Samples~/Example/Resources/Materials/BasicMaterial.mat.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 908a0dc9b1df22e498ccc2ec1dc715f2
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 2100000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Samples~/Example/Resources/Materials/CapsuleMaterial.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: CapsuleMaterial
11 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
12 | m_ShaderKeywords:
13 | m_LightmapFlags: 4
14 | m_EnableInstancingVariants: 1
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: 10309, guid: 0000000000000000f000000000000000, type: 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.421
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: 0.11764705, g: 0.46005243, b: 0.7176471, a: 1}
77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
78 | m_BuildTextureStacks: []
79 |
--------------------------------------------------------------------------------
/Samples~/Example/Resources/Materials/CapsuleMaterial.mat.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b1916487ad509314b9a41dc0713316db
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 2100000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Samples~/Example/Resources/Materials/PrefabMaterial.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: PrefabMaterial
11 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
12 | m_ShaderKeywords:
13 | m_LightmapFlags: 4
14 | m_EnableInstancingVariants: 1
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: 10309, guid: 0000000000000000f000000000000000, type: 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.895
65 | - _GlossyReflections: 1
66 | - _Metallic: 0.89
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: 0.11764705, g: 0.7176471, b: 0.13345292, a: 1}
77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
78 | m_BuildTextureStacks: []
79 |
--------------------------------------------------------------------------------
/Samples~/Example/Resources/Materials/PrefabMaterial.mat.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c2525727672f7b5438df37659c61a473
3 | NativeFormatImporter:
4 | externalObjects: {}
5 | mainObjectFileID: 2100000
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Samples~/Example/Resources/Meshes.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ae9f0d74a8b20d947b609720c02de95f
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Samples~/Example/Resources/Meshes/cube.obj:
--------------------------------------------------------------------------------
1 | o Cube
2 | v 1.000000 -1.000000 -1.000000
3 | v 1.000000 -1.000000 1.000000
4 | v -1.000000 -1.000000 1.000000
5 | v -1.000000 -1.000000 -1.000000
6 | v 1.000000 1.000000 -0.999999
7 | v 0.999999 1.000000 1.000001
8 | v -1.000000 1.000000 1.000000
9 | v -1.000000 1.000000 -1.000000
10 | vt 1.000000 0.333333
11 | vt 1.000000 0.666667
12 | vt 0.666667 0.666667
13 | vt 0.666667 0.333333
14 | vt 0.666667 0.000000
15 | vt 0.000000 0.333333
16 | vt 0.000000 0.000000
17 | vt 0.333333 0.000000
18 | vt 0.333333 1.000000
19 | vt 0.000000 1.000000
20 | vt 0.000000 0.666667
21 | vt 0.333333 0.333333
22 | vt 0.333333 0.666667
23 | vt 1.000000 0.000000
24 | vn 0.000000 -1.000000 0.000000
25 | vn 0.000000 1.000000 0.000000
26 | vn 1.000000 0.000000 0.000000
27 | vn -0.000000 0.000000 1.000000
28 | vn -1.000000 -0.000000 -0.000000
29 | vn 0.000000 0.000000 -1.000000
30 | usemtl Material
31 | s off
32 | f 2/1/1 3/2/1 4/3/1
33 | f 8/1/2 7/4/2 6/5/2
34 | f 5/6/3 6/7/3 2/8/3
35 | f 6/8/4 7/5/4 3/4/4
36 | f 3/9/5 7/10/5 8/11/5
37 | f 1/12/6 4/13/6 8/11/6
38 | f 1/4/1 2/1/1 4/3/1
39 | f 5/14/2 8/1/2 6/5/2
40 | f 1/12/3 5/6/3 2/8/3
41 | f 2/12/4 6/8/4 3/4/4
42 | f 4/13/5 3/9/5 8/11/5
43 | f 5/6/6 1/12/6 8/11/6
44 |
--------------------------------------------------------------------------------
/Samples~/Example/Resources/Meshes/cube.obj.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 06e04eb6f9a79504fbbceed38a753c65
3 | ModelImporter:
4 | serializedVersion: 20200
5 | internalIDToNameTable: []
6 | externalObjects: {}
7 | materials:
8 | materialImportMode: 2
9 | materialName: 0
10 | materialSearch: 1
11 | materialLocation: 1
12 | animations:
13 | legacyGenerateAnimations: 4
14 | bakeSimulation: 0
15 | resampleCurves: 1
16 | optimizeGameObjects: 0
17 | motionNodeName:
18 | rigImportErrors:
19 | rigImportWarnings:
20 | animationImportErrors:
21 | animationImportWarnings:
22 | animationRetargetingWarnings:
23 | animationDoRetargetingWarnings: 0
24 | importAnimatedCustomProperties: 0
25 | importConstraints: 0
26 | animationCompression: 1
27 | animationRotationError: 0.5
28 | animationPositionError: 0.5
29 | animationScaleError: 0.5
30 | animationWrapMode: 0
31 | extraExposedTransformPaths: []
32 | extraUserProperties: []
33 | clipAnimations: []
34 | isReadable: 0
35 | meshes:
36 | lODScreenPercentages: []
37 | globalScale: 1
38 | meshCompression: 0
39 | addColliders: 0
40 | useSRGBMaterialColor: 1
41 | sortHierarchyByName: 1
42 | importVisibility: 1
43 | importBlendShapes: 1
44 | importCameras: 1
45 | importLights: 1
46 | fileIdsGeneration: 2
47 | swapUVChannels: 0
48 | generateSecondaryUV: 0
49 | useFileUnits: 1
50 | keepQuads: 0
51 | weldVertices: 1
52 | bakeAxisConversion: 0
53 | preserveHierarchy: 0
54 | skinWeightsMode: 0
55 | maxBonesPerVertex: 4
56 | minBoneWeight: 0.001
57 | meshOptimizationFlags: -1
58 | indexFormat: 0
59 | secondaryUVAngleDistortion: 8
60 | secondaryUVAreaDistortion: 15.000001
61 | secondaryUVHardAngle: 88
62 | secondaryUVMarginMethod: 1
63 | secondaryUVMinLightmapResolution: 40
64 | secondaryUVMinObjectScale: 1
65 | secondaryUVPackMargin: 4
66 | useFileScale: 1
67 | tangentSpace:
68 | normalSmoothAngle: 60
69 | normalImportMode: 0
70 | tangentImportMode: 3
71 | normalCalculationMode: 4
72 | legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
73 | blendShapeNormalImportMode: 1
74 | normalSmoothingSource: 0
75 | referencedClips: []
76 | importAnimation: 1
77 | humanDescription:
78 | serializedVersion: 3
79 | human: []
80 | skeleton: []
81 | armTwist: 0.5
82 | foreArmTwist: 0.5
83 | upperLegTwist: 0.5
84 | legTwist: 0.5
85 | armStretch: 0.05
86 | legStretch: 0.05
87 | feetSpacing: 0
88 | globalScale: 1
89 | rootMotionBoneName:
90 | hasTranslationDoF: 0
91 | hasExtraRoot: 0
92 | skeletonHasParents: 1
93 | lastHumanDescriptionAvatarSource: {instanceID: 0}
94 | autoGenerateAvatarMappingIfUnspecified: 1
95 | animationType: 2
96 | humanoidOversampling: 1
97 | avatarSetup: 0
98 | addHumanoidExtraRootOnlyWhenUsingAvatar: 1
99 | additionalBone: 0
100 | userData:
101 | assetBundleName:
102 | assetBundleVariant:
103 |
--------------------------------------------------------------------------------
/Samples~/Example/Resources/Prefabs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a772a91571eb17041a698fc453516404
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Samples~/Example/Resources/Prefabs/Capsule.prefab.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ef2b4bea1b0cafb47949660bd2bed72b
3 | PrefabImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/Resources/Prefabs/Cylinder.prefab:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!1 &2042327550649366336
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: 3886876368305576483}
12 | - component: {fileID: 1345054910912011877}
13 | - component: {fileID: 741776741676055802}
14 | m_Layer: 0
15 | m_Name: Cylinder
16 | m_TagString: Untagged
17 | m_Icon: {fileID: 0}
18 | m_NavMeshLayer: 0
19 | m_StaticEditorFlags: 0
20 | m_IsActive: 1
21 | --- !u!4 &3886876368305576483
22 | Transform:
23 | m_ObjectHideFlags: 0
24 | m_CorrespondingSourceObject: {fileID: 0}
25 | m_PrefabInstance: {fileID: 0}
26 | m_PrefabAsset: {fileID: 0}
27 | m_GameObject: {fileID: 2042327550649366336}
28 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
29 | m_LocalPosition: {x: 0, y: 0, z: 0}
30 | m_LocalScale: {x: 10, y: 10, z: 10}
31 | m_Children: []
32 | m_Father: {fileID: 8638983403520855600}
33 | m_RootOrder: 0
34 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
35 | --- !u!33 &1345054910912011877
36 | MeshFilter:
37 | m_ObjectHideFlags: 0
38 | m_CorrespondingSourceObject: {fileID: 0}
39 | m_PrefabInstance: {fileID: 0}
40 | m_PrefabAsset: {fileID: 0}
41 | m_GameObject: {fileID: 2042327550649366336}
42 | m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0}
43 | --- !u!23 &741776741676055802
44 | MeshRenderer:
45 | m_ObjectHideFlags: 0
46 | m_CorrespondingSourceObject: {fileID: 0}
47 | m_PrefabInstance: {fileID: 0}
48 | m_PrefabAsset: {fileID: 0}
49 | m_GameObject: {fileID: 2042327550649366336}
50 | m_Enabled: 1
51 | m_CastShadows: 1
52 | m_ReceiveShadows: 1
53 | m_DynamicOccludee: 1
54 | m_MotionVectors: 1
55 | m_LightProbeUsage: 1
56 | m_ReflectionProbeUsage: 1
57 | m_RayTracingMode: 2
58 | m_RayTraceProcedural: 0
59 | m_RenderingLayerMask: 1
60 | m_RendererPriority: 0
61 | m_Materials:
62 | - {fileID: 2100000, guid: c2525727672f7b5438df37659c61a473, type: 2}
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_ReceiveGI: 1
71 | m_PreserveUVs: 0
72 | m_IgnoreNormalsForChartDetection: 0
73 | m_ImportantGI: 0
74 | m_StitchLightmapSeams: 1
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 | m_AdditionalVertexStreams: {fileID: 0}
84 | --- !u!1 &4420129388242616909
85 | GameObject:
86 | m_ObjectHideFlags: 0
87 | m_CorrespondingSourceObject: {fileID: 0}
88 | m_PrefabInstance: {fileID: 0}
89 | m_PrefabAsset: {fileID: 0}
90 | serializedVersion: 6
91 | m_Component:
92 | - component: {fileID: 8638983403520855600}
93 | m_Layer: 0
94 | m_Name: Cylinder
95 | m_TagString: Untagged
96 | m_Icon: {fileID: 0}
97 | m_NavMeshLayer: 0
98 | m_StaticEditorFlags: 0
99 | m_IsActive: 1
100 | --- !u!4 &8638983403520855600
101 | Transform:
102 | m_ObjectHideFlags: 0
103 | m_CorrespondingSourceObject: {fileID: 0}
104 | m_PrefabInstance: {fileID: 0}
105 | m_PrefabAsset: {fileID: 0}
106 | m_GameObject: {fileID: 4420129388242616909}
107 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
108 | m_LocalPosition: {x: 0, y: 0, z: 0}
109 | m_LocalScale: {x: 1, y: 1, z: 1}
110 | m_Children:
111 | - {fileID: 3886876368305576483}
112 | m_Father: {fileID: 0}
113 | m_RootOrder: 0
114 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
115 |
--------------------------------------------------------------------------------
/Samples~/Example/Resources/Prefabs/Cylinder.prefab.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4d7c3a48e21cb2f4c9e30af8fa9f3c4f
3 | PrefabImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/Resources/Prefabs/Sphere.prefab:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!1 &1750532205576889017
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: 2920967840762228369}
12 | - component: {fileID: 3849652759277049271}
13 | - component: {fileID: 3153240145180582075}
14 | m_Layer: 0
15 | m_Name: Sphere
16 | m_TagString: Untagged
17 | m_Icon: {fileID: 0}
18 | m_NavMeshLayer: 0
19 | m_StaticEditorFlags: 0
20 | m_IsActive: 1
21 | --- !u!4 &2920967840762228369
22 | Transform:
23 | m_ObjectHideFlags: 0
24 | m_CorrespondingSourceObject: {fileID: 0}
25 | m_PrefabInstance: {fileID: 0}
26 | m_PrefabAsset: {fileID: 0}
27 | m_GameObject: {fileID: 1750532205576889017}
28 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
29 | m_LocalPosition: {x: 125.698875, y: 140.86998, z: -159.90457}
30 | m_LocalScale: {x: 30, y: 30, z: 30}
31 | m_Children: []
32 | m_Father: {fileID: 0}
33 | m_RootOrder: 0
34 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
35 | --- !u!33 &3849652759277049271
36 | MeshFilter:
37 | m_ObjectHideFlags: 0
38 | m_CorrespondingSourceObject: {fileID: 0}
39 | m_PrefabInstance: {fileID: 0}
40 | m_PrefabAsset: {fileID: 0}
41 | m_GameObject: {fileID: 1750532205576889017}
42 | m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
43 | --- !u!23 &3153240145180582075
44 | MeshRenderer:
45 | m_ObjectHideFlags: 0
46 | m_CorrespondingSourceObject: {fileID: 0}
47 | m_PrefabInstance: {fileID: 0}
48 | m_PrefabAsset: {fileID: 0}
49 | m_GameObject: {fileID: 1750532205576889017}
50 | m_Enabled: 1
51 | m_CastShadows: 1
52 | m_ReceiveShadows: 1
53 | m_DynamicOccludee: 1
54 | m_MotionVectors: 1
55 | m_LightProbeUsage: 1
56 | m_ReflectionProbeUsage: 1
57 | m_RayTracingMode: 2
58 | m_RayTraceProcedural: 0
59 | m_RenderingLayerMask: 1
60 | m_RendererPriority: 0
61 | m_Materials:
62 | - {fileID: 2100000, guid: 716d09a2e9f6cd64da5a5cf540ec7aa8, type: 2}
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_ReceiveGI: 1
71 | m_PreserveUVs: 0
72 | m_IgnoreNormalsForChartDetection: 0
73 | m_ImportantGI: 0
74 | m_StitchLightmapSeams: 1
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 | m_AdditionalVertexStreams: {fileID: 0}
84 |
--------------------------------------------------------------------------------
/Samples~/Example/Resources/Prefabs/Sphere.prefab.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1e735b5f7424eb244b687123c6298462
3 | PrefabImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/Scenes.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1cebdb88cf3a6614784ec87350d45d35
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Samples~/Example/Scenes/Scene.unity.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: fa7e6197a8184b7449cc9c22d3194a55
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/SpawnerSystem.cs:
--------------------------------------------------------------------------------
1 | using Unity.Mathematics;
2 | using VodeoECS;
3 | using VodeoECS.Standard;
4 |
5 | public class SpawnerSystem : ScheduledSystemECS
6 | {
7 | private World world;
8 | private Random random;
9 |
10 | private DataComponentPool spawnerPool;
11 | private DataComponentPool positionPool;
12 | private DataComponentPool rotationPool;
13 |
14 | private EventListener newSpawnerEvents;
15 | private EventEmitter physicalEvents;
16 |
17 | private Entity spawnerPrototype;
18 |
19 | public SpawnerSystem(World world) : base(world, "Spawner" )
20 | {
21 | random = new Random( 334995 );
22 | newSpawnerEvents = world.Events.GetListener( this );
23 | physicalEvents = world.Events.GetEmitter( this );
24 | spawnerPool = world.GetDataComponentPool( );
25 | positionPool = world.GetDataComponentPool( );
26 | rotationPool = world.GetDataComponentPool( );
27 |
28 | this.world = world;
29 | }
30 |
31 | public override void Initialize ( )
32 | {
33 | spawnerPrototype = world.Prototypes.GetPrototype( "Spawner" );
34 | }
35 |
36 | public override void ProcessEvents ( )
37 | {
38 | foreach ( NewSpawnerEvent e in newSpawnerEvents)
39 | {
40 | if (e.spawner.outputRate > 0)
41 | {
42 | Entity entity = world.InstantiatePrototype( spawnerPrototype );
43 | spawnerPool.WriteInstantiated( e.spawner );
44 | positionPool.WriteInstantiated( new StaticPositionComponent( ) { position = new float3(e.moment.x, e.moment.y, e.moment.z) } );
45 |
46 | this.ScheduleQueue.Schedule( entity, e.moment.w +random.NextFloat( ) * 2.0f * e.spawner.outputRate );
47 | }
48 | }
49 | }
50 |
51 | public override void UpdateEntity ( Entity entity, float time )
52 | {
53 | SpawnerComponent spawner = spawnerPool[entity].Value;
54 | StaticPositionComponent position = positionPool[entity].Value;
55 | Entity spawned = world.InstantiatePrototype( spawner.prototype );
56 |
57 | rotationPool.WriteInstantiated( new RotationComponent( ) { quaternion = random.NextFloat4( ) } );
58 |
59 | physicalEvents.CreateEvent( new NewPhysicalEvent( )
60 | {
61 | entity = spawned,
62 |
63 | moment = new float4( )
64 | {
65 | x = position.position.x,
66 | y = position.position.y,
67 | z = position.position.z,
68 | w = time
69 | },
70 |
71 | velocity = spawner.outputVelocity * new float3( )
72 | {
73 | x = random.NextFloat( ) - random.NextFloat( ),
74 | y = random.NextFloat( ) * 3.0f,
75 | z = random.NextFloat( ) - random.NextFloat( )
76 | },
77 |
78 | deathTime = time + spawner.lifeTime * random.NextFloat( ) * 2
79 | } );
80 |
81 | if ( spawner.outputRate > 0 )
82 | {
83 | this.ScheduleQueue.Schedule( entity, time + random.NextFloat( ) * 2.0f * spawner.outputRate );
84 | }
85 | }
86 |
87 | public override void Dispose ( ) { }
88 | }
89 |
--------------------------------------------------------------------------------
/Samples~/Example/SpawnerSystem.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: cc6314276920e9647a9d3beeb52e0670
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: db770ce11a6642c49bc31f53035f201d
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d849be8a98d488f439e6d41e13776e35
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/AIFilter.json:
--------------------------------------------------------------------------------
1 | {
2 | "AI": 0
3 | }
4 |
5 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/AIFilter.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ff0503c14a4192646b3efb273099ad4a
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/FlyingComponent.json:
--------------------------------------------------------------------------------
1 | {
2 | "pitchAxis": 0.0,
3 | "yawAxis": 0.0,
4 | "rollAxis": 0.0,
5 | "throttle": 0.0,
6 | "maxSpeed": 0.0,
7 | "turnspeed": 0.0,
8 | "acceleration": 0.0,
9 | "velocity": 0.0
10 | }
11 |
12 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/FlyingComponent.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 212b784c8a48d6a4bb722e83787bbfb6
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/HomeComponent.json:
--------------------------------------------------------------------------------
1 | {
2 | "homeNode": {}
3 | }
4 |
5 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/HomeComponent.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 043397fc906f2d74aa2688b618cda664
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/MaterialFilter.json:
--------------------------------------------------------------------------------
1 | {
2 | "material": "BasicMaterial"
3 | }
4 |
5 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/MaterialFilter.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1ca994cdbc35c984bbcdf7ead4fb45ca
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/MeshRenderFilter.json:
--------------------------------------------------------------------------------
1 | {
2 | "mesh": "Cube"
3 | }
4 |
5 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/MeshRenderFilter.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3d17efce399715a46ae7cbc31d1c8c88
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/ObjectRendererComponent.json:
--------------------------------------------------------------------------------
1 | {
2 | "objectType": "Capsule"
3 | }
4 |
5 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/ObjectRendererComponent.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e6c0d752310748546baee63179253867
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/PathComponent.json:
--------------------------------------------------------------------------------
1 | {
2 | "destination": {},
3 | "step": 0,
4 | "range": 0.0,
5 | "invertedSpeed": 0.0
6 | }
7 |
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/PathComponent.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a8052f07a6175804fb87443194c16a2a
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/PathNodeElement.json:
--------------------------------------------------------------------------------
1 | {
2 | "node": {}
3 | }
4 |
5 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/PathNodeElement.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e0e5f64dceece3c4fb08af4ac53205c2
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/PhysicsComponent.json:
--------------------------------------------------------------------------------
1 | {
2 | "velocity": {
3 | "x": 0.0,
4 | "y": 0.0,
5 | "z": 0.0
6 | },
7 | "deathTime": 0.0
8 | }
9 |
10 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/PhysicsComponent.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 9b303d4dc833b9247886966beae358e0
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/PlayerFilter.json:
--------------------------------------------------------------------------------
1 | {
2 | "player": 0
3 | }
4 |
5 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/PlayerFilter.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 972dbe5da3694cd48b13e2a4c562046a
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/RenderLayerFilter.json:
--------------------------------------------------------------------------------
1 | {
2 | "layer": 0
3 | }
4 |
5 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/RenderLayerFilter.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5c87b65f06f83cb47b08c56549f6cdef
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/RenderParentComponent.json:
--------------------------------------------------------------------------------
1 | {
2 | "parent": {},
3 | "offset": {
4 | "x": 0.0,
5 | "y": 0.0,
6 | "z": 0.0
7 | }
8 | }
9 |
10 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/RenderParentComponent.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: acdcdc6e6267cdc448c21baf1c18bfb4
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/RoadComponent.json:
--------------------------------------------------------------------------------
1 | {
2 | "nodeA": {},
3 | "nodeB": {}
4 | }
5 |
6 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/RoadComponent.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: fd008dc81d624364f858c2410acc6f2f
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/RoadConnectionElement.json:
--------------------------------------------------------------------------------
1 | {
2 | "road": {}
3 | }
4 |
5 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/RoadConnectionElement.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6551e4675611fb140b6fed00908e6a0e
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/RotationComponent.json:
--------------------------------------------------------------------------------
1 | {
2 | "quaternion": {
3 | "x": 0.0,
4 | "y": 0.0,
5 | "z": 0.0,
6 | "w": 0.0
7 | }
8 | }
9 |
10 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/RotationComponent.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ba40a8fc6b5220c4597b854cddd5d429
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/ScaleComponent.json:
--------------------------------------------------------------------------------
1 | {
2 | "scale": {
3 | "x": 0.0,
4 | "y": 0.0,
5 | "z": 0.0
6 | }
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/ScaleComponent.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 02e290ef7be20604aa4299b9543336bc
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/SpawnerComponent.json:
--------------------------------------------------------------------------------
1 | {
2 | "outputRate": 0.0,
3 | "outputVelocity": 0.0,
4 | "lifeTime": 0.0,
5 | "position": {
6 | "x": 0.0,
7 | "y": 0.0,
8 | "z": 0.0
9 | },
10 | "prototype": {}
11 | }
12 |
13 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/SpawnerComponent.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4378e446ea66036438e5e38da2252f5a
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/StaticPositionComponent.json:
--------------------------------------------------------------------------------
1 | {
2 | "position": {
3 | "x": 0.0,
4 | "y": 0.0,
5 | "z": 0.0
6 | }
7 | }
8 |
9 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/StaticPositionComponent.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6ca1393a24bf83649bf1046438708e66
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/TrajectoryComponent.json:
--------------------------------------------------------------------------------
1 | {
2 | "start": {
3 | "x": 0.0,
4 | "y": 0.0,
5 | "z": 0.0,
6 | "w": 0.0
7 | },
8 | "end": {
9 | "x": 0.0,
10 | "y": 0.0,
11 | "z": 0.0,
12 | "w": 0.0
13 | }
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/TrajectoryComponent.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 23bd9d78989b07e4a97174fff6fa0fb1
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/TravelStateComponent.json:
--------------------------------------------------------------------------------
1 | {
2 | "returning": 0,
3 | "home": {}
4 | }
5 |
6 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/ComponentFormats/TravelStateComponent.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 47c9b37a3a7224e4c8288242e6d5ffe0
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/Prototypes.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: aafd5ea250891474cb60b64b4edba689
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/Prototypes/AICapsule.json:
--------------------------------------------------------------------------------
1 | {
2 | "ParentPrototype": "Capsule",
3 | "AIFilter": {}
4 | }
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/Prototypes/AICapsule.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 36b97deb1cfc3be4b90ce5526b326133
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/Prototypes/Agent.json:
--------------------------------------------------------------------------------
1 | {
2 | "TrajectoryComponent": {},
3 | "RotationComponent": {
4 | "quaternion": {
5 | "x": 1.0,
6 | "y": 0.0,
7 | "z": 0.0,
8 | "w": 0.0
9 | }
10 | },
11 | "PathNodeElement": [],
12 | "PathComponent": {
13 | "invertedSpeed": 0.015,
14 | "range": 10000
15 | },
16 | "ScaleComponent": {
17 | "scale": {
18 | "x": 2.5,
19 | "y": 2.5,
20 | "z": 2.5
21 | }
22 | },
23 | "MeshRenderFilter": {
24 | "mesh": "Cube"
25 | },
26 | "MaterialFilter": {
27 | "material": "AgentMaterial2"
28 | },
29 | "TravelStateComponent": {}
30 | }
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/Prototypes/Agent.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 93f8c632f3be69243a7c608a1d3d8de0
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/Prototypes/Capsule.json:
--------------------------------------------------------------------------------
1 | {
2 | "TrajectoryComponent": {},
3 | "RotationComponent": {
4 | "quaternion": {
5 | "x": 1.0,
6 | "y": 0.0,
7 | "z": 0.0,
8 | "w": 0.0
9 | }
10 | },
11 | "ObjectRendererComponent": {
12 | "objectType": "Capsule"
13 | },
14 | "RenderLayerFilter": {},
15 | "FlyingComponent": {
16 | "pitchAxis": 0.0,
17 | "yawAxis": 0.0,
18 | "rollAxis": 0.0,
19 | "throttle": 0.0,
20 | "maxSpeed": 200.0,
21 | "turnspeed": 300.0,
22 | "acceleration": 120.0,
23 | "velocity": 0.0
24 | }
25 | }
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/Prototypes/Capsule.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 45845c0c0656a32409b7f464bacfd421
3 | TextScriptImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/Prototypes/Cylinder.json:
--------------------------------------------------------------------------------
1 | {
2 | "TrajectoryComponent": {},
3 | "RotationComponent": {
4 | "quaternion": {
5 | "x": 1.0,
6 | "y": 0.0,
7 | "z": 0.0,
8 | "w": 0.0
9 | }
10 | },
11 | "ObjectRendererComponent": {
12 | "objectType": "Cylinder"
13 | },
14 | "RenderLayerFilter": {},
15 | "PhysicsComponent": {}
16 | }
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/Prototypes/Cylinder.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5a1875e08d3b4454cacdb7b5d856303c
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/Prototypes/Home.json:
--------------------------------------------------------------------------------
1 | {
2 | "HomeComponent" : {},
3 | "StaticPositionComponent": {},
4 | "RotationComponent": {
5 | "quaternion": {
6 | "x": 1.0,
7 | "y": 0.0,
8 | "z": 0.0,
9 | "w": 0.0
10 | }
11 | },
12 | "ObjectRendererComponent": {
13 | "objectType": "Sphere"
14 | },
15 | "RenderLayerFilter": {}
16 | }
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/Prototypes/Home.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 17a452c4e8fa14d40819db8af256c690
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/Prototypes/PlayerCapsule.json:
--------------------------------------------------------------------------------
1 | {
2 | "ParentPrototype": "Capsule",
3 | "PlayerFilter": {}
4 | }
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/Prototypes/PlayerCapsule.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c4c12221cdda7764db6ff30f3bb6c3b9
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/Prototypes/ReturningAgent.json:
--------------------------------------------------------------------------------
1 | {
2 | "TrajectoryComponent": {},
3 | "RotationComponent": {
4 | "quaternion": {
5 | "x": 1.0,
6 | "y": 0.0,
7 | "z": 0.0,
8 | "w": 0.0
9 | }
10 | },
11 | "PathNodeElement": [],
12 | "PathComponent": {
13 | "invertedSpeed": 0.015,
14 | "range": 10000
15 | },
16 | "ScaleComponent": {
17 | "scale": {
18 | "x": 3.5,
19 | "y": 3.5,
20 | "z": 3.5
21 | }
22 | },
23 | "MeshRenderFilter": {
24 | "mesh": "Cube"
25 | },
26 | "MaterialFilter": {
27 | "material": "AgentMaterial"
28 | },
29 | "TravelStateComponent": {}
30 | }
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/Prototypes/ReturningAgent.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f638bc749a6d2da40b4940b80ed6bfaf
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/Prototypes/Road.json:
--------------------------------------------------------------------------------
1 | {
2 | "RoadComponent": {},
3 | "StaticPositionComponent": {},
4 | "RotationComponent": {
5 | "quaternion": {
6 | "x": 1.0,
7 | "y": 0.0,
8 | "z": 0.0,
9 | "w": 0.0
10 | }
11 | },
12 | "ScaleComponent": {
13 | "scale": {
14 | "x": 0.5,
15 | "y": 0.5,
16 | "z": 0.5
17 | }
18 | },
19 | "MeshRenderFilter": {
20 | "mesh": "Cube"
21 | },
22 | "MaterialFilter": {
23 | "material": "BasicMaterial"
24 | }
25 | }
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/Prototypes/Road.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: fbcd57ee79dceaa4c94796605f8e8c0c
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/Prototypes/RoadNode.json:
--------------------------------------------------------------------------------
1 | {
2 | "RoadConnectionElement": [],
3 | "StaticPositionComponent": {}
4 | }
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/Prototypes/RoadNode.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b3655b56e649b3644a4674ffb2c4ef76
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/Prototypes/Spawner.json:
--------------------------------------------------------------------------------
1 | {
2 | "StaticPositionComponent": {},
3 | "SpawnerComponent": {}
4 | }
--------------------------------------------------------------------------------
/Samples~/Example/StreamingAssets/Prototypes/Spawner.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e334cb3c88cd2cb44bd5a1f3a69ea5f2
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/ScheduleQueue.cs:
--------------------------------------------------------------------------------
1 | namespace VodeoECS
2 | {
3 | ///
4 | /// Schedule Queues are requested from the Schedule Queue manager and track the scheduled updates of Entities by Systems.
5 | ///
6 | public struct ScheduleQueue
7 | {
8 | ///
9 | /// The length of the Schedule Queue.
10 | ///
11 | public int Count { get { return this.queue.Length; } }
12 | private NativePriorityQueue queue;
13 | ///
14 | /// For internal use by the Scheduling System and Schedule Queue Manager.
15 | ///
16 | /// The NativePriorityQueue to wrap as a ScheduleQueue.
17 | public ScheduleQueue ( NativePriorityQueue queue )
18 | {
19 | this.queue = queue;
20 | }
21 | ///
22 | /// Schedule an Entity update on the Schedule Queue.
23 | ///
24 | /// The Entity to update.
25 | /// The time at which the update is scheduled.
26 | public void Schedule ( Entity entity, float deadline )
27 | {
28 | queue.Push( entity, deadline );
29 | }
30 | ///
31 | /// For internal use by the System Manager and the base ScheduledSystem class. Returns the time at which the next update is scheduled.
32 | ///
33 | /// Returns the time at which the next update is scheduled.
34 | public float NextDeadline ( )
35 | {
36 | if ( queue.Length > 0 )
37 | {
38 | return queue.TopPriority( );
39 | }
40 | else
41 | {
42 | return float.MaxValue;
43 | }
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/ScheduleQueue.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e93256157e2556e438e7f92f58ab40dd
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/ScheduleQueueManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace VodeoECS
5 | {
6 | using QueueIndex = RegistryIndex>;
7 | ///
8 | /// The ECS Schedule Queue Manager is used by ECS Systems to register Schedule Queues and schedule Entity updates.
9 | ///
10 | public class ScheduleQueueManager : IDisposable
11 | {
12 | private NamedRegistry> queues;
13 | private Dictionary systems;
14 | private int capacity;
15 |
16 | ///
17 | /// Constructs a Schedule Queue Manager.
18 | ///
19 | /// Starting capacity for the queue.
20 | public ScheduleQueueManager ( int queueCapacity )
21 | {
22 | this.capacity = queueCapacity;
23 | this.queues = new NamedRegistry>( );
24 | this.systems = new Dictionary( );
25 | }
26 |
27 |
28 | ///
29 | /// Request a registered Schedule Queue by name and register the given Scheduled System as dependency.
30 | ///
31 | /// The name of the requested Queue.
32 | /// The Scheduled System to register as dependency.
33 | ///
34 | public ScheduleQueue GetQueue ( string name, ScheduledSystemECS system )
35 | {
36 | var index = this.queues.GetIndexByName( name );
37 | this.systems[index].Dependencies.Add( system );
38 |
39 | return new ScheduleQueue( this.queues[index] );
40 | }
41 |
42 | ///
43 | /// Request a registered Schedule Queue by name for use by a Passive System.
44 | ///
45 | /// The name of the requested Queue.
46 | /// The Scheduled System to register as dependency.
47 | ///
48 | public ScheduleQueue GetQueueWithoutDependency ( string name )
49 | {
50 | var index = this.queues.GetIndexByName( name );
51 |
52 | return new ScheduleQueue( this.queues[index] );
53 | }
54 |
55 | ///
56 | /// Register a new Schedule Queue by name. The queue is "owned" by a single System but Entities can be Scheduled onto it by any System.
57 | ///
58 | /// The name of the new Schedule Queue.
59 | /// The ECS System which will "own" this Schedule Queue.
60 | /// The created Queue.
61 | public NativePriorityQueue CreateQueue ( string name, ScheduledSystemECS system )
62 | {
63 | NativePriorityQueue queue = new NativePriorityQueue( capacity, Unity.Collections.Allocator.Persistent );
64 | this.systems.Add( this.queues.Register( queue, name ), system );
65 | return queue;
66 | }
67 |
68 | ///
69 | /// For internal use by the Serializer. Get the Queue Registry.
70 | ///
71 | /// The Schedule Queue Registry.
72 | public NamedRegistry> GetQueueRegistry ( )
73 | {
74 | return this.queues;
75 | }
76 |
77 | ///
78 | /// Dispose the Native Memory reserved by this Schedule Queue Manager.
79 | ///
80 | public void Dispose ( )
81 | {
82 | foreach ( NativePriorityQueue queue in queues )
83 | {
84 | queue.Dispose( );
85 | }
86 | }
87 | }
88 | }
--------------------------------------------------------------------------------
/ScheduleQueueManager.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c665542e2a9af624f92765e515809204
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/ScheduledSystemECS.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using UnityEngine;
4 |
5 | namespace VodeoECS
6 | {
7 | public abstract class ScheduledSystemECS : SystemECS
8 | {
9 | ///
10 | /// Get the Schedule Queue corresponding to this Scheduled System.
11 | ///
12 | public ScheduleQueue ScheduleQueue { get; }
13 | ///
14 | /// For internal use by the System Scheduler.
15 | ///
16 | public List Dependencies { get; }
17 |
18 | private NativePriorityQueue queue;
19 | ///
20 | /// Construct a Scheduled System.
21 | ///
22 | /// The World object.
23 | /// The name of this System's Schedule Queue.
24 | public ScheduledSystemECS ( World world, string queueName )
25 | {
26 | world.Systems.RegisterSystem( this );
27 | queue = world.ScheduleQueues.CreateQueue( queueName, this );
28 | this.ScheduleQueue = new ScheduleQueue( queue );
29 | this.Dependencies = new List( );
30 | }
31 |
32 | ///
33 | /// Update this system up to the given time.
34 | ///
35 | /// The time that the system needs to be updated up to.
36 | public void UpdateTo ( float time )
37 | {
38 | float t;
39 | int n = 0;
40 | while ( ( t = ScheduleQueue.NextDeadline( ) ) <= time )
41 | {
42 | n++;
43 | Entity entity = queue.Pop( );
44 | this.UpdateEntity( entity, t );
45 | if (n > 10000) throw new Exception( "Possible infinite update loop detected in "+this.GetType() );
46 | }
47 | }
48 | ///
49 | /// Update the given Entity at scheduled time.
50 | ///
51 | /// The Entity to update.
52 | /// The time of the update.
53 | public abstract void UpdateEntity ( Entity entity, float time );
54 | }
55 | }
--------------------------------------------------------------------------------
/ScheduledSystemECS.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 125d7d846f5afa34696a4776d57dcd60
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Standard.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 47f64449e35d2fc41ba6c4da68c12cad
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Standard/Components.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e4c2727b6fd23dc40b53f9550e846b9d
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Standard/Components/MaterialFilter.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace VodeoECS.Standard
4 | {
5 | ///
6 | /// The rendering material of an Entity.
7 | ///
8 | public struct MaterialFilter : IFilterComponent
9 | {
10 | public RegistryIndex material;
11 | public bool Equals ( MaterialFilter other )
12 | {
13 | return ( this.material == other.material );
14 | }
15 | public override int GetHashCode ( ) { return ( material ).GetHashCode( ); }
16 | }
17 | }
--------------------------------------------------------------------------------
/Standard/Components/MaterialFilter.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 66f00e11188216c4a9b09c5194be9f22
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Standard/Components/MeshRenderFilter.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace VodeoECS.Standard
4 | {
5 | ///
6 | /// The rendering mesh of an Entity.
7 | ///
8 | public struct MeshRenderFilter : IFilterComponent
9 | {
10 | public RegistryIndex mesh;
11 | public bool Equals ( MeshRenderFilter other )
12 | {
13 | return ( this.mesh == other.mesh );
14 | }
15 | public override int GetHashCode ( ) { return (mesh).GetHashCode( ); }
16 | }
17 | }
--------------------------------------------------------------------------------
/Standard/Components/MeshRenderFilter.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 49c6f8ec126e30e49bff3a4742f50046
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Standard/Components/ObjectRendererComponent.cs:
--------------------------------------------------------------------------------
1 | namespace VodeoECS.Standard
2 | {
3 | using RenderObjectType = RegistryIndex;
4 |
5 | ///
6 | /// The type of rendering GameObject associated with the Entity.
7 | ///
8 | public struct ObjectRendererComponent : IDataComponent
9 | {
10 | public RenderObjectType objectType;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Standard/Components/ObjectRendererComponent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4f408da24bb28074c96dac10d547d863
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Standard/Components/RenderLayerFilter.cs:
--------------------------------------------------------------------------------
1 | namespace VodeoECS.Standard
2 | {
3 | ///
4 | /// The rendering layer of the Entity.
5 | ///
6 | public struct RenderLayerFilter : IFilterComponent
7 | {
8 | public byte layer;
9 | public bool Equals ( RenderLayerFilter other )
10 | {
11 | return (
12 | this.layer == other.layer
13 | );
14 | }
15 | public override int GetHashCode ( ) { return ( layer ).GetHashCode( ); }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Standard/Components/RenderLayerFilter.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3b444d67e6589224cbf204529e1516ad
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Standard/Components/RenderParentComponent.cs:
--------------------------------------------------------------------------------
1 | using Unity.Mathematics;
2 |
3 | namespace VodeoECS.Standard
4 | {
5 | ///
6 | /// The parent Entity and offset that the Entity should be rendered relative to.
7 | ///
8 | public struct RenderParentComponent : IDataComponent
9 | {
10 | public Entity parent;
11 | public float3 offset;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Standard/Components/RenderParentComponent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: dea5d5d17a917674bb9e3743dd78df87
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Standard/Components/RotationComponent.cs:
--------------------------------------------------------------------------------
1 | using Unity.Mathematics;
2 |
3 | namespace VodeoECS.Standard
4 | {
5 | ///
6 | /// The spatial rotation of an Entity.
7 | ///
8 | public struct RotationComponent : IDataComponent
9 | {
10 | public float4 quaternion;
11 | }
12 | }
--------------------------------------------------------------------------------
/Standard/Components/RotationComponent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 58677db71f6454a43b51f3eb6f240508
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Standard/Components/ScaleComponent.cs:
--------------------------------------------------------------------------------
1 | using Unity.Mathematics;
2 |
3 | namespace VodeoECS.Standard
4 | {
5 | ///
6 | /// The scale transform of an Entity.
7 | ///
8 | public struct ScaleComponent : IDataComponent
9 | {
10 | public float3 scale;
11 | }
12 | }
--------------------------------------------------------------------------------
/Standard/Components/ScaleComponent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8c6e5f7f4453c4c459541a23fefc411a
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Standard/Components/StaticPositionComponent.cs:
--------------------------------------------------------------------------------
1 | using Unity.Mathematics;
2 |
3 | namespace VodeoECS.Standard
4 | {
5 | ///
6 | /// The static position of the Entity.
7 | ///
8 | public struct StaticPositionComponent : IDataComponent
9 | {
10 | public float3 position;
11 | }
12 | }
--------------------------------------------------------------------------------
/Standard/Components/StaticPositionComponent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3741d05460dc645469dd88f46e34c555
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Standard/Components/TrajectoryComponent.cs:
--------------------------------------------------------------------------------
1 | using Unity.Mathematics;
2 |
3 | namespace VodeoECS.Standard
4 | {
5 | ///
6 | /// The linear trajectory of the Entity in space, over a finite timespan.
7 | ///
8 | public struct TrajectoryComponent : IDataComponent
9 | {
10 | public float4 start;
11 | public float4 end;
12 | }
13 | }
--------------------------------------------------------------------------------
/Standard/Components/TrajectoryComponent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7d9c605e7ca6cd344a172fdda646b48f
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Standard/Events.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5636aaab47b9ed244b0f2f333f02919c
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Standard/Events/UpdateStaticMeshesEvent.cs:
--------------------------------------------------------------------------------
1 | namespace VodeoECS.Standard
2 | {
3 | ///
4 | /// This event should be called when Entities with static meshes have been updated and are in need of being refreshed.
5 | ///
6 | public struct UpdateStaticMeshesEvent : IEventECS {}
7 | }
--------------------------------------------------------------------------------
/Standard/Events/UpdateStaticMeshesEvent.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3ba33c0e01936d74aa19e6fae8d75c1c
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Standard/MeshRenderSystem.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d95c82987def28c4d97ddd27b655168f
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Standard/ObjectRenderSystem.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1daee75770c2d5b4a8954fcb7fac7abf
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Standard/PrefabPool.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using UnityEngine;
3 |
4 | namespace VodeoECS.Standard
5 | {
6 | ///
7 | /// This is a utility class to create a pool of Unity GameObjects from a given prefab.
8 | ///
9 | public class PrefabPool : MonoBehaviour
10 | {
11 | public GameObject prefab;
12 | public int objectCount = 16;
13 | public bool preallocate = false;
14 |
15 | Stack inactiveObjects = new Stack( );
16 | List activeObjects = new List( );
17 | bool allocated = false;
18 |
19 | public void Awake ( )
20 | {
21 | if ( !allocated )
22 | Allocate( );
23 | }
24 |
25 | ///
26 | /// Spawns a new GameObject in this pool.
27 | ///
28 | /// The spawned GameObject.
29 | public GameObject Spawn ( )
30 | {
31 | if ( !preallocate )
32 | {
33 | GameObject obj;
34 |
35 | if ( inactiveObjects.Count > 0 )
36 | {
37 | obj = inactiveObjects.Pop( );
38 | obj.SetActive( true );
39 | activeObjects.Add( obj );
40 | return obj;
41 | }
42 |
43 | obj = Instantiate( prefab.gameObject, transform, false );
44 | obj.SetActive( true );
45 | activeObjects.Add( obj );
46 | GameObject result = obj;
47 |
48 | return result;
49 | }
50 |
51 |
52 | if ( !allocated )
53 | Allocate( );
54 |
55 | try
56 | {
57 | GameObject obj = inactiveObjects.Pop( );
58 | obj.SetActive( true );
59 | activeObjects.Add( obj );
60 | return obj;
61 | }
62 | catch
63 | {
64 | Debug.LogError( name + ": PrefabPool over maximum capacity", this );
65 | return null;
66 | }
67 | }
68 |
69 |
70 | ///
71 | /// Despawns a given GameObject in this pool.
72 | ///
73 | /// The GameObject to despawn.
74 | /// The despawned GameObject.
75 | public GameObject Despawn ( GameObject obj )
76 | {
77 | obj.SetActive( false );
78 | obj.transform.SetParent( transform );
79 | inactiveObjects.Push( obj );
80 | activeObjects.Remove( obj );
81 | return obj;
82 | }
83 |
84 | ///
85 | /// Despawn all GameObjects in this pool.
86 | ///
87 | public void DespawnAll ( )
88 | {
89 | int numActiveObjects = activeObjects.Count - 1;
90 | for ( int i = numActiveObjects; i >= 0; i-- )
91 | {
92 | activeObjects[i].SetActive( false );
93 | activeObjects[i].transform.SetParent( transform );
94 | inactiveObjects.Push( activeObjects[i] );
95 | }
96 | activeObjects.Clear( );
97 | }
98 |
99 | ///
100 | /// Get a list of all GameObjects in this pool.
101 | ///
102 | /// The requested list of all GameObjects in this pool.
103 | public List GetAll ( )
104 | {
105 | List result = new List( );
106 | foreach ( GameObject obj in activeObjects )
107 | result.Add( obj );
108 |
109 | return result;
110 | }
111 |
112 | private void Allocate ( )
113 | {
114 | if ( !preallocate )
115 | {
116 | allocated = true;
117 | return;
118 | }
119 |
120 | for ( int i = 0; i <= objectCount; i++ )
121 | {
122 | GameObject obj = Instantiate( prefab.gameObject, transform, false ) as GameObject;
123 | obj.SetActive( false );
124 | inactiveObjects.Push( obj );
125 | }
126 |
127 | allocated = true;
128 | }
129 |
130 | }
131 | }
--------------------------------------------------------------------------------
/Standard/PrefabPool.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b23c050d6a5b8654580d6b00ee66d9f1
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Standard/RegistryLoaders.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 16f8b064fb338e64cb9cb401a7c36551
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Standard/RegistryLoaders/MaterialLoader.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace VodeoECS.Standard
4 | {
5 | ///
6 | /// Registry Loader for loading Materials.
7 | ///
8 | public class MaterialLoader : IRegistryLoader
9 | {
10 | public Material Load ( string name )
11 | {
12 | return Resources.Load( "Materials/" + name );
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/Standard/RegistryLoaders/MaterialLoader.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c708d04d77be1174289455e1ac9bc982
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Standard/RegistryLoaders/MeshLoader.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 |
3 | namespace VodeoECS.Standard
4 | {
5 | ///
6 | /// Registry Loader for loading Meshes.
7 | ///
8 | public class MeshLoader : IRegistryLoader
9 | {
10 | public Mesh Load ( string name )
11 | {
12 | return Resources.Load( "Meshes/" + name );
13 | }
14 | }
15 | }
--------------------------------------------------------------------------------
/Standard/RegistryLoaders/MeshLoader.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 55119539cf81aab449c0b8af24fa3dfb
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Standard/RegistryLoaders/PrefabLoader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using UnityEngine;
3 |
4 | namespace VodeoECS.Standard
5 | {
6 | ///
7 | /// Registry Loader for loading Prefabs.
8 | ///
9 | public class PrefabLoader : IRegistryLoader
10 | {
11 | private Transform pools;
12 | public PrefabLoader ( )
13 | {
14 | this.pools = new GameObject( "ObjectPools" ).transform;
15 | }
16 | public PrefabPool Load ( string name )
17 | {
18 | PrefabPool pool = new GameObject( name ).AddComponent( );
19 | pool.transform.parent = this.pools;
20 | pool.prefab = Resources.Load( "Prefabs/" + name );
21 | if ( pool.prefab == null ) throw new Exception( "Prefab " + name + " not found in assets." );
22 |
23 | return pool;
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Standard/RegistryLoaders/PrefabLoader.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 95989b3a7e6fdf94f9d5b3cdd119dc6c
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/StringRegistryConverter.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 | using System;
3 | using System.Collections;
4 | using System.Collections.Generic;
5 |
6 | namespace VodeoECS
7 | {
8 | public class StringRegistryConverter : JsonConverter>
9 | {
10 | protected Registry