기타/디자인패턴
[디자인 패턴] Command
Krapboss
2024. 5. 21. 18:37
[!!출처!!]https://unity.com/kr/resources/level-up-your-code-with-game-programming-patterns
Level up your programming with game programming patterns
Our new e-book explains well-known design patterns and shares practical examples for using them in your Unity project.
unity.com
하나 이상의 명령 개체를 캡슐화하여 저장
일련의 작업을 지연하거나 실행, 취소가 가능해짐
입력기록을 유지하는 것
ICommand | 캡슐화된 동작을 실제 구현하기 위해 사용 |
MoveCommand | ICommand를 상속받아 실제 움직임을 위한 동작을 구현 |
PlayerMover | 플레이어의 이동 경로를 표시 |
InputManager | CommandInvoker에 MoveCommand를 생성해서 보냄으로서, ICommand를 저장시킴 |
CommandInvoker | ICommnad 객체를 저장 후 요청에 따라 지정된 동작을 수행함. 새로운 입력이 들어오면 Redo 스택을 클리어 하고 새로운 UndoStack만 저장 |