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>
210 lines
No EOL
6.5 KiB
C#
210 lines
No EOL
6.5 KiB
C#
using System;
|
|
using System.Linq;
|
|
using MessagePack;
|
|
using Newtonsoft.Json;
|
|
using TMPro;
|
|
using UniRx.Triggers;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class ActionBarSlot : MonoBehaviour
|
|
{
|
|
public TextMeshProUGUI Label;
|
|
public RawImage Icon;
|
|
public TextMeshProUGUI InputLabel;
|
|
public Image InputIcon;
|
|
public TextMeshProUGUI QuantityRemaining;
|
|
public Image Fill;
|
|
public ObservablePointerEnterTrigger PointerEnterTrigger;
|
|
public ObservablePointerExitTrigger PointerExitTrigger;
|
|
private ActionBarBinding binding;
|
|
|
|
public ActionBarBinding Binding
|
|
{
|
|
get => binding;
|
|
set
|
|
{
|
|
binding = value;
|
|
if (binding == null)
|
|
{
|
|
Fill.fillAmount = 0;
|
|
Label.gameObject.SetActive(false);
|
|
QuantityRemaining.gameObject.SetActive(false);
|
|
Icon.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
Binding?.Update();
|
|
}
|
|
|
|
public SavedActionBarBinding Save()
|
|
{
|
|
return Binding switch
|
|
{
|
|
ActionBarConsumableBinding actionBarConsumableBinding => new SavedActionBarConsumableBinding
|
|
{
|
|
Target = actionBarConsumableBinding.Entity.ItemManager.ItemData.RefOf(actionBarConsumableBinding.Target)
|
|
},
|
|
ActionBarGearBinding actionBarGearBinding => new SavedActionBarGearBinding
|
|
{
|
|
EquipmentIndex = actionBarGearBinding.Entity.Equipment.IndexOf(actionBarGearBinding.Item),
|
|
BehaviorIndex = Array.IndexOf(actionBarGearBinding.Item.Behaviors, actionBarGearBinding.Behavior)
|
|
},
|
|
ActionBarWeaponGroupBinding actionBarWeaponGroupBinding => new SavedActionBarWeaponGroupBinding
|
|
{
|
|
Group = actionBarWeaponGroupBinding.Group
|
|
},
|
|
_ => null
|
|
};
|
|
}
|
|
|
|
public void Restore(SavedActionBarBinding binding, Entity entity)
|
|
{
|
|
Binding = binding switch
|
|
{
|
|
SavedActionBarConsumableBinding savedActionBarConsumableBinding =>
|
|
new ActionBarConsumableBinding(
|
|
entity,
|
|
this,
|
|
entity.ItemManager.ItemData.Get(savedActionBarConsumableBinding.Target)),
|
|
SavedActionBarGearBinding savedActionBarGearBinding =>
|
|
new ActionBarGearBinding(
|
|
entity,
|
|
this,
|
|
entity.Equipment[savedActionBarGearBinding.EquipmentIndex],
|
|
entity.Equipment[savedActionBarGearBinding.EquipmentIndex]
|
|
.Behaviors[savedActionBarGearBinding.BehaviorIndex] as IActivatedBehavior),
|
|
SavedActionBarWeaponGroupBinding savedActionBarWeaponGroupBinding =>
|
|
new ActionBarWeaponGroupBinding(entity, this, savedActionBarWeaponGroupBinding.Group),
|
|
_ => null
|
|
};
|
|
}
|
|
}
|
|
|
|
public abstract class ActionBarBinding
|
|
{
|
|
public Entity Entity { get; }
|
|
protected ActionBarSlot Slot { get; }
|
|
public abstract void Activate();
|
|
public abstract void Deactivate();
|
|
public abstract void Update();
|
|
public ActionBarBinding(Entity entity, ActionBarSlot slot)
|
|
{
|
|
Entity = entity;
|
|
Slot = slot;
|
|
}
|
|
}
|
|
|
|
public class ActionBarConsumableBinding : ActionBarBinding
|
|
{
|
|
public ConsumableItemData Target;
|
|
|
|
public ActionBarConsumableBinding(Entity entity, ActionBarSlot slot, ConsumableItemData target) : base(entity, slot)
|
|
{
|
|
Target = target;
|
|
Slot.QuantityRemaining.gameObject.SetActive(true);
|
|
var data = Target;
|
|
if(!string.IsNullOrEmpty(data.Icon))
|
|
{
|
|
Slot.Label.gameObject.SetActive(false);
|
|
Slot.Icon.gameObject.SetActive(true);
|
|
Slot.Icon.texture = Resources.Load<Texture2D>(data.Icon.Substring("Assets/Resources/".Length).Split('.').First());
|
|
}
|
|
else Slot.Icon.gameObject.SetActive(false);
|
|
}
|
|
|
|
public override void Activate()
|
|
{
|
|
Entity.TryActivateConsumable(Target);
|
|
}
|
|
|
|
public override void Deactivate()
|
|
{
|
|
}
|
|
|
|
public override void Update()
|
|
{
|
|
Slot.QuantityRemaining.text = $"{Entity.CountItemsInCargo(Entity.ItemManager.ItemData.RefOf<ItemData>(Target).Key)}";
|
|
var instance = Entity.FindActiveConsumable(Target);
|
|
if (instance == null) Slot.Fill.fillAmount = 0;
|
|
else Slot.Fill.fillAmount = instance.RemainingDuration / instance.Data.Duration;
|
|
}
|
|
}
|
|
|
|
public class ActionBarGearBinding : ActionBarBinding
|
|
{
|
|
public EquippedItem Item { get; }
|
|
public IActivatedBehavior Behavior { get; }
|
|
|
|
public bool Active;
|
|
|
|
public ActionBarGearBinding(Entity entity, ActionBarSlot slot, EquippedItem item, IActivatedBehavior behavior) : base(entity, slot)
|
|
{
|
|
Item = item;
|
|
var data = Entity.ItemManager.GetData(item.EquippableItem);
|
|
Behavior = behavior;
|
|
Slot.QuantityRemaining.gameObject.SetActive(false);
|
|
Slot.Icon.gameObject.SetActive(true);
|
|
Slot.Label.gameObject.SetActive(false);
|
|
if (!string.IsNullOrEmpty(Item.Data.ActionBarIcon))
|
|
Slot.Icon.texture = Resources.Load<Texture2D>(Item.Data.ActionBarIcon.Substring("Assets/Resources/".Length).Split('.').First());
|
|
else if (data is WeaponItemData weaponItemData)
|
|
Slot.Icon.texture = ActionGameManager.Instance.Settings.GetIcon(weaponItemData.WeaponType).texture;
|
|
else Slot.Icon.texture = ActionGameManager.Instance.Settings.GetIcon(data.HardpointType).texture;
|
|
}
|
|
|
|
public override void Activate()
|
|
{
|
|
Active = true;
|
|
Behavior.Activate();
|
|
}
|
|
|
|
public override void Deactivate()
|
|
{
|
|
Active = false;
|
|
Behavior.Deactivate();
|
|
}
|
|
|
|
public override void Update()
|
|
{
|
|
Slot.Fill.fillAmount = Active ? 1 : 0;
|
|
}
|
|
}
|
|
|
|
[MessagePackObject]
|
|
public class ActionBarWeaponGroupBinding : ActionBarBinding
|
|
{
|
|
[Key(0)] public int Group;
|
|
|
|
public ActionBarWeaponGroupBinding(Entity entity, ActionBarSlot slot, int group) : base(entity, slot)
|
|
{
|
|
Group = group;
|
|
slot.Label.gameObject.SetActive(true);
|
|
slot.Label.text = $"G{Group+1}";
|
|
Slot.Icon.gameObject.SetActive(false);
|
|
}
|
|
|
|
public override void Activate()
|
|
{
|
|
foreach (var weapon in Entity.WeaponGroups[Group].weapons)
|
|
{
|
|
weapon.Activate();
|
|
}
|
|
}
|
|
|
|
public override void Deactivate()
|
|
{
|
|
foreach (var weapon in Entity.WeaponGroups[Group].weapons)
|
|
{
|
|
weapon.Deactivate();
|
|
}
|
|
}
|
|
|
|
public override void Update()
|
|
{
|
|
|
|
}
|
|
} |