refactor on journey runtime manager

This commit is contained in:
Nilton Constantino 2026-06-26 19:10:27 +01:00
parent 720ec7def1
commit 91c193dc8a
No known key found for this signature in database
60 changed files with 8806 additions and 3287 deletions

View File

@ -1,86 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &119630160975831446
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2270435121348859238}
m_Layer: 0
m_Name: LandingStart
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2270435121348859238
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 119630160975831446}
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: 2378040738592165545}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &7631802331149991959
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2378040738592165545}
- component: {fileID: 7503967939848988478}
m_Layer: 0
m_Name: JourneyManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2378040738592165545
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7631802331149991959}
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: 2270435121348859238}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &7503967939848988478
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7631802331149991959}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: cdf542c2073144c5a39418e08512ca58, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::Intrepid.Gameplay.Journey.JourneyManager
subscriptionId: 5df34d67e6e44f3999042072ea652750
curtainType: {fileID: 11400000, guid: bc9a28f3d7c64606a8b88c91b94e8805, type: 2}
actionBeltManager: {fileID: 11400000, guid: 24d31645b4d544dd69b6ada8858ba50e, type: 2}
journeyService: {fileID: 11400000, guid: 53f1211059b4847a49bde1be4b8d166c, type: 2}
backStageService: {fileID: 11400000, guid: c58e40006278948db8d8b1f3477f83ea, type: 2}
isRunningTest: 0
stageToTest: {fileID: 0}
landingStart: {fileID: 2270435121348859238}

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 8cee629b6bf44433f98c6e28031d8f6b
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -149,7 +149,7 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: Assembly-CSharp::Intrepid.Temporary.FakeSceneManager m_EditorClassIdentifier: Assembly-CSharp::Intrepid.Temporary.FakeSceneManager
subscriptionId: 240c1e17dada481686201db0d4f74fd4 subscriptionId: 240c1e17dada481686201db0d4f74fd4
nextState: 4 nextState: 1
delay: 0.5 delay: 0.5
curtainType: {fileID: 11400000, guid: d91043b858654867aaa66b20d678191d, type: 2} curtainType: {fileID: 11400000, guid: d91043b858654867aaa66b20d678191d, type: 2}
sceneName: Boot sceneName: Boot

View File

@ -119,77 +119,340 @@ NavMeshSettings:
debug: debug:
m_Flags: 0 m_Flags: 0
m_NavMeshData: {fileID: 0} m_NavMeshData: {fileID: 0}
--- !u!1001 &7036882172617140290 --- !u!1 &150986195
PrefabInstance: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 150986196}
- component: {fileID: 150986197}
m_Layer: 0
m_Name: JourneyTransitionDirector
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &150986196
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 150986195}
serializedVersion: 2 serializedVersion: 2
m_Modification: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
serializedVersion: 3 m_LocalPosition: {x: 0, y: 0, z: 0}
m_TransformParent: {fileID: 0} m_LocalScale: {x: 1, y: 1, z: 1}
m_Modifications: m_ConstrainProportionsScale: 0
- target: {fileID: 2270435121348859238, guid: 8cee629b6bf44433f98c6e28031d8f6b, type: 3} m_Children: []
propertyPath: m_LocalPosition.x m_Father: {fileID: 256102357}
value: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
objectReference: {fileID: 0} --- !u!114 &150986197
- target: {fileID: 2270435121348859238, guid: 8cee629b6bf44433f98c6e28031d8f6b, type: 3} MonoBehaviour:
propertyPath: m_LocalPosition.z m_ObjectHideFlags: 0
value: 1 m_CorrespondingSourceObject: {fileID: 0}
objectReference: {fileID: 0} m_PrefabInstance: {fileID: 0}
- target: {fileID: 2378040738592165545, guid: 8cee629b6bf44433f98c6e28031d8f6b, type: 3} m_PrefabAsset: {fileID: 0}
propertyPath: m_LocalPosition.x m_GameObject: {fileID: 150986195}
value: 0 m_Enabled: 1
objectReference: {fileID: 0} m_EditorHideFlags: 0
- target: {fileID: 2378040738592165545, guid: 8cee629b6bf44433f98c6e28031d8f6b, type: 3} m_Script: {fileID: 11500000, guid: 12f4067aa70c4d2e81c42f92c28c8253, type: 3}
propertyPath: m_LocalPosition.y m_Name:
value: 0 m_EditorClassIdentifier: Gameplay::Intrepid.Gameplay.Journey.Runtime.Transition.JourneyTransitionDirector
objectReference: {fileID: 0} curtainType: {fileID: 11400000, guid: bc9a28f3d7c64606a8b88c91b94e8805, type: 2}
- target: {fileID: 2378040738592165545, guid: 8cee629b6bf44433f98c6e28031d8f6b, type: 3} backStageService: {fileID: 11400000, guid: c58e40006278948db8d8b1f3477f83ea, type: 2}
propertyPath: m_LocalPosition.z gameplayGate: {fileID: 546849436}
value: 0 stageLoader: {fileID: 188526493}
objectReference: {fileID: 0} landingService: {fileID: 1739106494}
- target: {fileID: 2378040738592165545, guid: 8cee629b6bf44433f98c6e28031d8f6b, type: 3} --- !u!1 &188526492
propertyPath: m_LocalRotation.w GameObject:
value: 1 m_ObjectHideFlags: 0
objectReference: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
- target: {fileID: 2378040738592165545, guid: 8cee629b6bf44433f98c6e28031d8f6b, type: 3} m_PrefabInstance: {fileID: 0}
propertyPath: m_LocalRotation.x m_PrefabAsset: {fileID: 0}
value: 0 serializedVersion: 6
objectReference: {fileID: 0} m_Component:
- target: {fileID: 2378040738592165545, guid: 8cee629b6bf44433f98c6e28031d8f6b, type: 3} - component: {fileID: 188526494}
propertyPath: m_LocalRotation.y - component: {fileID: 188526493}
value: 0 m_Layer: 0
objectReference: {fileID: 0} m_Name: JourneyStageLoader
- target: {fileID: 2378040738592165545, guid: 8cee629b6bf44433f98c6e28031d8f6b, type: 3} m_TagString: Untagged
propertyPath: m_LocalRotation.z m_Icon: {fileID: 0}
value: 0 m_NavMeshLayer: 0
objectReference: {fileID: 0} m_StaticEditorFlags: 0
- target: {fileID: 2378040738592165545, guid: 8cee629b6bf44433f98c6e28031d8f6b, type: 3} m_IsActive: 1
propertyPath: m_LocalEulerAnglesHint.x --- !u!114 &188526493
value: 0 MonoBehaviour:
objectReference: {fileID: 0} m_ObjectHideFlags: 0
- target: {fileID: 2378040738592165545, guid: 8cee629b6bf44433f98c6e28031d8f6b, type: 3} m_CorrespondingSourceObject: {fileID: 0}
propertyPath: m_LocalEulerAnglesHint.y m_PrefabInstance: {fileID: 0}
value: 0 m_PrefabAsset: {fileID: 0}
objectReference: {fileID: 0} m_GameObject: {fileID: 188526492}
- target: {fileID: 2378040738592165545, guid: 8cee629b6bf44433f98c6e28031d8f6b, type: 3} m_Enabled: 1
propertyPath: m_LocalEulerAnglesHint.z m_EditorHideFlags: 0
value: 0 m_Script: {fileID: 11500000, guid: 994b8b26229a4ecd90e04b60b3576495, type: 3}
objectReference: {fileID: 0} m_Name:
- target: {fileID: 7503967939848988478, guid: 8cee629b6bf44433f98c6e28031d8f6b, type: 3} m_EditorClassIdentifier: Gameplay::Intrepid.Gameplay.Journey.Runtime.Loading.JourneyStageLoader
propertyPath: isRunningTest --- !u!4 &188526494
value: 0 Transform:
objectReference: {fileID: 0} m_ObjectHideFlags: 0
- target: {fileID: 7631802331149991959, guid: 8cee629b6bf44433f98c6e28031d8f6b, type: 3} m_CorrespondingSourceObject: {fileID: 0}
propertyPath: m_Name m_PrefabInstance: {fileID: 0}
value: JourneyManager m_PrefabAsset: {fileID: 0}
objectReference: {fileID: 0} m_GameObject: {fileID: 188526492}
m_RemovedComponents: [] serializedVersion: 2
m_RemovedGameObjects: [] m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_AddedGameObjects: [] m_LocalPosition: {x: 0, y: 0, z: 0}
m_AddedComponents: [] m_LocalScale: {x: 1, y: 1, z: 1}
m_SourcePrefab: {fileID: 100100000, guid: 8cee629b6bf44433f98c6e28031d8f6b, type: 3} m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 256102357}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &256102355
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 256102357}
- component: {fileID: 256102356}
- component: {fileID: 256102358}
m_Layer: 0
m_Name: JourneyRuntimeManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &256102356
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 256102355}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 504b23f43fa0408fa7ddb33c266e9c43, type: 3}
m_Name:
m_EditorClassIdentifier: Gameplay::Intrepid.Gameplay.Journey.Runtime.JourneyRuntimeManager
subscriptionId: 8065b3cf65654ae6bdf808aaf83aae00
bootMode: 2
backStageService: {fileID: 11400000, guid: c58e40006278948db8d8b1f3477f83ea, type: 2}
bootDirector: {fileID: 256102358}
transitionDirector: {fileID: 150986197}
stageLoader: {fileID: 188526493}
socketTravelResolver: {fileID: 555055774}
--- !u!4 &256102357
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 256102355}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 10.5, y: 0, z: 3.5}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 150986196}
- {fileID: 546849435}
- {fileID: 188526494}
- {fileID: 1739106493}
- {fileID: 555055775}
- {fileID: 2111783067}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &256102358
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 256102355}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 51174fb8f8104ce4a8be71cf8537e2d4, type: 3}
m_Name:
m_EditorClassIdentifier: Gameplay::Intrepid.Gameplay.Journey.Runtime.JourneyBootDirector
stageToTest: {fileID: 11400000, guid: cc5ccc125b2b14b47bbb669268c567e3, type: 2}
landingStart: {fileID: 2111783067}
stageLoader: {fileID: 188526493}
gameplayGate: {fileID: 546849436}
landingService: {fileID: 1739106494}
--- !u!1 &546849434
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 546849435}
- component: {fileID: 546849436}
m_Layer: 0
m_Name: JourneyGameplayGate
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &546849435
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 546849434}
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: 256102357}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &546849436
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 546849434}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4b95e55c65424b97a5b8b42d5fab8adf, type: 3}
m_Name:
m_EditorClassIdentifier: Gameplay::Intrepid.Gameplay.Journey.Runtime.Gameplay.JourneyGameplayGate
actionBeltManagerTag: {fileID: 11400000, guid: 24d31645b4d544dd69b6ada8858ba50e, type: 2}
--- !u!1 &555055773
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 555055775}
- component: {fileID: 555055774}
m_Layer: 0
m_Name: JourneyTravelResolvers
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &555055774
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 555055773}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 271adef63546438294b61375c3f8486e, type: 3}
m_Name:
m_EditorClassIdentifier: Gameplay::Intrepid.Gameplay.Journey.Runtime.Resolvers.JourneySocketTravelResolver
--- !u!4 &555055775
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 555055773}
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: 256102357}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1739106492
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1739106493}
- component: {fileID: 1739106494}
m_Layer: 0
m_Name: JourneyLandingService
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1739106493
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1739106492}
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: 256102357}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1739106494
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1739106492}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0622c1b8106942cab16c931a05f59c99, type: 3}
m_Name:
m_EditorClassIdentifier: Gameplay::Intrepid.Gameplay.Journey.Runtime.JourneyLandingService
--- !u!1 &2111783066
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2111783067}
m_Layer: 0
m_Name: LandingStart
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2111783067
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2111783066}
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: 256102357}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1660057539 &9223372036854775807 --- !u!1660057539 &9223372036854775807
SceneRoots: SceneRoots:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_Roots: m_Roots:
- {fileID: 7036882172617140290} - {fileID: 256102357}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -35,14 +35,25 @@ namespace Intrepid.Core.Tags
return !IsValid(); return !IsValid();
} }
public bool IsLoaded()
{
var scene = SceneManager.GetSceneByName(Code);
return scene.IsValid() && scene.isLoaded;
}
public AsyncOperation LoadAsync(LoadSceneMode mode = LoadSceneMode.Additive) public AsyncOperation LoadAsync(LoadSceneMode mode = LoadSceneMode.Additive)
{ {
return SceneManager.LoadSceneAsync(SceneName, mode); return SceneManager.LoadSceneAsync(SceneName, mode);
} }
public void UnloadAsync() public AsyncOperation UnloadAsync()
{ {
SceneManager.UnloadSceneAsync(SceneName); return SceneManager.UnloadSceneAsync(SceneName);
}
public override string ToString()
{
return SceneName;
} }
} }
} }

