mirror of
https://github.com/0x7c13/Pal3.Unity.git
synced 2026-11-26 17:38:10 +08:00
Properly implement TrapObject for PAL3A
This commit is contained in:
1 parent
6590e58f0a
commit
ff13300bcd
1 file changed
+16
-2
@@ -9,6 +9,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
using Command;
|
||||
using Command.SceCommands;
|
||||
using Common;
|
||||
using Core.Animation;
|
||||
using Core.DataReader.Scn;
|
||||
using Core.GameBox;
|
||||
using Data;
|
||||
@@ -32,7 +33,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
GameObject sceneGameObject = base.Activate(resourceProvider, tintColor);
|
||||
|
||||
// Make trap trigger rect a bit smaller for better game experience
|
||||
var tweakedRect = new GameBoxRect()
|
||||
GameBoxRect triggerRect = new()
|
||||
{
|
||||
Left = ObjectInfo.TileMapTriggerRect.Left + 1,
|
||||
Right = ObjectInfo.TileMapTriggerRect.Right - 1,
|
||||
@@ -41,7 +42,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
};
|
||||
|
||||
_triggerController = sceneGameObject.AddComponent<TilemapTriggerController>();
|
||||
_triggerController.Init(tweakedRect, ObjectInfo.LayerIndex);
|
||||
_triggerController.Init(triggerRect, ObjectInfo.LayerIndex);
|
||||
_triggerController.OnPlayerActorEntered += OnPlayerActorEntered;
|
||||
|
||||
return sceneGameObject;
|
||||
@@ -57,7 +58,11 @@ namespace Pal3.Scene.SceneObjects
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(
|
||||
new ActorStopActionAndStandCommand(ActorConstants.PlayerActorVirtualID));
|
||||
|
||||
#if PAL3
|
||||
PlaySfx("wg007");
|
||||
#elif PAL3A
|
||||
PlaySfxIfAny();
|
||||
#endif
|
||||
|
||||
// Let player actor fall down
|
||||
if (ctx.PlayerActorGameObject.GetComponent<Rigidbody>() is { } rigidbody)
|
||||
@@ -71,6 +76,15 @@ namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
yield return GetCvdModelRenderer().PlayOneTimeAnimationAsync(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if PAL3A
|
||||
Transform transform = GetGameObject().transform;
|
||||
float yOffset = GameBoxInterpreter.ToUnityDistance(ObjectInfo.Parameters[2]);
|
||||
Vector3 finalPosition = transform.position + new Vector3(0f, -yOffset, 0f);
|
||||
yield return AnimationHelper.MoveTransformAsync(transform, finalPosition, 0.4f);
|
||||
#endif
|
||||
}
|
||||
|
||||
yield return ExecuteScriptAndWaitForFinishIfAnyAsync();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user