1using System.Globalization;
33 for (
int i = 0; i < inventory.
SlotsCount; i++) {
40 for (
int j = 0; j < inventory.
SlotsCount; j++) {
63 if (componentPlayer ==
null) {
65 if (componentBlockEntity !=
null) {
70 return componentPlayer;
89 int value = valuesDictionary.GetValue<
int>(
"SlotsCount");
90 for (
int i = 0; i < value; i++) {
94 for (
int j = 0; j <
m_slots.Count; j++) {
98 slot.Value = value3.GetValue<
int>(
"Contents");
99 slot.Count = value3.GetValue<
int>(
"Count");
106 valuesDictionary.SetValue(
"Slots", valuesDictionary2);
107 for (
int i = 0; i <
m_slots.Count; i++) {
109 if (slot.
Count > 0) {
111 valuesDictionary2.SetValue($
"Slot{i.ToString(CultureInfo.InvariantCulture)}", valuesDictionary3);
112 valuesDictionary3.SetValue(
"Contents", slot.
Value);
113 valuesDictionary3.SetValue(
"Count", slot.
Count);
120 && slotIndex <
m_slots.Count) {
121 if (
m_slots[slotIndex].Count <= 0) {
124 return m_slots[slotIndex].Value;
131 && slotIndex <
m_slots.Count) {
132 return m_slots[slotIndex].Count;
139 && slotIndex <
m_slots.Count) {
152 for (
int i = 0; i < blockBehaviors.Length; i++) {
154 if (processInventoryItemCapacity > 0) {
155 return processInventoryItemCapacity;
162 public virtual void AddSlotItems(
int slotIndex,
int value,
int count) {
165 && slotIndex <
m_slots.Count) {
171 && slotValue != value) {
172 throw new InvalidOperationException(
173 $
"Cannot add slot items because items are different. Slot {slotIndex} Contains BlockValue {slotValue} with count {slotCount}. The value to add is {value} with count {count}. Slot capacity is {slotCapacity}"
177 throw new InvalidOperationException(
178 $
"Cannot add slot items because it exceeded capacity. Slot {slotIndex} Contains BlockValue {slotValue} with count {slotCount}. The value to add is {value} with count {count}. Slot capacity is {slotCapacity}"
186 public virtual void ProcessSlotItems(
int slotIndex,
int value,
int count,
int processCount, out
int processedValue, out
int processedCount) {
195 if (processInventoryItemCapacity > 0) {
201 MathUtils.
Min(processInventoryItemCapacity, processCount),
209 processedValue = value;
210 processedCount = count;
215 && slotIndex <
m_slots.Count) {
static int Min(int x1, int x2)
virtual int GetMaxStacking(int value)
virtual int GetSlotCount(int slotIndex)
virtual int GetSlotCapacity(int slotIndex, int value)
Project IInventory. Project
virtual void DropAllItems(Vector3 position)
virtual void AddSlotItems(int slotIndex, int value, int count)
static void DropSlotItems(IInventory inventory, int slotIndex, Vector3 position, Vector3 velocity)
virtual int GetSlotValue(int slotIndex)
override void Save(ValuesDictionary valuesDictionary, EntityToIdMap entityToIdMap)
static int FindAcquireSlotForItem(IInventory inventory, int value)
virtual int GetSlotProcessCapacity(int slotIndex, int value)
static int AcquireItems(IInventory inventory, int value, int count)
virtual int VisibleSlotsCount
virtual int RemoveSlotItems(int slotIndex, int count)
实际移除的数量
ComponentPlayer FindInteractingPlayer()
virtual int ActiveSlotIndex
override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
virtual void ProcessSlotItems(int slotIndex, int value, int count, int processCount, out int processedValue, out int processedCount)
virtual void ProcessInventoryItem(IInventory inventory, int slotIndex, int value, int count, int processCount, out int processedValue, out int processedCount)
virtual int GetProcessInventoryItemCapacity(IInventory inventory, int slotIndex, int value)
static int ExtractContents(int value)
ValuesDictionary ValuesDictionary
Entity(Project project, ValuesDictionary valuesDictionary)
virtual Subsystem FindSubsystem(Type type, string name, bool throwOnError)
int RemoveSlotItems(int slotIndex, int count)
实际移除的数量
int GetSlotCount(int slotIndex)
int GetSlotCapacity(int slotIndex, int value)
void AddSlotItems(int slotIndex, int value, int count)
int GetSlotValue(int slotIndex)
static Vector3 Normalize(Vector3 v)