Open Eu4ng opened 1 year ago
UEquipmentComponent::SelectEquipment()에서 상태 패턴 적용을 위해 UEquipmentState를 사용한다.
State 관리를 위해 UEquipmentComponent의 초기화 단계에서 MainState, SubState 객체를 생성하여 사용하는데 상태가 변경될 때마다 State 객체를 생성하는 것이 아니라 미리 생성해둔 각 상태 별 단 한 개의 객체 만을 사용한다.
그러므로 MainState와 SubState가 가리키는 상태 객체가 변해서는 안 되므로 const 키워드를 활용하고 싶은데, EquipmentComponent에서 EquipmentState의 non-const 함수를 호출하므로 const UMainState* MainState는 사용할 수 없다.
그렇다고 UMainState* const MainState는 선언 단계가 아닌, 초기화 단계에서 NewObject 할당하므로 사용할 수 없다.
포인터 사용 시
변수
함수
참고 링크