Delete dead inventory weapon group shell
This commit is contained in:
parent
1066bce086
commit
fed0759074
14 changed files with 29 additions and 981 deletions
|
|
@ -1,56 +0,0 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class WeaponGroupAssignment : MonoBehaviour
|
||||
{
|
||||
public RectTransform Container;
|
||||
public WeaponGroupElement GroupPrefab;
|
||||
public Color ActiveColor;
|
||||
public Color InactiveColor;
|
||||
|
||||
Subject<(PointerEventData pointerEventData, int group)> _onBeginDrag;
|
||||
Subject<(PointerEventData pointerEventData, int group)> _onDrag;
|
||||
Subject<(PointerEventData pointerEventData, int group)> _onEndDrag;
|
||||
|
||||
public List<WeaponGroupElement> Groups { get; } = new List<WeaponGroupElement>();
|
||||
|
||||
public void Inspect(EquippedItem item)
|
||||
{
|
||||
var weapon = item.GetBehavior<Weapon>();
|
||||
if (weapon == null) throw new ArgumentException($"Attempted to inspect weapon groups on item \"{item.RuntimeItem?.Name ?? "Unknown item"}\" but no weapon is present!");
|
||||
var groupCount = ActionGameManager.Instance.Settings.GameplaySettings.WeaponGroupCount;
|
||||
for (int i = 0; i < groupCount; i++)
|
||||
{
|
||||
var i1 = i;
|
||||
bool groupContainsItem() => item.Entity.WeaponGroups[i1].items.Contains(item);
|
||||
var group = Instantiate(GroupPrefab, Container);
|
||||
Groups.Add(group);
|
||||
group.Label.text = $"G{i+1}";
|
||||
group.Label.color = groupContainsItem() ? ActiveColor : InactiveColor;
|
||||
group.Button.onClick.AddListener(() =>
|
||||
{
|
||||
var assigned = !groupContainsItem();
|
||||
if (ActionGameManager.Instance.CommitWeaponGroupMembership(item, i1, assigned))
|
||||
group.Label.color = assigned ? ActiveColor : InactiveColor;
|
||||
});
|
||||
|
||||
group.BeginDragTrigger.OnBeginDragAsObservable()
|
||||
.Subscribe(data => _onBeginDrag?.OnNext((data, i1)));
|
||||
group.DragTrigger.OnDragAsObservable()
|
||||
.Subscribe(data => _onDrag?.OnNext((data, i1)));
|
||||
group.EndDragTrigger.OnEndDragAsObservable()
|
||||
.Subscribe(data => _onEndDrag?.OnNext((data, i1)));
|
||||
}
|
||||
}
|
||||
|
||||
public UniRx.IObservable<(PointerEventData pointerEventData, int group)> OnBeginDragAsObservable() =>
|
||||
_onBeginDrag ?? (_onBeginDrag = new Subject<(PointerEventData pointerEventData, int group)>());
|
||||
public UniRx.IObservable<(PointerEventData pointerEventData, int group)> OnDragAsObservable() =>
|
||||
_onDrag ?? (_onDrag = new Subject<(PointerEventData pointerEventData, int group)>());
|
||||
public UniRx.IObservable<(PointerEventData pointerEventData, int group)> OnEndDragAsObservable() =>
|
||||
_onEndDrag ?? (_onEndDrag = new Subject<(PointerEventData pointerEventData, int group)>());
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b9b213fc96d20d848819b8159412680c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UniRx.Triggers;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class WeaponGroupElement : MonoBehaviour
|
||||
{
|
||||
public TextMeshProUGUI Label;
|
||||
public Button Button;
|
||||
public ObservableBeginDragTrigger BeginDragTrigger;
|
||||
public ObservableDragTrigger DragTrigger;
|
||||
public ObservableEndDragTrigger EndDragTrigger;
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 27f5673ad060b834489cad765159cb84
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
|
@ -11,7 +10,6 @@ using GameCult.Aetheria.State.Unity;
|
|||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
|
@ -36,9 +34,7 @@ public class PropertiesPanel : MonoBehaviour
|
|||
public IncrementField IncrementField;
|
||||
public StatSheet StatSheet;
|
||||
public CurveField CurveField;
|
||||
public WeaponGroupAssignment WeaponGroupAssignment;
|
||||
public RectTransform Content;
|
||||
public RectTransform DragParent;
|
||||
|
||||
[HideInInspector] public ActionGameManager GameManager;
|
||||
|
||||
|
|
@ -46,9 +42,6 @@ public class PropertiesPanel : MonoBehaviour
|
|||
protected event Action RefreshPropertyValues;
|
||||
protected bool RadioSelection = false;
|
||||
|
||||
private RectTransform _dragObject;
|
||||
|
||||
|
||||
protected event Action<GameObject> OnPropertyAdded;
|
||||
protected Action OnPropertiesChanged;
|
||||
|
||||
|
|
@ -570,81 +563,6 @@ public class PropertiesPanel : MonoBehaviour
|
|||
$"<color=#{ColorUtility.ToHtmlStringRGB(tier.Color.ToColor())}>{name}</color><smallcaps><size=60%> ({tier.Name}{new string('+', upgrades)})";
|
||||
}
|
||||
|
||||
public void Inspect(EquippedItem item)
|
||||
{
|
||||
Clear();
|
||||
if (item?.EquippableItem == null) return;
|
||||
|
||||
Title.text = GetTitle(item.EquippableItem);
|
||||
|
||||
AddItemProperties(item.EquippableItem);
|
||||
AddSpacer();
|
||||
|
||||
if (item.GetBehavior<Weapon>() != null)
|
||||
{
|
||||
var weaponGroups = Instantiate(WeaponGroupAssignment, Content ?? transform);
|
||||
weaponGroups.Inspect(item);
|
||||
var dragOffset = Vector2.zero;
|
||||
Transform dragObject = null;
|
||||
weaponGroups.OnBeginDragAsObservable().Subscribe(x =>
|
||||
{
|
||||
//Debug.Log($"Began dragging weapon group {x.group}");
|
||||
GameManager.BeginDrag(new WeaponGroupDragObject(x.group));
|
||||
dragObject = Instantiate(weaponGroups.Groups[x.group], DragParent, true).transform;
|
||||
dragOffset = (Vector2)dragObject.position - x.pointerEventData.position;
|
||||
});
|
||||
weaponGroups.OnDragAsObservable().Subscribe(x =>
|
||||
{
|
||||
dragObject.position = x.pointerEventData.position + dragOffset;
|
||||
});
|
||||
weaponGroups.OnEndDragAsObservable().Subscribe(x =>
|
||||
{
|
||||
//Debug.Log($"Ended dragging weapon group {x.group}");
|
||||
GameManager.EndDrag();
|
||||
Destroy(dragObject.gameObject);
|
||||
});
|
||||
Properties.Add(weaponGroups.gameObject);
|
||||
OnPropertyAdded?.Invoke(weaponGroups.gameObject);
|
||||
}
|
||||
|
||||
var typedItem = FindTypedPropertyItem(item.EquippableItem);
|
||||
var thermalRange = GetThermalRange(typedItem);
|
||||
var thermalCurve = GetThermalPerformanceCurve(typedItem);
|
||||
var statusSheet = AddStatSheet();
|
||||
if (item.EquippableItem.Durability < .01f)
|
||||
statusSheet.AddStat("Durability", () => "Item Destroyed!");
|
||||
else statusSheet.AddStat("Durability", () => $"{(int)(item.EquippableItem.Durability / GetMaxDurability(item.EquippableItem) * 100)}%");
|
||||
statusSheet.AddStat("Temperature", () => ActionGameManager.RuntimePlayerSettings.FormatTemperature(item.Temperature));
|
||||
|
||||
var heatCurve = AddCurveField();
|
||||
heatCurve.Show(
|
||||
"Thermal Performance",
|
||||
thermalCurve,
|
||||
t => ActionGameManager.RuntimePlayerSettings.FormatTemperature(lerp(thermalRange.minimum, thermalRange.maximum, t)),
|
||||
true);
|
||||
RefreshPropertyValues += () => heatCurve.SetCurrent(unlerp(thermalRange.minimum, thermalRange.maximum, item.Temperature));
|
||||
AddEquippableItemProperties(item.EquippableItem, item.Evaluate);
|
||||
AddSpacer();
|
||||
|
||||
AddField("Override Shutdown",
|
||||
() => item.EquippableItem.OverrideShutdown,
|
||||
b => ActionGameManager.Instance?.CommitEquippedItemOverrideShutdown(item, b));
|
||||
|
||||
foreach (var behavior in item.Behaviors)
|
||||
{
|
||||
switch (behavior)
|
||||
{
|
||||
case Thermotoggle thermotoggle when thermotoggle.Adjustable:
|
||||
AddField("Target Temperature",
|
||||
() => thermotoggle.TargetTemperature,
|
||||
temp => ActionGameManager.Instance?.CommitThermotoggleTargetTemperature(thermotoggle, temp));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
RefreshValues();
|
||||
}
|
||||
|
||||
public void Inspect(ItemInstance item)
|
||||
{
|
||||
Clear();
|
||||
|
|
|
|||
Loading…
Reference in a new issue