EquipItemCommand.cs 821 B

12345678910111213141516171819202122232425262728
  1. using KairoEngine.Core;
  2. using KairoEngine.Inventory;
  3. namespace KairoEngine.CharacterSystem
  4. {
  5. public class EquipItemCommand : ICommand
  6. {
  7. ItemRef itemRef;
  8. CharacterController character;
  9. public EquipItemCommand(ItemRef itemRef, CharacterController character)
  10. {
  11. this.itemRef = itemRef;
  12. this.character = character;
  13. }
  14. public void Execute()
  15. {
  16. CharacterEquipItemAction action = new CharacterEquipItemAction(itemRef, character);
  17. ActionController actionController = character.GetComponent<ActionController>();
  18. if(actionController == null) return;
  19. if(actionController.HasAction(action) == false)
  20. {
  21. actionController.AddAction(action);
  22. }
  23. }
  24. }
  25. }