private void CreateCollisionArea(float x, float z, int index)
        {
            ComponentType[] components = GenericInformation.GetGenericComponents();
            components = GenericInformation.AddComponents(components, new ComponentType[]
            {
                typeof(CollisionAreaTag)
            });

            Entity entity = entityManager.CreateEntity(entityManager.CreateArchetype(components));

            entityManager.SetComponentData <CollisionAreaTag>(entity, new CollisionAreaTag
            {
                AgentIndex = index
            });

            entityManager.SetComponentData <Translation>(entity, new Translation
            {
                Value = new float3(x, 0.02f, z)
            });

            entityManager.SetSharedComponentData <RenderMesh>(entity, new RenderMesh
            {
                mesh     = collisionAreaMesh,
                material = collisionAreaMaterial
            });

            entityManager.AddComponentData <Scale>(entity, new Scale
            {
                Value = colliderSize
            });
        }
Beispiel #2
0
        private void SetupLightArchetype()
        {
            ComponentType[] components = GenericInformation.GetGenericComponents();
            components = GenericInformation.AddComponents(components, new ComponentType[]
            {
                typeof(Light)
            });

            agentArchetype = entityManager.CreateArchetype(components);
        }
        private void SetupGridDotArchetype()
        {
            ComponentType[] components = GenericInformation.GetGenericComponents();
            components = GenericInformation.AddComponents(components, new ComponentType[]
            {
                typeof(GridDotTag),
                typeof(Speed),
                typeof(MoveForward),
                typeof(AccumulatedAgents)
            });

            gridDotArchetype = entityManager.CreateArchetype(components);
        }
        private void CreateCommunicationArea(float x, float z, int index)
        {
            ComponentType[] components = GenericInformation.GetGenericComponents();
            components = GenericInformation.AddComponents(components, new ComponentType[]
            {
                typeof(CommunicationAreaTag)
            });

            Entity entity = entityManager.CreateEntity(entityManager.CreateArchetype(components));

            entityManager.SetComponentData <CommunicationAreaTag>(entity, new CommunicationAreaTag
            {
                AgentIndex = index
            });

            entityManager.SetComponentData <Translation>(entity, new Translation
            {
                Value = new float3(x, 0.01f, z)
            });

            entityManager.SetSharedComponentData <RenderMesh>(entity, new RenderMesh
            {
                mesh     = communcationAreaMesh,
                material = communicationAreaMaterial
            });

            /// Communication distance is defined as the distance till you reach another agent.
            /// A few assumptios are made:
            /// 1. All agents have their Communication device on.
            /// 2. Communication reach is circular.
            /// From 1 and 2 we can infere that the trigger system works in a straight line from robot to robot,
            /// this means that to replicate the results in Heiko's work, we need to take into account also the
            /// size of the robots. We will assume that the communication device is located at the center of the
            /// agents, so if the distance is 3.5m between robots, then the communication area is 1.75m effectively.
            entityManager.AddComponentData <Scale>(entity, new Scale
            {
                Value = communicationDistance
            });
        }