예제 #1
0
                public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
                {
                    NativeArray <BoxColliderComponentData> boxColliders = chunk.GetNativeArray(BoxColliderType);
                    NativeArray <Rotation> rotations = chunk.GetNativeArray(RotationType);
                    NativeArray <Position> positions = chunk.GetNativeArray(PositionType);
                    NativeArray <Scale>    scales    = chunk.GetNativeArray(ScaleType);

                    NativeArray <Entity> entities = chunk.GetNativeArray(EntityType);

                    float3 zero = float3.zero;

                    for (int i = 0, length = boxColliders.Length; i < length; ++i)
                    {
                        BoxColliderComponentData box = boxColliders[i];
                        Position position            = positions[i];
                        Rotation rotation            = rotations[i];
                        Scale    scale = scales[i];

                        BoxcastCommand boxCast = new BoxcastCommand(position.Value + box.Center,
                                                                    box.Size * scale.Value * 0.5f,
                                                                    quaternion.identity,
                                                                    float3.zero, 0,
                                                                    0);
                        BoxCasts.TryAdd(entities[i], boxCast);
                    }
                }
 void UpdateBoxColliders(NativeArray <Entity> entities,
                         [ReadOnly] ArchetypeChunkComponentObjects <BoxCollider> boxColliders)
 {
     for (int i = 0, length = boxColliders.Length; i < length; ++i)
     {
         BoxCollider box = boxColliders[i];
         if (box != null)
         {
             BoxColliderComponentData boxInfo = new BoxColliderComponentData();
             boxInfo.Center    = box.center;
             boxInfo.Size      = box.size;
             boxInfo.IsTrigger = box.isTrigger ? (byte)1 : (byte)0;
             Utils.Utils.AddOrSetComponent(entities[i], boxInfo, GetComponentDataFromEntity <BoxColliderComponentData>(true), EntityManager);
         }
     }
 }