2026-08-10 14:57:50 +01:00
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
2020-12-22 03:13:43 +00:00
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
2026-08-10 14:57:50 +01:00
|
|
|
|
using System.Collections;
|
2020-12-14 02:56:35 +00:00
|
|
|
|
using System.Collections.Generic;
|
2020-12-20 03:04:52 +00:00
|
|
|
|
using System.Linq;
|
2020-12-14 02:56:35 +00:00
|
|
|
|
using UnityEngine;
|
2020-12-20 03:04:52 +00:00
|
|
|
|
using UniRx;
|
|
|
|
|
|
using UniRx.Triggers;
|
2026-09-14 17:39:12 +02:00
|
|
|
|
using CultMath;
|
2026-08-10 14:57:50 +01:00
|
|
|
|
using UnityEngine.InputSystem;
|
|
|
|
|
|
using UnityEngine.UI;
|
2020-12-14 02:56:35 +00:00
|
|
|
|
|
|
|
|
|
|
public class InventoryMenu : MonoBehaviour
|
|
|
|
|
|
{
|
2020-12-20 03:04:52 +00:00
|
|
|
|
public InventoryPanel[] InventoryPanels;
|
2026-08-10 14:57:50 +01:00
|
|
|
|
public PropertiesPanel PropertiesPanel;
|
|
|
|
|
|
public ActionGameManager GameManager;
|
|
|
|
|
|
public RectTransform DragParent;
|
2021-01-06 14:56:39 +00:00
|
|
|
|
public ConfirmationDialog Dialog;
|
2021-05-12 00:15:11 +01:00
|
|
|
|
// public ClickCatcher Background;
|
2020-12-20 03:04:52 +00:00
|
|
|
|
|
2026-08-10 14:57:50 +01:00
|
|
|
|
private int _currentPanel = -1;
|
|
|
|
|
|
|
|
|
|
|
|
private int2 _selectedPosition;
|
|
|
|
|
|
private InventoryPanel _selectedPanel;
|
|
|
|
|
|
private ItemInstance _selectedItem;
|
|
|
|
|
|
private ItemData _selectedItemData;
|
2021-01-17 02:45:52 +00:00
|
|
|
|
private void OnEnable()
|
|
|
|
|
|
{
|
2021-05-12 00:15:11 +01:00
|
|
|
|
// Background.gameObject.SetActive(true);
|
2021-01-17 02:45:52 +00:00
|
|
|
|
|
2021-05-12 00:15:11 +01:00
|
|
|
|
// Background.OnEnter.Subscribe(enter =>
|
|
|
|
|
|
// {
|
|
|
|
|
|
// _destroyItem = true;
|
|
|
|
|
|
// });
|
|
|
|
|
|
// BackgroundExited.OnPointerExitAsObservable().Subscribe(enter =>
|
|
|
|
|
|
// {
|
|
|
|
|
|
// _destroyItem = false;
|
|
|
|
|
|
// });
|
2026-08-10 14:57:50 +01:00
|
|
|
|
var cargo = GameManager.DockingBay ?? GameManager.CurrentEntity.CargoBays.FirstOrDefault();
|
2021-01-17 02:45:52 +00:00
|
|
|
|
if (cargo!=null)
|
|
|
|
|
|
InventoryPanels[0].Display(cargo);
|
2021-04-10 01:47:16 +01:00
|
|
|
|
else InventoryPanels[0].Clear();
|
2026-08-10 14:57:50 +01:00
|
|
|
|
if(GameManager.CurrentEntity != null)
|
|
|
|
|
|
InventoryPanels[1].Display(GameManager.CurrentEntity);
|
2021-02-01 08:13:14 +00:00
|
|
|
|
else InventoryPanels[1].Clear();
|
2021-01-17 02:45:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnDisable()
|
|
|
|
|
|
{
|
2021-05-12 00:15:11 +01:00
|
|
|
|
// Background.gameObject.SetActive(false);
|
2021-01-17 02:45:52 +00:00
|
|
|
|
}
|
2020-12-20 03:04:52 +00:00
|
|
|
|
|
2020-12-14 02:56:35 +00:00
|
|
|
|
void Start()
|
|
|
|
|
|
{
|
2026-08-10 14:57:50 +01:00
|
|
|
|
PropertiesPanel.GameManager = GameManager;
|
2020-12-20 03:04:52 +00:00
|
|
|
|
foreach (var panel in InventoryPanels)
|
|
|
|
|
|
{
|
2026-08-10 14:57:50 +01:00
|
|
|
|
panel.OnClickAsObservable().Subscribe(e =>
|
2021-03-07 01:10:31 +00:00
|
|
|
|
{
|
2026-08-10 14:57:50 +01:00
|
|
|
|
if (e.data is InventoryCargoEventData cargoEvent)
|
2026-06-17 01:50:15 +01:00
|
|
|
|
{
|
2026-08-10 14:57:50 +01:00
|
|
|
|
var item = cargoEvent.CargoBay.Occupancy[cargoEvent.Position.x, cargoEvent.Position.y];
|
|
|
|
|
|
if(item!=null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.clickCount == 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
var otherPanel = panel == InventoryPanels[0] ? InventoryPanels[1] : InventoryPanels[0];
|
|
|
|
|
|
if (otherPanel.CanDropItem(item))
|
|
|
|
|
|
{
|
|
|
|
|
|
otherPanel.DropItem(item);
|
|
|
|
|
|
// TODO: SFX: Equip
|
|
|
|
|
|
cargoEvent.CargoBay.Remove(item);
|
|
|
|
|
|
panel.RefreshCells();
|
|
|
|
|
|
otherPanel.RefreshCells();
|
|
|
|
|
|
}
|
|
|
|
|
|
// else
|
|
|
|
|
|
// TODO: SFX: Fail
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_selectedPanel != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_selectedPanel.CellInstances.ContainsKey(_selectedPosition))
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var v in _selectedItemData.Shape.Coordinates)
|
|
|
|
|
|
{
|
|
|
|
|
|
var v2 = _selectedItemData.Shape.Rotate(v, _selectedItem.Rotation) + _selectedPosition;
|
|
|
|
|
|
_selectedPanel.CellInstances[v2].Icon.color = _selectedPanel.GetColor(v2);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
_selectedPanel = panel;
|
|
|
|
|
|
_selectedPosition = cargoEvent.Position;
|
|
|
|
|
|
PropertiesPanel.Inspect(item);
|
|
|
|
|
|
_selectedPanel = panel;
|
|
|
|
|
|
_selectedPosition = cargoEvent.CargoBay.Cargo[item];
|
|
|
|
|
|
_selectedItem = item;
|
Replace the Database Tools with the Studio and cut Unity over
Cut 8b. The Unity project compiles with 0 errors in 6000.3.24f1 batchmode.
Packages: manifest.json pins org.gamecult.cultlib at cultlib-unity-v1.0.57
and org.gamecult.caching.unity at caching-unity-v1.2.0, next to the 8a
CultMath tag. Aetheria.Shared.Unity references GameCult.CultLib and keeps
noEngineReferences.
The Database Tools (Assets/Scripts/CultCache/Editor) are deleted in this
commit, alongside their five ported drawers in
Assets/Scripts/Editor/CultCacheDrawers.cs, each an
[CultInspectorDrawer] ICultInspectorDrawer:
- InspectableType: popup of the attribute type's [Union] member names,
writing the string.
- InspectableColor: float3 and float4 through ColorField.
- InspectableAnimationCurve: float4[] and BezierCurve through CurveField.
- InspectableTemperature: Kelvin, Celsius and Fahrenheit fields over one
value.
- InspectableSchematicShape: size and cell toggles. The old drawer also
drew the item's schematic texture and tinted hull hardpoints, which need
the parent document. The tagged Studio hands a drawer only the value, so
those wait on the Studio exposing the open record.
Unity call sites:
- ActionGameManager opens the catalog through AetheriaStores; Cut 10 adds
the run and player stores.
- Refs resolve through ItemManager.GetData or Get(ref); orbit, planet and
belt maps key by CultRecordKey; identity is compared by reference or key.
- The PlayerSettings.msgpack reader and writer, which Cut 10 deletes, pass
CultDocumentMessagePackSerialization.OptionsFor, since the embedded run
reaches CultMath values and refs. Keyboard layouts need no resolver and
keep MessagePack's defaults until Cut 10.
- The input map uses the nested action to binding shape.
- PropertiesPanel reads CultInspectorRangeAttribute.
- NameTools loses its legacy name-file writer.
- Slime compares serialized settings instead of the deleted SHA1 helper.
- FieldDriver drops InspectorHeader.
- .gitignore covers the test project's build output.
Builds: Aetheria.Shared, AetherDb, Aetheria.Shared.Tests (6/6), Unity
batchmode (0 errors).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 19:15:20 +02:00
|
|
|
|
_selectedItemData = GameManager.ItemManager.GetData(item);
|
2026-08-10 14:57:50 +01:00
|
|
|
|
foreach (var v in _selectedItemData.Shape.Coordinates)
|
|
|
|
|
|
{
|
|
|
|
|
|
var v2 = _selectedItemData.Shape.Rotate(v, _selectedItem.Rotation) + _selectedPosition;
|
|
|
|
|
|
_selectedPanel.CellInstances[v2].Icon.color = _selectedPanel.GetColor(v2, true);
|
|
|
|
|
|
}
|
|
|
|
|
|
// TODO: SFX: Success
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-06-17 01:50:15 +01:00
|
|
|
|
}
|
2026-08-10 14:57:50 +01:00
|
|
|
|
else if (e.data is InventoryEntityEventData entityEvent)
|
2026-06-17 01:50:15 +01:00
|
|
|
|
{
|
2026-08-10 14:57:50 +01:00
|
|
|
|
var item = entityEvent.Entity.GearOccupancy[entityEvent.Position.x, entityEvent.Position.y];
|
|
|
|
|
|
if (item != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.clickCount == 2)
|
|
|
|
|
|
{
|
|
|
|
|
|
var otherPanel = panel == InventoryPanels[0] ? InventoryPanels[1] : InventoryPanels[0];
|
|
|
|
|
|
if (otherPanel.CanDropItem(item.EquippableItem))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!entityEvent.Entity.Active)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (entityEvent.Entity.TryUnequip(item) != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
otherPanel.DropItem(item.EquippableItem);
|
|
|
|
|
|
// TODO: SFX: Unequip
|
|
|
|
|
|
panel.RefreshCells();
|
|
|
|
|
|
otherPanel.RefreshCells();
|
|
|
|
|
|
}
|
|
|
|
|
|
// else
|
|
|
|
|
|
// TODO: SFX: Fail
|
|
|
|
|
|
}
|
|
|
|
|
|
// else
|
|
|
|
|
|
// TODO: SFX: Fail
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_selectedPanel != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_selectedPanel.CellInstances.ContainsKey(_selectedPosition))
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var v in _selectedItemData.Shape.Coordinates)
|
|
|
|
|
|
{
|
|
|
|
|
|
var v2 = _selectedItemData.Shape.Rotate(v, _selectedItem.Rotation) + _selectedPosition;
|
|
|
|
|
|
_selectedPanel.CellInstances[v2].Icon.color = _selectedPanel.GetColor(v2);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PropertiesPanel.Inspect(item);
|
|
|
|
|
|
_selectedPanel = panel;
|
|
|
|
|
|
_selectedPosition = item.Position;
|
|
|
|
|
|
_selectedItem = item.EquippableItem;
|
|
|
|
|
|
_selectedItemData = GameManager.ItemManager.GetData(item.EquippableItem);
|
|
|
|
|
|
foreach (var v in _selectedItemData.Shape.Coordinates)
|
|
|
|
|
|
{
|
|
|
|
|
|
var v2 = _selectedItemData.Shape.Rotate(v, _selectedItem.Rotation) + _selectedPosition;
|
|
|
|
|
|
_selectedPanel.CellInstances[v2].Icon.color = _selectedPanel.GetColor(v2, true);
|
|
|
|
|
|
}
|
|
|
|
|
|
// TODO: SFX: Success
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-06-17 01:50:15 +01:00
|
|
|
|
}
|
2026-08-10 14:57:50 +01:00
|
|
|
|
});
|
2026-06-17 01:50:15 +01:00
|
|
|
|
|
2026-08-10 14:57:50 +01:00
|
|
|
|
panel.OnBackgroundClick.Subscribe(data =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (GameManager.CurrentEntity == null) return; // Only show ship settings if there's a ship, duh!
|
|
|
|
|
|
|
|
|
|
|
|
PropertiesPanel.Clear();
|
|
|
|
|
|
PropertiesPanel.AddField("Shutdown Threshold",
|
|
|
|
|
|
() => GameManager.CurrentEntity.Settings.ShutdownPerformance,
|
|
|
|
|
|
f => GameManager.CurrentEntity.Settings.ShutdownPerformance = f,
|
|
|
|
|
|
0,
|
|
|
|
|
|
1);
|
|
|
|
|
|
});
|
2026-06-28 09:48:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-12-14 02:56:35 +00:00
|
|
|
|
void Update()
|
|
|
|
|
|
{
|
2021-05-12 00:15:11 +01:00
|
|
|
|
// if (Keyboard.current.qKey.wasPressedThisFrame && _dragItem != null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// _dragItem.Rotation = (ItemRotation) (((int) _dragItem.Rotation + 1) % 4);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (Keyboard.current.eKey.wasPressedThisFrame && _dragItem != null)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// _dragItem.Rotation = (ItemRotation) (((int) _dragItem.Rotation + 3) % 4);
|
|
|
|
|
|
// }
|
2020-12-14 02:56:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|