Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lorux0 committed Sep 13, 2024
1 parent 44b65d4 commit fe0e27e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace DCL.CharacterTriggerArea.Components
public struct CharacterTriggerAreaComponent : IDirtyMarker
{
private static readonly IReadOnlyCollection<Transform> EMPTY_COLLECTION = Array.Empty<Transform>();
private CharacterTriggerArea? monoBehaviour;
internal CharacterTriggerArea? monoBehaviour;
private readonly bool targetOnlyMainPlayer;
public Vector3 AreaSize { get; private set; }

Expand All @@ -37,11 +37,6 @@ public CharacterTriggerAreaComponent(Vector3 areaSize, bool targetOnlyMainPlayer
IsDirty = true;
}

public void ForceAssignArea(CharacterTriggerArea characterTriggerArea)
{
monoBehaviour = characterTriggerArea;
}

public void TryAssignArea(IComponentPool<CharacterTriggerArea> pool, Transform mainPlayerTransform)
{
if (IsDirty == false) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using DCL.Profiles;
using DCL.SDKComponents.AvatarModifierArea.Components;
using DCL.SDKComponents.AvatarModifierArea.Systems;
using DCL.Utilities;
using ECS.LifeCycle.Components;
using ECS.Prioritization.Components;
using ECS.TestSuite;
Expand Down Expand Up @@ -196,17 +195,44 @@ public void UpdateAvatarModifierAreaComponentCorrectly()
[Test]
public void ToggleHidingFlagCorrectly()
{
var excludedIds = new HashSet<string>();
const string FAKE_USER_ID = "Ia4Ia5Cth0ulhu2Ftaghn2";

globalWorld.Add(fakeAvatarEntity, new Profile(FAKE_USER_ID, "fake user", new Avatar(
BodyShape.MALE,
WearablesConstants.DefaultWearables.GetDefaultWearablesForBodyShape(BodyShape.MALE),
WearablesConstants.DefaultColors.GetRandomEyesColor(),
WearablesConstants.DefaultColors.GetRandomHairColor(),
WearablesConstants.DefaultColors.GetRandomSkinColor())), new AvatarShapeComponent());

world.Add(fakeAvatarEntity, new AvatarShapeComponent());

var pbComponent = new PBAvatarModifierArea
{
Area = new Vector3
{
X = 1.68f,
Y = 2.96f,
Z = 8.66f,
},
IsDirty = true,
};

world.Add(triggerAreaEntity, pbComponent);
system.Update(0);

// "Enter" trigger area
characterTriggerArea.OnTriggerEnter(fakeAvatarShapeCollider);
CharacterTriggerAreaComponent component = world.Get<CharacterTriggerAreaComponent>(triggerAreaEntity);
component.monoBehaviour = characterTriggerArea;
world.Set(triggerAreaEntity, component);

system.Update(0f);
// system.ShowAvatar(fakeAvatarShapeTransform, true, excludedIds);

Assert.IsTrue(globalWorld.Get<AvatarShapeComponent>(fakeAvatarEntity).HiddenByModifierArea);

characterTriggerArea.OnTriggerExit(fakeAvatarShapeCollider);

system.Update(0f);
// system.ShowAvatar(fakeAvatarShapeTransform, false, excludedIds);

Assert.IsFalse(globalWorld.Get<AvatarShapeComponent>(fakeAvatarEntity).HiddenByModifierArea);
}
Expand All @@ -227,7 +253,6 @@ public void FilterByExcludedIds()
excludedIds.Add(FAKE_USER_ID);

system.Update(0f);
// system.ShowAvatar(fakeAvatarShapeTransform, true, excludedIds);

Assert.IsFalse(globalWorld.Get<AvatarShapeComponent>(fakeAvatarEntity).HiddenByModifierArea);
}
Expand Down Expand Up @@ -289,7 +314,7 @@ public void HandleExcludedIdsUpdateCorrectly()
characterTriggerArea.OnTriggerEnter(fakeAvatar2ShapeCollider);

CharacterTriggerAreaComponent component = world.Get<CharacterTriggerAreaComponent>(triggerAreaEntity);
component.ForceAssignArea(characterTriggerArea);
component.monoBehaviour = characterTriggerArea;
world.Set(triggerAreaEntity, component);

system.Update(0);
Expand Down Expand Up @@ -328,6 +353,15 @@ public void HandleExcludedIdsUpdateCorrectly()
[Test]
public void HandleComponentRemoveCorrectly()
{
const string FAKE_USER_ID = "Ia4Ia5Cth0ulhu2Ftaghn2";

globalWorld.Add(fakeAvatarEntity, new Profile(FAKE_USER_ID, "fake user", new Avatar(
BodyShape.MALE,
WearablesConstants.DefaultWearables.GetDefaultWearablesForBodyShape(BodyShape.MALE),
WearablesConstants.DefaultColors.GetRandomEyesColor(),
WearablesConstants.DefaultColors.GetRandomHairColor(),
WearablesConstants.DefaultColors.GetRandomSkinColor())));

var pbComponent = new PBAvatarModifierArea
{
Area = new Vector3
Expand All @@ -347,7 +381,7 @@ public void HandleComponentRemoveCorrectly()
// "Enter" trigger area
characterTriggerArea.OnTriggerEnter(fakeAvatarShapeCollider);
CharacterTriggerAreaComponent component = world.Get<CharacterTriggerAreaComponent>(triggerAreaEntity);
component.ForceAssignArea(characterTriggerArea);
component.monoBehaviour = characterTriggerArea;
world.Set(triggerAreaEntity, component);

system.Update(0);
Expand All @@ -367,6 +401,15 @@ public void HandleComponentRemoveCorrectly()
[Test]
public void HandleEntityDestructionCorrectly()
{
const string FAKE_USER_ID = "Ia4Ia5Cth0ulhu2Ftaghn2";

globalWorld.Add(fakeAvatarEntity, new Profile(FAKE_USER_ID, "fake user", new Avatar(
BodyShape.MALE,
WearablesConstants.DefaultWearables.GetDefaultWearablesForBodyShape(BodyShape.MALE),
WearablesConstants.DefaultColors.GetRandomEyesColor(),
WearablesConstants.DefaultColors.GetRandomHairColor(),
WearablesConstants.DefaultColors.GetRandomSkinColor())));

var pbComponent = new PBAvatarModifierArea
{
Area = new Vector3
Expand All @@ -386,7 +429,7 @@ public void HandleEntityDestructionCorrectly()
// "Enter" trigger area
characterTriggerArea.OnTriggerEnter(fakeAvatarShapeCollider);
CharacterTriggerAreaComponent component = world.Get<CharacterTriggerAreaComponent>(triggerAreaEntity);
component.ForceAssignArea(characterTriggerArea);
component.monoBehaviour = characterTriggerArea;
world.Set(triggerAreaEntity, component);

system.Update(0);
Expand Down

0 comments on commit fe0e27e

Please sign in to comment.