View File

@ -29,5 +29,17 @@ namespace Intrepid.Gameplay.Journey
return null; return null;
} }
public override string ToString()
{
var d = directionality switch
{
JConnectionDirectionality.Bidirectional => "<=>",
JConnectionDirectionality.AToB => " =>",
JConnectionDirectionality.BToA => "<= ",
_ => "???"
};
return $"{endpointAId} {d} {endpointBId}";
}
} }
} }

View File

@ -1,228 +0,0 @@
using System;
using System.Collections;
using Intrepid.Core.Camera;
using Intrepid.Diagnostics;
using Intrepid.GameManagers;
using Intrepid.Gameplay.Data;
using Intrepid.Gameplay.Entities.Player.ActionBelt.Events;
using Intrepid.Gameplay.Entities.Player.Tags;
using Intrepid.Gameplay.Journey.Messages.Events;
using Intrepid.Integration.Input;
using Intrepid.SimpleEvents;
using Intrepid.Theatre.BackStage;
using Intrepid.Theatre.Curtain;
using Intrepid.Utilities;
using Sirenix.OdinInspector;
using UnityEngine;
namespace Intrepid.Gameplay.Journey
{
public class JourneyManager : SingletonEventListener<JourneyManager>, IBackStageProcessor
{
private const string Id = "JourneyManager";
[GroupConfigurations, SerializeField] private CurtainTypeTag curtainType;
[GroupInjections, SerializeField] private ActionBeltManagerTag actionBeltManager;
[GroupInjections, SerializeField] private BackStageService backStageService;
#if UNITY_EDITOR
[GroupDebug, SerializeField, ToggleLeft] private bool isRunningTest;
[GroupDebug, SerializeField, ShowIf("IsRunningTest")] private StageTag stageToTest;
[GroupDebug, SerializeField, ShowIf("IsRunningTest")] private Transform landingStart;
#endif
private StageStateMachine StageStateMachine { get; } = new();
private CurtainTypeTag CurtainType => curtainType;
private BackStageService BackStageService => backStageService;
#if UNITY_EDITOR
private bool IsRunningTest => isRunningTest;
#endif
private StageTag StageToChange { get; set; }
private IBackStageWindowExecution CallbackProcessors { get; set; }
private string DestinyEndpoint { get; set; }
private InputSchema LastInputSchema { get; set; } = InputSchema.None;
private bool IsBooting { get; set; } = true;
public bool IsProcessFinished => !IsBooting && StageStateMachine.IsLoadingFinished && !CameraSystem.Instance.IsCameraBlending;
protected override void InitializeVariables()
{
SingletonInstantiation(false, manager =>
{
manager.StageStateMachine.LoadMachine(JourneyService.Instance.StageTags);
});
}
protected override void OnBootstrap()
{
#if UNITY_EDITOR
if (IsRunningTest && stageToTest.IsNotNull())
{
LoadJourneyForTesting(stageToTest);
return;
}
#endif
if (SentinelDataStorage.Instance.HasLatestSaveStationData)
{
var request = SentinelDataStorage.Instance.LoadJourneyRequest;
StageStateMachine.InitMachine(request.StageTag);
StartCoroutine(WaitUntilStageLoadingIsFinished(() =>
{
Proxy.Instance.EventBus.Raise(new StageDispatchDeploymentPointEvent
{
DeploymentPoint = request.DeploymentPoint,
DeploymentDirection = Vector2.down,
});
StartCoroutine(WaitingNSecs(1, () => IsBooting = false));
}));
}
}
protected override void Subscriptions()
{
}
private void Update()
{
BackStageService.UpdateCurtains();
}
protected override void OnTearDown()
{
StageStateMachine.TearDown();
}
[GroupDebug, Button(ButtonSizes.Large, ButtonStyle.FoldoutButton)]
private void LoadJourneyForTesting(StageTag stageTag, Transform landing = null)
{
if (stageTag.IsNull())
{
DLogger.LogWarn("stage tag is empty, you should bootstrap manually");
return;
}
StageStateMachine.InitMachine(stageTag);
IsBooting = false;
if (IsRunningTest)
{
Proxy.Instance.EventBus.Raise(new StageDispatchDeploymentPointEvent
{
DeploymentPoint = landing?.position ?? landingStart.position,
DeploymentDirection = Vector2.down,
});
StartCoroutine(WaitingNSecs(1, () =>
{
var openCurtainProgress = Proxy.Instance.CurtainStateMachine.RaiseCommand(CurtainCommandType.Open);
StartCoroutine(WaitUntilCurtainGetsOpened(openCurtainProgress, AfterOpened));
}));
}
else
{
StartCoroutine(WaitUntilStageLoadingIsFinished(() =>
{
Proxy.Instance.EventBus.Raise(new StageDispatchDeploymentPointEvent
{
DeploymentPoint = landing?.position ?? landingStart.position,
DeploymentDirection = Vector2.down,
});
StartCoroutine(WaitingNSecs(1, () =>
{
var openCurtainProgress = Proxy.Instance.CurtainStateMachine.RaiseCommand(CurtainCommandType.Open);
StartCoroutine(WaitUntilCurtainGetsOpened(openCurtainProgress, AfterOpened));
}));
}));
}
}
private IEnumerator WaitUntilCurtainGetsOpened(ICurtainProgress openCurtainProgress, Action action)
{
yield return new WaitUntil(openCurtainProgress.IsFinished);
action?.Invoke();
}
private IEnumerator WaitUntilStageLoadingIsFinished(Action action)
{
yield return new WaitUntil(() => StageStateMachine?.IsLoadingFinished ?? false);
action?.Invoke();
}
private IEnumerator WaitingNSecs(float nSecs, Action action)
{
yield return new WaitForSeconds(nSecs);
action?.Invoke();
}
[GroupDebug, Button(ButtonSizes.Large, ButtonStyle.FoldoutButton)]
private void ChangeStageForTesting(StageTag stageTag, string destinyEndpoint)
{
ChangeStageTo(stageTag, destinyEndpoint);
}
public void ChangeStageTo(
StageTag stageTag,
string destinyEndpoint,
IBackStageWindowExecution callbacks = null)
{
#if UNITY_EDITOR
if (IsRunningTest)
{
DLogger.LogDebug("that is a test and has a fake journey manager. STAGE WILL NOT BE CHANGED.");
return;
}
#endif
if (stageTag.IsNull() || string.IsNullOrEmpty(stageTag.Code))
{
throw new ArgumentException("stage tag cannot be null or empty");
}
if (StageStateMachine.CurrentStageTag == stageTag) return;
DestinyEndpoint = destinyEndpoint;
if (BackStageService.KickProcess(CurtainType, Id, this))
{
StageToChange = stageTag;
}
CallbackProcessors = callbacks;
}
public void AfterOpened()
{
DestinyEndpoint = null;
CallbackProcessors?.AfterOpened();
Proxy.Instance.EventBus.Raise(new ChangeStageEndEvent());
var lastInputSchema = LastInputSchema == InputSchema.None
? InputSchema.Sentinel
: LastInputSchema;
InputService.Instance.ChangeInputSchema(lastInputSchema);
Proxy.Instance.EventBus.Raise(new ActionBeltEnableEvent
{
ActionBeltManger = actionBeltManager,
});
LastInputSchema = InputSchema.None;
}
public void BeforeOpening()
{
CallbackProcessors?.BeforeOpening();
Proxy.Instance.EventBus.Raise(new ChangeStageLandingOnStageStepEvent
{
DestinyEndpoint = DestinyEndpoint
});
}
public void AfterClosed()
{
Proxy.Instance.EventBus.Raise(new ChangeStageStartEvent());
StageStateMachine.ChangeState(StageToChange);
CallbackProcessors?.AfterClosed();
}
public void BeforeClosing()
{
LastInputSchema = InputService.Instance.CurrentInputSchema;
InputService.Instance.ChangeInputSchema(InputSchema.None);
CallbackProcessors?.BeforeClosing();
Proxy.Instance.EventBus.Raise(new ChangeStageTouchedEvent());
Proxy.Instance.EventBus.Raise(new ActionBeltDisableEvent
{
ActionBeltManger = actionBeltManager,
});
}
}
}

