Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
0x7c13 committed Aug 18, 2023
1 parent 5e73768 commit 5eb5574
Show file tree
Hide file tree
Showing 12 changed files with 163 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Assets/Scripts/Core/DataReader/Scn/ScnFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public bool IsCity(string cityName)
return string.Equals(CityName, cityName, StringComparison.OrdinalIgnoreCase);
}

private bool IsScene(string sceneName)
public bool IsScene(string sceneName)
{
return string.Equals(SceneName, sceneName, StringComparison.OrdinalIgnoreCase);
}
Expand Down
13 changes: 13 additions & 0 deletions Assets/Scripts/Pal3/GamePlay/PlayerActorManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,19 @@ public void Execute(ActorPathToCommand command)
{
if (command.ActorId == ActorConstants.PlayerActorVirtualID)
{
// Fix a bug in PAL3 script
// TODO: Implement a better solution to fix command at dispatching time
#if PAL3
if (command.TileXPosition == 289 &&
command.TileYPosition == 21 &&
command.Mode == 0)
{
CommandDispatcher<ICommand>.Instance.Dispatch(
new ActorPathToCommand((int)_playerActor, 288, 20, command.Mode));
return;
}
#endif

CommandDispatcher<ICommand>.Instance.Dispatch(
new ActorPathToCommand((int)_playerActor, command.TileXPosition, command.TileYPosition, command.Mode));
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/Pal3/GameSystem/BigMapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public void Execute(ResetGameStateCommand command)

public void Execute(GameSwitchRenderingStateCommand command)
{
if (command.State == 13)
if ((RenderingState)command.State == RenderingState.BigMap)
{
Show();
}
Expand Down
2 changes: 2 additions & 0 deletions Assets/Scripts/Pal3/Input/InputManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public void SwitchCurrentActionMap(GameState state)
GameState.Gameplay => _playerInputActions.Gameplay.Get(),
GameState.Cutscene => _playerInputActions.Cutscene.Get(),
GameState.VideoPlaying => _playerInputActions.VideoPlaying.Get(),
GameState.Combat => _playerInputActions.Combat.Get(),
GameState.Debug => _playerInputActions.Debug.Get(),
_ => null
};

Expand Down
98 changes: 98 additions & 0 deletions Assets/Scripts/Pal3/Input/PlayerInputActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,18 @@ public @PlayerInputActions()
""isPartOfComposite"": false
}
]
},
{
""name"": ""Debug"",
""id"": ""76cd9d4b-6f9c-4f58-a69b-859c0b6d3c6b"",
""actions"": [],
""bindings"": []
},
{
""name"": ""Combat"",
""id"": ""49ab487c-79cc-4f76-9e0f-872d16db5f30"",
""actions"": [],
""bindings"": []
}
],
""controlSchemes"": []
Expand Down Expand Up @@ -1289,6 +1301,10 @@ public @PlayerInputActions()
m_UI_ToggleBigMap = m_UI.FindAction("ToggleBigMap", throwIfNotFound: true);
m_UI_ToggleStorySelector = m_UI.FindAction("ToggleStorySelector", throwIfNotFound: true);
m_UI_ExitCurrentShowingMenu = m_UI.FindAction("ExitCurrentShowingMenu", throwIfNotFound: true);
// Debug
m_Debug = asset.FindActionMap("Debug", throwIfNotFound: true);
// Combat
m_Combat = asset.FindActionMap("Combat", throwIfNotFound: true);
}

public void Dispose()
Expand Down Expand Up @@ -1762,6 +1778,82 @@ public void SetCallbacks(IUIActions instance)
}
}
public UIActions @UI => new UIActions(this);

