UseInstantEffectItemAction.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using KairoEngine.Core;
  5. using KairoEngine.Inventory;
  6. using KairoEngine.Stats;
  7. namespace KairoEngine.CharacterSystem
  8. {
  9. // Todo: Fix status effect controller link
  10. public class UseInstantEffectItemAction : IAction
  11. {
  12. ItemContainer itemContainer; // Reference to the character that will move
  13. ItemRef itemRef;
  14. public UseInstantEffectItemAction(ItemContainer itemContainer, ItemRef itemRef)
  15. {
  16. this.itemContainer = itemContainer;
  17. this.itemRef = itemRef;
  18. }
  19. public void Start()
  20. {
  21. ItemBaseInstantEffect item = (ItemBaseInstantEffect)itemRef.item;
  22. StatusEffectsController statusEffectsController = itemContainer.GetComponent<StatusEffectsController>();
  23. if(statusEffectsController == null)
  24. {
  25. Debug.LogError("Missing StatusEffectsController in " + itemContainer.gameObject.name);
  26. return;
  27. }
  28. // ! Fix: Change status effect controller
  29. //statusEffectsController.Add(item.statusEffect);
  30. Debug.LogError("Missing Status Effect Controller");
  31. itemRef.quantity -= 1;
  32. itemRef.lastUsed = 0f;
  33. if(itemRef.quantity <= 0)
  34. {
  35. itemContainer.RemoveItem(itemRef);
  36. }
  37. else
  38. {
  39. itemContainer.UpdateItem(itemRef);
  40. }
  41. }
  42. public void Update()
  43. {
  44. }
  45. public void End()
  46. {
  47. }
  48. public bool IsDone()
  49. {
  50. return true;
  51. }
  52. }
  53. }