Skip to content

Commit

Permalink
fixed dynamic modification of excluded ids property
Browse files Browse the repository at this point in the history
  • Loading branch information
pravusjif committed Jan 4, 2024
1 parent cac5485 commit 2fe56a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public void OnComponentModelUpdated(IParcelScene scene, IDCLEntity entity, PBAva
excludedIds.Add(modelExcludeId.ToLower());
}
internalComponentModel.excludedIds = excludedIds;
internalComponentModel.avatarsInArea = new HashSet<GameObject>();

if (internalComponentModel.avatarsInArea?.Count == 0)
internalComponentModel.avatarsInArea = new HashSet<GameObject>();

internalAvatarModifierArea.PutFor(scene, entity, internalComponentModel);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public void Update()
var model = componentGroup[i].value.model;
Transform entityTransform = scene.entities[entityId].gameObject.transform;

if (model.excludedIds != null && model.excludedIds.Count > 0)
UpdateExcludedCollidersCollection(model.excludedIds);
UpdateExcludedCollidersCollection(model.excludedIds);

HashSet<GameObject> currentAvatarsInArea = ECSAvatarUtils.DetectAvatars(model.area, entityTransform.position,
entityTransform.rotation, excludedColliders);
Expand Down Expand Up @@ -91,9 +90,11 @@ private bool AreSetsEqual(HashSet<GameObject> set1, HashSet<GameObject> set2)

private void UpdateExcludedCollidersCollection(HashSet<string> excludedIds)
{
var ownPlayer = dataStore.ownPlayer.Get();
excludedColliders.Clear();

if (excludedIds == null || excludedIds.Count == 0) return;

var ownPlayer = dataStore.ownPlayer.Get();
foreach (string excludedId in excludedIds)
{
if (dataStore.otherPlayers.TryGetValue(excludedId, out Player player))
Expand Down

0 comments on commit 2fe56a0

Please sign in to comment.