View File

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

View File

@ -2,8 +2,9 @@ using Intrepid.SimpleEvents;
namespace Intrepid.Gameplay.Journey.Messages.Events namespace Intrepid.Gameplay.Journey.Messages.Events
{ {
public class ChangeStageLandingOnStageStepEvent : IEventBase public class JourneyLandingRequestedEvent : IEventBase
{ {
public StageTag DestinyStageTag { get; set; }
public string DestinyEndpoint { get; set; } public string DestinyEndpoint { get; set; }
} }
} }

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 968d34da989d49b39bf854e903730f77
timeCreated: 1782479245

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 76961f885fe94924aff318fda68ded4e
timeCreated: 1782479905

View File

@ -0,0 +1,10 @@
using Intrepid.SimpleEvents;
namespace Intrepid.Gameplay.Journey.Runtime.Events
{
public class StageSocketChangeEnterEvent : IEventBase
{
public StageTag StageTag { get; set; }
public string EndpointId { get; set; }
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f71691b3de58447ea7b65a8a9b55909e
timeCreated: 1782479924

View File

@ -0,0 +1,10 @@
using Intrepid.SimpleEvents;
namespace Intrepid.Gameplay.Journey.Runtime.Events
{
public class StageSocketChangeExitEvent : IEventBase
{
public StageTag StageTag { get; set; }
public string EndpointId { get; set; }
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e9ae6f44194a4369b2fde96bd3de6a7b
timeCreated: 1782480060

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0e2fb89b11644e6ea8544e5e13015659
timeCreated: 1782483598

View File

@ -0,0 +1,95 @@
using Intrepid.Diagnostics;
using Intrepid.GameManagers;
using Intrepid.Gameplay.Entities.Player.ActionBelt.Events;
using Intrepid.Gameplay.Entities.Player.Tags;
using Intrepid.Gameplay.Journey.Runtime.Messages;
using Intrepid.Integration.Input;
using Intrepid.Utilities;
using UnityEngine;
namespace Intrepid.Gameplay.Journey.Runtime.Gameplay
{
public sealed class JourneyGameplayGate : MonoBehaviour
{
[GroupInjections, SerializeField] private ActionBeltManagerTag actionBeltManagerTag;
public JourneyGameplayGateState State { get; private set; } = JourneyGameplayGateState.Open;
public bool IsLocked => State == JourneyGameplayGateState.Locked;
public JourneyGameplayGateContext Lock(JourneyTravelRequest request)
{
if (IsLocked)
{
DLogger.LogWarn($"tried to lock gameplay, but it is already locked. Request: {request}", ctx: this);
return JourneyGameplayGateContext.Invalid;
}
var previousInputSchema = InputService.Instance.CurrentInputSchema;
InputService.Instance.ChangeInputSchema(InputSchema.None);
Proxy.Instance.EventBus.Raise(new ActionBeltDisableEvent
{
ActionBeltManger = actionBeltManagerTag,
});
State = JourneyGameplayGateState.Locked;
DLogger.LogDebug($"locked gameplay. Previous input schema: {previousInputSchema}. Request: {request}", ctx: this);
return new JourneyGameplayGateContext(previousInputSchema);
}
public void Unlock(JourneyGameplayGateContext context, JourneyTravelRequest request)
{
if (!IsLocked)
{
DLogger.LogWarn($"tried to unlock gameplay, but it is already open. Request: {request}", ctx: this);
return;
}
if (context is not { IsValid: true })
{
DLogger.LogWarn($"received an invalid unlock context. Falling back to Sentinel input. Request: {request}", ctx: this);
RestoreInput(InputSchema.Sentinel);
}
else
{
var schemaToRestore = context.PreviousInputSchema == InputSchema.None
? InputSchema.Sentinel
: context.PreviousInputSchema;
RestoreInput(schemaToRestore);
}
Proxy.Instance.EventBus.Raise(new ActionBeltEnableEvent
{
ActionBeltManger = actionBeltManagerTag,
});
State = JourneyGameplayGateState.Open;
DLogger.LogDebug($"unlocked gameplay. Request: {request}", ctx: this);
}
public void OpenForBoot()
{
InputService.Instance.ChangeInputSchema(InputSchema.Sentinel);
Proxy.Instance.EventBus.Raise(new ActionBeltEnableEvent
{
ActionBeltManger = actionBeltManagerTag,
});
State = JourneyGameplayGateState.Open;
DLogger.LogDebug("opened gameplay for boot.", ctx: this);
}
private static void RestoreInput(InputSchema inputSchema)
{
InputService.Instance.ChangeInputSchema(inputSchema);
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4b95e55c65424b97a5b8b42d5fab8adf
timeCreated: 1782483693

View File

@ -0,0 +1,24 @@
using Intrepid.Integration.Input;
namespace Intrepid.Gameplay.Journey.Runtime.Gameplay
{
public sealed class JourneyGameplayGateContext
{
public InputSchema PreviousInputSchema { get; }
public bool IsValid { get; }
public JourneyGameplayGateContext(InputSchema previousInputSchema)
{
PreviousInputSchema = previousInputSchema;
IsValid = true;
}
public static JourneyGameplayGateContext Invalid { get; } = new();
private JourneyGameplayGateContext()
{
PreviousInputSchema = InputSchema.None;
IsValid = false;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3bd2bd007c5e45858cb0c6ae41437211
timeCreated: 1782483662

View File

@ -0,0 +1,8 @@
namespace Intrepid.Gameplay.Journey.Runtime.Gameplay
{
public enum JourneyGameplayGateState
{
Open,
Locked
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1510aa8be0fa4dd78449fe387f230f8a
timeCreated: 1782483627

View File

@ -0,0 +1,171 @@
using System;
using System.Collections;
using Intrepid.Core.Camera;
using Intrepid.Diagnostics;
using Intrepid.GameManagers;
using Intrepid.Gameplay.Data;
using Intrepid.Gameplay.Journey.Runtime.Gameplay;
using Intrepid.Gameplay.Journey.Runtime.Loading;
using Intrepid.Theatre.Curtain;
using Intrepid.Utilities;
using UnityEngine;
namespace Intrepid.Gameplay.Journey.Runtime
{
public class JourneyBootDirector : MonoBehaviour
{
#if UNITY_EDITOR
[GroupDebug, SerializeField] private StageTag stageToTest;
[GroupDebug, SerializeField] private Transform landingStart;
#endif
[GroupInjections, SerializeField] private JourneyStageLoader stageLoader;
[GroupInjections, SerializeField] private JourneyGameplayGate gameplayGate;
[GroupInjections, SerializeField] private JourneyLandingService landingService;
public bool IsBooted { get; private set; }
public void StartBoot(
JourneyRuntimeBootMode bootMode,
Action<StageTag> onFinished,
Action onFailed)
{
#if UNITY_EDITOR
if (JourneyRuntimeBootMode.UseOpenedTestStage == bootMode)
{
StartCoroutine(BootOpenedStageForTesting(stageToTest, landingStart, onFinished, onFailed));
return;
}
if (JourneyRuntimeBootMode.LoadTestStage == bootMode)
{
if (landingStart.IsNull())
{
DLogger.LogWarn("cannot boot test stage because landing start is null.", ctx: this);
onFailed?.Invoke();
return;
}
StartCoroutine(BootStage(
stageToTest,
landingStart.position,
Vector2.down,
true,
onFinished,
onFailed));
return;
}
#endif
if (SentinelDataStorage.Instance.HasLatestSaveStationData)
{
var request = SentinelDataStorage.Instance.LoadJourneyRequest;
StartCoroutine(BootStage(
request.StageTag,
request.DeploymentPoint,
Vector2.down,
false,
onFinished,
onFailed));
return;
}
DLogger.LogWarn("no boot request.", ctx: this);
onFailed?.Invoke();
}
private IEnumerator BootStage(StageTag stageTag,
Vector3 deploymentPoint,
Vector2 deploymentDirection,
bool isFakeBoot,
Action<StageTag> onFinished = null,
Action onFailed = null)
{
if (stageTag.IsNull())
{
DLogger.LogWarn("cannot boot null stage.", ctx: this);
onFailed?.Invoke();
yield break;
}
DLogger.LogDebug($"booting stage: {stageTag.StageId}", ctx: this);
stageLoader.Init(stageTag);
yield return new WaitUntil(() => stageLoader.IsLoadingFinished);
landingService.DeployAt(deploymentPoint, deploymentDirection);
yield return null;
yield return new WaitUntil(() => !CameraSystem.Instance.IsCameraBlending);
if (isFakeBoot)
{
var openCurtainProgress = Proxy.Instance.CurtainStateMachine.RaiseCommand(CurtainCommandType.Open);
if (openCurtainProgress != null)
{
yield return new WaitUntil(openCurtainProgress.IsFinished);
}
}
gameplayGate.OpenForBoot();
onFinished?.Invoke(stageTag);
DLogger.LogDebug($"booted stage: {stageTag.StageId}", ctx: this);
}
#if UNITY_EDITOR
private IEnumerator BootOpenedStageForTesting(
StageTag stageTag,
Transform landing,
Action<StageTag> onFinished = null,
Action onFailed = null)
{
if (stageTag.IsNull())
{
DLogger.LogWarn("cannot boot opened test stage because stage tag is null.", ctx: this);
onFailed?.Invoke();
yield break;
}
if (landing.IsNull())
{
DLogger.LogWarn("cannot boot opened test stage because landing is null.", ctx: this);
onFailed?.Invoke();
yield break;
}
DLogger.LogDebug($"adopting opened stage: {stageTag.StageId}", ctx: this);
if (!stageLoader.AdoptLoadedStage(stageTag))
{
DLogger.LogWarn($"could not adopt opened stage: {stageTag.StageId}", ctx: this);
onFailed?.Invoke();
yield break;
}
landingService.DeployAt(landing.position, Vector2.down);
yield return null;
yield return new WaitUntil(() => !CameraSystem.Instance.IsCameraBlending);
var openCurtainProgress = Proxy.Instance.CurtainStateMachine.RaiseCommand(CurtainCommandType.Open);
if (openCurtainProgress != null)
{
yield return new WaitUntil(openCurtainProgress.IsFinished);
}
gameplayGate.OpenForBoot();
onFinished?.Invoke(stageTag);
DLogger.LogDebug($"booted opened test stage: {stageTag.StageId}", ctx: this);
}
#endif
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 51174fb8f8104ce4a8be71cf8537e2d4
timeCreated: 1782494195

View File

@ -0,0 +1,27 @@
using Intrepid.GameManagers;
using Intrepid.Gameplay.Journey.Messages.Events;
using UnityEngine;
namespace Intrepid.Gameplay.Journey.Runtime
{
public class JourneyLandingService : MonoBehaviour
{
public void LandAtEndpoint(StageTag destinyStageTag, string destinyEndpointId)
{
Proxy.Instance.EventBus.Raise(new JourneyLandingRequestedEvent
{
DestinyStageTag = destinyStageTag,
DestinyEndpoint = destinyEndpointId
});
}
public void DeployAt(Vector3 deploymentPoint, Vector2 deploymentDirection)
{
Proxy.Instance.EventBus.Raise(new StageDispatchDeploymentPointEvent
{
DeploymentPoint = deploymentPoint,
DeploymentDirection = deploymentDirection
});
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0622c1b8106942cab16c931a05f59c99
timeCreated: 1782485859

View File

@ -0,0 +1,193 @@
using Intrepid.Diagnostics;
using Intrepid.Gameplay.Journey.Runtime.Events;
using Intrepid.Gameplay.Journey.Runtime.Loading;
using Intrepid.Gameplay.Journey.Runtime.Messages;
using Intrepid.Gameplay.Journey.Runtime.Resolvers;
using Intrepid.Gameplay.Journey.Runtime.State;
using Intrepid.Gameplay.Journey.Runtime.Transition;
using Intrepid.SimpleEvents;
using Intrepid.Theatre.BackStage;
using Intrepid.Utilities;
using UnityEngine;
namespace Intrepid.Gameplay.Journey.Runtime
{
public enum JourneyRuntimeBootMode
{
FromSave,
LoadTestStage,
UseOpenedTestStage
}
public class JourneyRuntimeManager : SingletonEventListener<JourneyRuntimeManager>
{
#if UNITY_EDITOR
[GroupDebug, SerializeField]
private JourneyRuntimeBootMode bootMode = JourneyRuntimeBootMode.FromSave;
#endif
[GroupInjections, SerializeField] private BackStageService backStageService;
[GroupInjections, SerializeField] private JourneyBootDirector bootDirector;
[GroupInjections, SerializeField] private JourneyTransitionDirector transitionDirector;
[GroupInjections, SerializeField] private JourneyStageLoader stageLoader;
[GroupInjections, SerializeField] private JourneySocketTravelResolver socketTravelResolver;
private JourneyRuntimeState RuntimeState { get; } = new();
public JourneyRuntimePhase Phase => RuntimeState.Phase;
public bool IsBooted => RuntimeState.IsBooted;
public bool IsTransitionRunning => RuntimeState.IsTransitionRunning;
public StageTag CurrentStageTag => RuntimeState.CurrentStageTag;
private JourneyRuntimeBootMode BootMode
{
get
{
#if UNITY_EDITOR
return bootMode;
#else
return JourneyRuntimeBootMode.FromSave;
#endif
}
}
protected override void InitializeVariables()
{
SingletonInstantiation(false, _ =>
{
stageLoader.LoadMachine();
});
}
protected override void OnBootstrap()
{
RuntimeState.BeginBoot();
bootDirector.StartBoot(
BootMode,
OnBootFinished,
OnBootFailed);
}
protected override void OnTearDown()
{
stageLoader.TearDown();
RuntimeState.Reset();
}
protected override void Subscriptions()
{
Subscribe<StageSocketChangeEnterEvent>(OnStageSocketChangeEnterEvent);
}
private void Update()
{
backStageService.UpdateCurtains();
}
private void OnStageSocketChangeEnterEvent(StageSocketChangeEnterEvent e)
{
if (!CanAcceptTravelRequest())
{
return;
}
if (!socketTravelResolver.TryCreateSocketTravelRequest(
RuntimeState.CurrentStageTag,
e.StageTag,
e.EndpointId,
out var request))
{
return;
}
Travel(request);
}
private bool CanAcceptTravelRequest()
{
if (RuntimeState.CanAcceptTravelRequest(out var reason))
{
return true;
}
DLogger.LogWarn(
$"rejected travel request because {reason}. State: {RuntimeState}",
ctx: this);
return false;
}
private void Travel(JourneyTravelRequest request)
{
if (!RuntimeState.TryBeginTransition(request, out var reason))
{
DLogger.LogWarn(
$"rejected travel because {reason}. " +
$"Request: {request}. State: {RuntimeState}",
ctx: this);
return;
}
DLogger.LogDebug(
$"travelling: {request}. State: {RuntimeState}",
ctx: this);
var started = transitionDirector.StartTravel(
request,
OnTravelFinished,
OnTravelFailed);
if (started)
{
return;
}
if (RuntimeState.IsTransitionRunning)
{
RuntimeState.FailTransition();
}
DLogger.LogWarn(
$"failed to start transition. Request: {request}. State: {RuntimeState}",
ctx: this);
}
private void OnBootFinished(StageTag stageTag)
{
RuntimeState.CompleteBoot(stageTag);
DLogger.LogDebug(
$"boot finished: {stageTag}. State: {RuntimeState}",
ctx: this);
}
private void OnBootFailed()
{
RuntimeState.FailBoot();
DLogger.LogWarn(
$"boot failed. State: {RuntimeState}",
ctx: this);
}
private void OnTravelFinished(JourneyTravelRequest request)
{
RuntimeState.CompleteTransition(request);
DLogger.LogDebug(
$"travel finished: {request}. State: {RuntimeState}",
ctx: this);
}
private void OnTravelFailed(JourneyTravelRequest request)
{
RuntimeState.FailTransition();
DLogger.LogWarn(
$"travel failed: {request}. State: {RuntimeState}",
ctx: this);
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 504b23f43fa0408fa7ddb33c266e9c43
timeCreated: 1782479255

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9811c03fa3904df1934d08efcd4a54ce
timeCreated: 1782485360

View File

@ -0,0 +1,84 @@
using System;
using Intrepid.Diagnostics;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Intrepid.Gameplay.Journey.Runtime.Loading
{
public sealed class JourneyStageLoader : MonoBehaviour
{
private StageStateMachine StageStateMachine { get; } = new();
public StageTag CurrentStageTag => StageStateMachine.CurrentStageTag;
public bool IsLoadingFinished => StageStateMachine.IsLoadingFinished;
public bool HasCurrentStage => CurrentStageTag.IsNotNull();
public void LoadMachine()
{
StageStateMachine.LoadMachine(JourneyService.Instance.StageTags);
DLogger.LogDebug("loaded stage machine.", ctx: this);
}
public void Init(StageTag stageTag)
{
if (stageTag.IsNull())
{
DLogger.LogWarn("cannot init null stage.", ctx: this);
return;
}
StageStateMachine.InitMachine(stageTag);
DLogger.LogDebug($"initialized stage: {stageTag.StageId}", ctx: this);
}
public void ChangeTo(StageTag stageTag)
{
if (stageTag.IsNull())
{
DLogger.LogWarn("cannot change to null stage.", ctx: this);
return;
}
if (CurrentStageTag == stageTag)
{
DLogger.LogDebug($"ignored change to same stage: {stageTag.StageId}", ctx: this);
return;
}
StageStateMachine.ChangeState(stageTag);
DLogger.LogDebug($"changing to stage: {stageTag.StageId}", ctx: this);
}
public void TearDown()
{
StageStateMachine.TearDown();
DLogger.LogDebug("tear down.", ctx: this);
}
public bool AdoptLoadedStage(StageTag stageTag)
{
if (stageTag.IsNull())
{
DLogger.LogWarn("cannot adopt null stage.", ctx: this);
return false;
}
var scene = SceneManager.GetSceneByName(stageTag.Code);
if (!scene.IsValid() || !scene.isLoaded)
{
DLogger.LogWarn($"cannot adopt stage {stageTag.StageId}; scene is not loaded.", ctx: this);
return false;
}
StageStateMachine.InitMachine(stageTag);
DLogger.LogDebug($"adopted loaded stage: {stageTag.StageId}", ctx: this);
return true;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 994b8b26229a4ecd90e04b60b3576495
timeCreated: 1782485474

View File

@ -0,0 +1,167 @@
using System;
using Intrepid.Diagnostics;
using Intrepid.FSM;
using Intrepid.Structures;
using UnityEngine;
namespace Intrepid.Gameplay.Journey.Runtime.Loading
{
public enum StageLoadOwnership
{
LoadedByJourney,
AdoptedFromEditor
}
[Serializable]
public class StageLoadingService : IState<StageTag, StageLoadingService>
{
private StageTag StageTag { get; }
private StageLoadOwnership Ownership { get; }
private bool UnloadOnExit { get; }
private AsyncOperation LoadOperation { get; set; }
private AsyncOperation UnloadOperation { get; set; }
private bool HasEntered { get; set; }
public bool IsLoadingFinished
{
get
{
if (StageTag.IsNull())
{
return false;
}
if (StageTag.IsLoaded())
{
return true;
}
return LoadOperation?.isDone ?? false;
}
}
public bool IsUnloading => UnloadOperation is { isDone: false };
public bool CanEnterState => true;
public bool CanExitState => true;
private StageLoadingService(
StageTag stageTag,
StageLoadOwnership ownership = StageLoadOwnership.LoadedByJourney,
bool unloadOnExit = true)
{
StageTag = stageTag;
Ownership = ownership;
UnloadOnExit = unloadOnExit;
}
public static StageLoadingService CreateLoadedByJourney(StageTag stageTag)
{
return new StageLoadingService(stageTag);
}
public static StageLoadingService CreateAdoptedFromEditor(StageTag stageTag, bool unloadOnExit = true)
{
return new StageLoadingService(stageTag, StageLoadOwnership.AdoptedFromEditor, unloadOnExit);
}
public StageTag GetStateKey()
{
return StageTag;
}
public StageLoadingService Implementation()
{
return this;
}
public void OnEnterState(ParameterStore ps)
{
HasEntered = true;
UnloadOperation = null;
if (StageTag.IsNull())
{
DLogger.LogWarn("cannot enter stage loading state because StageTag is null.");
return;
}
if (StageTag.IsLoaded())
{
LoadOperation = null;
DLogger.LogDebug($"stage is already loaded, adopting loaded scene: {StageTag}");
return;
}
if (Ownership == StageLoadOwnership.AdoptedFromEditor)
{
LoadOperation = null;
DLogger.LogWarn($"stage was marked as adopted from editor, but scene is not loaded: {StageTag}");
return;
}
if (!StageTag.IsReadyToBeLoaded())
{
LoadOperation = null;
DLogger.LogWarn($"stage is not ready to be loaded: {StageTag}");
return;
}
LoadOperation = StageTag.LoadAsync();
if (LoadOperation == null)
{
DLogger.LogWarn($"stage load operation returned null: {StageTag}");
return;
}
DLogger.LogDebug($"started loading stage: {StageTag}");
}
public void OnExitState()
{
if (StageTag.IsNull())
{
DLogger.LogWarn("cannot exit stage loading state because StageTag is null.");
return;
}
if (!HasEntered)
{
DLogger.LogWarn($"stage loading state was never entered. Ignoring unload: {StageTag}");
return;
}
if (!UnloadOnExit)
{
DLogger.LogDebug($"stage unload skipped by policy: {StageTag}");
return;
}
if (IsUnloading)
{
DLogger.LogWarn($"stage is already unloading: {StageTag}");
return;
}
if (!StageTag.IsLoaded())
{
DLogger.LogWarn($"stage is already unloaded. Ignoring unload: {StageTag}");
return;
}
UnloadOperation = StageTag.UnloadAsync();
if (UnloadOperation == null)
{
DLogger.LogWarn($"stage unload operation returned null: {StageTag}");
return;
}
DLogger.LogDebug($"started unloading stage: {StageTag}");
}
}
}

View File

@ -2,7 +2,7 @@ using System.Collections.Generic;
using Intrepid.Diagnostics; using Intrepid.Diagnostics;
using Intrepid.FSM; using Intrepid.FSM;
namespace Intrepid.Gameplay.Journey namespace Intrepid.Gameplay.Journey.Runtime.Loading
{ {
public sealed class StageStateMachine public sealed class StageStateMachine
{ {
@ -22,7 +22,7 @@ namespace Intrepid.Gameplay.Journey
} }
foreach (var stageTag in stageTags) foreach (var stageTag in stageTags)
{ {
StateMachine.AddState(new StageLoadingService(stageTag)); StateMachine.AddState(StageLoadingService.CreateLoadedByJourney(stageTag));
} }
} }

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 76c91cc3db0144478402d49794640b0f
timeCreated: 1782479898

View File

@ -0,0 +1,16 @@
namespace Intrepid.Gameplay.Journey.Runtime.Messages
{
public sealed class JourneyTravelRequest
{
public StageTag OriginStageTag { get; set; }
public string OriginEndpointId { get; set; }
public StageTag DestinyStageTag { get; set; }
public string DestinyEndpointId { get; set; }
public JConnection Connection { get; set; }
public override string ToString()
{
return $"{OriginStageTag}.{OriginEndpointId} --> {DestinyStageTag}.{DestinyEndpointId}";
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8805a7851de34e9598481769d7171bc5
timeCreated: 1782481515

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 734f88d523a54cb08fc2d351a8563799
timeCreated: 1782492642

View File

@ -0,0 +1,383 @@
using System;
using Intrepid.Diagnostics;
using Intrepid.Gameplay.Journey.Runtime.Messages;
using UnityEngine;
namespace Intrepid.Gameplay.Journey.Runtime.Resolvers
{
public sealed class JourneySocketTravelResolver : MonoBehaviour
{
public bool TryCreateSocketTravelRequest(
StageTag currentStageTag,
StageTag originStageTag,
string originEndpointId,
out JourneyTravelRequest request)
{
request = null;
if (!ValidateOriginStage(currentStageTag, originStageTag, originEndpointId))
{
return false;
}
if (!TryGetOriginEndpoint(
originStageTag,
originEndpointId,
out var originEndpoint))
{
return false;
}
if (!TryGetSingleSocketConnection(
originStageTag,
originEndpointId,
out var connection))
{
return false;
}
if (!ValidateConnectionDirection(
connection,
originEndpointId,
originStageTag))
{
return false;
}
if (!TryGetDestinyEndpoint(
connection,
originEndpointId,
originStageTag,
out var destinyEndpointId,
out var destinyEndpoint))
{
return false;
}
if (!TryGetDestinyStageTag(
destinyEndpointId,
originStageTag,
originEndpointId,
out var destinyStageTag))
{
return false;
}
request = new JourneyTravelRequest
{
OriginStageTag = originStageTag,
OriginEndpointId = originEndpoint.id,
DestinyStageTag = destinyStageTag,
DestinyEndpointId = destinyEndpoint.id,
Connection = connection,
};
DLogger.LogDebug($"resolved socket travel: {request}", ctx: this);
return true;
}
private bool ValidateOriginStage(
StageTag currentStageTag,
StageTag originStageTag,
string originEndpointId)
{
if (originStageTag.IsNull())
{
DLogger.LogWarn(
"cannot resolve travel because origin stage is null. " +
$"Endpoint: {originEndpointId}",
ctx: this);
return false;
}
if (string.IsNullOrWhiteSpace(originStageTag.StageId))
{
DLogger.LogWarn(
"cannot resolve travel because origin stage has no StageId. " +
$"Stage: {originStageTag}, Endpoint: {originEndpointId}",
ctx: this);
return false;
}
if (string.IsNullOrWhiteSpace(originEndpointId))
{
DLogger.LogWarn(
"cannot resolve travel because origin endpoint id is empty. " +
$"Stage: {originStageTag.StageId}",
ctx: this);
return false;
}
if (currentStageTag.IsNull())
{
DLogger.LogWarn(
"cannot resolve travel because current stage is null. " +
$"Origin stage: {originStageTag.StageId}, Endpoint: {originEndpointId}",
ctx: this);
return false;
}
if (currentStageTag != originStageTag)
{
DLogger.LogWarn(
"rejected travel from a stage that is not current. " +
$"Current: {currentStageTag.StageId}, " +
$"Origin: {originStageTag.StageId}, " +
$"Endpoint: {originEndpointId}",
ctx: this);
return false;
}
return true;
}
private bool TryGetOriginEndpoint(
StageTag originStageTag,
string originEndpointId,
out JEndpoint originEndpoint)
{
originEndpoint = null;
if (!JourneyService.Instance.TryGetEndpoint(originEndpointId, out originEndpoint))
{
DLogger.LogWarn(
"could not find origin endpoint. " +
$"Stage: {originStageTag.StageId}, Endpoint: {originEndpointId}",
ctx: this);
return false;
}
if (!string.Equals(originEndpoint.stageId, originStageTag.StageId, StringComparison.Ordinal))
{
DLogger.LogWarn(
"rejected endpoint because it does not belong to the origin stage. " +
$"Origin stage: {originStageTag.StageId}, " +
$"Endpoint: {originEndpoint.id}, " +
$"Endpoint stage: {originEndpoint.stageId}",
ctx: this);
return false;
}
if (!originEndpoint.IsSocket)
{
DLogger.LogWarn(
"rejected endpoint because it is not a socket. " +
$"Stage: {originStageTag.StageId}, " +
$"Endpoint: {originEndpoint.id}, " +
$"Kind: {originEndpoint.kind}",
ctx: this);
return false;
}
return true;
}
private bool TryGetSingleSocketConnection(
StageTag originStageTag,
string originEndpointId,
out JConnection connection)
{
connection = null;
if (!JourneyService.Instance.TryGetJConnections(
originStageTag.StageId,
originEndpointId,
out var connections))
{
DLogger.LogWarn(
"could not find connection list for socket endpoint. " +
$"Stage: {originStageTag.StageId}, Endpoint: {originEndpointId}",
ctx: this);
return false;
}
switch (connections.Count)
{
case <= 0:
DLogger.LogWarn(
$"found no connection from socket endpoint. " +
$"Stage: {originStageTag.StageId}, Endpoint: {originEndpointId}",
ctx: this);
return false;
case > 1:
DLogger.LogWarn(
"found multiple connections from socket endpoint. " +
"Socket endpoints should have exactly one connection. " +
$"Stage: {originStageTag.StageId}, Endpoint: {originEndpointId}, " +
$"Connections: {connections.Count}",
ctx: this);
return false;
}
connection = connections[0];
if (connection == null)
{
DLogger.LogWarn(
"found a null connection. " +
$"Stage: {originStageTag.StageId}, Endpoint: {originEndpointId}",
ctx: this);
return false;
}
if (!connection.ContainsEndpoint(originEndpointId))
{
DLogger.LogWarn(
"rejected connection because it does not contain the origin endpoint. " +
$"Stage: {originStageTag.StageId}, " +
$"Endpoint: {originEndpointId}, " +
$"Connection: {connection}",
ctx: this);
return false;
}
return true;
}
private bool ValidateConnectionDirection(
JConnection connection,
string originEndpointId,
StageTag originStageTag)
{
if (CanTravelThrough(connection, originEndpointId))
{
return true;
}
DLogger.LogWarn(
"rejected travel because connection direction does not allow it. " +
$"Stage: {originStageTag.StageId}, " +
$"Origin endpoint: {originEndpointId}, " +
$"Connection: {connection}",
ctx: this);
return false;
}
private bool TryGetDestinyEndpoint(
JConnection connection,
string originEndpointId,
StageTag originStageTag,
out string destinyEndpointId,
out JEndpoint destinyEndpoint)
{
destinyEndpointId = null;
destinyEndpoint = null;
destinyEndpointId = connection.GetOtherEndpointId(originEndpointId);
if (string.IsNullOrWhiteSpace(destinyEndpointId))
{
DLogger.LogWarn(
"could not resolve destiny endpoint from connection. " +
$"Stage: {originStageTag.StageId}, " +
$"Origin endpoint: {originEndpointId}, " +
$"Connection: {connection}",
ctx: this);
return false;
}
if (!JourneyService.Instance.TryGetEndpoint(destinyEndpointId, out destinyEndpoint))
{
DLogger.LogWarn(
"could not find destiny endpoint. " +
$"Origin stage: {originStageTag.StageId}, " +
$"Origin endpoint: {originEndpointId}, " +
$"Destiny endpoint: {destinyEndpointId}, " +
$"Connection: {connection}",
ctx: this);
return false;
}
if (!destinyEndpoint.IsSocket)
{
DLogger.LogWarn(
"rejected destiny endpoint because it is not a socket. " +
$"Origin stage: {originStageTag.StageId}, " +
$"Origin endpoint: {originEndpointId}, " +
$"Destiny endpoint: {destinyEndpoint.id}, " +
$"Kind: {destinyEndpoint.kind}",
ctx: this);
return false;
}
return true;
}
private bool TryGetDestinyStageTag(
string destinyEndpointId,
StageTag originStageTag,
string originEndpointId,
out StageTag destinyStageTag)
{
destinyStageTag = null;
if (!JourneyService.Instance.TryGetStageTagFromEndpoint(
destinyEndpointId,
out destinyStageTag))
{
DLogger.LogWarn(
"could not resolve destiny stage from endpoint. " +
$"Origin stage: {originStageTag.StageId}, " +
$"Origin endpoint: {originEndpointId}, " +
$"Destiny endpoint: {destinyEndpointId}",
ctx: this);
return false;
}
if (destinyStageTag.IsNull())
{
DLogger.LogWarn(
"resolved a null destiny stage. " +
$"Origin stage: {originStageTag.StageId}, " +
$"Origin endpoint: {originEndpointId}, " +
$"Destiny endpoint: {destinyEndpointId}",
ctx: this);
return false;
}
return true;
}
private static bool CanTravelThrough(
JConnection connection,
string originEndpointId)
{
return connection.directionality switch
{
JConnectionDirectionality.Bidirectional => true,
JConnectionDirectionality.AToB => string.Equals(
connection.endpointAId,
originEndpointId,
StringComparison.Ordinal),
JConnectionDirectionality.BToA => string.Equals(
connection.endpointBId,
originEndpointId,
StringComparison.Ordinal),
_ => false
};
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 271adef63546438294b61375c3f8486e
timeCreated: 1782492126

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1a36268522fb444ca03bcc4b65a6bcb6
timeCreated: 1782496435

View File

@ -0,0 +1,11 @@
namespace Intrepid.Gameplay.Journey.Runtime.State
{
public enum JourneyRuntimePhase
{
None,
Booting,
Ready,
Transitioning,
Failed
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7beb4c7d6f7a40198fcba0c2de2d18c9
timeCreated: 1782496411

View File

@ -0,0 +1,171 @@
using System;
using Intrepid.Gameplay.Journey.Runtime.Messages;
namespace Intrepid.Gameplay.Journey.Runtime.State
{
public sealed class JourneyRuntimeState
{
public JourneyRuntimePhase Phase { get; private set; } = JourneyRuntimePhase.None;
public StageTag CurrentStageTag { get; private set; }
public JourneyTravelRequest CurrentTravelRequest { get; private set; }
public bool IsBooting => Phase == JourneyRuntimePhase.Booting;
public bool IsReady => Phase == JourneyRuntimePhase.Ready;
public bool IsTransitionRunning => Phase == JourneyRuntimePhase.Transitioning;
public bool IsFailed => Phase == JourneyRuntimePhase.Failed;
public bool IsBooted =>
Phase == JourneyRuntimePhase.Ready ||
Phase == JourneyRuntimePhase.Transitioning;
public bool HasCurrentStage => CurrentStageTag.IsNotNull();
public void BeginBoot()
{
Phase = JourneyRuntimePhase.Booting;
CurrentStageTag = null;
CurrentTravelRequest = null;
}
public void CompleteBoot(StageTag stageTag)
{
CurrentStageTag = stageTag;
CurrentTravelRequest = null;
Phase = JourneyRuntimePhase.Ready;
}
public void FailBoot()
{
CurrentTravelRequest = null;
CurrentStageTag = null;
Phase = JourneyRuntimePhase.Failed;
}
public bool CanAcceptTravelRequest(out string reason)
{
if (IsBooting)
{
reason = "runtime is still booting";
return false;
}
if (!IsBooted)
{
reason = "runtime is not booted";
return false;
}
if (IsTransitionRunning)
{
reason = "another transition is running";
return false;
}
if (CurrentStageTag.IsNull())
{
reason = "current stage is null";
return false;
}
reason = null;
return true;
}
public bool TryBeginTransition(
JourneyTravelRequest request,
out string reason)
{
if (!CanAcceptTravelRequest(out reason))
{
return false;
}
if (request == null)
{
reason = "request is null";
return false;
}
if (request.OriginStageTag.IsNull())
{
reason = "origin stage is null";
return false;
}
if (request.DestinyStageTag.IsNull())
{
reason = "destiny stage is null";
return false;
}
if (request.OriginStageTag != CurrentStageTag)
{
reason =
"origin stage is not current. " +
$"Current: {CurrentStageTag.StageId}, " +
$"Origin: {request.OriginStageTag.StageId}";
return false;
}
if (request.DestinyStageTag == CurrentStageTag)
{
reason =
"destiny stage is already current. " +
$"Stage: {CurrentStageTag.StageId}";
return false;
}
CurrentTravelRequest = request;
Phase = JourneyRuntimePhase.Transitioning;
reason = null;
return true;
}
public void CompleteTransition(JourneyTravelRequest request)
{
if (request != null)
{
CurrentStageTag = request.DestinyStageTag;
}
CurrentTravelRequest = null;
Phase = JourneyRuntimePhase.Ready;
}
public void FailTransition()
{
CurrentTravelRequest = null;
if (CurrentStageTag.IsNull())
{
Phase = JourneyRuntimePhase.Failed;
return;
}
Phase = JourneyRuntimePhase.Ready;
}
public void Reset()
{
Phase = JourneyRuntimePhase.None;
CurrentStageTag = null;
CurrentTravelRequest = null;
}
public override string ToString()
{
return
$"Phase={Phase}, " +
$"CurrentStage={CurrentStageTag?.StageId}, " +
$"CurrentTravel={CurrentTravelRequest}";
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6ad2a80737154408a10a3cf0d6a3848a
timeCreated: 1782496442

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4d9c6066ef67482f893e5a4ef9207f3d
timeCreated: 1782483094

View File

@ -0,0 +1,110 @@
using System;
using Intrepid.Core.Camera;
using Intrepid.Diagnostics;
using Intrepid.GameManagers;
using Intrepid.Gameplay.Journey.Messages.Events;
using Intrepid.Gameplay.Journey.Runtime.Gameplay;
using Intrepid.Gameplay.Journey.Runtime.Loading;
using Intrepid.Gameplay.Journey.Runtime.Messages;
using Intrepid.Theatre.BackStage;
using Intrepid.Theatre.Curtain;
using Intrepid.Utilities;
using UnityEngine;
namespace Intrepid.Gameplay.Journey.Runtime.Transition
{
public sealed class JourneyTransitionDirector : MonoBehaviour, IBackStageProcessor
{
private const string Id = "JourneyTransitionDirector";
[GroupConfigurations, SerializeField] private CurtainTypeTag curtainType;
[GroupInjections, SerializeField] private BackStageService backStageService;
[GroupInjections, SerializeField] private JourneyGameplayGate gameplayGate;
[GroupInjections, SerializeField] private JourneyStageLoader stageLoader;
[GroupInjections, SerializeField] private JourneyLandingService landingService;
private JourneyTravelRequest CurrentRequest { get; set; }
private JourneyGameplayGateContext GameplayGateContext { get; set; }
private Action<JourneyTravelRequest> OnFinished { get; set; }
private Action<JourneyTravelRequest> OnFailed { get; set; }
public JourneyStageLoader StageLoader => stageLoader;
public JourneyLandingService LandingService => landingService;
public JourneyGameplayGate GameplayGate => gameplayGate;
public bool IsRunning => CurrentRequest is not null;
public bool IsProcessFinished =>
CurrentRequest is not null &&
stageLoader.IsLoadingFinished &&
!CameraSystem.Instance.IsCameraBlending;
public bool StartTravel(
JourneyTravelRequest request,
Action<JourneyTravelRequest> onFinished,
Action<JourneyTravelRequest> onFailed = null)
{
if (IsRunning)
{
DLogger.LogWarn($"is already running. Request: {request}", ctx: this);
onFailed?.Invoke(request);
return false;
}
CurrentRequest = request;
OnFinished = onFinished;
OnFailed = onFailed;
var kicked = backStageService.KickProcess(curtainType, Id, this);
if (!kicked)
{
DLogger.LogWarn($"could not kick backstage process. Request: {request}", ctx: this);
Clear();
onFailed?.Invoke(request);
return false;
}
DLogger.LogDebug($"started travel: {request}", ctx: this);
return true;
}
public void BeforeClosing()
{
DLogger.LogDebug($"BeforeClosing: {CurrentRequest}", ctx: this);
GameplayGateContext = gameplayGate.Lock(CurrentRequest);
Proxy.Instance.EventBus.Raise(new ChangeStageTouchedEvent());
}
public void AfterClosed()
{
DLogger.LogDebug($"AfterClosed: {CurrentRequest}", ctx: this);
Proxy.Instance.EventBus.Raise(new ChangeStageStartEvent());
stageLoader.ChangeTo(CurrentRequest.DestinyStageTag);
}
public void BeforeOpening()
{
DLogger.LogDebug($"BeforeOpening: {CurrentRequest}", ctx: this);
landingService.LandAtEndpoint(CurrentRequest.DestinyStageTag, CurrentRequest.DestinyEndpointId);
}
public void AfterOpened()
{
DLogger.LogDebug($"AfterOpened: {CurrentRequest}", ctx: this);
Proxy.Instance.EventBus.Raise(new ChangeStageEndEvent());
gameplayGate.Unlock(GameplayGateContext, CurrentRequest);
var finishedRequest = CurrentRequest;
OnFinished?.Invoke(finishedRequest);
Clear();
}
private void Clear()
{
CurrentRequest = null;
GameplayGateContext = null;
OnFinished = null;
OnFailed = null;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 12f4067aa70c4d2e81c42f92c28c8253
timeCreated: 1782483099

View File

@ -1,47 +0,0 @@
using System;
using Intrepid.FSM;
using Intrepid.Structures;
using UnityEngine;
namespace Intrepid.Gameplay.Journey
{
[Serializable]
public class StageLoadingService : IState<StageTag, StageLoadingService>
{
private StageTag StageTag { get; }
public StageLoadingService(StageTag stageTag)
{
StageTag = stageTag;
}
private AsyncOperation AsyncOperation { get; set; }
public bool IsLoadingFinished => AsyncOperation?.isDone ?? false;
public bool CanEnterState => true;
public bool CanExitState => true;
public StageTag GetStateKey()
{
return StageTag;
}
public StageLoadingService Implementation()
{
return this;
}
public void OnEnterState(ParameterStore ps)
{
if (StageTag.IsReadyToBeLoaded())
{
AsyncOperation = StageTag.LoadAsync();
}
}
public void OnExitState()
{
StageTag.UnloadAsync();
}
}
}

View File

@ -35,8 +35,9 @@ namespace Intrepid.Gameplay.Journey
protected override void Subscriptions() protected override void Subscriptions()
{ {
Subscribe<ChangeStageLandingOnStageStepEvent>(e => Subscribe<JourneyLandingRequestedEvent>(e =>
{ {
if (e.DestinyStageTag != StageTag) return;
if (SocketMap.TryGetValue(e.DestinyEndpoint, out var stageSocket)) if (SocketMap.TryGetValue(e.DestinyEndpoint, out var stageSocket))
{ {
Proxy.Instance.EventBus.Raise(new StageDispatchDeploymentPointEvent Proxy.Instance.EventBus.Raise(new StageDispatchDeploymentPointEvent

View File

@ -19,8 +19,8 @@ namespace Intrepid.Gameplay.Prototyping
[GroupInjections, SerializeField] private StageSocketDeploymentPoint deploymentPoint; [GroupInjections, SerializeField] private StageSocketDeploymentPoint deploymentPoint;
[GroupInjections, SerializeField] private StageSocketChangeTrigger changeTrigger; [GroupInjections, SerializeField] private StageSocketChangeTrigger changeTrigger;
[GroupDebug, SerializeField, ReadOnly] private StageManager stageManager; [GroupDebug, SerializeField, ReadOnly] private StageManager stageManager;
public string StageId => stageManager.StageTag.StageId; public StageTag StageTag => stageManager.StageTag;
[GroupDebug, ShowInInspector, ReadOnly] public string EndpointId { get; private set; } [GroupDebug, ShowInInspector, ReadOnly] public string EndpointId { get; private set; }
public JSocketFace SocketFace public JSocketFace SocketFace
{ {

View File

@ -1,10 +1,8 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using Intrepid.Core.Entities; using Intrepid.Core.Entities;
using Intrepid.Core.Tags; using Intrepid.Core.Tags;
using Intrepid.Diagnostics; using Intrepid.GameManagers;
using Intrepid.Gameplay.Journey; using Intrepid.Gameplay.Journey.Runtime.Events;
using Intrepid.Utilities; using Intrepid.Utilities;
using UnityEngine; using UnityEngine;
@ -18,36 +16,20 @@ namespace Intrepid.Gameplay.Prototyping.Sockets
protected override void WhenRaiseEnterEvent(Collider other, EntitySensor entitySensor, List<BehaviourTag> behaviourTags) protected override void WhenRaiseEnterEvent(Collider other, EntitySensor entitySensor, List<BehaviourTag> behaviourTags)
{ {
var stageId = socket.StageId; Proxy.Instance.EventBus.Raise(new StageSocketChangeEnterEvent
var endpointId = socket.EndpointId;
if (!JourneyService.Instance.TryGetJConnections(stageId, endpointId, out var jConnections))
{ {
DLogger.LogWarn($"Stage {stageId} has invalid endpoint: {endpointId}"); StageTag = socket.StageTag,
return; EndpointId = socket.EndpointId,
} });
if (jConnections.Count > 1)
{
DLogger.LogWarn($"Stage {stageId} has multiple connections from endpoint: {endpointId}");
return;
}
var destinyEndpoint = GrabDestinyEndpoint(jConnections.First());
if (!JourneyService.Instance.TryGetStageTagFromEndpoint(destinyEndpoint, out var stageTag))
{
DLogger.LogWarn($"Stage {stageId} has invalid endpoint: {endpointId}");
return;
}
JourneyManager.Instance.ChangeStageTo(stageTag, destinyEndpoint);
}
private string GrabDestinyEndpoint(JConnection jConnection)
{
return socket.EndpointId.Equals(jConnection.endpointAId, StringComparison.Ordinal)
? jConnection.endpointBId
: jConnection.endpointAId;
} }
protected override void WhenRaiseExitEvent(Collider other, EntitySensor entitySensor) protected override void WhenRaiseExitEvent(Collider other, EntitySensor entitySensor)
{ {
Proxy.Instance.EventBus.Raise(new StageSocketChangeExitEvent
{
StageTag = socket.StageTag,
EndpointId = socket.EndpointId,
});
} }
#if UNITY_EDITOR #if UNITY_EDITOR