mirror of
https://github.com/0x7c13/Pal3.Unity.git
synced 2026-11-26 17:38:10 +08:00
Correct PAL3A parameter signatures and add handlers for fortune selection, skybox sequences, actor facing and attacks, team and progression state, camera constraints, and battle preparation flags. Give script instances separate locals, advance grouped waits concurrently, and pause PAL3A parents only for their directly decoded child calls. Cancel stale interactions and save replay on reset, preserve finite action semantics, and restore camera orientation after releasing horizontal constraints. Persist supported state in v2 saves and add protocol, runtime, and progression regressions. Full combat gameplay remains outside this change. Validation: PAL3 274/274 and PAL3A 291/291 EditMode tests; 18 PAL3 and 22 PAL3A runtime checks. All 77,889 PAL3A instruction boundaries match EXE signatures.
119 lines
3.4 KiB
C#
119 lines
3.4 KiB
C#
// ------------------------------------------------------------------------
|
|
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
|
// See LICENSE file in the project root for license information.
|
|
// ------------------------------------------------------------------------
|
|
|
|
namespace Pal3.Game.Actor
|
|
{
|
|
using Core.Contract.Constants;
|
|
using Core.Contract.Enums;
|
|
using Core.DataReader.Scn;
|
|
using Data;
|
|
using Engine.Extensions;
|
|
|
|
public sealed class GameActor : ActorBase
|
|
{
|
|
private const float DEFAULT_ROTATION_SPEED = 20f;
|
|
|
|
public ScnNpcInfo Info { get; }
|
|
|
|
private int? _noTurnOverride;
|
|
public int NoTurn => _noTurnOverride ?? (int)Info.NoTurn;
|
|
public bool IsNoTurnChanged => _noTurnOverride.HasValue;
|
|
public void SetNoTurn(int noTurn) => _noTurnOverride = noTurn;
|
|
|
|
private uint? _overwrittenScriptId;
|
|
private uint? _overwrittenMoveSpeed;
|
|
|
|
public GameActor(GameResourceProvider resourceProvider, ScnNpcInfo npcInfo) :
|
|
base(resourceProvider, npcInfo.Id, npcInfo.Name)
|
|
{
|
|
Info = npcInfo;
|
|
}
|
|
|
|
public uint GetScriptId()
|
|
{
|
|
return _overwrittenScriptId ?? Info.ScriptId;
|
|
}
|
|
|
|
public void ChangeScriptId(uint scriptId)
|
|
{
|
|
_overwrittenScriptId = scriptId;
|
|
}
|
|
|
|
public bool IsScriptIdChanged()
|
|
{
|
|
return _overwrittenScriptId != null;
|
|
}
|
|
|
|
public float GetMovementSpeed(MovementMode movementMode)
|
|
{
|
|
if (_overwrittenMoveSpeed != null)
|
|
{
|
|
return _overwrittenMoveSpeed.Value;
|
|
}
|
|
|
|
if (Info.GameBoxMoveSpeed > 0)
|
|
{
|
|
return Info.GameBoxMoveSpeed / UnityPrimitivesConvertor.GameBoxUnitToUnityUnit / 2f;
|
|
}
|
|
|
|
if (Info.Type == ActorType.MainActor)
|
|
{
|
|
return movementMode == MovementMode.Run
|
|
? ActorConstants.PlayerActorRunSpeed
|
|
: ActorConstants.PlayerActorWalkSpeed;
|
|
}
|
|
else
|
|
{
|
|
return movementMode == MovementMode.Run
|
|
? ActorConstants.NpcActorRunSpeed
|
|
: ActorConstants.NpcActorWalkSpeed;
|
|
}
|
|
}
|
|
|
|
public float GetRotationSpeed()
|
|
{
|
|
return DEFAULT_ROTATION_SPEED;
|
|
}
|
|
|
|
public void ChangeMoveSpeed(uint moveSpeed)
|
|
{
|
|
_overwrittenMoveSpeed = moveSpeed;
|
|
}
|
|
|
|
public void ResetMoveSpeed()
|
|
{
|
|
_overwrittenMoveSpeed = null;
|
|
}
|
|
|
|
public string GetInitAction()
|
|
{
|
|
return !string.IsNullOrEmpty(Info.InitAction) && HasAction(Info.InitAction) ?
|
|
Info.InitAction :
|
|
GetIdleAction();
|
|
}
|
|
|
|
public float GetInteractionMaxDistance()
|
|
{
|
|
return Info.Type switch
|
|
{
|
|
ActorType.Soldier => 4f,
|
|
ActorType.MainActor => 4f,
|
|
ActorType.StoryNpc => 4f,
|
|
ActorType.HotelManager => 6f,
|
|
ActorType.Dealer => 6f,
|
|
_ => 4f
|
|
};
|
|
}
|
|
|
|
public bool HasColliderAndRigidBody()
|
|
{
|
|
#if PAL3
|
|
return (PlayerActorId) Id != PlayerActorId.HuaYing;
|
|
#elif PAL3A
|
|
return (PlayerActorId) Id != PlayerActorId.TaoZi;
|
|
#endif
|
|
}
|
|
}
|
|
} |