1
This commit is contained in:
47
Assets/Artists/Scripts/Equip/PlacingController.cs
Normal file
47
Assets/Artists/Scripts/Equip/PlacingController.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITFALL.Entities.Inventory;
|
||||
using BITFALL.Placement;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
using BITKit.StateMachine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITFALL.Player.Equip
|
||||
{
|
||||
public interface IPlacingState:IState{}
|
||||
public class PlacingController : BITEquipBase<IPlacingState>
|
||||
{
|
||||
internal AssetablePlacement _placement => item as AssetablePlacement;
|
||||
|
||||
[SerializeField] private Vector3 offset;
|
||||
|
||||
[Inject] private IEntityInventory _inventory;
|
||||
[Inject] private IEntityMovement _movement;
|
||||
[Inject] private IPlayerEquipSelector _equipSelector;
|
||||
|
||||
public override void OnAwake()
|
||||
{
|
||||
base.OnAwake();
|
||||
animator[0].onStateExit += OnStateExit;
|
||||
}
|
||||
|
||||
private void OnStateExit(string obj)
|
||||
{
|
||||
if (IsEntered is false || obj is not BITConstant.Player.Use) return;
|
||||
if (!_inventory.Remove(Item)) return;
|
||||
var instance = _placement.CreateInstance() as MonoBehaviour;
|
||||
instance!.transform.SetPositionAndRotation(_movement.Position + _movement.Rotation * offset, _movement.Rotation);
|
||||
|
||||
_equipSelector.Cancel();
|
||||
}
|
||||
|
||||
public override void Entry()
|
||||
{
|
||||
base.Entry();
|
||||
animator.Play(BITConstant.Player.Draw);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user