182 lines
6.2 KiB
C#
182 lines
6.2 KiB
C#
using Cielonos.MainGame.Inventory;
|
|
using UnityEngine;
|
|
|
|
namespace Cielonos.MainGame.Characters
|
|
{
|
|
public partial class PlayerInventorySubcontroller : SubcontrollerBase<Player>, IPlayerSubcontroller
|
|
{
|
|
public Player player => owner;
|
|
private PlayerInputSubcontroller inputSc => player.inputSc;
|
|
private PlayerOperationSubcontroller operationSc => player.operationSc;
|
|
public MainWeaponBase testMainWeapon;
|
|
public PlayerEquipmentSubmodule equipmentSm;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
RegisterOperations();
|
|
equipmentSm = new PlayerEquipmentSubmodule(this);
|
|
equipmentSm.EquipMainWeapon(testMainWeapon);
|
|
}
|
|
}
|
|
|
|
public partial class PlayerInventorySubcontroller
|
|
{
|
|
private MainWeaponBase currentMainWeapon => equipmentSm.currentMainWeapon;
|
|
|
|
private void RegisterOperations()
|
|
{
|
|
//operationSc.OnMainWeaponSpecialPress += MainWeaponSpecialPress;
|
|
//operationSc.OnMainWeaponSpecialRelease += MainWeaponSpecialRelease;
|
|
|
|
operationSc.OnMainWeaponPrimaryPress += MainWeaponPrimaryPress;
|
|
operationSc.OnMainWeaponPrimaryRelease += MainWeaponPrimaryRelease;
|
|
operationSc.OnMainWeaponSecondaryPress += MainWeaponSecondaryPress;
|
|
operationSc.OnMainWeaponSecondaryRelease += MainWeaponSecondaryRelease;
|
|
operationSc.OnMainWeaponTertiaryPress += MainWeaponTertiaryPress;
|
|
operationSc.OnMainWeaponTertiaryRelease += MainWeaponTertiaryRelease;
|
|
operationSc.OnMainWeaponQuaternaryPress += MainWeaponQuaternaryPress;
|
|
operationSc.OnMainWeaponQuaternaryRelease += MainWeaponQuaternaryRelease;
|
|
operationSc.OnMainWeaponQuinaryPress += MainWeaponQuinaryPress;
|
|
operationSc.OnMainWeaponQuinaryRelease += MainWeaponQuinaryRelease;
|
|
|
|
/*
|
|
operationSc.OnSwitchMainWeapon += delegate(float dir) { SwitchMainWeapon(dir > 0 ? 1 : -1); };
|
|
operationSc.OnUseSupportEquipment0Press += delegate { SupportEquipmentPress(0); };
|
|
operationSc.OnUseSupportEquipment1Press += delegate { SupportEquipmentPress(1); };
|
|
operationSc.OnUseSupportEquipment2Press += delegate { SupportEquipmentPress(2); };
|
|
operationSc.OnUseSupportEquipment3Press += delegate { SupportEquipmentPress(3); };
|
|
operationSc.OnReload += MainWeaponReload;*/
|
|
}
|
|
|
|
public virtual void Update()
|
|
{
|
|
if (inputSc.IsHoldingPrimary)
|
|
{
|
|
currentMainWeapon.OnPrimaryHold();
|
|
}
|
|
|
|
if (inputSc.IsHoldingSecondary)
|
|
{
|
|
currentMainWeapon.OnSecondaryHold();
|
|
}
|
|
|
|
if (inputSc.IsHoldingTertiary)
|
|
{
|
|
currentMainWeapon.OnTertiaryHold();
|
|
}
|
|
|
|
if (inputSc.IsHoldingQuaternary)
|
|
{
|
|
currentMainWeapon.OnQuaternaryHold();
|
|
}
|
|
|
|
if (inputSc.IsHoldingQuinary)
|
|
{
|
|
currentMainWeapon.OnQuinaryHold();
|
|
}
|
|
}
|
|
}
|
|
|
|
public partial class PlayerInventorySubcontroller
|
|
{
|
|
public void MainWeaponPrimaryPress()
|
|
{
|
|
if (currentMainWeapon != null)
|
|
{
|
|
player.movementSc.isSprinting = false;
|
|
currentMainWeapon.OnPrimaryPress();
|
|
if (!currentMainWeapon.disablePrimaryPreinput)
|
|
{
|
|
inputSc.preinputSubmodule.RegisterPreinputAction(() => currentMainWeapon.OnPrimaryPress(), 0);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void MainWeaponPrimaryRelease()
|
|
{
|
|
if (currentMainWeapon != null)
|
|
{
|
|
currentMainWeapon.OnPrimaryRelease();
|
|
}
|
|
}
|
|
|
|
public void MainWeaponSecondaryPress()
|
|
{
|
|
if (currentMainWeapon != null)
|
|
{
|
|
player.movementSc.isSprinting = false;
|
|
currentMainWeapon.OnSecondaryPress();
|
|
if (!currentMainWeapon.disableSecondaryPreinput)
|
|
{
|
|
inputSc.preinputSubmodule.RegisterPreinputAction(() => currentMainWeapon.OnSecondaryPress(), 0);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void MainWeaponSecondaryRelease()
|
|
{
|
|
if (currentMainWeapon != null)
|
|
{
|
|
currentMainWeapon.OnSecondaryRelease();
|
|
}
|
|
}
|
|
|
|
public void MainWeaponTertiaryPress()
|
|
{
|
|
if (currentMainWeapon != null)
|
|
{
|
|
player.movementSc.isSprinting = false;
|
|
currentMainWeapon.OnTertiaryPress();
|
|
|
|
inputSc.preinputSubmodule.RegisterPreinputAction(() => currentMainWeapon.OnTertiaryPress(), 0);
|
|
}
|
|
}
|
|
|
|
public void MainWeaponTertiaryRelease()
|
|
{
|
|
if (currentMainWeapon != null)
|
|
{
|
|
currentMainWeapon.OnTertiaryRelease();
|
|
}
|
|
}
|
|
|
|
public void MainWeaponQuaternaryPress()
|
|
{
|
|
if (currentMainWeapon != null)
|
|
{
|
|
player.movementSc.isSprinting = false;
|
|
currentMainWeapon.OnQuaternaryPress();
|
|
|
|
inputSc.preinputSubmodule.RegisterPreinputAction(() => currentMainWeapon.OnQuaternaryPress(), 0);
|
|
}
|
|
}
|
|
|
|
public void MainWeaponQuaternaryRelease()
|
|
{
|
|
if (currentMainWeapon != null)
|
|
{
|
|
currentMainWeapon.OnQuaternaryRelease();
|
|
}
|
|
}
|
|
|
|
public void MainWeaponQuinaryPress()
|
|
{
|
|
if (currentMainWeapon != null)
|
|
{
|
|
player.movementSc.isSprinting = false;
|
|
currentMainWeapon.OnQuinaryPress();
|
|
|
|
inputSc.preinputSubmodule.RegisterPreinputAction(() => currentMainWeapon.OnQuinaryPress(), 0);
|
|
}
|
|
}
|
|
|
|
public void MainWeaponQuinaryRelease()
|
|
{
|
|
if (currentMainWeapon != null)
|
|
{
|
|
currentMainWeapon.OnQuinaryRelease();
|
|
}
|
|
}
|
|
}
|
|
} |