-
Notifications
You must be signed in to change notification settings - Fork 17
fix: events JumpIn lands in the middle of the scene #9567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ecac098
fix: Events Jump In lands on the scene's spawn point when the event p…
popuz c1ad030
Merge branch 'dev' into fix/spawn-points-landing-inside-scene
popuz e98ebc3
Merge branch 'dev' into fix/spawn-points-landing-inside-scene
popuz 94ef25c
simplified to pick first spawn point
popuz 4112107
Merge remote-tracking branch 'origin/fix/spawn-points-landing-inside-…
popuz 2b77d0b
Update Explorer/Assets/DCL/Infrastructure/SceneLifeCycle/TeleportUtil…
popuz 7cb4a30
moved local function down
popuz d14370d
Merge remote-tracking branch 'origin/fix/spawn-points-landing-inside-…
popuz 2b935ac
Merge branch 'dev' into fix/spawn-points-landing-inside-scene
popuz fb3b928
Merge branch 'dev' into fix/spawn-points-landing-inside-scene
popuz 556555e
Merge branch 'dev' into fix/spawn-points-landing-inside-scene
popuz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
...rer/Assets/DCL/Character/CharacterMotion/Tests/TeleportPositionCalculationSystemShould.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| using Arch.Core; | ||
| using DCL.Character.CharacterMotion.Systems; | ||
| using DCL.CharacterMotion.Components; | ||
| using DCL.Ipfs; | ||
| using ECS.SceneLifeCycle; | ||
| using ECS.SceneLifeCycle.Realm; | ||
| using ECS.TestSuite; | ||
| using NSubstitute; | ||
| using NUnit.Framework; | ||
| using System.Collections.Generic; | ||
| using System.Threading; | ||
| using UnityEngine; | ||
| using Utility; | ||
|
|
||
| namespace DCL.Character.CharacterMotion.Tests | ||
| { | ||
| public class TeleportPositionCalculationSystemShould : UnitySystemTestBase<TeleportPositionCalculationSystem> | ||
| { | ||
| private const int PARCEL = ParcelMathHelper.PARCEL_SIZE; | ||
| private const float EPSILON = 0.001f; | ||
|
|
||
| [SetUp] | ||
| public void Setup() | ||
| { | ||
| system = new TeleportPositionCalculationSystem(world, Substitute.For<ILandscape>()); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// A land-on-parcel intent aims at the requested parcel's centre rather than the scene's spawn | ||
| /// point, so an event at a parcel that holds no spawn point of its own (e.g. the Theatre at 0,5 | ||
| /// inside Genesis Plaza) lands on that parcel. Whether such an intent is raised at all is decided | ||
| /// upstream by <see cref="TeleportUtils.TryPickSpawnPointNameInParcel" />. | ||
| /// </summary> | ||
| [Test] | ||
| public void AimAtParcelCentreWhenIntentLandsOnParcel() | ||
| { | ||
| var baseParcel = new Vector2Int(0, 0); | ||
| var eventParcel = new Vector2Int(0, 5); | ||
|
|
||
| var parcels = new List<Vector2Int>(); | ||
|
|
||
| for (int y = baseParcel.y; y <= eventParcel.y; y++) | ||
| parcels.Add(new Vector2Int(0, y)); | ||
|
|
||
| SceneEntityDefinition sceneDef = BuildSceneDef( | ||
| baseParcel, | ||
| parcels, | ||
| MakeSpawnPoint(x: 2f, z: 2f)); | ||
|
|
||
| Entity entity = world.Create(new PlayerTeleportIntent(sceneDef, eventParcel, Vector3.zero, CancellationToken.None, landOnParcel: true)); | ||
|
|
||
| system!.Update(0); | ||
|
|
||
| Vector3 position = world.Get<PlayerTeleportIntent>(entity).Position; | ||
|
|
||
| Assert.That(position.x, Is.EqualTo((eventParcel.x * PARCEL) + ParcelMathHelper.HALF_PARCEL_SIZE).Within(EPSILON)); | ||
| Assert.That(position.z, Is.EqualTo((eventParcel.y * PARCEL) + ParcelMathHelper.HALF_PARCEL_SIZE).Within(EPSILON)); | ||
| } | ||
|
|
||
| private static SceneEntityDefinition BuildSceneDef(Vector2Int baseParcel, IReadOnlyList<Vector2Int> parcels, params SceneMetadata.SpawnPoint[] spawnPoints) | ||
| { | ||
| var sceneSection = new SceneMetadataScene | ||
| { | ||
| DecodedBase = baseParcel, | ||
| DecodedParcels = parcels, | ||
| }; | ||
|
|
||
| var metadata = new SceneMetadata | ||
| { | ||
| scene = sceneSection, | ||
| spawnPoints = new List<SceneMetadata.SpawnPoint>(spawnPoints), | ||
| }; | ||
|
|
||
| return new SceneEntityDefinition("test-scene", metadata); | ||
| } | ||
|
|
||
| private static SceneMetadata.SpawnPoint MakeSpawnPoint(float x, float z) => | ||
| new () | ||
| { | ||
| name = "TestSpawn", | ||
| @default = true, | ||
| position = new SceneMetadata.SpawnPoint.Position | ||
| { | ||
| x = new SceneMetadata.SpawnPoint.Coordinate { SingleValue = x }, | ||
| y = new SceneMetadata.SpawnPoint.Coordinate { SingleValue = 0f }, | ||
| z = new SceneMetadata.SpawnPoint.Coordinate { SingleValue = z }, | ||
| }, | ||
| }; | ||
| } | ||
| } |
2 changes: 2 additions & 0 deletions
2
...ssets/DCL/Character/CharacterMotion/Tests/TeleportPositionCalculationSystemShould.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.