示例#1
0
        public void FixedArrayComponentGroupIteration()
        {
            /*var entity64 =*/ m_Manager.CreateEntity(ComponentType.FixedArray(typeof(int), 64));
            /*var entity10 =*/ m_Manager.CreateEntity(ComponentType.FixedArray(typeof(int), 10));

            var group = m_Manager.CreateComponentGroup(typeof(int));

            var fixedArray = group.GetFixedArrayArray <int>();

            Assert.AreEqual(2, fixedArray.Length);
            Assert.AreEqual(64, fixedArray[0].Length);
            Assert.AreEqual(10, fixedArray[1].Length);

            Assert.AreEqual(0, fixedArray[0][3]);
            Assert.AreEqual(0, fixedArray[1][3]);

            NativeArray <int> array;

            array    = fixedArray[0];
            array[3] = 0;

            array    = fixedArray[1];
            array[3] = 1;

            for (int i = 0; i < fixedArray.Length; i++)
            {
                Assert.AreEqual(i, fixedArray[i][3]);
            }
        }
示例#2
0
        public void RemoveComponentWithUnspecifiedLength()
        {
            var entity = m_Manager.CreateEntity(ComponentType.FixedArray(typeof(int), 11));

            m_Manager.RemoveComponent(entity, typeof(int));
            Assert.IsFalse(m_Manager.HasComponent(entity, typeof(int)));
        }
示例#3
0
        public void CreateEntityWithTwoSameTypeFixedArraysThrows()
        {
            var array11Type = ComponentType.FixedArray(typeof(int), 11);
            var array12Type = ComponentType.FixedArray(typeof(int), 12);

            Assert.Throws <ArgumentException>(() => { m_Manager.CreateEntity(array11Type, array12Type); });
        }
示例#4
0
 public void CreateTooBigArchetypeThrows()
 {
     Assert.Throws <System.ArgumentException>(() =>
     {
         m_Manager.CreateArchetype(ComponentType.FixedArray(typeof(int), 10000), ComponentType.FixedArray(typeof(float), 10000));
     });
 }
示例#5
0
        public void CreateEntityArrayWithValidLengths([Values(0, 1, 2, 100)] int length)
        {
            var entity = m_Manager.CreateEntity(ComponentType.FixedArray(typeof(int), length));

            var array = m_Manager.GetFixedArray <int>(entity);

            Assert.AreEqual(length, array.Length);
        }
示例#6
0
        public void RemoveComponentWithExactLength()
        {
            var fixed11 = ComponentType.FixedArray(typeof(int), 11);
            var entity  = m_Manager.CreateEntity(fixed11);

            m_Manager.RemoveComponent(entity, fixed11);
            Assert.IsFalse(m_Manager.HasComponent(entity, typeof(int)));
        }
示例#7
0
        public void RemoveComponentWithIncorrectLength()
        {
            var fixed11 = ComponentType.FixedArray(typeof(int), 11);
            var fixed1  = ComponentType.FixedArray(typeof(int), 1);
            var entity  = m_Manager.CreateEntity(fixed11);

            Assert.Throws <ArgumentException>(() => { m_Manager.RemoveComponent(entity, fixed1); });
        }
示例#8
0
        public void InequalityOperator_WhenDifferentLength_ReturnsTrue()
        {
            var t1 = ComponentType.FixedArray(typeof(Entity), 1);
            var t2 = ComponentType.FixedArray(typeof(Entity), 2);

            var result = t1 != t2;

            Assert.IsTrue(result);
        }
示例#9
0
        public void HasComponent()
        {
            var array11Type = ComponentType.FixedArray(typeof(int), 11);
            var array12Type = ComponentType.FixedArray(typeof(int), 12);
            var entity      = m_Manager.CreateEntity(array11Type);

            Assert.IsTrue(m_Manager.HasComponent(entity, typeof(int)));
            Assert.IsTrue(m_Manager.HasComponent(entity, array11Type));

            Assert.IsFalse(m_Manager.HasComponent(entity, array12Type));
        }