// Debug
private readonly InputActionMap m_Debug;
private List<IDebugActions> m_DebugActionsCallbackInterfaces = new List<IDebugActions>();
public struct DebugActions
{
private @PlayerInputActions m_Wrapper;
public DebugActions(@PlayerInputActions wrapper) { m_Wrapper = wrapper; }
public InputActionMap Get() { return m_Wrapper.m_Debug; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(DebugActions set) { return set.Get(); }
public void AddCallbacks(IDebugActions instance)
{
if (instance == null || m_Wrapper.m_DebugActionsCallbackInterfaces.Contains(instance)) return;
m_Wrapper.m_DebugActionsCallbackInterfaces.Add(instance);
}

private void UnregisterCallbacks(IDebugActions instance)
{
}

public void RemoveCallbacks(IDebugActions instance)
{
if (m_Wrapper.m_DebugActionsCallbackInterfaces.Remove(instance))
UnregisterCallbacks(instance);
}

public void SetCallbacks(IDebugActions instance)
{
foreach (var item in m_Wrapper.m_DebugActionsCallbackInterfaces)
UnregisterCallbacks(item);
m_Wrapper.m_DebugActionsCallbackInterfaces.Clear();
AddCallbacks(instance);
}
}
public DebugActions @Debug => new DebugActions(this);

// Combat
private readonly InputActionMap m_Combat;
private List<ICombatActions> m_CombatActionsCallbackInterfaces = new List<ICombatActions>();
public struct CombatActions
{
private @PlayerInputActions m_Wrapper;
public CombatActions(@PlayerInputActions wrapper) { m_Wrapper = wrapper; }
public InputActionMap Get() { return m_Wrapper.m_Combat; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
public bool enabled => Get().enabled;
public static implicit operator InputActionMap(CombatActions set) { return set.Get(); }
public void AddCallbacks(ICombatActions instance)
{
if (instance == null || m_Wrapper.m_CombatActionsCallbackInterfaces.Contains(instance)) return;
m_Wrapper.m_CombatActionsCallbackInterfaces.Add(instance);
}

private void UnregisterCallbacks(ICombatActions instance)
{
}

public void RemoveCallbacks(ICombatActions instance)
{
if (m_Wrapper.m_CombatActionsCallbackInterfaces.Remove(instance))
UnregisterCallbacks(instance);
}

public void SetCallbacks(ICombatActions instance)
{
foreach (var item in m_Wrapper.m_CombatActionsCallbackInterfaces)
UnregisterCallbacks(item);
m_Wrapper.m_CombatActionsCallbackInterfaces.Clear();
AddCallbacks(instance);
}
}
public CombatActions @Combat => new CombatActions(this);
public interface IGameplayActions
{
void OnMovement(InputAction.CallbackContext context);
Expand Down Expand Up @@ -1807,5 +1899,11 @@ public interface IUIActions
void OnToggleStorySelector(InputAction.CallbackContext context);
void OnExitCurrentShowingMenu(InputAction.CallbackContext context);
}
public interface IDebugActions
{
}
public interface ICombatActions
{
}
}
}
12 changes: 12 additions & 0 deletions Assets/Scripts/Pal3/Input/PlayerInputActions.inputactions
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,18 @@
"isPartOfComposite": false
}
]
},
{
"name": "Debug",
"id": "76cd9d4b-6f9c-4f58-a69b-859c0b6d3c6b",
"actions": [],
"bindings": []
},
{
"name": "Combat",
"id": "49ab487c-79cc-4f76-9e0f-872d16db5f30",
"actions": [],
"bindings": []
}
],
"controlSchemes": []
Expand Down
15 changes: 15 additions & 0 deletions Assets/Scripts/Pal3/MetaData/RenderingStateConstants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2023, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------

namespace Pal3.MetaData
{
// OG game rendering state constants
public enum RenderingState
{
Gameplay = 0, // 游戏
BigMap = 13, // 大地图
MonsterCatalogue = 17, // 降妖谱
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Pal3/MetaData/RenderingStateConstants.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Assets/Scripts/Pal3/Scene/Scene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -521,14 +521,16 @@ private HashSet<Vector2Int> GetAllActiveActorBlockingTilePositions(int layerInde
{
var actorMovementController = actor.GetComponent<ActorMovementController>();
if (actorMovementController.GetCurrentLayerIndex() != layerIndex) continue;
Vector2Int tilePosition = _tilemap.GetTilePosition(actorMovementController.GetWorldPosition(), layerIndex);
Vector2Int tilePosition = actorMovementController.GetTilePosition();
actorTiles.Add(tilePosition);
}
}

var obstacles = new HashSet<Vector2Int>();
foreach (Vector2Int actorTile in actorTiles)
{
if (!_tilemap.IsTilePositionInsideTileMap(actorTile, layerIndex)) continue;

obstacles.Add(actorTile);

// Mark 8 tiles right next to the actor tile as obstacles
Expand Down
6 changes: 4 additions & 2 deletions Assets/Scripts/Pal3/Scene/SceneObjects/GeneralSceneObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ public override GameObject Activate(GameResourceProvider resourceProvider, Color
{
_meshCollider = sceneGameObject.AddComponent<SceneObjectMeshCollider>();
}
// All general objects (except indicators) in M22 scene should block player
// All general objects (except indicators or object 45 in M22-3)
// in M22 scene should block player
if (SceneInfo.IsCity("m22") &&
ObjectInfo.Parameters[0] == 0)
ObjectInfo.Parameters[0] == 0 &&
!(SceneInfo.IsScene("3") && ObjectInfo is { Id: 45 }))
{
_meshCollider = sceneGameObject.AddComponent<SceneObjectMeshCollider>();
}
Expand Down
2 changes: 2 additions & 0 deletions Assets/Scripts/Pal3/State/GameState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ public enum GameState
Gameplay,
Cutscene,
VideoPlaying,
Combat,
Debug,
}
}
3 changes: 1 addition & 2 deletions Assets/Scripts/Pal3/State/GameStateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ private void UpdateInputManagerState()
public void EnterDebugState()
{
_isDebugging = true;
// Let's go to cutscene state to "disable" all input from player
_inputManager.SwitchCurrentActionMap(GameState.Cutscene);
_inputManager.SwitchCurrentActionMap(GameState.Debug);
}

public void LeaveDebugState()
Expand Down

0 comments on commit 5eb5574

Please sign in to comment.