{"id":20290066,"url":"https://github.com/extrys/ez-dots-extensions","last_synced_at":"2025-04-11T10:59:07.462Z","repository":{"id":191611986,"uuid":"246869827","full_name":"Extrys/EZ-DOTS-Extensions","owner":"Extrys","description":"Just a set of easy to use extensions mostly for Unity DOTS","archived":false,"fork":false,"pushed_at":"2022-03-03T16:12:05.000Z","size":51,"stargazers_count":15,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T07:22:54.733Z","etag":null,"topics":["collisions","data-oriented-technology-stack","dots","dots-extensions","ecs","extension","ez-dots-extensions","iteration","repetition","triggers","unity"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Extrys.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-03-12T15:33:12.000Z","updated_at":"2024-07-18T00:36:18.000Z","dependencies_parsed_at":"2023-08-30T17:36:24.149Z","dependency_job_id":"7d48c86b-e531-4cc6-9886-a76764501d4c","html_url":"https://github.com/Extrys/EZ-DOTS-Extensions","commit_stats":null,"previous_names":["extrys/ez-dots-extensions"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Extrys%2FEZ-DOTS-Extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Extrys%2FEZ-DOTS-Extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Extrys%2FEZ-DOTS-Extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Extrys%2FEZ-DOTS-Extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Extrys","download_url":"https://codeload.github.com/Extrys/EZ-DOTS-Extensions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248381704,"owners_count":21094525,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collisions","data-oriented-technology-stack","dots","dots-extensions","ecs","extension","ez-dots-extensions","iteration","repetition","triggers","unity"],"created_at":"2024-11-14T15:06:06.406Z","updated_at":"2025-04-11T10:59:07.439Z","avatar_url":"https://github.com/Extrys.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"EZ-DOTS-Extensions\n\nWelcome! This is just a project that I'm starting and in which I'll add all the extensions that I'll create in my projects, which will help me and maybe you to have an easier to use, more readable, more modular and shorter code, avoiding repetitions. \u003c/br\u003eEverything is focused mainly to use with DOTS\n\n\n\u003cb\u003eThis is a WIP README\u003c/b\u003e\u003c/br\u003e\n    · \u003ca href=\"## Util for Collisions and triggers for avoid repetitions\"\u003eUtils for Collisions\u003c/a\u003e\u003c/br\u003e\n    · \u003ca href=\"## DOTS EZ Quaternion Extensions\"\u003eQuaternion Extensions\u003c/a\u003e\u003c/br\u003e\n\nmeanwhile this repo is growing i will put here one of the first utils that is made for DOTS Physics collisions and triggers\n\n\n## Util for Collisions and triggers for avoid repetitions\nfor example i will leave a job for detecting collisions that comes with Unity DOTS Physics Samples\n```csharp\n    [BurstCompile]\n    struct CollisionEventImpulseJob : ICollisionEventsJob\n    {\n        [ReadOnly]\n        public ComponentDataFromEntity\u003cCollisionEventImpulse\u003e ColliderEventImpulseGroup;\n        public ComponentDataFromEntity\u003cPhysicsVelocity\u003e PhysicsVelocityGroup;\n\n        public void Execute(CollisionEvent collisionEvent)\n        {\n            Entity entityA = collisionEvent.Entities.EntityA;\n            Entity entityB = collisionEvent.Entities.EntityB;\n\n            bool isBodyADynamic = PhysicsVelocityGroup.Exists(entityA);\n            bool isBodyBDynamic = PhysicsVelocityGroup.Exists(entityB);\n\n            bool isBodyARepulser = ColliderEventImpulseGroup.Exists(entityA);\n            bool isBodyBRepulser = ColliderEventImpulseGroup.Exists(entityB);\n\n            if(isBodyARepulser \u0026\u0026 isBodyBDynamic)\n            {\n                var impulseComponent = ColliderEventImpulseGroup[entityA];\n                var velocityComponent = PhysicsVelocityGroup[entityB];\n                velocityComponent.Linear = impulseComponent.Impulse;\n                PhysicsVelocityGroup[entityB] = velocityComponent;\n            }\n            if (isBodyBRepulser \u0026\u0026 isBodyADynamic)\n            {\n                var impulseComponent = ColliderEventImpulseGroup[entityB];\n                var velocityComponent = PhysicsVelocityGroup[entityA];\n                velocityComponent.Linear = impulseComponent.Impulse;\n                PhysicsVelocityGroup[entityA] = velocityComponent;\n            }\n        }\n    }\n```\nThis is not completly bad but for me atleast the repetition hurts and my eyes bleed\nalso if i modify anything i have to do it too inside the condition below\nthis is made this way to detect interactions in two directions\nso if i have a Sword that is Breaker and breakable that collides with another one\nboth swords needs to be broken\nthis is made this way just for doing this (weaponA breaks weaponB) \u003c-\u003e (weaponB breaks weaponA)\nIn most of cases you will need to use it in the two directions\nso you will need unnecesarly duplicate the code\n\ni came with a solution for this\n\u003cb\u003eMethod A:\u003c/b\u003e you can do this way with TryInteract Extension this will made it two directional by default and you dont create noisy A\u0026B variablesit will iterate 2 times, one for each direction\n```csharp\n[BurstCompile]\nstruct CollisionEventImpulseJob : ICollisionEventsJob\n{\n    [ReadOnly]\n    public ComponentDataFromEntity\u003cCollisionEventImpulse\u003e impulseGetter;\n    public ComponentDataFromEntity\u003cPhysicsVelocity\u003e velocityGetter;\n\n    public void Execute(CollisionEvent collisionEvent)\n    {\n        for (int i = 0; collisionEvent.Entities.TryInteract(ref i, impulseGetter, velocityGetter, out Entity impulseEntity, out Entity velocityEntity);)\n        {\n            var impulseComponent = impulseGetter[impulseEntity];\n            var velocityComponent = velocityGetter[velocityEntity];\n            velocityComponent.Linear = impulseComponent.Impulse;\n            velocityGetter[velocityEntity] = velocityComponent;\n        }\n    }\n}\n```\n\u003cbr/\u003ebut one of the problems of this is that the \"for\" line can be so long is for that i created also another way to doing so\n\n\u003cb\u003eMethod B:\u003c/b\u003e this way will need you take the copy of the pair because it will switch the values between the value pairs.\nIt uses an extension metod called ``SwitchPair`` that you can use at you will\n```csharp\n        var pair = collisionEvent.Entities;\n        for (int i = 0; i\u003c2; i++)\n        {\n            if( pair.SwitchAndTryInteract(impulseGetter, velocityGetter))\n            {\n                var impulseEntity = pair.EntityA; \n                var velocityEntity = pair.EntityB;\n\n                var impulseComponent = impulseGetter[impulseEntity];\n                var velocityComponent = velocityGetter[velocityEntity];\n                velocityComponent.Linear = impulseComponent.Impulse;\n                velocityGetter[velocityEntity] = velocityComponent;\n            }\n        }\n```\nwhat im doing in both is Just create a \"for\" loop that iterates 2 times and call the switch after one iteration so the second will do the same iteration but with the entities take away the repetition with the loop which is simply a dual direction check\n\n\n\nI will be updating the Documentation and adding more functionality to this library so it will become larger with time to make your life a bit easier, if it helps you i will be happy\n\n\n## DOTS EZ Quaternion Extensions\nSome extensions to work with quaternions for DOTS\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextrys%2Fez-dots-extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fextrys%2Fez-dots-extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextrys%2Fez-dots-extensions/lists"}