示例#10
0
        public void MutateFixedArrayData()
        {
            var entity = m_Manager.CreateEntity();

            m_Manager.AddComponent(entity, ComponentType.FixedArray(typeof(int), 11));

            var array = m_Manager.GetFixedArray <int>(entity);

            Assert.AreEqual(11, array.Length);
            array[7] = 5;
            Assert.AreEqual(5, array[7]);
        }
示例#11
0
    // EntityArchetype entityArchetype;

    void Start()
    {
        var particles = new List <DynamicBoneParticle> ();
        var bones     = new List <Transform> ();

        GenerateParticles(particles, bones);

        entityManager = World.Active.GetExistingManager <EntityManager> ();
        // entityArchetype = entityManager.CreateArchetype (
        //     ComponentType.Create<DynamicBoneRoot> (),
        //     ComponentType.FixedArray (typeof (DynamicBoneParticle), particles.Count)
        // );

        // var entity = bones[0].gameObject.AddComponent<GameObjectEntity> ().Entity;
        var entity = GameObjectEntity.AddToEntityManager(entityManager, bones[0].gameObject);

        entityManager.AddComponentData(entity, new DynamicBoneRoot()
        {
            length             = particles.Count,
            rootInvertRotation = Quaternion.Inverse(root.rotation),
            objectMove         = new float3(),
            objectPrevPosition = root.position
        });

        entityManager.AddComponentData(entity, new DynamicBoneTransform()
        {
            owner             = entity,
            index             = 0,
            initLocalPosition = bones[0].localPosition,
            initLocalRotation = bones[0].localRotation,
        });

        entityManager.AddComponent(entity, ComponentType.FixedArray(typeof(DynamicBoneParticle), particles.Count));
        var particleArray = entityManager.GetFixedArray <DynamicBoneParticle> (entity);

        for (int i = 0; i < particles.Count; i++)
        {
            particleArray[i] = particles[i];
        }

        for (int i = 1; i < particles.Count; i++)
        {
            // var boneEntity = bones[i].gameObject.AddComponent<GameObjectEntity> ().Entity;
            var boneEntity = GameObjectEntity.AddToEntityManager(entityManager, bones[i].gameObject);
            entityManager.AddComponentData(boneEntity, new DynamicBoneTransform()
            {
                owner             = entity,
                index             = i,
                initLocalPosition = bones[i].localPosition,
                initLocalRotation = bones[i].localRotation,
            });
        }
    }
        public void FromEntitySystemIncrementInJobWorks()
        {
            var system = World.GetOrCreateManager <FromEntitySystemIncrementInJob> ();

            var entity = m_Manager.CreateEntity(typeof(EcsTestData), ComponentType.FixedArray(typeof(int), 5));

            system.entity = entity;
            system.Update();
            system.Update();

            Assert.AreEqual(2, m_Manager.GetComponentData <EcsTestData>(entity).value);
            Assert.AreEqual(2, m_Manager.GetFixedArray <int>(entity)[0]);
        }
示例#13
0
    internal Entity CreateNetworkComponentData <T>(Entity entityReference, int numberOfMembers)
    {
        Entity entity = NetworkEntityManager.CreateEntity(
            ComponentType.Create <NetworkComponentData <T> >(),
            ComponentType.Create <NetworkComponentEntityReference>(),
            ComponentType.FixedArray(typeof(int), numberOfMembers * 2)); // 2x because of history

        NetworkEntityManager.SetComponentData(entity, new NetworkComponentEntityReference {
            Index = entityReference.Index, Version = entityReference.Version
        });

        return(entity);
    }
