Properly implement TrapObject for PAL3A

This commit is contained in:
Jackie Liu committed 2023-03-14 01:26:25 -07:00
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();
}