added gameplay lifetimescope

This commit is contained in:
Savya Bikram Shah
2026-05-27 12:13:45 +05:45
parent 50ca3a0a0f
commit 442836ad89
28 changed files with 349 additions and 19 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5aaa3a66fb83e44d7a2a762d88e4092b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f555e5ed9c45e44cd804a598d08efc6c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f26c384b6ed9f482b8b3f325ba5e06f5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
using System;
using Darkmatter.Core.Contracts.Features.Paper;
using UnityEngine;
namespace Darkmatter.Features.PaperRig
{
[Serializable]
public class PaperRig : IPaperRig
{
[SerializeField] private Camera artCamera;
[SerializeField] private RectTransform displayRect;
public Camera ArtCamera => artCamera;
public RectTransform DisplayRect => displayRect;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: fd7db17694325451c8441d824b221199

View File

@@ -0,0 +1,18 @@
{
"name": "Features.PaperRig",
"rootNamespace": "Darkmatter.Features.PaperRig",
"references": [
"GUID:6a0a834eb41764f12ba55c3fb04a40cb",
"GUID:b0214a6008ed146ff8f122a6a9c2f6cc",
"GUID:c1c03c0e5b2f4412b9f2be1c20d6a9b1"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c54b3e6267ecb41b68cc06079d4b39f2
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0156c96d959344bfbf0c1212ea68d473
timeCreated: 1779859615

View File

@@ -0,0 +1,45 @@
using Darkmatter.Core.Contracts.Features.Paper;
using Darkmatter.Core.Contracts.Services.Camera;
using UnityEngine;
using CameraType = Darkmatter.Core.Enums.Services.Camera.CameraType;
namespace Darkmatter.Features.PaperRig.Darkmatter.Code.Features.PaperRig.Input
{
public class ArtInputBridge : IArtInputBridge
{
private readonly IPaperRig _paperRig;
private ICameraService _cameraService;
public ArtInputBridge(IPaperRig paperRig, ICameraService cameraService)
{
_paperRig = paperRig;
_cameraService = cameraService;
}
public bool TryScreenToArtWorld(Vector2 screenPos, out Vector2 artWorldPos)
{
var rectT = _paperRig.DisplayRect;
var uiCamera = _cameraService.GetCamera(CameraType.UICamera);
if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(
rectT, screenPos, uiCamera, out var local))
{
artWorldPos = default;
return false;
}
var rect = rectT.rect;
var uv = new Vector2(
(local.x - rect.xMin) / rect.width,
(local.y - rect.yMin) / rect.height);
if (uv.x < 0 || uv.x > 1 || uv.y < 0 || uv.y > 1)
{
artWorldPos = default;
return false;
}
artWorldPos = _paperRig.ArtCamera.ViewportToWorldPoint(uv);
return true;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0337c48e57934443887873de8e382d4e
timeCreated: 1779859625

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ecba85ae080a44ef9b1a1d55f3f86659
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using Darkmatter.Core.Contracts.Features.Paper;
using Darkmatter.Features.PaperRig.Darkmatter.Code.Features.PaperRig.Input;
using Darkmatter.Libs.Installers;
using UnityEngine;
using VContainer;
using VContainer.Unity;
namespace Darkmatter.Features.PaperRig
{
public class PaperRigServiceModule : MonoBehaviour, IServiceModule
{
[SerializeField] private PaperRig paperRig;
public void Register(IContainerBuilder builder)
{
builder.RegisterComponent<IPaperRig>(paperRig);
builder.Register<IArtInputBridge, ArtInputBridge>(Lifetime.Singleton);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: ef7eaa67fc66d48c88c8ec12d27f9b14