示例#14
0
        public void FixedArrayFromEntityWorks()
        {
            var entityInt = m_Manager.CreateEntity(ComponentType.FixedArray(typeof(int), 3));

            m_Manager.GetFixedArray <int>(entityInt).CopyFrom(new int[] { 1, 2, 3 });

            var intLookup = EmptySystem.GetFixedArrayFromEntity <int>();

            Assert.IsTrue(intLookup.Exists(entityInt));
            Assert.IsFalse(intLookup.Exists(new Entity()));

            Assert.AreEqual(2, intLookup[entityInt][1]);
        }
示例#15
0
    internal Entity CreateNetworkComponentData <T>(Entity entity, int fieldsCount)
    {
        var newEntity = NetworkEntityManager.CreateEntity(
            ComponentType.Create <NetworkComponentData <T> >(),
            ComponentType.Create <ComponentEntity>(),
            ComponentType.FixedArray(typeof(int), fieldsCount * 2)); // 2x because of history

        var component = new ComponentEntity {
            Index   = entity.Index,
            Version = entity.Version
        };

        NetworkEntityManager.SetComponentData(newEntity, component);

        return(newEntity);
    }
示例#16
0
    void Start()
    {
        cubes = GetComponent <SphereGenerator> ().GetTransforms();
        depth = GetDepth(cubes[0]);

        entityManager   = World.Active.GetExistingManager <EntityManager> ();
        entityArchetype = entityManager.CreateArchetype(
            ComponentType.Create <ChainRoot> (),
            ComponentType.FixedArray(typeof(ChainData), depth)
            );

        var time = Time.realtimeSinceStartup;

        for (int i = 0; i < cubes.Length; i++)
        {
            var entity = entityManager.CreateEntity(entityArchetype);
            entityManager.SetComponentData(entity, new ChainRoot()
            {
                Length = depth
            });

            var chain      = cubes[i].GetComponentsInChildren <Transform> ();
            var chainDatas = entityManager.GetFixedArray <ChainData> (entity);
            for (int j = 0; j < depth; j++)
            {
                chainDatas[j] = new ChainData()
                {
                    InitLocalPosition = chain[j].localPosition
                };
            }

            for (int j = 0; j < depth; j++)
            {
                // var subEntity = chain[j].gameObject.AddComponent<GameObjectEntity> ().Entity;
                var subEntity = GameObjectEntity.AddToEntityManager(entityManager, chain[j].gameObject);  // faster initialization
                entityManager.AddComponentData(subEntity, new Owner()
                {
                    Value = entity, Index = j
                });
            }
        }
        Debug.Log(Time.realtimeSinceStartup - time);
    }
示例#17
0
        /// <summary>
        /// Add a fixed array to the entity
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="length"></param>
        /// <typeparam name="T"></typeparam>
        protected void AddFixedArray <T>(Entity entity, int length)
            where T : struct
        {
            var typeIndex = TypeManager.GetTypeIndex <T>();

            void LocalCreateFixedArray()
            {
                EntityManager.AddComponent(entity, ComponentType.FixedArray(typeof(T), length));
            }

            if (EntityManager.HasComponent(entity, ComponentType.FromTypeIndex(typeIndex)))
            {
                var fixedArray = EntityManager.GetFixedArray <T>(entity);
                if (fixedArray.Length != length)
                {
                    EntityManager.RemoveComponent(entity, ComponentType.FromTypeIndex(typeIndex));
                    LocalCreateFixedArray();
                }
            }
            else
            {
                LocalCreateFixedArray();
            }
        }
