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

AttributeProcessor

aa edited this page Oct 25, 2021 · 7 revisions

Namespace: Syadeu.Presentation.Attributes

[Preserve]
public abstract class AttributeProcessor : ProcessorBase, IAttributeProcessor

AttributeBase 의 동작부를 선언할 수 있습니다.

Inheritance: ProcessorBase -> AttributeProcessor
Derived: asdasd
Implements: IAttributeProcessor

Overview

  • AttributeBase 의 각 행동별 동작에 대해 구현할 수 있습니다.
  • 동작이 없는 AttributeBase 의 메소드 호출을 피하기 위해 구현과 동작이 분리되었습니다. C++ header 와 cpp 와 유사한 구조를 가집니다.

Remarks

abstract 를 상속받는 객체는 추가 동작을 구현할 수 있습니다. IAttributeOnProxy, IAttributeOnProxyCreated, IAttributeOnProxyRemoved 를 참조하세요.

목표 AttributeBase 의 타입을 지정하여 동작을 구현할 수 있습니다. AttributeProcessor<T> 를 참조하세요.

Description

프로세서를 통해 각 AttributeBase 인스턴스들의 데이터를 수정 및 가공할 수 있지만, 데이터를 저장하여 다른 객체가 접근하게 하는 것은 권장되지 않습니다. IEntityComponent 를 통한 데이터 컴포넌트 선언을 하여 해당 컴포넌트에 데이터를 저장하도록 권장합니다. 이는 AttributeBase 또한 부모 EntityDataBase 에 종속되어 같이 재사용되기 때문인데 (ObjectBase.OnReserve 를 참조하세요), 사용자에 의해 선언된 reference type 은 데이터 복사가 이루어지지 않아, 객체 재사용으로 인해 추후 알 수 없는 문제를 야기할 수 있습니다. 사용자는 이를 방지하기 위해 수동으로 해당 맴버를 초기화하거나, 새로운 인스턴스를 생성시 선언된 맴버도 인스턴스된 객체를 사용하도록 추가적인 조치(ObjectBase.Copy 를 참조하세요)를 취해야할 것 입니다 (ObjectBase.OnCreated 를 참조하세요. 객체 초기화는 ObjectBase.OnInitialize 를 참조하세요).

Examples

아래는 간단한 프로세서를 작성하는 방법에 대해 설명합니다.

// Processor 의 타겟이 될 Attribute 를 먼저 작성합니다.
public class TestAttribute : AttributeBase
{
    
}

internal sealed class TestAttributeProcessor : AttributeProcessor
{
    // 타겟을 지정합니다.
    protected override Type TargetAttribute => TypeHelper.TypeOf<TestAttribute>.Type;
    
    protected override void OnInitialize()
    {
        // 이 Processor 가 처음 생성되어 초기화 될 때 실행됩니다.
        // Processor 는 인스턴스가 하나만 생성되어
        // 모든 target Attribute 들이 같이 사용합니다.
    }
    protected override void OnCreated(IAttribute attribute, EntityData<IEntityData> entity)
    {
        // 해당 entity 가 생성되었을때 실행되는 메소드입니다.
        // entity 가 이 Attribute 를 상속받았을 때만 실행됩니다.
    }
    protected override OnDestroy()
    {
        // 해당 entity 가 파괴되었을때 실행되는 메소드입니다.
        // 모든 entity 들은 파괴된 후, Attribute 를 포함하여
        // 전부 재사용하므로 OnDestroy 에서는 사용했던 모든
        // Reference type 을 초기화 할 수 있습니다.
    }
    protected override OnDispose()
    {
        // 이 Processor 가 파괴될 때 실행되는 메소드입니다.
        // 일반적인 flow 에서는 이 메소드는 게임이 완전히 종료될 때
        // 실행됩니다.
    }
}

- 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