Better player interaction logic + code refactoring

This commit is contained in:
Jackie Liu committed 2022-11-28 18:31:21 -08:00
1 parent 8b232aeffd
commit e0cc85ca7f
15 files changed
+152 -91

No files matched your search

+1 -5
View File
@@ -22,9 +22,7 @@ namespace Pal3.Actor
ICommandExecutor<ActorRotateFacingCommand>,
ICommandExecutor<ActorRotateFacingDirectionCommand>,
ICommandExecutor<ActorSetScriptCommand>,
#if PAL3A
ICommandExecutor<ActorSetYPositionCommand>,
#endif
ICommandExecutor<ActorChangeScaleCommand>
{
private Actor _actor;
@@ -227,8 +225,7 @@ namespace Pal3.Actor
new ScriptRunnerWaitRequest(waiter));
StartCoroutine(AnimateScale(command.Scale, 2f, waiter));
}
#if PAL3A
public void Execute(ActorSetYPositionCommand command)
{
if (command.ActorId != _actor.Info.Id) return;
@@ -237,6 +234,5 @@ namespace Pal3.Actor
GameBoxInterpreter.ToUnityYPosition(command.GameBoxYPosition),
oldPosition.z);
}
#endif
}
}
@@ -47,6 +47,7 @@ namespace Pal3.Actor
{
private const float MAX_Y_DIFFERENTIAL = 2f;
private const float MAX_Y_DIFFERENTIAL_CROSS_LAYER = 2f;
private const float MAX_Y_DIFFERENTIAL_CROSS_PLATFORM = 1.5f;
private const float DEFAULT_ROTATION_SPEED = 20f;
private Actor _actor;
@@ -167,7 +168,8 @@ namespace Pal3.Actor
{
if (_isMovementOnHold || _currentPath.IsEndOfPath()) return;
MovementResult result = MoveTowards(_currentPath.GetCurrentWayPoint(), _currentPath.MovementMode,
MovementResult result = MoveTowards(_currentPath.GetCurrentWayPoint(),
_currentPath.MovementMode,
_currentPath.IgnoreObstacle);
switch (result)
@@ -214,7 +216,11 @@ namespace Pal3.Actor
{
Vector3 currentPosition = transform.position;
if (!_tilemap.TryGetTile(currentPosition, _currentLayerIndex, out NavTile tile))
if (_isNearOrOnTopOfPlatform)
{
// Do nothing.
}
else if (!_tilemap.TryGetTile(currentPosition, _currentLayerIndex, out NavTile tile))
{
transform.position = _lastKnownValidPositionWhenCollisionEnter;
}
@@ -241,8 +247,12 @@ namespace Pal3.Actor
Vector3 currentActorPosition = transform.position;
Vector2Int currentTilePosition = _tilemap.GetTilePosition(currentActorPosition, _currentLayerIndex);
if (_tilemap.TryGetTile(currentActorPosition, _currentLayerIndex, out NavTile tile) && tile.IsWalkable())
if (_isNearOrOnTopOfPlatform)
{
_lastKnownValidPositionWhenCollisionEnter = currentActorPosition;
}
else if (_tilemap.TryGetTile(currentActorPosition, _currentLayerIndex, out NavTile tile) && tile.IsWalkable())
{
_lastKnownValidPositionWhenCollisionEnter = currentActorPosition;
}
@@ -275,9 +285,13 @@ namespace Pal3.Actor
_activeStandingPlatform = standingPlatformController;
_activeStandingPlatformLastKnownPosition = triggerCollider.gameObject.transform.position;
var targetYPosition = _activeStandingPlatform.GetPlatformHeight();
// Move the actor to the platform surface
Vector3 currentPosition = transform.position;
transform.position = new Vector3(currentPosition.x, targetYPosition, currentPosition.z);
var targetYPosition = _activeStandingPlatform.GetPlatformHeight();
if (Mathf.Abs(currentPosition.y - targetYPosition) <= MAX_Y_DIFFERENTIAL_CROSS_PLATFORM)
{
transform.position = new Vector3(currentPosition.x, targetYPosition, currentPosition.z);
}
}
}
@@ -392,7 +406,8 @@ namespace Pal3.Actor
Vector3 newPosition = Vector3.MoveTowards(currentPosition, targetPosition, moveSpeed * Time.deltaTime);
// If actor is moving towards a collider, check if the new position is still inside the collider.
// If yes, don't move the actor. This is to prevent the actor from moving through the collider.
// If yes, don't move the actor. This is to prevent the actor from moving through the collider
// since we are not moving the rigidbody directly but instead moving the transform.
if (IsDuringCollision() && _actionController.GetRigidBody() is { isKinematic: false } &&
IsNewPositionInsideCollisionCollider(currentPosition, newPosition))
{
@@ -495,13 +510,14 @@ namespace Pal3.Actor
newYPosition = 0f;
// Check if actor is on top of a platform
if (_activeStandingPlatform != null)
if (_isNearOrOnTopOfPlatform && _activeStandingPlatform != null)
{
var targetYPosition = _activeStandingPlatform.GetPlatformHeight();
// Make sure actor is on top of the platform
if (Utility.IsPointWithinCollider(_activeStandingPlatform.GetCollider(),
new Vector3(newPosition.x, targetYPosition, newPosition.z)))
new Vector3(newPosition.x, targetYPosition, newPosition.z)) &&
Mathf.Abs(currentPosition.y - targetYPosition) <= MAX_Y_DIFFERENTIAL_CROSS_PLATFORM)
{
newYPosition = targetYPosition;
return true;
+5 -6
View File
@@ -13,7 +13,6 @@ namespace Pal3.Audio
using Command;
using Command.InternalCommands;
using Command.SceCommands;
using Core.DataLoader;
using Core.DataReader.Cpk;
using Core.DataReader.Scn;
using Core.Extensions;
@@ -47,8 +46,8 @@ namespace Pal3.Audio
private string _currentScriptMusic = string.Empty;
private readonly List<string> _playingSfxSourceNames = new ();
// TODO: Fix and remove this hack
private const string PLAYER_ACTOR_MOVEMENT_SFX_AUDIO_SOURCE_NAME = "PlayerActorMovementSfx";
// TODO: Maybe it is better to control movement sfx
// by the player gameplay controller instead of AudioManager?
private bool _playerMovementSfxInProgress;
private CancellationTokenSource _sceneAudioCts = new ();
@@ -168,7 +167,7 @@ namespace Pal3.Audio
sfxAudioClip == null) yield break;
if (parent != _mainCamera.gameObject &&
audioSourceName == PLAYER_ACTOR_MOVEMENT_SFX_AUDIO_SOURCE_NAME &&
audioSourceName == AudioConstants.PlayerActorMovementSfxAudioSourceName &&
_playerMovementSfxInProgress == false)
{
yield break; // Means movement sfx is already stopped before it started due to the delay of the coroutine
@@ -346,7 +345,7 @@ namespace Pal3.Audio
public void Execute(AttachSfxToGameObjectRequest request)
{
if (request.AudioSourceName == PLAYER_ACTOR_MOVEMENT_SFX_AUDIO_SOURCE_NAME)
if (request.AudioSourceName == AudioConstants.PlayerActorMovementSfxAudioSourceName)
{
_playerMovementSfxInProgress = true;
}
@@ -366,7 +365,7 @@ namespace Pal3.Audio
public void Execute(StopSfxPlayingAtGameObjectRequest command)
{
if (command.AudioSourceName == PLAYER_ACTOR_MOVEMENT_SFX_AUDIO_SOURCE_NAME)
if (command.AudioSourceName == AudioConstants.PlayerActorMovementSfxAudioSourceName)
{
_playerMovementSfxInProgress = false;
}
@@ -215,6 +215,14 @@ namespace Pal3.Command
new ActorSetTilePositionCommand(actorId, tileXPosition, tileYPosition));
}
// <auto-generated/>
[ConsoleMethodAttribute("ActorSetYPosition", "给角色设置Y坐标参数:角色ID,Y坐标(原GameBox引擎下的Y坐标单位)")]
public static void ActorSetYPosition(System.Int32 actorId, System.Single gameBoxYPosition)
{
CommandDispatcher<ICommand>.Instance.Dispatch(
new ActorSetYPositionCommand(actorId, gameBoxYPosition));
}
// <auto-generated/>
[ConsoleMethodAttribute("ActorShowEmoji", "在角色头顶出现表情符号,参数:角色ID,表情编号ID")]
public static void ActorShowEmoji(System.Int32 actorId, System.Int32 emojiId)
@@ -5,7 +5,6 @@
namespace Pal3.Command.SceCommands
{
#if PAL3A
[AvailableInConsole]
[SceCommand(178, "给角色设置Y坐标" +
"参数:角色ID,Y坐标(原GameBox引擎下的Y坐标单位)")]
@@ -22,5 +21,4 @@ namespace Pal3.Command.SceCommands
public int ActorId { get; }
public float GameBoxYPosition { get; }
}
#endif
}
@@ -0,0 +1,12 @@
// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.MetaData
{
public static class AudioConstants
{
public const string PlayerActorMovementSfxAudioSourceName = "PlayerActorMovementSfx";
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7e7e5cf50cd24b11aacd44f9f12c5914
timeCreated: 1669684332
@@ -51,7 +51,6 @@ namespace Pal3.Player
private Camera _camera;
private string _currentMovementSfxAudioName = string.Empty;
private const string PLAYER_ACTOR_MOVEMENT_SFX_AUDIO_SOURCE_NAME = "PlayerActorMovementSfx";
private const float PLAYER_ACTOR_MOVEMENT_SFX_WALK_VOLUME = 0.6f;
private const float PLAYER_ACTOR_MOVEMENT_SFX_RUN_VOLUME = 1.0f;
@@ -222,7 +221,7 @@ namespace Pal3.Player
{
CommandDispatcher<ICommand>.Instance.Dispatch(
new StopSfxPlayingAtGameObjectRequest(_playerActorGameObject,
PLAYER_ACTOR_MOVEMENT_SFX_AUDIO_SOURCE_NAME,
AudioConstants.PlayerActorMovementSfxAudioSourceName,
disposeSource: false));
}
else
@@ -230,7 +229,7 @@ namespace Pal3.Player
CommandDispatcher<ICommand>.Instance.Dispatch(
new AttachSfxToGameObjectRequest(_playerActorGameObject,
newMovementSfxAudioFileName,
PLAYER_ACTOR_MOVEMENT_SFX_AUDIO_SOURCE_NAME,
AudioConstants.PlayerActorMovementSfxAudioSourceName,
loopCount: -1,
actionType == ActorActionType.Walk
? PLAYER_ACTOR_MOVEMENT_SFX_WALK_VOLUME
@@ -421,7 +420,7 @@ namespace Pal3.Player
private void InteractWithFacingInteractable()
{
Vector3 actorFacingDirection = _playerActorMovementController.transform.forward;
Vector3 actorPosition = _playerActorMovementController.GetWorldPosition();
Vector3 actorCenterPosition = _playerActorActionController.GetRendererBounds().center;
Vector2Int tilePosition = _playerActorMovementController.GetTilePosition();
var currentLayerIndex = _playerActorMovementController.GetCurrentLayerIndex();
@@ -436,10 +435,9 @@ namespace Pal3.Player
if (sceneObject.ObjectInfo.Type != ScnSceneObjectType.Climbable &&
sceneObject.ObjectInfo.LayerIndex != currentLayerIndex) continue;
Vector3 sceneObjectPosition = sceneObject.GetGameObject().transform.position;
float distanceToActor = Vector2.Distance(new Vector2(actorPosition.x, actorPosition.z),
new Vector2(sceneObjectPosition.x, sceneObjectPosition.z));
Vector3 actorToObjectFacing = sceneObjectPosition - actorPosition;
Vector3 closetPointOnObject = sceneObject.GetRendererBounds().ClosestPoint(actorCenterPosition);
float distanceToActor = Vector3.Distance(actorCenterPosition, closetPointOnObject);
Vector3 actorToObjectFacing = closetPointOnObject - actorCenterPosition;
float facingAngle = Vector2.Angle(
new Vector2(actorFacingDirection.x, actorFacingDirection.z),
new Vector2(actorToObjectFacing.x, actorToObjectFacing.z));
@@ -454,6 +452,7 @@ namespace Pal3.Player
if (sceneObject.IsInteractable(interactionContext) &&
facingAngle < nearestInteractableFacingAngle)
{
//Debug.DrawLine(actorCenterPosition, closetPointOnObject, Color.white, 1000);
nearestInteractableFacingAngle = facingAngle;
interactionAction = () => sceneObject.Interact(triggerredByPlayer: true);
}
@@ -463,17 +462,16 @@ namespace Pal3.Player
_sceneManager.GetCurrentScene().GetAllActorGameObjects())
{
var actorController = actorInfo.Value.GetComponent<ActorController>();
var actorActionController = actorInfo.Value.GetComponent<ActorActionController>();
var actorMovementController = actorInfo.Value.GetComponent<ActorMovementController>();
if (actorMovementController.GetCurrentLayerIndex() != currentLayerIndex ||
actorInfo.Key == (int)_playerManager.GetPlayerActor() ||
!actorController.IsActive) continue;
Vector3 targetActorPosition = actorController.transform.position;
var distance = Vector2.Distance(
new Vector2(actorPosition.x, actorPosition.z),
new Vector2(targetActorPosition.x, targetActorPosition.z));
Vector3 actorToActorFacing = targetActorPosition - actorPosition;
Vector3 targetActorCenterPosition = actorActionController.GetRendererBounds().center;
var distance = Vector3.Distance(actorCenterPosition,targetActorCenterPosition);
Vector3 actorToActorFacing = targetActorCenterPosition - actorCenterPosition;
float facingAngle = Vector2.Angle(
new Vector2(actorFacingDirection.x, actorFacingDirection.z),
new Vector2(actorToActorFacing.x, actorToActorFacing.z));
@@ -481,6 +479,7 @@ namespace Pal3.Player
if (actorController.IsInteractable(distance) &&
facingAngle < nearestInteractableFacingAngle)
{
//Debug.DrawLine(actorCenterPosition, targetActorCenterPosition, Color.white, 1000);
nearestInteractableFacingAngle = facingAngle;
interactionAction = () => InteractWithActor(actorInfo.Key, actorInfo.Value);
}
@@ -837,7 +836,7 @@ namespace Pal3.Player
_currentMovementSfxAudioName = string.Empty;
CommandDispatcher<ICommand>.Instance.Dispatch(
new StopSfxPlayingAtGameObjectRequest(_playerActorGameObject,
PLAYER_ACTOR_MOVEMENT_SFX_AUDIO_SOURCE_NAME,
AudioConstants.PlayerActorMovementSfxAudioSourceName,
disposeSource: true));
}
@@ -940,7 +939,7 @@ namespace Pal3.Player
_currentMovementSfxAudioName = string.Empty;
CommandDispatcher<ICommand>.Instance.Dispatch(
new StopSfxPlayingAtGameObjectRequest(_playerActorGameObject,
PLAYER_ACTOR_MOVEMENT_SFX_AUDIO_SOURCE_NAME,
AudioConstants.PlayerActorMovementSfxAudioSourceName,
disposeSource: true));
}
@@ -45,9 +45,7 @@ namespace Pal3.Player
ICommandExecutor<ActorFadeInCommand>,
ICommandExecutor<ActorFadeOutCommand>,
ICommandExecutor<ActorSetScriptCommand>,
#if PAL3A
ICommandExecutor<ActorSetYPositionCommand>,
#endif
ICommandExecutor<PlayerEnableInputCommand>,
ICommandExecutor<CameraFocusOnActorCommand>,
ICommandExecutor<EffectAttachToActorCommand>,
@@ -354,7 +352,6 @@ namespace Pal3.Player
}
}
#if PAL3A
public void Execute(ActorSetYPositionCommand command)
{
if (command.ActorId == ActorConstants.PlayerActorVirtualID)
@@ -363,7 +360,6 @@ namespace Pal3.Player
new ActorSetYPositionCommand((int)_playerActor, command.GameBoxYPosition));
}
}
#endif
public void Execute(CameraFocusOnActorCommand command)
{
@@ -41,7 +41,7 @@ namespace Pal3.Scene.SceneObjects.Common
{
// A little bit lower than the collider bounds just to make sure
// the actor is always inside the collider when standing on the platform.
return _collider.bounds.max.y - 0.05f;
return _collider.bounds.max.y - 0.01f;
}
private void OnTriggerEnter(Collider other)
@@ -10,7 +10,6 @@ namespace Pal3.Scene.SceneObjects
using Command.SceCommands;
using Common;
using Core.DataReader.Scn;
using Core.Renderer;
using Data;
using MetaData;
using State;
@@ -33,6 +32,10 @@ namespace Pal3.Scene.SceneObjects
if (Activated) return GetGameObject();
GameObject sceneGameObject = base.Activate(resourceProvider, tintColor);
sceneGameObject.AddComponent<InvestigationTriggerController>().Init(this);
if (ObjectInfo.IsNonBlocking == 0)
{
sceneGameObject.AddComponent<SceneObjectMeshCollider>(); // Add collider to block player
}
return sceneGameObject;
}
@@ -64,22 +67,10 @@ namespace Pal3.Scene.SceneObjects
internal class InvestigationTriggerController : MonoBehaviour
{
private InvestigationTriggerObject _object;
private Bounds _bounds;
public void Init(InvestigationTriggerObject investigationTriggerObject)
{
_object = investigationTriggerObject;
// 2: 模型触发
if (_object.ObjectInfo.TriggerType == 2 &&
GetComponentInChildren<StaticMeshRenderer>() is { } meshRenderer)
{
_bounds = meshRenderer.GetRendererBounds();
}
else
{
_bounds = investigationTriggerObject.ObjectInfo.Bounds;
}
}
}
}
@@ -12,6 +12,7 @@ namespace Pal3.Scene.SceneObjects
using Core.Animation;
using Core.DataReader.Scn;
using Core.GameBox;
using Core.Services;
using Data;
using Renderer;
using UnityEngine;
@@ -21,7 +22,7 @@ namespace Pal3.Scene.SceneObjects
{
private LiftingMechanismObjectController _objectController;
private StandingPlatformController _platformController;
public LiftingMechanismObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
: base(objectInfo, sceneInfo)
{
@@ -35,11 +36,18 @@ namespace Pal3.Scene.SceneObjects
// Set to final position if the platform is already activated
if (ObjectInfo.SwitchState == 1)
{
Vector3 finalPosition = sceneGameObject.transform.position;
Vector3 position = sceneGameObject.transform.position;
float gameBoxYPosition = ObjectInfo.Parameters[0];
// A small Y offset to ensure actor shadow is properly rendered
finalPosition.y = GameBoxInterpreter.ToUnityYPosition(gameBoxYPosition) - 0.02f;
sceneGameObject.transform.position = finalPosition;
var finalYPosition = GameBoxInterpreter.ToUnityYPosition(gameBoxYPosition);
var yOffset = finalYPosition - position.y;
position.y = finalYPosition;
sceneGameObject.transform.position = position;
// Set Y position of the object on the platform
if (ObjectInfo.Parameters[2] != 0)
{
// TODO: impl
}
}
_objectController = sceneGameObject.AddComponent<LiftingMechanismObjectController>();
@@ -55,13 +63,11 @@ namespace Pal3.Scene.SceneObjects
bounds = polyModelRenderer.GetMeshBounds();
}
// Some tweaks to the bounds to fit better with the rendering model
Vector3 tweakedBoundsCenter = bounds.center;
tweakedBoundsCenter.y -= 0.4f;
// Some tweaks to the bounds to make sure actor won't stuck
// near the edge of the platform
Vector3 tweakedBoundsSize = bounds.size;
tweakedBoundsSize.x += 0.4f;
tweakedBoundsSize.z += 0.4f;
bounds.center = tweakedBoundsCenter;
tweakedBoundsSize.x += 0.5f;
tweakedBoundsSize.z += 0.5f;
bounds.size = tweakedBoundsSize;
_platformController = sceneGameObject.AddComponent<StandingPlatformController>();
@@ -109,6 +115,7 @@ namespace Pal3.Scene.SceneObjects
public void Interact()
{
CommandDispatcher<ICommand>.Instance.Dispatch(new PlayerEnableInputCommand(0));
StartCoroutine(InteractInternal());
}
@@ -119,21 +126,46 @@ namespace Pal3.Scene.SceneObjects
CommandDispatcher<ICommand>.Instance.Dispatch(
new CameraFocusOnSceneObjectCommand(_object.ObjectInfo.Id));
Vector3 finalPosition = transform.position;
Vector3 position = transform.position;
float gameBoxYPosition = _object.ObjectInfo.Parameters[0];
// A small Y offset to ensure actor shadow is properly rendered
finalPosition.y = GameBoxInterpreter.ToUnityYPosition(gameBoxYPosition) - 0.02f;
var finalYPosition = GameBoxInterpreter.ToUnityYPosition(gameBoxYPosition);
var yOffset = finalYPosition - position.y;
_object.PlaySfxIfAny();
var hasObjectOnPlatform = false;
GameObject objectOnThePlatform = null;
Vector3 objectOnThePlatformOriginalPosition = Vector3.zero;
// Set Y position of the object on the platform
if (_object.ObjectInfo.Parameters[2] != 0)
{
hasObjectOnPlatform = true;
objectOnThePlatform = ServiceLocator.Instance.Get<SceneManager>()
.GetCurrentScene()
.GetSceneObject(_object.ObjectInfo.Parameters[2])
.GetGameObject();
objectOnThePlatformOriginalPosition = objectOnThePlatform.transform.position;
}
yield return AnimationHelper.MoveTransform(gameObject.transform,
finalPosition,
LIFTING_ANIMATION_DURATION,
AnimationCurveType.Sine);
yield return AnimationHelper.EnumerateValue(0f, yOffset, LIFTING_ANIMATION_DURATION, AnimationCurveType.Sine,
offset =>
{
transform.position = new Vector3(position.x, position.y + offset, position.z);
if (hasObjectOnPlatform)
{
objectOnThePlatform.transform.position = new Vector3(
objectOnThePlatformOriginalPosition.x,
objectOnThePlatformOriginalPosition.y + offset,
objectOnThePlatformOriginalPosition.z);
}
});
CommandDispatcher<ICommand>.Instance.Dispatch(
new CameraFreeCommand(1));
CommandDispatcher<ICommand>.Instance.Dispatch(
new PlayerEnableInputCommand(1));
}
}
}
@@ -171,6 +171,25 @@ namespace Pal3.Scene.SceneObjects
return _sceneObjectGameObject;
}
public Bounds GetRendererBounds()
{
if (_polyModelRenderer != null)
{
return _polyModelRenderer.GetRendererBounds();
}
if (_cvdModelRenderer != null)
{
return _cvdModelRenderer.GetRendererBounds();
}
return new Bounds
{
center = GameBoxInterpreter.ToUnityPosition(ObjectInfo.GameBoxPosition),
size = Vector3.one
};
}
public GameObject GetGameObject()
{
return _sceneObjectGameObject;
@@ -20,6 +20,8 @@ namespace Pal3.Scene.SceneObjects
[ScnSceneObject(ScnSceneObjectType.SpecialMechanism)]
public class SpecialMechanismObject : SceneObject
{
private const float MAX_INTERACTION_DISTANCE = 4f;
private SpecialMechanismObjectController _objectController;
public SpecialMechanismObject(ScnObjectInfo objectInfo, ScnSceneInfo sceneInfo)
@@ -40,7 +42,7 @@ namespace Pal3.Scene.SceneObjects
PlayerActorId.JingTian => 1.5f,
PlayerActorId.XueJian => 1.5f,
PlayerActorId.LongKui => 1.2f,
PlayerActorId.ZiXuan => 1.3f,
PlayerActorId.ZiXuan => 1.2f,
PlayerActorId.ChangQing => 1.7f,
#endif
_ => 1f
@@ -54,25 +56,10 @@ namespace Pal3.Scene.SceneObjects
return sceneGameObject;
}
private float GetInteractionMaxDistance()
{
return (PlayerActorId) ObjectInfo.Parameters[0] switch
{
#if PAL3
PlayerActorId.JingTian => 4.5f,
PlayerActorId.XueJian => 5f,
PlayerActorId.LongKui => 8f,
PlayerActorId.ZiXuan => 4.5f,
PlayerActorId.ChangQing => 4.5f,
#endif
_ => 4.5f
};
}
public override bool IsInteractable(InteractionContext ctx)
{
return Activated &&
ctx.DistanceToActor < GetInteractionMaxDistance() &&
ctx.DistanceToActor < MAX_INTERACTION_DISTANCE &&
ctx.ActorId == ObjectInfo.Parameters[0]; // Only specified actor can interact with this object
}
+5
View File
@@ -16,6 +16,7 @@ namespace Pal3.State
using Command.InternalCommands;
using Command.SceCommands;
using Core.DataReader.Scn;
using Core.GameBox;
using Effect;
using Effect.PostProcessing;
using Feature;
@@ -114,6 +115,8 @@ namespace Pal3.State
var playerActorMovementController = currentScene
.GetActorGameObject((int) _playerManager.GetPlayerActor()).GetComponent<ActorMovementController>();
Vector2Int playerActorTilePosition = playerActorMovementController.GetTilePosition();
Vector3 playerActorGameBoxPosition = GameBoxInterpreter
.ToGameBoxPosition(playerActorMovementController.GetWorldPosition());
var varsToSave = _scriptManager.GetGlobalVariables();
if (saveLevel == SaveLevel.Minimal)
@@ -206,6 +209,8 @@ namespace Pal3.State
playerActorMovementController.GetCurrentLayerIndex()),
new ActorSetTilePositionCommand(currentPlayerActorId,
playerActorTilePosition.x, playerActorTilePosition.y),
new ActorSetYPositionCommand(currentPlayerActorId,
playerActorGameBoxPosition.y),
new ActorRotateFacingCommand(currentPlayerActorId,
-(int)playerActorMovementController.gameObject.transform.rotation.eulerAngles.y)
});