코드 리팩토링
재사용성 및 확장성을 고려하여 코드 전반을 리팩토링함
This commit is contained in:
41
Assets/Scripts/Player/PlaceableBehavior.cs
Normal file
41
Assets/Scripts/Player/PlaceableBehavior.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Placeable behavior for building/placing items.
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "Items/Behaviors/Placeable Behavior")]
|
||||
public class PlaceableBehavior : ItemBehavior
|
||||
{
|
||||
[Header("Placement Settings")]
|
||||
[SerializeField] private GameObject placeablePrefab;
|
||||
[SerializeField] private bool requiresGround = true;
|
||||
[SerializeField] private float placementRange = 5f;
|
||||
|
||||
public override bool IsConsumable => true;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (string.IsNullOrEmpty(behaviorName)) behaviorName = "Place";
|
||||
if (string.IsNullOrEmpty(animTrigger)) animTrigger = "Place";
|
||||
canRepeat = false;
|
||||
}
|
||||
|
||||
public override bool CanUse(GameObject user, GameObject target)
|
||||
{
|
||||
// Would integrate with BuildManager for placement validation
|
||||
return placeablePrefab != null;
|
||||
}
|
||||
|
||||
public override void Use(GameObject user, GameObject target)
|
||||
{
|
||||
// Actual placement would be handled by BuildManager
|
||||
// This is a placeholder for the behavior pattern
|
||||
Debug.Log($"[PlaceableBehavior] Would place {placeablePrefab?.name}");
|
||||
}
|
||||
|
||||
public override string GetBlockedReason(GameObject user, GameObject target)
|
||||
{
|
||||
if (placeablePrefab == null) return "Invalid placement item";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user