first commit

This commit is contained in:
2026-06-04 23:22:13 +03:00
commit d329f501be
310 changed files with 36395 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
using UnityEngine;
namespace OTGIntegrated.Items
{
public enum ItemType
{
Resource,
Consumable,
Weapon,
Quest,
Crafted
}
[CreateAssetMenu(fileName = "ItemData", menuName = "OTG Integrated/Item Data")]
public sealed class ItemData : ScriptableObject
{
public string itemId;
public string displayName;
[TextArea(2, 5)] public string description;
[Min(1)] public int maxStack = 20;
public ItemType itemType = ItemType.Resource;
public Color itemColor = Color.white;
public Sprite icon;
private void OnValidate()
{
if (string.IsNullOrWhiteSpace(itemId))
{
itemId = name;
}
if (string.IsNullOrWhiteSpace(displayName))
{
displayName = itemId;
}
maxStack = Mathf.Max(1, maxStack);
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 078fc01ab57931f239a827eff5dce814
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+44
View File
@@ -0,0 +1,44 @@
using OTGIntegrated.Core;
using OTGIntegrated.Inventory;
using OTGIntegrated.Player;
using UnityEngine;
namespace OTGIntegrated.Items
{
[RequireComponent(typeof(Collider))]
public sealed class ItemPickup : MonoBehaviour, IInteractable
{
public ItemData itemData;
[Min(1)] public int amount = 1;
public Transform InteractTransform => transform;
private void Awake()
{
Collider ownCollider = GetComponent<Collider>();
ownCollider.isTrigger = true;
}
public string GetPrompt()
{
string label = itemData != null ? itemData.displayName : "Предмет";
return $"E — подобрать: {label}";
}
public bool CanInteract(GameObject interactor)
{
return itemData != null && amount > 0;
}
public void Interact(GameObject interactor)
{
OTGIntegrated.Inventory.Inventory inventory = GameManager.Instance != null
? GameManager.Instance.inventory
: interactor.GetComponentInChildren<OTGIntegrated.Inventory.Inventory>();
if (inventory != null && inventory.AddItem(itemData, amount))
{
Destroy(gameObject);
}
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 662778782848d943092b5de50a866096
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+90
View File
@@ -0,0 +1,90 @@
using System.Collections;
using OTGIntegrated.Core;
using OTGIntegrated.Player;
using UnityEngine;
namespace OTGIntegrated.Items
{
[RequireComponent(typeof(Collider))]
public sealed class ResourceNode : MonoBehaviour, IInteractable
{
public ItemData itemData;
[Min(1)] public int amount = 1;
[Min(0f)] public float respawnCooldown = 0f;
public string actionLabel = "собрать";
private Collider nodeCollider;
private Renderer[] renderers;
private bool depleted;
public Transform InteractTransform => transform;
private void Awake()
{
nodeCollider = GetComponent<Collider>();
nodeCollider.isTrigger = true;
renderers = GetComponentsInChildren<Renderer>();
}
public string GetPrompt()
{
string label = itemData != null ? itemData.displayName : "Ресурс";
return $"E — {actionLabel}: {label}";
}
public bool CanInteract(GameObject interactor)
{
return !depleted && itemData != null && amount > 0;
}
public void Interact(GameObject interactor)
{
if (!CanInteract(interactor))
{
return;
}
OTGIntegrated.Inventory.Inventory inventory = GameManager.Instance != null
? GameManager.Instance.inventory
: interactor.GetComponentInChildren<OTGIntegrated.Inventory.Inventory>();
if (inventory == null || !inventory.AddItem(itemData, amount))
{
return;
}
if (respawnCooldown > 0f)
{
StartCoroutine(RespawnRoutine());
}
else
{
Destroy(gameObject);
}
}
private IEnumerator RespawnRoutine()
{
SetDepleted(true);
yield return new WaitForSeconds(respawnCooldown);
SetDepleted(false);
}
private void SetDepleted(bool value)
{
depleted = value;
if (nodeCollider != null)
{
nodeCollider.enabled = !value;
}
for (int i = 0; i < renderers.Length; i++)
{
if (renderers[i] != null)
{
renderers[i].enabled = !value;
}
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4a33ea5d7040fcd0c92797efb964064a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: