Action Bar (WIP)

Refactor item instance to use DatabaseLink
Labels now pop up when aiming at loot
Yeeted HUD trigger group UI into the abyss
Created rebindable action bar (missing: assigning actions)
Created Consumable Items
Refactored behaviors to work on consumable items
Implemented Velocity Conversion Behavior
This commit is contained in:
Reinier Vens 2021-04-18 05:13:20 +01:00
commit 4489b18452
217 changed files with 5105 additions and 5703 deletions

View file

@ -21,6 +21,7 @@ public class ConsoleView : MonoBehaviour {
private string _inputString = "";
private CursorLockMode _previousCursorLockMode;
private bool _playerInputPreviouslyEnabled;
public string InputString
{
@ -113,17 +114,19 @@ public class ConsoleView : MonoBehaviour {
Visible = visible;
if(visible)
{
_playerInputPreviouslyEnabled = GameManager.Input.Player.enabled;
GameManager.Input.Global.Disable();
GameManager.Input.Player.Disable();
GameManager.DisablePlayerInput();
GameManager.Input.UI.Disable();
_previousCursorLockMode = Cursor.lockState;
Cursor.lockState = CursorLockMode.None;
}
else
{
if(_playerInputPreviouslyEnabled)
GameManager.EnablePlayerInput();
else GameManager.Input.UI.Enable();
GameManager.Input.Global.Enable();
GameManager.Input.Player.Enable();
GameManager.Input.UI.Enable();
Cursor.lockState = _previousCursorLockMode;
}
}

View file

@ -87,7 +87,7 @@ public class InventoryMenu : MonoBehaviour
var item = cargoEvent.CargoBay.Occupancy[cargoEvent.Position.x, cargoEvent.Position.y];
if (item != null)
{
var itemData = GameManager.ItemManager.GetData(item);
var itemData = item.Data.Value;
var itemPosition = cargoEvent.CargoBay.Cargo[item];
_originalOccupancy = cargoEvent.CargoBay.Data.InteriorShape.Inset(itemData.Shape, itemPosition, item.Rotation);
@ -244,7 +244,7 @@ public class InventoryMenu : MonoBehaviour
if (cargoEvent.CargoBay.ItemFits(_dragItem, _dragTargetPosition))
{
foreach (var cell in _dragCells) cell.gameObject.SetActive(false);
var itemData = GameManager.ItemManager.GetData(_dragItem);
var itemData = _dragItem.Data.Value;
panel.FakeItem = _dragItem;
panel.FakeOccupancy = cargoEvent.CargoBay.Data.InteriorShape.Inset(itemData.Shape, _dragTargetPosition, _dragItem.Rotation);
_dragTargetValid = true;
@ -258,7 +258,7 @@ public class InventoryMenu : MonoBehaviour
if (eqItem != null && entityEvent.Entity.ItemFits(eqItem, _dragTargetPosition))
{
foreach (var cell in _dragCells) cell.gameObject.SetActive(false);
var itemData = GameManager.ItemManager.GetData(_dragItem);
var itemData = _dragItem.Data.Value;
panel.FakeEquipment = _originalEquippedItem;
panel.FakeOccupancy = hullData.Shape.Inset(itemData.Shape, _dragTargetPosition, _dragItem.Rotation);
_dragTargetValid = true;
@ -325,7 +325,7 @@ public class InventoryMenu : MonoBehaviour
_selectedPanel = panel;
_selectedPosition = cargoEvent.CargoBay.Cargo[item];
_selectedItem = item;
_selectedItemData = GameManager.ItemManager.GetData(item);
_selectedItemData = item.Data.Value;
foreach (var v in _selectedItemData.Shape.Coordinates)
{
var v2 = _selectedItemData.Shape.Rotate(v, _selectedItem.Rotation) + _selectedPosition;

View file

@ -661,7 +661,7 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
return Color.white * .25f;
var c = float3(1);
if (GameManager.ItemManager.GetData(item) is EquippableItemData equippable)
if (item.Data.Value is EquippableItemData equippable)
c = HardpointData.GetColor(equippable.HardpointType);
if(!highlight)

View file

@ -387,7 +387,7 @@ public class PropertiesPanel : MonoBehaviour
private void AddItemProperties(ItemInstance item)
{
var data = ActionGameManager.CultCache.Get<ItemData>(item.Data);
var data = item.Data.Value;
AddProperty(data.Description);
@ -447,7 +447,7 @@ public class PropertiesPanel : MonoBehaviour
private string GetTitle(EquippableItem item)
{
var data = ActionGameManager.CultCache.Get<ItemData>(item.Data);
var data = item.Data.Value;
var (tier, upgrades) = GameManager.ItemManager.GetTier(item);
return
$"<color=#{ColorUtility.ToHtmlStringRGB(tier.Color.ToColor())}>{data.Name}</color><smallcaps><size=60%> ({tier.Name}{new string('+', upgrades)})";

View file

@ -13,7 +13,6 @@ public class SchematicDisplay : MonoBehaviour
{
public GameSettings Settings;
public Prototype ListElementPrototype;
public Prototype TriggerGroupPrototype;
public Color HeaderElementEnabledColor;
public Color HeaderElementDisabledColor;
@ -24,7 +23,6 @@ public class SchematicDisplay : MonoBehaviour
public Image HeatsinkBackground;
public GameObject AetherDriveUi;
public GameObject AetherDriveUiSpacer;
public TextMeshProUGUI EnergyLabel;
public TextMeshProUGUI CockpitTemperatureLabel;
@ -48,12 +46,6 @@ public class SchematicDisplay : MonoBehaviour
public RectTransform StrafeRPMFill;
public RectTransform TurnRPMFill;
public CanvasGroup TriggerGroups;
public float TriggerGroupsFadeDuration = .5f;
public float TriggerGroupsPersistDuration = 5f;
public Color TriggerGroupColor;
private Entity _entity;
private EquippableItem _hull;
private Radiator[] _radiators;
@ -63,14 +55,8 @@ public class SchematicDisplay : MonoBehaviour
private HeatStorage[] _heatStorages;
private EquippedCargoBay[] _cargoBays;
private SchematicDisplayItem[] _schematicItems;
private Graphic[] _groupGraphics;
private AetherDrive _aetherDrive;
private int _selectedGroupIndex;
private int _selectedItemIndex;
private bool _triggerGroupsVisible;
private float _triggerGroupsFadeOutTime;
private bool _enemy;
private Entity _player;
@ -79,31 +65,10 @@ public class SchematicDisplay : MonoBehaviour
get { return _schematicItems; }
}
public int SelectedItemIndex
{
get => _selectedItemIndex;
set
{
_selectedItemIndex = (value + _schematicItems.Length) % _schematicItems.Length;
UpdateTriggerGroups();
}
}
public int SelectedGroupIndex
{
get => _selectedGroupIndex;
set
{
_selectedGroupIndex = (value + Settings.GameplaySettings.TriggerGroupCount) % Settings.GameplaySettings.TriggerGroupCount;
UpdateTriggerGroups();
}
}
public class SchematicDisplayItem
{
public EquippedItem Item;
public SchematicListElement ListElement;
public SchematicTriggerGroupElement TriggerGroupElement;
public IProgressBehavior Cooldown;
// public ItemUsage ItemUsage;
public Weapon Weapon;
@ -117,7 +82,6 @@ public class SchematicDisplay : MonoBehaviour
foreach (var item in _schematicItems)
{
item.ListElement.GetComponent<Prototype>().ReturnToPool();
item.TriggerGroupElement?.GetComponent<Prototype>().ReturnToPool();
}
_entity = entity;
@ -128,7 +92,6 @@ public class SchematicDisplay : MonoBehaviour
_capacitors = entity.GetBehaviors<Capacitor>().ToArray();
_aetherDrive = entity.GetBehavior<AetherDrive>();
AetherDriveUi.SetActive(_aetherDrive != null);
AetherDriveUiSpacer.SetActive(_aetherDrive != null);
_radiators = entity.GetBehaviors<Radiator>().ToArray();
if (_radiators.Length == 0)
@ -149,7 +112,6 @@ public class SchematicDisplay : MonoBehaviour
{
Item = x,
ListElement = ListElementPrototype.Instantiate<SchematicListElement>(),
TriggerGroupElement = _enemy ? null : TriggerGroupPrototype.Instantiate<SchematicTriggerGroupElement>(),
Cooldown = _enemy ? null : (IProgressBehavior) x.Behaviors.FirstOrDefault(b=> b is IProgressBehavior),
// ItemUsage = _enemy ? null : (ItemUsage) x.Behaviors.FirstOrDefault(b=> b is ItemUsage),
Weapon = (Weapon) x.Behaviors.FirstOrDefault(b=>b is Weapon)
@ -164,72 +126,12 @@ public class SchematicDisplay : MonoBehaviour
{
x.ListElement.InfiniteAmmoIcon.gameObject.SetActive(x.Weapon.WeaponData.AmmoType == Guid.Empty);
x.ListElement.AmmoLabel.gameObject.SetActive(x.Weapon.WeaponData.AmmoType != Guid.Empty);
foreach (var group in x.TriggerGroupElement.GroupBackgrounds)
group.color = TriggerGroupColor;
}
}
if (!_enemy)
UpdateTriggerGroups();
}
public void UpdateTriggerGroups()
{
if (!_triggerGroupsVisible)
{
StartCoroutine(FadeInTriggerGroups());
_triggerGroupsVisible = true;
}
_triggerGroupsFadeOutTime = Time.time + TriggerGroupsPersistDuration;
for (var itemIndex = 0; itemIndex < _schematicItems.Length; itemIndex++)
{
var item = _schematicItems[itemIndex];
for (var groupIndex = 0; groupIndex < item.TriggerGroupElement.GroupBackgrounds.Length; groupIndex++)
{
var backgroundColor = TriggerGroupColor;
if (_selectedGroupIndex == groupIndex)
backgroundColor.a *= 2;
if (_selectedItemIndex == itemIndex)
backgroundColor.a *= 2;
item.TriggerGroupElement.GroupBackgrounds[groupIndex].color = backgroundColor;
item.TriggerGroupElement.GroupLabel[groupIndex].color =
_entity.TriggerGroups[groupIndex].items.Contains(item.Item) ? Color.white : Color.gray;
}
}
}
IEnumerator FadeInTriggerGroups()
{
var startTime = Time.time;
while (Time.time - startTime < TriggerGroupsFadeDuration)
{
var lerp = (Time.time - startTime) / TriggerGroupsFadeDuration;
TriggerGroups.alpha = lerp;
yield return null;
}
TriggerGroups.alpha = 1;
}
IEnumerator FadeOutTriggerGroups()
{
var startTime = Time.time;
while (Time.time - startTime < TriggerGroupsFadeDuration)
{
var lerp = (Time.time - startTime) / TriggerGroupsFadeDuration;
TriggerGroups.alpha = 1-lerp;
yield return null;
}
TriggerGroups.alpha = 0;
}
void Update()
{
if (_triggerGroupsVisible && _triggerGroupsFadeOutTime < Time.time)
{
_triggerGroupsVisible = false;
StartCoroutine(FadeOutTriggerGroups());
}
if (_entity != null)
{
if (!_enemy)
@ -237,11 +139,11 @@ public class SchematicDisplay : MonoBehaviour
OverrideIcon.SetActive(_entity.OverrideShutdown && cos(Time.time * OverrideIconBlinkSpeed) > 0);
ShieldIcon.SetActive(_entity.Shield!=null && _entity.Shield.Item.Active.Value);
if (_radiators.Length == 1)
RadiatorTemperatureLabel.text = $"{((int)(_radiators[0].Temperature - 273.15f)).ToString()}°C";
RadiatorTemperatureLabel.text = $"{((int)(_radiators[0].RadiatorTemperature - 273.15f)).ToString()}°C";
else if (_radiators.Length > 1)
RadiatorTemperatureLabel.text =
$"{((int)(_radiators.Min(r => r.Temperature) - 273.15f)).ToString()}-" +
$"{((int)(_radiators.Max(r => r.Temperature) - 273.15f)).ToString()}°C";
$"{((int)(_radiators.Min(r => r.RadiatorTemperature) - 273.15f)).ToString()}-" +
$"{((int)(_radiators.Max(r => r.RadiatorTemperature) - 273.15f)).ToString()}°C";
HeatsinkBackground.color = _entity.HeatsinksEnabled ? HeaderElementEnabledColor : HeaderElementDisabledColor;
if (_heatStorages.Length == 1)

View file

@ -220,7 +220,7 @@ public class TradeMenu : MonoBehaviour
data => data.Shape.Width*data.Shape.Height));
var items = Inventory.Cargo.Keys
.Select<ItemInstance, (ItemInstance item, ItemData data)>(ii=>(ii, GameManager.ItemManager.GetData(ii)));
.Select<ItemInstance, (ItemInstance item, ItemData data)>(ii=>(ii, ii.Data.Value));
if (MinimumSizeFilter.gameObject.activeSelf)
items = items.Where(i =>
@ -287,7 +287,7 @@ public class TradeMenu : MonoBehaviour
x => () =>
{
if (x.data is HullData)
return GameManager.DockedEntity.Children.Count(s => s.Hull.Data == x.data.ID && s is Ship {IsPlayerShip: true}).ToString();
return GameManager.DockedEntity.Children.Count(s => s.Hull.Data.LinkID == x.data.ID && s is Ship {IsPlayerShip: true}).ToString();
if(x.data is SimpleCommodityData)
return (_targetCargo.ItemsOfType.ContainsKey(x.data.ID) ? _targetCargo.ItemsOfType[x.data.ID].Cast<SimpleCommodity>().Sum(s=>s.Quantity) : 0).ToString();
return (_targetCargo.ItemsOfType.ContainsKey(x.data.ID) ? _targetCargo.ItemsOfType[x.data.ID].Count : 0).ToString();
@ -295,7 +295,7 @@ public class TradeMenu : MonoBehaviour
data =>
{
if (data is HullData)
return GameManager.DockedEntity.Children.Count(s => s.Hull.Data == data.ID && s is Ship {IsPlayerShip: true});
return GameManager.DockedEntity.Children.Count(s => s.Hull.Data.LinkID == data.ID && s is Ship {IsPlayerShip: true});
if(data is SimpleCommodityData)
return _targetCargo.ItemsOfType.ContainsKey(data.ID) ? _targetCargo.ItemsOfType[data.ID].Cast<SimpleCommodity>().Sum(s=>s.Quantity) : 0;
return _targetCargo.ItemsOfType.ContainsKey(data.ID) ? _targetCargo.ItemsOfType[data.ID].Count : 0;

View file

@ -272,7 +272,7 @@ public class TradeMenuDebug : MonoBehaviour
data => () =>
{
if (data is HullData)
return GameManager.DockedEntity.Children.Count(s => s.Hull.Data == data.ID && s is Ship {IsPlayerShip: true}).ToString();
return GameManager.DockedEntity.Children.Count(s => s.Hull.Data.LinkID == data.ID && s is Ship {IsPlayerShip: true}).ToString();
if(data is SimpleCommodityData)
return (_targetCargo.ItemsOfType.ContainsKey(data.ID) ? _targetCargo.ItemsOfType[data.ID].Cast<SimpleCommodity>().Sum(s=>s.Quantity) : 0).ToString();
return (_targetCargo.ItemsOfType.ContainsKey(data.ID) ? _targetCargo.ItemsOfType[data.ID].Count : 0).ToString();
@ -280,7 +280,7 @@ public class TradeMenuDebug : MonoBehaviour
data =>
{
if (data is HullData)
return GameManager.DockedEntity.Children.Count(s => s.Hull.Data == data.ID && s is Ship {IsPlayerShip: true});
return GameManager.DockedEntity.Children.Count(s => s.Hull.Data.LinkID == data.ID && s is Ship {IsPlayerShip: true});
if(data is SimpleCommodityData)
return _targetCargo.ItemsOfType.ContainsKey(data.ID) ? _targetCargo.ItemsOfType[data.ID].Cast<SimpleCommodity>().Sum(s=>s.Quantity) : 0;
return _targetCargo.ItemsOfType.ContainsKey(data.ID) ? _targetCargo.ItemsOfType[data.ID].Count : 0;