added gameplay lifetimescope
This commit is contained in:
6
.idea/.idea.Colorbook/.idea/vcs.xml
generated
Normal file
6
.idea/.idea.Colorbook/.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -3,16 +3,19 @@ using UnityEngine;
|
||||
using VContainer;
|
||||
using VContainer.Unity;
|
||||
|
||||
public abstract class BaseLifetimeScope : LifetimeScope
|
||||
namespace Darkmatter.App.LifetimeScopes
|
||||
{
|
||||
[SerializeField] private MonoBehaviour[] serviceModules;
|
||||
|
||||
protected override void Configure(IContainerBuilder builder)
|
||||
public abstract class BaseLifetimeScope : LifetimeScope
|
||||
{
|
||||
foreach (var module in serviceModules)
|
||||
[SerializeField] private MonoBehaviour[] serviceModules;
|
||||
|
||||
protected override void Configure(IContainerBuilder builder)
|
||||
{
|
||||
if (module is IServiceModule serviceModule)
|
||||
serviceModule.Register(builder);
|
||||
foreach (var module in serviceModules)
|
||||
{
|
||||
if (module is IServiceModule serviceModule)
|
||||
serviceModule.Register(builder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,11 @@
|
||||
using VContainer;
|
||||
|
||||
public class GameLifetimeScope : BaseLifetimeScope
|
||||
namespace Darkmatter.App.LifetimeScopes
|
||||
{
|
||||
protected override void Configure(IContainerBuilder builder)
|
||||
public class GameLifetimeScope : BaseLifetimeScope
|
||||
{
|
||||
protected override void Configure(IContainerBuilder builder)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Darkmatter.App.LifetimeScopes
|
||||
{
|
||||
public class GameplayLifetimescope : BaseLifetimeScope
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b08651ebc7d8347b4957067e8be677bc
|
||||
@@ -1,9 +1,11 @@
|
||||
using VContainer;
|
||||
using VContainer.Unity;
|
||||
|
||||
public class RootLifetimeScope : BaseLifetimeScope
|
||||
namespace Darkmatter.App.LifetimeScopes
|
||||
{
|
||||
protected override void Configure(IContainerBuilder builder)
|
||||
public class RootLifetimeScope : BaseLifetimeScope
|
||||
{
|
||||
protected override void Configure(IContainerBuilder builder)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2dcdc5f13849d4559b718fda525c6a65
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,10 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core
|
||||
{
|
||||
public interface ICommand
|
||||
{
|
||||
void Execute();
|
||||
void Undo();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 92465f7eb9c044c59b1046fccb01247c
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Darkmatter.Core.Contracts.Features.History
|
||||
{
|
||||
public interface IUndoStack
|
||||
{
|
||||
bool CanUndo { get; }
|
||||
bool CanRedo { get; }
|
||||
void Push(ICommand cmd); // executes + appends
|
||||
void Undo();
|
||||
void Redo();
|
||||
void Clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7b0a633ff0da42289a1ace00298f217
|
||||
@@ -5,9 +5,6 @@ namespace Darkmatter.Core.Contracts.Features.Paper
|
||||
public interface IPaperRig
|
||||
{
|
||||
Camera ArtCamera { get; }
|
||||
RenderTexture Surface { get; }
|
||||
Vector2Int SurfaceSize { get; }
|
||||
float DesignHalfSize { get; }
|
||||
Transform PaperRoot { get; }
|
||||
RectTransform DisplayRect { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ namespace Darkmatter.Core.Enums.Services.Camera
|
||||
public enum CameraType
|
||||
{
|
||||
MainCamera,
|
||||
UICamera,
|
||||
ArtCamera
|
||||
UICamera
|
||||
}
|
||||
}
|
||||
|
||||
8
Assets/Darkmatter/Code/Features/History.meta
Normal file
8
Assets/Darkmatter/Code/Features/History.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5aaa3a66fb83e44d7a2a762d88e4092b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Darkmatter/Code/Features/PaperRig.meta
Normal file
8
Assets/Darkmatter/Code/Features/PaperRig.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f555e5ed9c45e44cd804a598d08efc6c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Darkmatter/Code/Features/PaperRig/Core.meta
Normal file
8
Assets/Darkmatter/Code/Features/PaperRig/Core.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f26c384b6ed9f482b8b3f325ba5e06f5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
15
Assets/Darkmatter/Code/Features/PaperRig/Core/PaperRig.cs
Normal file
15
Assets/Darkmatter/Code/Features/PaperRig/Core/PaperRig.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fd7db17694325451c8441d824b221199
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c54b3e6267ecb41b68cc06079d4b39f2
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
3
Assets/Darkmatter/Code/Features/PaperRig/Input.meta
Normal file
3
Assets/Darkmatter/Code/Features/PaperRig/Input.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0156c96d959344bfbf0c1212ea68d473
|
||||
timeCreated: 1779859615
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0337c48e57934443887873de8e382d4e
|
||||
timeCreated: 1779859625
|
||||
8
Assets/Darkmatter/Code/Features/PaperRig/Installers.meta
Normal file
8
Assets/Darkmatter/Code/Features/PaperRig/Installers.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ecba85ae080a44ef9b1a1d55f3f86659
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef7eaa67fc66d48c88c8ec12d27f9b14
|
||||
@@ -417,7 +417,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Darkmatter.App::GameLifetimeScope
|
||||
parentReference:
|
||||
TypeName:
|
||||
TypeName: RootLifetimeScope
|
||||
autoRun: 1
|
||||
autoInjectGameObjects: []
|
||||
serviceModules:
|
||||
|
||||
@@ -410,6 +410,136 @@ Transform:
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1224714931
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1224714932}
|
||||
- component: {fileID: 1224714933}
|
||||
m_Layer: 0
|
||||
m_Name: GameplayLifetimeScope
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1224714932
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1224714931}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 1132.1088, y: 564.77155, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 1965442263}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1224714933
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1224714931}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: b08651ebc7d8347b4957067e8be677bc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Darkmatter.App::Darkmatter.App.LifetimeScopes.GameplayLifetimescope
|
||||
parentReference:
|
||||
TypeName: Darkmatter.App.LifetimeScopes.GameLifetimeScope
|
||||
autoRun: 1
|
||||
autoInjectGameObjects: []
|
||||
serviceModules:
|
||||
- {fileID: 1594774441}
|
||||
--- !u!1 &1594774439
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1594774440}
|
||||
- component: {fileID: 1594774441}
|
||||
m_Layer: 0
|
||||
m_Name: PaperRigServiceModule
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1594774440
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1594774439}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1965442263}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1594774441
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1594774439}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ef7eaa67fc66d48c88c8ec12d27f9b14, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Features.PaperRig::Darkmatter.Features.PaperRig.PaperRigServiceModule
|
||||
paperRig:
|
||||
artCamera: {fileID: 942391591}
|
||||
displayRect: {fileID: 2081960987}
|
||||
--- !u!1 &1965442262
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1965442263}
|
||||
m_Layer: 0
|
||||
m_Name: ServiceModules
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1965442263
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1965442262}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 1594774440}
|
||||
m_Father: {fileID: 1224714932}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &2069155637
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -593,3 +723,4 @@ SceneRoots:
|
||||
- {fileID: 942391592}
|
||||
- {fileID: 2069155641}
|
||||
- {fileID: 590523275}
|
||||
- {fileID: 1224714932}
|
||||
|
||||
Reference in New Issue
Block a user