diff --git a/Assets/Scripts/Pal3.Game/Actor/ActorFactory.cs b/Assets/Scripts/Pal3.Game/Actor/ActorFactory.cs index 22934bf5..68a1b9e9 100644 --- a/Assets/Scripts/Pal3.Game/Actor/ActorFactory.cs +++ b/Assets/Scripts/Pal3.Game/Actor/ActorFactory.cs @@ -13,7 +13,6 @@ namespace Pal3.Game.Actor using Dev.Presenters; using Engine.Core.Abstraction; using Engine.Core.Implementation; - using GameSystems.Combat; using Scene; using Color = Core.Primitives.Color; @@ -22,7 +21,7 @@ namespace Pal3.Game.Actor public static class ActorFactory { public static IGameEntity CreateActorGameEntity(GameResourceProvider resourceProvider, - Actor actor, + GameActor actor, Tilemap tilemap, bool isDropShadowEnabled, Color tintColor, @@ -110,56 +109,5 @@ namespace Pal3.Game.Actor return actorGameEntity; } - - public static IGameEntity CreateCombatActorGameEntity(GameResourceProvider resourceProvider, - CombatActor actor, - ElementPosition elementPosition, - bool isDropShadowEnabled) - { - IGameEntity actorGameEntity = GameEntityFactory.Create($"CombatActor_{actor.Id}_{actor.Name}"); - - // Attach CombatActorInfo to the GameEntity for better debuggability - #if UNITY_EDITOR - CombatActorInfoPresenter combatActorInfoPresent = actorGameEntity.AddComponent(); - combatActorInfoPresent.combatActorInfo = actor.Info; - #endif - - ActorActionController actionController; - switch (actor.AnimationType) - { - case ActorAnimationType.Vertex: - { - VertexAnimationActorActionController vertexActionController = - actorGameEntity.AddComponent(); - vertexActionController.Init(resourceProvider, - actor, - hasColliderAndRigidBody: false, // combat actor has no collider and rigidbody - isDropShadowEnabled, - autoStand: true, // combat actor always auto stand - canPerformHoldAnimation: false); // combat actor can't perform hold animation - actionController = vertexActionController; - break; - } - case ActorAnimationType.Skeletal: - { - SkeletalAnimationActorActionController skeletalActionController = - actorGameEntity.AddComponent(); - skeletalActionController.Init(resourceProvider, - actor, - hasColliderAndRigidBody: false, // combat actor has no collider and rigidbody - isDropShadowEnabled); - actionController = skeletalActionController; - break; - } - default: - throw new NotSupportedException($"Unsupported actor animation type: {actor.AnimationType}"); - } - - CombatActorController actorController = actorGameEntity.AddComponent(); - actorController.Init(actor, actionController, elementPosition); - actorController.IsActive = true; // combat actor is always active - - return actorGameEntity; - } } } \ No newline at end of file diff --git a/Assets/Scripts/Pal3.Game/Actor/Controllers/ActorController.cs b/Assets/Scripts/Pal3.Game/Actor/Controllers/ActorController.cs index 34f2cfc7..0daddc03 100644 --- a/Assets/Scripts/Pal3.Game/Actor/Controllers/ActorController.cs +++ b/Assets/Scripts/Pal3.Game/Actor/Controllers/ActorController.cs @@ -35,7 +35,7 @@ namespace Pal3.Game.Actor.Controllers ICommandExecutor, ICommandExecutor { - private Actor _actor; + private GameActor _actor; private ActorActionController _actionController; private ActorMovementController _movementController; private PlayerInputActions _inputActions; @@ -64,7 +64,7 @@ namespace Pal3.Game.Actor.Controllers CommandExecutorRegistry.Instance.UnRegister(this); } - public void Init(Actor actor, + public void Init(GameActor actor, ActorActionController actionController, ActorMovementController movementController) { @@ -90,7 +90,7 @@ namespace Pal3.Game.Actor.Controllers return _actor.GetScriptId() != ScriptConstants.InvalidScriptId; } - public Actor GetActor() + public GameActor GetActor() { return _actor; } diff --git a/Assets/Scripts/Pal3.Game/Actor/Controllers/ActorMovementController.cs b/Assets/Scripts/Pal3.Game/Actor/Controllers/ActorMovementController.cs index 639f2717..3b7874f5 100644 --- a/Assets/Scripts/Pal3.Game/Actor/Controllers/ActorMovementController.cs +++ b/Assets/Scripts/Pal3.Game/Actor/Controllers/ActorMovementController.cs @@ -65,7 +65,7 @@ namespace Pal3.Game.Actor.Controllers ICommandExecutor, ICommandExecutor { - private Actor _actor; + private GameActor _actor; private Tilemap _tilemap; private ActorActionController _actionController; private int _currentLayerIndex = 0; @@ -97,7 +97,7 @@ namespace Pal3.Game.Actor.Controllers CommandExecutorRegistry.Instance.UnRegister(this); } - public void Init(Actor actor, + public void Init(GameActor actor, Tilemap tilemap, ActorActionController actionController, float movementMaxYDifferential, diff --git a/Assets/Scripts/Pal3.Game/Actor/Actor.cs b/Assets/Scripts/Pal3.Game/Actor/GameActor.cs similarity index 96% rename from Assets/Scripts/Pal3.Game/Actor/Actor.cs rename to Assets/Scripts/Pal3.Game/Actor/GameActor.cs index 99b87294..b0a7ec8e 100644 --- a/Assets/Scripts/Pal3.Game/Actor/Actor.cs +++ b/Assets/Scripts/Pal3.Game/Actor/GameActor.cs @@ -11,7 +11,7 @@ namespace Pal3.Game.Actor using Data; using Engine.Extensions; - public sealed class Actor : ActorBase + public sealed class GameActor : ActorBase { private const float DEFAULT_ROTATION_SPEED = 20f; @@ -20,7 +20,7 @@ namespace Pal3.Game.Actor private uint? _overwrittenScriptId; private uint? _overwrittenMoveSpeed; - public Actor(GameResourceProvider resourceProvider, ScnNpcInfo npcInfo) : + public GameActor(GameResourceProvider resourceProvider, ScnNpcInfo npcInfo) : base(resourceProvider, npcInfo.Id, npcInfo.Name) { Info = npcInfo; diff --git a/Assets/Scripts/Pal3.Game/Actor/Actor.cs.meta b/Assets/Scripts/Pal3.Game/Actor/GameActor.cs.meta similarity index 100% rename from Assets/Scripts/Pal3.Game/Actor/Actor.cs.meta rename to Assets/Scripts/Pal3.Game/Actor/GameActor.cs.meta diff --git a/Assets/Scripts/Pal3.Game/Effect/EffectManager.cs b/Assets/Scripts/Pal3.Game/Effect/EffectManager.cs index fd1cbf88..1d3ec720 100644 --- a/Assets/Scripts/Pal3.Game/Effect/EffectManager.cs +++ b/Assets/Scripts/Pal3.Game/Effect/EffectManager.cs @@ -120,7 +120,7 @@ namespace Pal3.Game.Effect #if PAL3A private void HandleNanGongHuangTransformEffect(EffectAttachToActorCommand effectAttachToActorCommand, EffectPlayCommand effectPlayCommand, - Scene currentScene) + GameScene currentScene) { int actorId = effectAttachToActorCommand.ActorId; switch (effectPlayCommand.EffectGroupId) @@ -128,7 +128,7 @@ namespace Pal3.Game.Effect // 南宫煌切换为狼妖形态特效 case 164: { - Actor actor = currentScene.GetActor(actorId); + GameActor actor = currentScene.GetActor(actorId); actor.ChangeName(ActorConstants.NanGongHuangWolfModeActorName); if (actor.IsActive) { @@ -141,7 +141,7 @@ namespace Pal3.Game.Effect // 南宫煌切换为人形态特效 case 315: { - Actor actor = currentScene.GetActor(actorId); + GameActor actor = currentScene.GetActor(actorId); actor.ChangeName(ActorConstants.NanGongHuangHumanModeActorName); if (actor.IsActive) { diff --git a/Assets/Scripts/Pal3.Game/GamePlay/PlayerGamePlayManager.Climb.cs b/Assets/Scripts/Pal3.Game/GamePlay/PlayerGamePlayManager.Climb.cs index ccbd1eaa..b6e5f128 100644 --- a/Assets/Scripts/Pal3.Game/GamePlay/PlayerGamePlayManager.Climb.cs +++ b/Assets/Scripts/Pal3.Game/GamePlay/PlayerGamePlayManager.Climb.cs @@ -31,7 +31,7 @@ namespace Pal3.Game.GamePlay { public void Execute(ActorPerformClimbActionCommand command) { - Scene scene = _sceneManager.GetCurrentScene(); + GameScene scene = _sceneManager.GetCurrentScene(); SceneObject climbableSceneObject = scene.GetSceneObject(command.ObjectId); IGameEntity climbableEntity = climbableSceneObject.GetGameEntity(); if (climbableEntity == null) diff --git a/Assets/Scripts/Pal3.Game/GamePlay/PlayerGamePlayManager.Interaction.cs b/Assets/Scripts/Pal3.Game/GamePlay/PlayerGamePlayManager.Interaction.cs index 48c48990..c1c3c1bc 100644 --- a/Assets/Scripts/Pal3.Game/GamePlay/PlayerGamePlayManager.Interaction.cs +++ b/Assets/Scripts/Pal3.Game/GamePlay/PlayerGamePlayManager.Interaction.cs @@ -35,7 +35,7 @@ namespace Pal3.Game.GamePlay { public void Execute(PlayerInteractWithObjectCommand command) { - Scene currentScene = _sceneManager.GetCurrentScene(); + GameScene currentScene = _sceneManager.GetCurrentScene(); if (currentScene.GetAllActivatedSceneObjects().Contains(command.SceneObjectId)) { Pal3.Instance.StartCoroutine(InteractWithSceneObjectAsync( @@ -175,7 +175,7 @@ namespace Pal3.Game.GamePlay Pal3.Instance.Execute(new GameStateChangeRequest(GameState.Cutscene)); Pal3.Instance.Execute(new ActorStopActionAndStandCommand(ActorConstants.PlayerActorVirtualID)); - Actor targetActor = _sceneManager.GetCurrentScene().GetActor(actorId); + GameActor targetActor = _sceneManager.GetCurrentScene().GetActor(actorId); Quaternion rotationBeforeInteraction = actorGameEntity.Transform.Rotation; ActorController actorController = actorGameEntity.GetComponent(); diff --git a/Assets/Scripts/Pal3.Game/GamePlay/PlayerGamePlayManager.Jump.cs b/Assets/Scripts/Pal3.Game/GamePlay/PlayerGamePlayManager.Jump.cs index d91fdd3c..37ddfaea 100644 --- a/Assets/Scripts/Pal3.Game/GamePlay/PlayerGamePlayManager.Jump.cs +++ b/Assets/Scripts/Pal3.Game/GamePlay/PlayerGamePlayManager.Jump.cs @@ -114,7 +114,7 @@ namespace Pal3.Game.GamePlay Vector3 currentPosition = _playerActorMovementController.GetWorldPosition(); - Scene currentScene = _sceneManager.GetCurrentScene(); + GameScene currentScene = _sceneManager.GetCurrentScene(); Tilemap tilemap = currentScene.GetTilemap(); bool IsPositionCanJumpTo(Vector3 position, int layerIndex, out float yPosition, out int distanceToObstacle) diff --git a/Assets/Scripts/Pal3.Game/GamePlay/PlayerGamePlayManager.Movement.cs b/Assets/Scripts/Pal3.Game/GamePlay/PlayerGamePlayManager.Movement.cs index c498a6f0..fab49eb6 100644 --- a/Assets/Scripts/Pal3.Game/GamePlay/PlayerGamePlayManager.Movement.cs +++ b/Assets/Scripts/Pal3.Game/GamePlay/PlayerGamePlayManager.Movement.cs @@ -79,7 +79,7 @@ namespace Pal3.Game.GamePlay { if (!_lastInputTapPosition.HasValue) return; - Scene currentScene = _sceneManager.GetCurrentScene(); + GameScene currentScene = _sceneManager.GetCurrentScene(); int hitCount = _physicsManager.CameraRaycastFromScreenPoint( _lastInputTapPosition.Value, diff --git a/Assets/Scripts/Pal3.Game/GamePlay/PlayerGamePlayManager.cs b/Assets/Scripts/Pal3.Game/GamePlay/PlayerGamePlayManager.cs index 9f861a56..5afd553d 100644 --- a/Assets/Scripts/Pal3.Game/GamePlay/PlayerGamePlayManager.cs +++ b/Assets/Scripts/Pal3.Game/GamePlay/PlayerGamePlayManager.cs @@ -67,7 +67,7 @@ namespace Pal3.Game.GamePlay private int _longKuiLastKnownMode = 0; #endif - private Actor _playerActor; + private GameActor _playerActor; private IGameEntity _playerActorGameEntity; private ActorController _playerActorController; private ActorActionController _playerActorActionController; diff --git a/Assets/Scripts/Pal3.Game/GameSystems/Combat/Actor.meta b/Assets/Scripts/Pal3.Game/GameSystems/Combat/Actor.meta new file mode 100644 index 00000000..7463cf1e --- /dev/null +++ b/Assets/Scripts/Pal3.Game/GameSystems/Combat/Actor.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6bb2ce918fa3466faf2a2cb83e43bdef +timeCreated: 1726912744 \ No newline at end of file diff --git a/Assets/Scripts/Pal3.Game/Actor/CombatActor.cs b/Assets/Scripts/Pal3.Game/GameSystems/Combat/Actor/CombatActor.cs similarity index 96% rename from Assets/Scripts/Pal3.Game/Actor/CombatActor.cs rename to Assets/Scripts/Pal3.Game/GameSystems/Combat/Actor/CombatActor.cs index 76473b57..f9cbf6e4 100644 --- a/Assets/Scripts/Pal3.Game/Actor/CombatActor.cs +++ b/Assets/Scripts/Pal3.Game/GameSystems/Combat/Actor/CombatActor.cs @@ -3,12 +3,13 @@ // See LICENSE file in the project root for license information. // --------------------------------------------------------------------------------------------- -namespace Pal3.Game.Actor +namespace Pal3.Game.GameSystems.Combat.Actor { using Core.Contract.Constants; using Core.Contract.Enums; using Core.DataReader.Gdb; using Data; + using Game.Actor; public sealed class CombatActor : ActorBase { diff --git a/Assets/Scripts/Pal3.Game/Actor/CombatActor.cs.meta b/Assets/Scripts/Pal3.Game/GameSystems/Combat/Actor/CombatActor.cs.meta similarity index 100% rename from Assets/Scripts/Pal3.Game/Actor/CombatActor.cs.meta rename to Assets/Scripts/Pal3.Game/GameSystems/Combat/Actor/CombatActor.cs.meta diff --git a/Assets/Scripts/Pal3.Game/GameSystems/Combat/Actor/CombatActorFactory.cs b/Assets/Scripts/Pal3.Game/GameSystems/Combat/Actor/CombatActorFactory.cs new file mode 100644 index 00000000..9a61050f --- /dev/null +++ b/Assets/Scripts/Pal3.Game/GameSystems/Combat/Actor/CombatActorFactory.cs @@ -0,0 +1,64 @@ +// --------------------------------------------------------------------------------------------- +// Copyright (c) 2021-2024, Jiaqi (0x7c13) Liu. All rights reserved. +// See LICENSE file in the project root for license information. +// --------------------------------------------------------------------------------------------- + +namespace Pal3.Game.GameSystems.Combat.Actor +{ + using System; + using Combat; + using Controllers; + using Data; + using Dev.Presenters; + using Engine.Core.Abstraction; + using Engine.Core.Implementation; + using Game.Actor; + using Game.Actor.Controllers; + + using Color = Core.Primitives.Color; + using Vector2Int = UnityEngine.Vector2Int; + + public static class CombatActorFactory + { + public static IGameEntity CreateCombatActorGameEntity(GameResourceProvider resourceProvider, + CombatActor actor, + ElementPosition elementPosition, + bool isDropShadowEnabled) + { + IGameEntity actorGameEntity = GameEntityFactory.Create($"CombatActor_{actor.Id}_{actor.Name}"); + + // Attach CombatActorInfo to the GameEntity for better debuggability + #if UNITY_EDITOR + CombatActorInfoPresenter combatActorInfoPresent = actorGameEntity.AddComponent(); + combatActorInfoPresent.combatActorInfo = actor.Info; + #endif + + ActorActionController actionController; + switch (actor.AnimationType) + { + case ActorAnimationType.Vertex: + { + VertexAnimationActorActionController vertexActionController = + actorGameEntity.AddComponent(); + vertexActionController.Init(resourceProvider, + actor, + hasColliderAndRigidBody: false, // combat actor has no collider and rigidbody + isDropShadowEnabled, + autoStand: true, // combat actor always auto stand + canPerformHoldAnimation: false); // combat actor can't perform hold animation + actionController = vertexActionController; + break; + } + case ActorAnimationType.Skeletal: + default: + throw new NotSupportedException($"Unsupported actor animation type: {actor.AnimationType}"); + } + + CombatActorController actorController = actorGameEntity.AddComponent(); + actorController.Init(actor, actionController, elementPosition); + actorController.IsActive = true; // combat actor is always active + + return actorGameEntity; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Pal3.Game/GameSystems/Combat/Actor/CombatActorFactory.cs.meta b/Assets/Scripts/Pal3.Game/GameSystems/Combat/Actor/CombatActorFactory.cs.meta new file mode 100644 index 00000000..7d72eebb --- /dev/null +++ b/Assets/Scripts/Pal3.Game/GameSystems/Combat/Actor/CombatActorFactory.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 839f09ca72114971b5274895a2a88fa8 +timeCreated: 1726912818 \ No newline at end of file diff --git a/Assets/Scripts/Pal3.Game/GameSystems/Combat/Actor/Controllers.meta b/Assets/Scripts/Pal3.Game/GameSystems/Combat/Actor/Controllers.meta new file mode 100644 index 00000000..ac900a28 --- /dev/null +++ b/Assets/Scripts/Pal3.Game/GameSystems/Combat/Actor/Controllers.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 974221895412441db28592f1c874c01c +timeCreated: 1726912777 \ No newline at end of file diff --git a/Assets/Scripts/Pal3.Game/Actor/Controllers/CombatActorController.cs b/Assets/Scripts/Pal3.Game/GameSystems/Combat/Actor/Controllers/CombatActorController.cs similarity index 95% rename from Assets/Scripts/Pal3.Game/Actor/Controllers/CombatActorController.cs rename to Assets/Scripts/Pal3.Game/GameSystems/Combat/Actor/Controllers/CombatActorController.cs index e5833269..475d3060 100644 --- a/Assets/Scripts/Pal3.Game/Actor/Controllers/CombatActorController.cs +++ b/Assets/Scripts/Pal3.Game/GameSystems/Combat/Actor/Controllers/CombatActorController.cs @@ -3,16 +3,15 @@ // See LICENSE file in the project root for license information. // --------------------------------------------------------------------------------------------- -namespace Pal3.Game.Actor.Controllers +namespace Pal3.Game.GameSystems.Combat.Actor.Controllers { using System; using System.Collections; + using Combat; using Engine.Animation; using Engine.Core.Implementation; - using Engine.Coroutine; - using GameSystems.Combat; + using Game.Actor.Controllers; using Scene; - using Script.Waiter; using Quaternion = UnityEngine.Quaternion; using Vector3 = UnityEngine.Vector3; @@ -73,6 +72,7 @@ namespace Pal3.Game.Actor.Controllers { if (_actionController is VertexAnimationActorActionController vertexActionController) { + vertexActionController.AnimationEventTriggered -= AnimationEventTriggered; vertexActionController.AnimationEventTriggered += AnimationEventTriggered; } diff --git a/Assets/Scripts/Pal3.Game/Actor/Controllers/CombatActorController.cs.meta b/Assets/Scripts/Pal3.Game/GameSystems/Combat/Actor/Controllers/CombatActorController.cs.meta similarity index 100% rename from Assets/Scripts/Pal3.Game/Actor/Controllers/CombatActorController.cs.meta rename to Assets/Scripts/Pal3.Game/GameSystems/Combat/Actor/Controllers/CombatActorController.cs.meta diff --git a/Assets/Scripts/Pal3.Game/GameSystems/Combat/CombatCoordinator.cs b/Assets/Scripts/Pal3.Game/GameSystems/Combat/CombatCoordinator.cs index 9073cc57..9c209e05 100644 --- a/Assets/Scripts/Pal3.Game/GameSystems/Combat/CombatCoordinator.cs +++ b/Assets/Scripts/Pal3.Game/GameSystems/Combat/CombatCoordinator.cs @@ -9,7 +9,6 @@ namespace Pal3.Game.GameSystems.Combat using System.Collections.Generic; using System.Data; using System.Linq; - using Actor.Controllers; using Audio; using Command; using Command.Extensions; @@ -24,8 +23,10 @@ namespace Pal3.Game.GameSystems.Combat using Data; using Engine.Core.Abstraction; using Engine.Logging; + using Game.Actor; + using Game.Actor.Controllers; + using Game.Scene; using GamePlay; - using Scene; using Script.Waiter; using Settings; using State; @@ -94,7 +95,7 @@ namespace Pal3.Game.GameSystems.Combat { if (!_gameSettings.IsTurnBasedCombatEnabled) return; - Scene currentScene = _sceneManager.GetCurrentScene(); + GameScene currentScene = _sceneManager.GetCurrentScene(); // Figure out which combat scene to use string combatSceneName = GetCombatSceneName(currentScene); @@ -156,7 +157,7 @@ namespace Pal3.Game.GameSystems.Combat } } - private string GetCombatSceneName(Scene currentScene) + private string GetCombatSceneName(GameScene currentScene) { ScnSceneInfo sceneInfo = currentScene.GetSceneInfo(); @@ -318,18 +319,18 @@ namespace Pal3.Game.GameSystems.Combat { Pal3.Instance.Execute(new ActorStopActionAndStandCommand(ActorConstants.PlayerActorVirtualID)); - Scene currentScene = _sceneManager.GetCurrentScene(); - Actor.Actor combatActor = currentScene.GetActor(command.CombatActorId); + GameScene currentScene = _sceneManager.GetCurrentScene(); + GameActor gameActor = currentScene.GetActor(command.CombatActorId); ITransform playerTransform = currentScene.GetActorGameEntity(command.PlayerActorId).Transform; ITransform enemyTransform = currentScene.GetActorGameEntity(command.CombatActorId).Transform; _combatContextBuilder.WithMeetType(CalculateMeetType(playerTransform, enemyTransform)); Execute(new CombatEnterNormalFightCommand( - combatActor.Info.NumberOfMonsters, - combatActor.Info.MonsterIds[0], - combatActor.Info.MonsterIds[1], - combatActor.Info.MonsterIds[2])); + gameActor.Info.NumberOfMonsters, + gameActor.Info.MonsterIds[0], + gameActor.Info.MonsterIds[1], + gameActor.Info.MonsterIds[2])); } else // TODO: Remove once combat system is fully implemented { diff --git a/Assets/Scripts/Pal3.Game/GameSystems/Combat/CombatManager.cs b/Assets/Scripts/Pal3.Game/GameSystems/Combat/CombatManager.cs index 03e4d273..2507b73d 100644 --- a/Assets/Scripts/Pal3.Game/GameSystems/Combat/CombatManager.cs +++ b/Assets/Scripts/Pal3.Game/GameSystems/Combat/CombatManager.cs @@ -22,6 +22,7 @@ namespace Pal3.Game.GameSystems.Combat using Data; using Engine.Core.Abstraction; using Engine.Extensions; + using Game.Scene; using Scene; using State; using Team; diff --git a/Assets/Scripts/Pal3.Game/GameSystems/Combat/Scene.meta b/Assets/Scripts/Pal3.Game/GameSystems/Combat/Scene.meta new file mode 100644 index 00000000..15f9d6b7 --- /dev/null +++ b/Assets/Scripts/Pal3.Game/GameSystems/Combat/Scene.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 27caea06d42f449698c44ff0b011317d +timeCreated: 1726913181 \ No newline at end of file diff --git a/Assets/Scripts/Pal3.Game/Scene/CombatScene.cs b/Assets/Scripts/Pal3.Game/GameSystems/Combat/Scene/CombatScene.cs similarity index 93% rename from Assets/Scripts/Pal3.Game/Scene/CombatScene.cs rename to Assets/Scripts/Pal3.Game/GameSystems/Combat/Scene/CombatScene.cs index f0344cfc..6817d2bf 100644 --- a/Assets/Scripts/Pal3.Game/Scene/CombatScene.cs +++ b/Assets/Scripts/Pal3.Game/GameSystems/Combat/Scene/CombatScene.cs @@ -3,7 +3,7 @@ // See LICENSE file in the project root for license information. // --------------------------------------------------------------------------------------------- -namespace Pal3.Game.Scene +namespace Pal3.Game.GameSystems.Combat.Scene { using System.Collections.Generic; using Actor; @@ -18,7 +18,6 @@ namespace Pal3.Game.Scene using Engine.Core.Abstraction; using Engine.Core.Implementation; using Engine.Extensions; - using GameSystems.Combat; using Rendering.Material; using Rendering.Renderer; @@ -106,8 +105,7 @@ namespace Pal3.Game.Scene public CombatActorController GetCombatActorController(ElementPosition elementPosition) { - return _combatActorControllers.TryGetValue(elementPosition, - out CombatActorController combatActorController) ? combatActorController : null; + return _combatActorControllers.GetValueOrDefault(elementPosition); } public void LoadActors(Dictionary combatActors, @@ -126,8 +124,8 @@ namespace Pal3.Game.Scene combatActorInfo.ModelId = combatActorInfo.Id.ToString(); } - CombatActor combatActor = new CombatActor(_resourceProvider, combatActorInfo); - IGameEntity combatActorGameEntity = ActorFactory.CreateCombatActorGameEntity( + CombatActor combatActor = new(_resourceProvider, combatActorInfo); + IGameEntity combatActorGameEntity = CombatActorFactory.CreateCombatActorGameEntity( _resourceProvider, combatActor, elementPosition, diff --git a/Assets/Scripts/Pal3.Game/Scene/CombatScene.cs.meta b/Assets/Scripts/Pal3.Game/GameSystems/Combat/Scene/CombatScene.cs.meta similarity index 100% rename from Assets/Scripts/Pal3.Game/Scene/CombatScene.cs.meta rename to Assets/Scripts/Pal3.Game/GameSystems/Combat/Scene/CombatScene.cs.meta diff --git a/Assets/Scripts/Pal3.Game/Scene/Scene.cs b/Assets/Scripts/Pal3.Game/Scene/GameScene.cs similarity index 99% rename from Assets/Scripts/Pal3.Game/Scene/Scene.cs rename to Assets/Scripts/Pal3.Game/Scene/GameScene.cs index 0f915a64..40739f74 100644 --- a/Assets/Scripts/Pal3.Game/Scene/Scene.cs +++ b/Assets/Scripts/Pal3.Game/Scene/GameScene.cs @@ -37,7 +37,7 @@ namespace Pal3.Game.Scene using UnityEngine; using Color = Core.Primitives.Color; - public sealed class Scene : SceneBase, + public sealed class GameScene : SceneBase, ICommandExecutor, ICommandExecutor, ICommandExecutor, @@ -196,12 +196,12 @@ namespace Pal3.Game.Scene return SceneObjects; } - public Actor GetActor(int id) + public GameActor GetActor(int id) { return Actors.GetValueOrDefault(id); } - public Dictionary GetAllActors() + public Dictionary GetAllActors() { return Actors; } @@ -420,7 +420,7 @@ namespace Pal3.Game.Scene private void InitActorObjects(Color tintColor, Tilemap tilemap) { - foreach (Actor actorObject in Actors.Values) + foreach (GameActor actorObject in Actors.Values) { CreateActorObject(actorObject, tintColor, tilemap); } @@ -469,7 +469,7 @@ namespace Pal3.Game.Scene SceneObjects[id].Deactivate(); } - private void CreateActorObject(Actor actor, Color tintColor, Tilemap tileMap) + private void CreateActorObject(GameActor actor, Color tintColor, Tilemap tileMap) { if (_actorEntities.ContainsKey(actor.Id)) return; diff --git a/Assets/Scripts/Pal3.Game/Scene/Scene.cs.meta b/Assets/Scripts/Pal3.Game/Scene/GameScene.cs.meta similarity index 100% rename from Assets/Scripts/Pal3.Game/Scene/Scene.cs.meta rename to Assets/Scripts/Pal3.Game/Scene/GameScene.cs.meta diff --git a/Assets/Scripts/Pal3.Game/Scene/SceneBase.cs b/Assets/Scripts/Pal3.Game/Scene/SceneBase.cs index edc6a265..c6e1aa8b 100644 --- a/Assets/Scripts/Pal3.Game/Scene/SceneBase.cs +++ b/Assets/Scripts/Pal3.Game/Scene/SceneBase.cs @@ -45,7 +45,7 @@ namespace Pal3.Game.Scene protected (CvdFile CvdFile, ITextureResourceProvider TextureProvider)? SceneCvdMesh; protected readonly Dictionary SceneObjects = new (); - protected readonly Dictionary Actors = new (); + protected readonly Dictionary Actors = new (); private HashSet _sceneObjectIdsToNotLoadFromSaveState; @@ -178,14 +178,14 @@ namespace Pal3.Game.Scene { foreach (ScnNpcInfo npcInfo in ScnFile.NpcInfos) { - Actors[npcInfo.Id] = new Actor(_resourceProvider, npcInfo); + Actors[npcInfo.Id] = new GameActor(_resourceProvider, npcInfo); } foreach (ScnNpcInfo playerInfo in NpcInfoFactory.CreateAllPlayerActorNpcInfos()) { if (!Actors.ContainsKey(playerInfo.Id)) { - Actors[playerInfo.Id] = new Actor(_resourceProvider, playerInfo); + Actors[playerInfo.Id] = new GameActor(_resourceProvider, playerInfo); } } @@ -194,7 +194,7 @@ namespace Pal3.Game.Scene { if (!Actors.ContainsKey(fengYaSongInfo.Id)) { - Actors[fengYaSongInfo.Id] = new Actor(_resourceProvider, fengYaSongInfo); + Actors[fengYaSongInfo.Id] = new GameActor(_resourceProvider, fengYaSongInfo); } } #endif diff --git a/Assets/Scripts/Pal3.Game/Scene/SceneManager.cs b/Assets/Scripts/Pal3.Game/Scene/SceneManager.cs index 6d5f7546..16464d43 100644 --- a/Assets/Scripts/Pal3.Game/Scene/SceneManager.cs +++ b/Assets/Scripts/Pal3.Game/Scene/SceneManager.cs @@ -22,6 +22,7 @@ namespace Pal3.Game.Scene using Engine.Core.Implementation; using Engine.Extensions; using Engine.Logging; + using GameSystems.Combat.Scene; using Newtonsoft.Json; using Script; using Settings; @@ -43,7 +44,7 @@ namespace Pal3.Game.Scene private IGameEntity _currentSceneRoot; private IGameEntity _currentCombatSceneRoot; - private Scene _currentScene; + private GameScene _currentGameScene; private CombatScene _currentCombatScene; private readonly HashSet _sceneObjectIdsToNotLoadFromSaveState = new (); @@ -70,9 +71,9 @@ namespace Pal3.Game.Scene CommandExecutorRegistry.Instance.UnRegister(this); } - public Scene GetCurrentScene() + public GameScene GetCurrentScene() { - return _currentScene; + return _currentGameScene; } public CombatScene GetCurrentCombatScene() @@ -94,7 +95,7 @@ namespace Pal3.Game.Scene return null; } - public Scene LoadScene(string sceneCityName, string sceneName) + public GameScene LoadScene(string sceneCityName, string sceneName) { Stopwatch timer = Stopwatch.StartNew(); @@ -109,14 +110,14 @@ namespace Pal3.Game.Scene _currentSceneRoot = GameEntityFactory.Create($"Scene_{sceneCityName}_{sceneName}", null, worldPositionStays: false); - _currentScene = _currentSceneRoot.AddComponent(); - _currentScene.Init(_resourceProvider, + _currentGameScene = _currentSceneRoot.AddComponent(); + _currentGameScene.Init(_resourceProvider, _sceneObjectFactory, _sceneStateManager, _gameSettings.IsRealtimeLightingAndShadowsEnabled, _cameraEntity, _sceneObjectIdsToNotLoadFromSaveState); - _currentScene.Load(scnFile, _currentSceneRoot); + _currentGameScene.Load(scnFile, _currentSceneRoot); // Must to clear the exclude list after loading the scene. _sceneObjectIdsToNotLoadFromSaveState.Clear(); @@ -135,7 +136,7 @@ namespace Pal3.Game.Scene // Also a good time to collect garbage System.GC.Collect(); - return _currentScene; + return _currentGameScene; } public CombatScene LoadCombatScene(string combatSceneName) @@ -244,11 +245,11 @@ namespace Pal3.Game.Scene _temporarilyDisabledRenderers.Clear(); _temporarilyDisabledGameObjects.Clear(); - if (_currentScene != null) + if (_currentGameScene != null) { Pal3.Instance.Execute(new SceneLeavingCurrentSceneNotification()); - _currentScene.Destroy(); - _currentScene = null; + _currentGameScene.Destroy(); + _currentGameScene = null; } if (_currentCombatScene != null) diff --git a/Assets/Scripts/Pal3.Game/Scene/SceneObjects/SceneObject.cs b/Assets/Scripts/Pal3.Game/Scene/SceneObjects/SceneObject.cs index 545721a8..5a329ec7 100644 --- a/Assets/Scripts/Pal3.Game/Scene/SceneObjects/SceneObject.cs +++ b/Assets/Scripts/Pal3.Game/Scene/SceneObjects/SceneObject.cs @@ -47,7 +47,7 @@ namespace Pal3.Game.Scene.SceneObjects { public Guid CorrelationId; public int InitObjectId; - public Scene CurrentScene; + public GameScene CurrentScene; public IGameEntity PlayerActorGameEntity; public bool StartedByPlayer; } diff --git a/Assets/Scripts/Pal3.Game/Script/UserVariableManager.cs b/Assets/Scripts/Pal3.Game/Script/UserVariableManager.cs index 84089b88..7e714472 100644 --- a/Assets/Scripts/Pal3.Game/Script/UserVariableManager.cs +++ b/Assets/Scripts/Pal3.Game/Script/UserVariableManager.cs @@ -174,7 +174,7 @@ namespace Pal3.Game.Script public void Execute(ScriptVarSetObjectUsageStatusCommand command) { - Scene scene = ServiceLocator.Instance.Get().GetCurrentScene(); + GameScene scene = ServiceLocator.Instance.Get().GetCurrentScene(); ScnSceneInfo sceneInfo = scene.GetSceneInfo(); SceneStateManager sceneStateManager = ServiceLocator.Instance.Get(); diff --git a/Assets/Scripts/Pal3.Game/State/SaveManager.cs b/Assets/Scripts/Pal3.Game/State/SaveManager.cs index df079722..cc7a7220 100644 --- a/Assets/Scripts/Pal3.Game/State/SaveManager.cs +++ b/Assets/Scripts/Pal3.Game/State/SaveManager.cs @@ -262,7 +262,7 @@ namespace Pal3.Game.State (int)playerActorMovementController.GameEntity.Transform.EulerAngles.y) }); - Dictionary allActors = currentScene.GetAllActors(); + Dictionary allActors = currentScene.GetAllActors(); Dictionary allActorGameEntities = currentScene.GetAllActorGameEntities(); // Save npc actor state @@ -324,7 +324,7 @@ namespace Pal3.Game.State private static void SaveNpcActorState(List commands, int actorId, IGameEntity actorGameEntity, - Dictionary allActors) + Dictionary allActors) { ActorController actorController = actorGameEntity.GetComponent(); @@ -337,7 +337,7 @@ namespace Pal3.Game.State if (!actorController.IsActive) return; // Skip inactive actor - Actor actor = actorController.GetActor(); + GameActor actor = actorController.GetActor(); if (actor.Info.InitActive == 0) { @@ -384,7 +384,7 @@ namespace Pal3.Game.State if (actor.IsScriptIdChanged()) { commands.Add(new ActorSetScriptCommand(actorId, - (int) actor.GetScriptId())); + (int)actor.GetScriptId())); } } diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index c2aca546..e9458d38 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -49,6 +49,7 @@ PlayerSettings: m_StereoRenderingPath: 0 m_ActiveColorSpace: 0 unsupportedMSAAFallback: 0 + m_SpriteBatchMaxVertexCount: 65535 m_SpriteBatchVertexThreshold: 300 m_MTRendering: 0 mipStripping: 0 @@ -710,6 +711,7 @@ PlayerSettings: playModeTestRunnerEnabled: 0 runPlayModeTestAsEditModeTest: 0 actionOnDotNetUnhandledException: 1 + editorGfxJobOverride: 1 enableInternalProfiler: 0 logObjCUncaughtExceptions: 1 enableCrashReportAPI: 0 diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index 77054c5b..b75375e6 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 6000.0.19f1 -m_EditorVersionWithRevision: 6000.0.19f1 (302b264628f9) +m_EditorVersion: 6000.0.20f1 +m_EditorVersionWithRevision: 6000.0.20f1 (05208a74e9aa)