mirror of
https://github.com/0x7c13/Pal3.Unity.git
synced 2026-11-26 17:38:10 +08:00
Cover SCE command contracts, binary readers, resource layouts and full local CPK decompression for PAL3 and PAL3A. Fix CVD time rebasing, binary read bounds and short reads, and CPK/NAV validation. Standardize first-party copyright headers, preserve correct creation years, and update console source generation. Validate both variants in Unity and verify all live CPK entries.
72 lines
2.5 KiB
C#
72 lines
2.5 KiB
C#
// ------------------------------------------------------------------------
|
|
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
|
// See LICENSE file in the project root for license information.
|
|
// ------------------------------------------------------------------------
|
|
|
|
#if PAL3
|
|
|
|
namespace Pal3.Game.Scene.SceneObjects
|
|
{
|
|
using System.Collections;
|
|
using Command;
|
|
using Command.Extensions;
|
|
using Common;
|
|
using Core.Command;
|
|
using Core.Contract.Enums;
|
|
using Core.DataReader.Scn;
|
|
using Data;
|
|
using Engine.Core.Abstraction;
|
|
using Engine.Services;
|
|
|
|
using Color = Core.Primitives.Color;
|
|
using Vector2Int = UnityEngine.Vector2Int;
|
|
using Vector3 = UnityEngine.Vector3;
|
|
|
|
[ScnSceneObject(SceneObjectType.EyeBall)]
|
|
public sealed class EyeBallObject : SceneObject,
|
|
ICommandExecutor<PlayerActorTilePositionUpdatedNotification>
|
|
{
|
|
private readonly Tilemap _tilemap;
|
|
|
|
public EyeBallObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
|
|
: base(objectInfo, sceneInfo)
|
|
{
|
|
_tilemap = ServiceLocator.Instance.Get<SceneManager>().GetCurrentScene().GetTilemap();
|
|
}
|
|
|
|
public override IGameEntity Activate(GameResourceProvider resourceProvider,
|
|
Color tintColor)
|
|
{
|
|
if (IsActivated) return GetGameEntity();
|
|
IGameEntity sceneObjectGameEntity = base.Activate(resourceProvider, tintColor);
|
|
CommandExecutorRegistry<ICommand>.Instance.Register(this);
|
|
return sceneObjectGameEntity;
|
|
}
|
|
|
|
public void Execute(PlayerActorTilePositionUpdatedNotification command)
|
|
{
|
|
IGameEntity eyeBallGameEntity = GetGameEntity();
|
|
Vector3 actorPosition = _tilemap.GetWorldPosition(
|
|
new Vector2Int(command.TileXPosition, command.TileYPosition), command.LayerIndex);
|
|
actorPosition.y += 3f; // 3f is about the height of the player actor
|
|
eyeBallGameEntity.Transform.LookAt(actorPosition);
|
|
}
|
|
|
|
public override bool IsDirectlyInteractable(float distance) => false;
|
|
|
|
public override bool ShouldGoToCutsceneWhenInteractionStarted() => true;
|
|
|
|
public override IEnumerator InteractAsync(InteractionContext ctx)
|
|
{
|
|
yield break;
|
|
}
|
|
|
|
public override void Deactivate()
|
|
{
|
|
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
|
|
base.Deactivate();
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif |