This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using NUnit.Framework; | |
| using System; | |
| using System.Diagnostics; | |
| using System.Linq; | |
| using Unity.Collections; | |
| using Unity.Entities; | |
| using Unity.PerformanceTesting; | |
| namespace Packages.com.vella.events.Tests | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using NUnit.Framework; | |
| using System; | |
| using System.Diagnostics; | |
| using System.Linq; | |
| using Unity.Collections; | |
| using Unity.Entities; | |
| using Unity.PerformanceTesting; | |
| namespace Packages.com.vella.events.Tests | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Test, Performance, TestCategory(TestCategory.Performance)] | |
| public void CompareToDefaultApproaches([Values(1, 25, 100, 250, 1000, 5000)] int eventsPerArchetype) | |
| { | |
| var system = World.GetOrCreateSystem<EntityEventSystem>(); | |
| var components = new[] | |
| { | |
| ComponentType.ReadWrite<EntityEvent>(), | |
| ComponentType.ReadWrite<EcsTestData>(), | |
| }; | |
| var archetype = Manager.CreateArchetype(components); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static unsafe class EntityComponentID | |
| { | |
| internal static uint NextID() => ++EntityComponentIDCounter.Ref.Data.Id; // first id = 1 | |
| } | |
| public struct SomeGenericParam { } | |
| public struct MyStaticData | |
| { | |
| public uint Id; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using Unity.Entities; | |
| namespace Vella.Events | |
| { | |
| /// <summary> | |
| /// System that is responsible for creating the EntityEventSystem. | |
| /// It allows a package user to control where the <see cref="EntityEventSystem"/> is located. | |
| /// </summary> | |
| [UpdateInGroup(typeof(InitializationSystemGroup))] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public struct C1 : IComponentData { } | |
| public struct C2 : IComponentData { } | |
| public struct C3 : IComponentData { } | |
| [Test] | |
| unsafe public void HasTest() | |
| { | |
| Manager.CreateEntity(new[] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public struct MyComponent : IComponentData | |
| { | |
| public Entity Reference; | |
| public int Value; | |
| } | |
| public struct MyElement : IBufferElementData | |
| { | |
| public Entity Reference; | |
| public int Value; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public struct MyComponent : IComponentData | |
| { | |
| public Entity Reference; | |
| public int Value; | |
| } | |
| public class MySystem : SystemBase | |
| { | |
| protected override void OnUpdate() | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class ScoreSystem : SystemBase | |
| { | |
| public const int BaseScoreMultiplier = 10; | |
| private EventQueue<ScoreAddedEvent> _addScoreQueue; | |
| protected override void OnCreate() | |
| { | |
| _addScoreQueue = World.GetOrCreateSystem<EntityEventSystem>().GetQueue<ScoreAddedEvent>(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int count; | |
| int* countPtr = &count; | |
| NativeKeyValueArrays<int, UnsafeEventBatch> pairsMaster = default; | |
| NativeArray<Entity> entitiesMaster = default; | |
| var pairsPtr = UnsafeUtility.AddressOf(ref pairsMaster); | |
| var entitiesPtr = UnsafeUtility.AddressOf(ref entitiesMaster); | |
| var sw = Stopwatch.StartNew(); |