Первый коммит с LFS.

This commit is contained in:
vladislove committed 2026-01-11 17:04:23 +03:00
1 parent 4fcb1e2f24
commit 179816dc4b
5084 files changed
+3714098 -1

No files matched your search

@@ -0,0 +1,99 @@
using UnityEngine;
namespace Quest_Environment.Q4
{
[RequireComponent(typeof(Collider))]
public class FurniturePlacementZone : MonoBehaviour, IInteractable
{
[Tooltip("The ID of the furniture that belongs in this zone.")]
[SerializeField] private string targetFurnitureId;
[Tooltip("The furniture object to show when placed.")]
[SerializeField] private GameObject placedFurniturePrefab;
[Tooltip("The GameObject with an Outline component that acts as a visual indicator.")]
[SerializeField] private GameObject zoneIndicator;
private bool _isOccupied = false;
private Outline _indicatorOutline; // *** НОВОЕ ПОЛЕ для хранения компонента
void Start()
{
// *** ИЗМЕНЕНИЕ: Находим и кэшируем компонент Outline
if (zoneIndicator != null)
{
_indicatorOutline = zoneIndicator.GetComponent<Outline>();
}
ResetZone();
}
public void Interact()
{
if (QuestManager.Instance?.currentQuest is Q4_PlaceFurnitureQuest furnitureQuest)
{
if (!_isOccupied && furnitureQuest.HeldFurnitureId == targetFurnitureId)
{
InteractionHandler.Instance.NotifyInteraction(gameObject);
}
}
}
public string GetDescription()
{
if (QuestManager.Instance?.currentQuest is Q4_PlaceFurnitureQuest furnitureQuest)
{
if (!_isOccupied && furnitureQuest.HeldFurnitureId == targetFurnitureId)
{
return $"Поставить {targetFurnitureId}";
}
}
return "";
}
public void PlaceItem()
{
_isOccupied = true;
if (placedFurniturePrefab != null) placedFurniturePrefab.SetActive(true);
// *** ИЗМЕНЕНИЕ: Выключаем Outline через компонент
if (_indicatorOutline != null)
{
_indicatorOutline.enabled = false;
}
}
public void ResetZone()
{
_isOccupied = false;
if (placedFurniturePrefab != null) placedFurniturePrefab.SetActive(false);
// *** ИЗМЕНЕНИЕ: Выключаем Outline через компонент
if (_indicatorOutline != null)
{
_indicatorOutline.enabled = false;
}
}
void Update()
{
// Если у нас нет компонента подсветки или зона уже занята, ничего не делаем
if (_indicatorOutline == null || _isOccupied)
{
return;
}
bool shouldBeActive = false;
if (QuestManager.Instance?.currentQuest is Q4_PlaceFurnitureQuest furnitureQuest)
{
if (furnitureQuest.HeldFurnitureId == targetFurnitureId)
{
shouldBeActive = true;
}
}
// *** ИЗМЕНЕНИЕ: Включаем/выключаем сам компонент, а не весь GameObject
if (_indicatorOutline.enabled != shouldBeActive)
{
_indicatorOutline.enabled = shouldBeActive;
}
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5a6c0505d876d3b9087aca44c7e5e5db
@@ -0,0 +1,36 @@
using UnityEngine;
namespace Quest_Environment.Q4
{
[RequireComponent(typeof(Outline))]
public class MovableFurniture : MonoBehaviour, IInteractable
{
[Tooltip("A unique ID for this piece of furniture (e.g., 'Chair', 'Lamp').")]
[SerializeField] private string furnitureId;
public void Interact()
{
// Проверяем, что сейчас идет квест с мебелью, прежде чем что-то делать
if (QuestManager.Instance?.currentQuest is Q4_PlaceFurnitureQuest)
{
InteractionHandler.Instance.NotifyInteraction(gameObject);
}
}
public string GetDescription()
{
// Описание будет только если активен квест по расстановке мебели
if (QuestManager.Instance?.currentQuest is Q4_PlaceFurnitureQuest furnitureQuest)
{
// И если игрок ничего не "держит" в руках
if (furnitureQuest.HeldFurnitureId == null)
{
return $"Подобрать {furnitureId}";
}
}
// В противном случае возвращаем пустую строку, и подсветки не будет
return "";
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 21362de71083aec96a3b66b617e67ee1
@@ -0,0 +1,136 @@
using UnityEngine;
using System.Collections.Generic;
using System.Linq;
namespace Quest_Environment.Q4
{
public class Q4_PlaceFurnitureQuest : MonoBehaviour, IQuest
{
[System.Serializable]
public class FurnitureTask
{
public string furnitureId;
[Tooltip("The object that can be picked up.")]
public GameObject pickupObject;
[Tooltip("The zone where the object should be placed.")]
public FurniturePlacementZone placementZone;
[HideInInspector] public bool isPlaced;
}
[Header("Quest Settings")]
[SerializeField] private string questName = "Tidy Up the Room";
[SerializeField] private List<FurnitureTask> furnitureTasks;
private string _heldFurnitureId = null;
private int _placedCount = 0;
public string QuestName => questName;
public string Description { get; private set; }
public int CurrentStep => _placedCount;
public int TotalSteps => furnitureTasks.Count;
public bool IsCompleted => _placedCount >= TotalSteps;
public string HeldFurnitureId => _heldFurnitureId;
public event System.Action<string> OnQuestStepChanged;
public void StartQuest()
{
_placedCount = 0;
_heldFurnitureId = null;
foreach (var task in furnitureTasks)
{
task.isPlaced = false;
if (task.placementZone != null) task.placementZone.ResetZone();
if (task.pickupObject != null) task.pickupObject.SetActive(true);
}
PlayerHandsController.Instance?.HideHands();
if (InteractionHandler.Instance != null)
{
InteractionHandler.Instance.onObjectInteracted += HandleInteraction;
}
UpdateQuestState();
}
void OnDestroy()
{
if (InteractionHandler.Instance != null)
{
InteractionHandler.Instance.onObjectInteracted -= HandleInteraction;
}
}
private void HandleInteraction(GameObject interactedObject)
{
if (IsCompleted) return;
if (_heldFurnitureId == null)
{
var task = furnitureTasks.FirstOrDefault(t => !t.isPlaced && t.pickupObject == interactedObject);
if (task != null)
{
_heldFurnitureId = task.furnitureId;
task.pickupObject.SetActive(false);
UpdateQuestState();
return;
}
}
else
{
var task = furnitureTasks.FirstOrDefault(t => t.furnitureId == _heldFurnitureId && t.placementZone.gameObject == interactedObject);
if (task != null)
{
task.isPlaced = true;
task.placementZone.PlaceItem();
_heldFurnitureId = null;
_placedCount++;
QuestManager.Instance.StepCompleted();
if (IsCompleted)
{
FinishQuest();
}
else
{
UpdateQuestState();
}
return;
}
}
}
private void UpdateQuestState()
{
if (IsCompleted)
{
Description = "Everything is in its place!";
}
else if (_heldFurnitureId != null)
{
Description = $"Place the {_heldFurnitureId}.";
}
else
{
Description = $"Arrange the furniture: {_placedCount} / {TotalSteps}";
}
OnQuestStepChanged?.Invoke(Description);
}
private void FinishQuest()
{
UpdateQuestState();
QuestManager.Instance.CompleteQuest();
}
public void AdvanceQuestStep() { }
public void CompleteQuest()
{
if (InteractionHandler.Instance != null)
{
InteractionHandler.Instance.onObjectInteracted -= HandleInteraction;
}
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 016d18b175bddbe869252563f50f76c7