Skip to content
This repository was archived by the owner on Jul 12, 2022. It is now read-only.

IEntityComponent

Syadeu edited this page Oct 22, 2021 · 3 revisions

Namespace: Syadeu.Collections

public interface IEntityComponent

EntityData<T>, Entity<T> 에 추가될 수 있는 컴포넌트를 만듭니다.

Inheritance: System.Object -> IEntityComponent
Derived: asdasd

Overview

  • 1

Remarks

사용자는 추가로 IDisposable 을 상속하여 엔티티가 파괴될 때 실행할 메모리 수집을 선언할 수 있습니다. INotifyComponent<TComponent> 를 참조하세요.

선언된 컴포넌트는 EntityData<T>.AddComponent<TComponent>(TComponent), Entity<T>.AddComponent<TComponent>(TComponent) 로 추가할 수 있고, EntityData<T>.GetComponent<TComponent>(), Entity<T>.GetComponent<TComponent>() 를 통해 가져올 수 있습니다.

Description

Runtime 도중, Entity 에 데이터를 저장하거나 가공하고, 이를 Batching 하여 Processing 속도를 극대화 할 수 있습니다. Entity 에 연결하기 위해 선언된 모든 컴포넌트들은 Initialize stage 에서 전부 수집되어 해당 컴포넌트를 저장하기 위한 시스템 버퍼를 생성합니다 (EntityComponentSystem 을 참조하세요). 이로 인해 Runtime 중 Reflection, 혹은 기타 Runtime-compliation 라이브러리등으로 컴포넌트를 새로 작성하는 것은 허용하지 않습니다.

Batching 하여 Parallel Processing 하는 방법에 대해서는 IJobParallelForEntities<TComponent> 를 참조하세요.

Examples

아래는 간단한 컴포넌트를 선언하고, 이를 Entity<ActorEntity> 에 연결하는 방법에 대해 설명합니다.

// 컴포넌트는 항상 unmanaged type 이어야합니다.
// 맴버내 reference type 을 포함하거나, 선언된 컴포넌트가
// managed type 일 경우에는 에러를 발생합니다.
public struct TestComponent : IEntityComponent
{
    public int testInt;
    public bool testBoolen;
}

// Entity 가 있다고 가정합니다.
Entity<ActorEntity> actor = /* ... */ ;

public void TestAddComponent()
{
    // 컴포넌트를 해당 Entity 에 추가합니다.
    actor.AddComponent<TestComponent>();
    // 추가한 컴포넌트를 가져옵니다.
    ref TestComponent component = ref actor.GetComponent<TestComponent>();
    
    /*
    	Some data works..
    */
}

컴포넌트로 선언될 타겟은 항상 struct 이고, unmanaged type 이어야 합니다. 이는 Native 에서 byte 로 heap 에 데이터를 저장하기 때문인데, 이를 통해 GC allocation 을 피함과 메모리 접근 속도를 개선할 수 있습니다. 선언된 컴포넌트가 managed type 일 경우에는 에러를 발생합니다.


- Interfaces
- Enums
- Attributes
- Abstract Classes
- Classes
- Structs
- Exceptions

- Syadeu.Presentation
- Syadeu.Collections
- Syadeu.Collections.Converters
- Syadeu.Collections.Proxy
- Syadeu.Presentation.Proxy
- Syadeu.Presentation.Internal
- Syadeu.Presentation.Entities
- Syadeu.Presentation.Attributes
- Syadeu.Presentation.Components
- Syadeu.Presentation.Actions
- Syadeu.Presentation.Render
  • CameraData
  • CameraFrustum
  • IntersectionType
  • RenderSystem
  • WorldCanvasSystem
- Syadeu.Presentation.Data
  • DataContainerSystem
  • DataObjectBase
  • EntityAnimationClipEventData
- Syadeu.Presentation.Events

Clone this wiki locally