示例#18
0
        private void AddSoftbody(DefKit.TetMesh tetMesh)
        {
            int[] constraintsCounter = new int[tetMesh.pointsCount];
            for (int i = 0; i < tetMesh.edgesCount; i++)
            {
                //bilateral constraints
                Entity distanceConstraint = EntityManager.CreateEntity(typeof(DistanceConstraint));
                EntityManager.SetComponentData(distanceConstraint, new DistanceConstraint
                {
                    idA        = tetMesh.edges[i].idA,
                    idB        = tetMesh.edges[i].idB,
                    restLength = tetMesh.edges[i].restLength
                });

                constraintsCounter[tetMesh.edges[i].idA]++;
                constraintsCounter[tetMesh.edges[i].idB]++;
            }

            int maxCount = 0;

            for (int i = 0; i < tetMesh.pointsCount; i++)
            {
                maxCount = math.max(maxCount, constraintsCounter[i]);
                constraintsCounter[i] = 0;
            }

            NativeArray <Entity> particles = new NativeArray <Entity>(tetMesh.pointsCount, Allocator.Temp);

            EntityManager.CreateEntity(ParticleArchetype, particles);
            for (int i = 0; i < tetMesh.pointsCount; i++)
            {
                EntityManager.SetComponentData(particles[i], new Position {
                    Value = tetMesh.nodesPositions[i]
                });
                EntityManager.SetComponentData(particles[i], new MassInv {
                    Value = 1
                });
                EntityManager.AddComponent(particles[i], ComponentType.FixedArray(typeof(DistanceConstraintUni), maxCount));
                EntityManager.AddSharedComponentData(particles[i], ParticleLook);

                //fill the arrays with -1s (end of entry marker)
                NativeArray <DistanceConstraintUni> cnstrsArr = EntityManager.GetFixedArray <DistanceConstraintUni>(particles[i]);
                for (int c = 0; c < maxCount; c++)
                {
                    cnstrsArr[c] = new DistanceConstraintUni {
                        otherId = -1, restLength = 0
                    }
                }
                ;
            }


            //unilateral constraints
            for (int i = 0; i < tetMesh.edgesCount; i++)
            {
                int   idA        = tetMesh.edges[i].idA;
                int   idB        = tetMesh.edges[i].idB;
                float restLength = tetMesh.edges[i].restLength;

                NativeArray <DistanceConstraintUni> cnstrsArrA = EntityManager.GetFixedArray <DistanceConstraintUni>(particles[idA]);
                NativeArray <DistanceConstraintUni> cnstrsArrB = EntityManager.GetFixedArray <DistanceConstraintUni>(particles[idB]);

                cnstrsArrA[constraintsCounter[idA]] = new DistanceConstraintUni {
                    otherId = idB, restLength = restLength
                };
                cnstrsArrB[constraintsCounter[idB]] = new DistanceConstraintUni {
                    otherId = idA, restLength = restLength
                };

                constraintsCounter[idA]++;
                constraintsCounter[idB]++;
            }

            particles.Dispose();
        }
