This commit is contained in:
CortexCore
2024-03-29 00:58:24 +08:00
parent 967ad8eacf
commit 05315ef4a8
232 changed files with 53368 additions and 8539 deletions

View File

@@ -16,6 +16,7 @@ using BITFALL.Entities.Inventory;
using BITFALL.Player.Equip;
using BITFALL.Player.Inventory;
using BITKit.Entities.Player;
using BITKit.UX;
using Cysharp.Threading.Tasks;
using JetBrains.Annotations;
using UnityEditor;
@@ -58,13 +59,16 @@ namespace BITFALL.Entities.Equipment
private ImprovisedServiceInterface _improvisedService;
[Inject]
private IEntityEquipmentContainer _equipmentContainer;
[Inject]
private IEquipService _equipService;
[Inject(true)]
private InputActionGroup _inputActionGroup;
[Inject(true)]
private IUXPopup _uxPopup;
private readonly List<int> _blockList=new();
[Inject(true)] private InputActionGroup _inputActionGroup;
private readonly Optional<int> playerChoose = new ();
@@ -120,7 +124,28 @@ namespace BITFALL.Entities.Equipment
private void OnScroll(InputAction.CallbackContext obj)
{
if (BITAppForUnity.AllowCursor) return;
if (obj.performed is false) return;
var value = obj.ReadValue<Vector2>().y;
if (playerChoose.Allow is false)
{
if (equips.ContainsKey(1))
{
playerChoose.SetValueThenAllow(1);
Equip(1);
}else if (equips.ContainsKey(2))
{
playerChoose.SetValueThenAllow(2);
Equip(2);
}
}
//Debug.Log(playerChoose.Value);
var nextChoose = playerChoose.Value is 1 ? 2 : 1;
if (equips.ContainsKey(nextChoose))
{
playerChoose.SetValueThenAllow(nextChoose);
Equip(nextChoose);
}
}
@@ -301,36 +326,42 @@ namespace BITFALL.Entities.Equipment
}
private void OnTactics(InputAction.CallbackContext obj)
{
switch(obj)
{
case {interaction:TapInteraction, performed: true}:
Equip<EquipmentAsTactics>();
break;
}
// switch(obj)
// {
// case {interaction:TapInteraction, performed: true}:
// Equip<EquipmentAsTactics>();
// break;
// }
}
public void Throw(InputAction.CallbackContext context)
{
//Debug.Log(context);
switch (context)
{
case { interaction: HoldInteraction, performed: true }:
if (currentEquip is null) return;
if (equips.TryGetAny(x => x.Value.AddressablePath == currentEquip.AddressablePath, out var pair))
{
if (_inventory.DropOrSpawn(currentEquip))
{
equips.Remove(pair.Key);
_equipment.EntryEquip((IBasicItem)null);
currentEquip = null;
UpdateEquip();
}
}
break;
case { interaction: TapInteraction, performed: true }:
case {interaction:TapInteraction, started: true}:
Equip<EquipmentAsThrow>();
break;
}
// switch (context)
// {
// case { interaction: HoldInteraction, performed: true }:
// if (currentEquip is null) return;
// if (equips.TryGetAny(x => x.Value.AddressablePath == currentEquip.AddressablePath, out var pair))
// {
// if (_inventory.DropOrSpawn(currentEquip))
// {
// equips.Remove(pair.Key);
// _equipment.EntryEquip((IBasicItem)null);
// currentEquip = null;
// UpdateEquip();
// }
// }
//
// break;
// case { interaction: TapInteraction, performed: true }:
// Equip<EquipmentAsThrow>();
// break;
// }
}
public void OnRemove(IBasicItem item)
{
@@ -417,6 +448,19 @@ namespace BITFALL.Entities.Equipment
{
if(_knockdown.IsKnockdown && item.Value.GetAssetable().AllowUseWhileKnocked is false) return false;
}
try
{
if (_inventory.AllowUseItem(item.Value) is false)
{
return false;
}
}
catch (InGameException e)
{
_uxPopup?.Popup(e.Message);
return false;
}
_improvisedService.TryUnEquipImprovised(out _);
Equip(item.Value);
return true;