stuff
This commit is contained in:
@@ -60,6 +60,24 @@ namespace RebootReality.jelycho.Items {
|
||||
s_Logger.Error($"Item {actor.name} is not in the inventory.");
|
||||
return false;
|
||||
}
|
||||
|
||||
public ItemActor TryDropOne(int slotIndex) {
|
||||
if (slotIndex < 0 || slotIndex >= m_Items.Length) {
|
||||
s_Logger.Error($"Slot index {slotIndex} is out of range.");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (m_Items[slotIndex].Actors.Count == 0) {
|
||||
s_Logger.Error($"No items in slot {slotIndex} to drop.");
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemActor actor = m_Items[slotIndex].Actors[0];
|
||||
m_Items[slotIndex].Actors.RemoveAt(0);
|
||||
OnItemDropped?.Invoke(actor);
|
||||
OnSlotUpdated?.Invoke(slotIndex);
|
||||
return actor;
|
||||
}
|
||||
|
||||
public int GetQuantity(int slotIndex) {
|
||||
if (slotIndex < 0 || slotIndex >= m_Items.Length) {
|
||||
@@ -78,7 +96,6 @@ namespace RebootReality.jelycho.Items {
|
||||
return m_Items[slotIndex].Actors[0];
|
||||
}
|
||||
|
||||
s_Logger.Error($"No items in slot {slotIndex}.");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,24 @@
|
||||
using System;
|
||||
using Unity.Collections;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootReality.jelycho.Items {
|
||||
public enum ItemType {
|
||||
Neutral = 0,
|
||||
Egg = 1,
|
||||
Sword = 2,
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public struct ItemConfig {
|
||||
public FixedString32Bytes itemID;
|
||||
public class ItemConfig {
|
||||
public ItemType itemType = ItemType.Neutral;
|
||||
public Sprite icon;
|
||||
|
||||
[MaxLength(32)] public string characterEquippedMountSlotName = "hand_right";
|
||||
|
||||
[Header("Chargeable")]
|
||||
public bool isChargeable = false;
|
||||
public float chargeDuration = 0.5f;
|
||||
public float chargeCooldown = 1.0f;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user