Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
0x7c13 committed Sep 16, 2024
1 parent b016e38 commit 85d2e15
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Assets/Scripts/Pal3.Core/DataReader/Cpk/CpkArchive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public byte[] ReadAllBytes(uint fileVirtualPathCrcHash)
}
else
{
using var stream = new FileStream(_filePath, FileMode.Open, FileAccess.Read);
using FileStream stream = new(_filePath, FileMode.Open, FileAccess.Read);
stream.Seek(entity.StartPos, SeekOrigin.Begin);
byte[] buffer = new byte[entity.PackedSize];
_ = stream.Read(buffer.AsSpan());
Expand Down
3 changes: 1 addition & 2 deletions Assets/Scripts/Pal3.Core/DataReader/Gdb/GdbFileReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,7 @@ private static Dictionary<ActorCombatStateType, CombatStateImpact> GetCombatStat
{
combatStateImpacts[combatState] = new CombatStateImpact
{
Type = combatStateImpactTypes.TryGetValue(combatState, out CombatStateImpactType impactType) ?
impactType : CombatStateImpactType.None,
Type = combatStateImpactTypes.GetValueOrDefault(combatState, CombatStateImpactType.None),
Value = impactValue
};
}
Expand Down
3 changes: 1 addition & 2 deletions Assets/Scripts/Pal3.Core/DataReader/Mv3/Mv3FileReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,8 @@ private static Mv3Mesh GetMv3Mesh(string name,

int triangleIndex = 0;

for (int i = 0; i < attributes[0].IndexBuffers.Length; i++)
foreach (Mv3IndexBuffer indexBuffer in attributes[0].IndexBuffers)
{
Mv3IndexBuffer indexBuffer = attributes[0].IndexBuffers[i];
for (int j = 0; j < 3; j++)
{
for (int k = 0; k < vertFrames.Length; k++)
Expand Down
17 changes: 7 additions & 10 deletions Assets/Scripts/Pal3.Game/Camera/CameraManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,12 @@ public sealed class CameraManager : IDisposable,
private const float SCENE_IN_DOOR_ROOM_FLOOR_HEIGHT = 1.6f;
private const float CAMERA_DEFAULT_DISTANCE = 46f;
private const float CAMERA_IN_DOOR_DISTANCE = 34f;
private const float CAMERA_ROTATION_SPEED_KEY_PRESS = 120f;
private const float CAMERA_ROTATION_SPEED_PER_SECOND_KEYBOARD = 120f;
private const float CAMERA_ROTATION_SPEED_PER_SECOND_MOUSE_SCROLL = 520f;
private const float CAMERA_ROTATION_SPEED_DRAG = 10f;
private const float CAMERA_SMOOTH_FOLLOW_TIME = 0.2f;
private const float CAMERA_SMOOTH_FOLLOW_MAX_DISTANCE = 7f;

#if UNITY_6000_0_OR_NEWER
private const float CAMERA_ROTATION_SPEED_SCROLL = 700f;
#else
private const float CAMERA_ROTATION_SPEED_SCROLL = 15f;
#endif


private static readonly Quaternion[] DefaultCameraRotations =
{
Expand Down Expand Up @@ -220,17 +216,18 @@ private void RotateCameraBasedOnUserInput(float deltaTime)
{
if (_inputActions.Gameplay.RotateCameraClockwise.inProgress)
{
RotateToOrbitPoint(deltaTime * CAMERA_ROTATION_SPEED_KEY_PRESS);
RotateToOrbitPoint(deltaTime * CAMERA_ROTATION_SPEED_PER_SECOND_KEYBOARD);
}
else if (_inputActions.Gameplay.RotateCameraCounterClockwise.inProgress)
{
RotateToOrbitPoint(-deltaTime * CAMERA_ROTATION_SPEED_KEY_PRESS);
RotateToOrbitPoint(-deltaTime * CAMERA_ROTATION_SPEED_PER_SECOND_KEYBOARD);
}

float mouseScroll = _inputActions.Gameplay.OnScroll.ReadValue<float>();
if (mouseScroll != 0)
{
RotateToOrbitPoint(mouseScroll * deltaTime * CAMERA_ROTATION_SPEED_SCROLL);
float direction = mouseScroll > 0 ? 1 : -1;
RotateToOrbitPoint(direction * deltaTime * CAMERA_ROTATION_SPEED_PER_SECOND_MOUSE_SCROLL);
}

if (!_isTouchEnabled) return;
Expand Down

0 comments on commit 85d2e15

Please sign in to comment.