示例#19
0
    protected override void OnUpdate()
    {
        var pathType = ComponentType.FixedArray(typeof(PathPoint), SimulationState.MaxPathSize);
        var fortressSpawnFormation = new NativeList <Entity>(fortresses.Length, Allocator.Temp);
        var fortressSpawnUnit      = new NativeList <Entity>(fortresses.Length, Allocator.Temp);

        //收集需要生成的军队
        for (int i = 0; i < fortresses.Length; ++i)
        {
            var marchData = fortresses.dispatchs[i];
            var request   = fortresses.pathRequests[i];

            if (marchData.troops > 0 && request.status == PathRequestStatus.Done)
            {
                if (marchData.doneDispatch == 1)
                {
                    fortressSpawnFormation.Add(fortresses.entities[i]);
                }
                else
                {
                    fortressSpawnUnit.Add(fortresses.entities[i]);
                }
            }
        }

        for (int i = 0; i < fortressSpawnFormation.Length; ++i)
        {
            var fortress  = fortressSpawnFormation[i];
            var formation = EntityManager.CreateEntity();

            var dispatch       = EntityManager.GetComponentData <DispatchData>(fortress);
            var targetDispatch = EntityManager.GetComponentData <DispatchData>(dispatch.target);

            var path    = EntityManager.GetFixedArray <PathPoint>(fortress);
            var type    = EntityManager.GetComponentData <FormationTypeData>(fortress);
            var owner   = EntityManager.GetComponentData <OwnerData>(fortress);
            var request = EntityManager.GetComponentData <PathRequestData>(fortress);


            var position = new Position {
                Value = path[0].location.position
            };
            var dir     = new float3(dispatch.offset.x, 0, dispatch.offset.z);
            var heading = new Heading {
                Value = math_experimental.normalizeSafe(dir)
            };


            var midPos = request.end;
            var side   = math_experimental.normalizeSafe(new float3(-targetDispatch.offset.z, 0, targetDispatch.offset.x));
            var align  = -side * (type.unitType.formationWidth * 0.5f) * (type.unitType.radius * 2 + 0.05f);

            var formationData = new FormationData
            {
                troops     = 0,
                sideOffset = 0,
                goal       = dispatch.target,
                goalLineL  = midPos - align,
                goalLineR  = midPos + align,
                state      = FormationState.Spawning
            };

            var agent = new FormationAgentData
            {
                location    = path[0].location,
                pathId      = 1,
                steerTarget = path[1],
                fromPoint   = path[0],
                state       = AgentState.Moving,
            };

            EntityManager.AddComponentData(formation, position);
            EntityManager.AddComponentData(formation, formationData);
            EntityManager.AddComponentData(formation, agent);
            EntityManager.AddComponentData(formation, owner);
            EntityManager.AddComponentData(formation, heading);
            EntityManager.AddComponent(formation, pathType);
            EntityManager.AddComponentData(formation, type);

            var pathData = EntityManager.GetFixedArray <PathPoint>(formation);
            path = EntityManager.GetFixedArray <PathPoint>(fortress);
            pathData.CopyFrom(path);


            dispatch.remain       = 0;
            dispatch.doneDispatch = 0;
            dispatch.dispatching  = formation;
            EntityManager.SetComponentData(fortress, dispatch);
        }

        fortressSpawnFormation.Dispose();

        for (int i = 0; i < fortressSpawnUnit.Length; ++i)
        {
            var fortress = fortressSpawnUnit[i];
            var dispatch = EntityManager.GetComponentData <DispatchData>(fortress);
            dispatch.remain -= Time.deltaTime;
            if (dispatch.remain <= 0f)
            {
                var formation        = dispatch.dispatching;
                var fortressData     = EntityManager.GetComponentData <FortressData>(fortress);
                var formationData    = EntityManager.GetComponentData <FormationData>(formation);
                var fortressPosition = EntityManager.GetComponentData <Position>(fortress);
                var type             = EntityManager.GetComponentData <FormationTypeData>(fortress);
                var troops           = Mathf.Min(dispatch.troops, type.unitType.formationWidth, fortressData.troops, type.unitType.maxTroops - formationData.troops);
                fortressData.troops -= troops;
                dispatch.troops     -= troops;
                dispatch.troops      = Mathf.Min(fortressData.troops, dispatch.troops);
                dispatch.remain      = dispatch.frequency;
                if (formationData.troops == type.unitType.maxTroops || dispatch.troops == 0) //done
                {
                    dispatch.doneDispatch = 1;
                    formationData.state  &= ~FormationState.Spawning;
                }
                var units  = new NativeArray <Entity>(troops, Allocator.Temp);
                var side   = math_experimental.normalizeSafe(new float3(-dispatch.offset.z, 0, dispatch.offset.x));
                var midPos = fortressPosition.Value + dispatch.offset;
                var dir    = new float3(dispatch.offset.x, 0, dispatch.offset.z);
                var prefab = FortressSettings.Instance.unitPrefab;
                EntityManager.Instantiate(prefab, units);
                //@TODO: Spawn Unit
                for (var j = 0; j < troops; ++j)
                {
                    var unit     = units[j];
                    var alignPos = side * (j - (type.unitType.formationWidth * 0.5f)) * (type.unitType.radius * 2 + 0.05f) + midPos;
                    var location = query.MapLocation(alignPos, Vector3.one * 10f, agentType);

                    var agent = new UnitAgentData
                    {
                        location = location,
                        velocity = new float2()
                    };
                    var position = new Position {
                        Value = location.position
                    };
                    var heading = new Heading {
                        Value = math_experimental.normalizeSafe(dir)
                    };
                    var inFormation = new InFormationData
                    {
                        formationEntity = formation,
                        index           = formationData.troops
                    };
                    EntityManager.AddComponentData(unit, type.unitType);
                    EntityManager.AddComponentData(unit, agent);
                    EntityManager.AddComponentData(unit, inFormation);
                    EntityManager.SetComponentData(unit, position);
                    EntityManager.SetComponentData(unit, heading);
                    formationData.troops++;
                }
                units.Dispose();
                EntityManager.SetComponentData(formation, formationData);
                EntityManager.SetComponentData(fortress, fortressData);
            }
            EntityManager.SetComponentData(fortress, dispatch);
        }

        fortressSpawnUnit.Dispose();
    }
    public unsafe Entity Spawn(FormationData formationData, float3 spawnPointOffset, FormationWaypoint[] waypoints, bool spawnedFromPortals = false, float3?forward = null)
    {
        var formationEntity = entityManager.CreateEntity();

        RaycastHit hit;

        if (Physics.Raycast(new Ray((Vector3)formationData.Position + new Vector3(0, 1000000, 0), Vector3.down), out hit))
        {
            formationData.Position.y = hit.point.y;
        }
        if (!spawnedFromPortals)
        {
            formationData.SpawnedCount = formationData.UnitCount;
        }
        var location = mapLocationQuery.MapLocation(formationData.Position, new Vector3(100, 100, 100), 0);

        formationData.Position = location.position;

        if (forward == null)
        {
            formationData.Forward = new float3(0, 0, formationData.Position.z > 0 ? -1 : 1);
        }
        else
        {
            formationData.Forward = forward.Value;
        }

        formationData.HighLevelPathIndex = 1;

        FormationWaypoint bridgeStart = GetClosestWaypoint(waypoints, formationData.Position, !formationData.IsFriendly);
        FormationWaypoint bridgeEnd   = Array.Find(waypoints, x => x.index == bridgeStart.index && x.isLeft != bridgeStart.isLeft);

        FormationHighLevelPath highLevelPath = new FormationHighLevelPath
        {
            target1             = bridgeStart.transform.position,
            target2             = bridgeEnd.transform.position,
            ultimateDestination = new float3(formationData.Position.x, formationData.Position.y, -Mathf.Sign(formationData.Position.z) * 200)
        };

        entityManager.AddComponentData(formationEntity, formationData);
        entityManager.AddComponentData(formationEntity, new FormationClosestData()
        {
        });
        entityManager.AddComponentData(formationEntity, new FormationNavigationData {
            TargetPosition = formationData.Position
        });

        entityManager.AddComponentData(formationEntity, new CrowdAgent {
            worldPosition = formationData.Position, type = 0, location = location
        });
        entityManager.AddComponentData(formationEntity, highLevelPath);
        entityManager.AddComponent(formationEntity, ComponentType.FixedArray(typeof(EntityRef), formationData.UnitCount));
        entityManager.AddComponent(formationEntity, ComponentType.FixedArray(typeof(PolygonId), 128));
        entityManager.AddComponentData(formationEntity, new FormationIntegrityData()
        {
        });

        var crowd = new CrowdAgentNavigator()
        {
            active = true,
            newDestinationRequested = false,
            goToDestination         = false,
            destinationInView       = false,
            destinationReached      = true,
        };

        entityManager.AddComponentData(formationEntity, crowd);

        var unitType = (UnitType)formationData.UnitType;

        GameObject minionPrefab;

        minionPrefab = GetMinionPrefab(unitType);

        var prototypeMinion = entityManager.Instantiate(minionPrefab);

        entityManager.AddComponentData(prototypeMinion, new MinionBitmask(formationData.IsFriendly, spawnedFromPortals));
        entityManager.AddComponentData(prototypeMinion, new MinionAttackData(new Entity()));
        entityManager.AddComponentData(prototypeMinion, new MinionPathData());
        entityManager.AddComponent(prototypeMinion, ComponentType.FixedArray(typeof(float3), SimulationState.MaxPathSize));
        entityManager.AddComponentData(prototypeMinion, new IndexInFormationData(-1));
        entityManager.AddComponentData(prototypeMinion, new NavMeshLocationComponent());


        var minions = new NativeArray <Entity>(formationData.UnitCount, Allocator.Temp);

        entityManager.Instantiate(prototypeMinion, minions);

        for (int i = 0; i < minions.Length; ++i)
        {
            var entity           = minions[i];
            var transform        = entityManager.GetComponentData <UnitTransformData>(entity);
            var animator         = entityManager.GetComponentData <TextureAnimatorData>(entity);
            var minion           = entityManager.GetComponentData <MinionData>(entity);
            var indexInFormation = entityManager.GetComponentData <IndexInFormationData>(entity);

            transform.FormationEntity         = formationEntity;
            indexInFormation.IndexInFormation = i;
            transform.UnitType = (int)unitType;
            transform.Forward  = formationData.Forward;

            float scale = entityManager.GetSharedComponentData <RenderingData>(entity).LodData.Scale;
            transform.Scale = UnityEngine.Random.Range(SimulationSettings.Instance.MinionScaleMin, SimulationSettings.Instance.MinionScaleMax) * scale;
            if (unitType != UnitType.Skeleton)
            {
                transform.HeightOffset = UnityEngine.Random.Range(SimulationSettings.Instance.MinionHeightOffsetMin,
                                                                  SimulationSettings.Instance.MinionHeightOffsetMax);
            }

            if (!spawnedFromPortals)
            {
                transform.Position = formationData.GetOffsetFromCenter(i) + formationData.Position;
            }
            else
            {
                float3 unitOffset = new float3((i % SimulationSettings.countPerSpawner), 0f, 0);
                transform.Position = formationData.Position + unitOffset + spawnPointOffset;
            }

            entityManager.SetComponentData(entity, new NavMeshLocationComponent(mapLocationQuery.MapLocation(transform.Position, Vector3.one * 10, 0)));

            animator.UnitType = (int)unitType;
            animator.AnimationSpeedVariation = UnityEngine.Random.Range(SimulationSettings.Instance.MinionAnimationSpeedMin,
                                                                        SimulationSettings.Instance.MinionAnimationSpeedMax);

            minion.attackCycle = -1;

            MinionPathData pathComponent = new MinionPathData()
            {
                bitmasks           = 0,
                pathSize           = 0,
                currentCornerIndex = 0
            };

            entityManager.SetComponentData(entity, pathComponent);

            entityManager.SetComponentData(entity, transform);
            entityManager.SetComponentData(entity, animator);
            entityManager.SetComponentData(entity, minion);
            entityManager.SetComponentData(entity, indexInFormation);
        }

        minions.Dispose();
        entityManager.DestroyEntity(prototypeMinion);

        return(formationEntity);
    }
示例#21
0
        public void CreateEntityWithInvalidFixedArraySize(int length)
        {
            var arrayType = ComponentType.FixedArray(typeof(int), length);

            Assert.Throws <ArgumentException>(() => m_Manager.CreateEntity(arrayType));
        }
示例#22
0
 public void CreatingFixedArrayOfIComponentDataThrows()
 {
     Assert.Throws <ArgumentException>(() => { m_Manager.CreateEntity(ComponentType.FixedArray(typeof(EcsTestData), 2)); });
 }