Skip to content

Commit

Permalink
Fixed visibility of respawned objects
Browse files Browse the repository at this point in the history
The OldBucket has to be null before adding it to the bucket of the map.
Otherwise, the players ObserverToWorldViewAdapter will return early,
because it thinks it already observes the oldBucket (='where the object
came from').
See also #39.
  • Loading branch information
sven-n committed Jul 13, 2018
1 parent 8a6520e commit dbb2c9d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/GameLogic/BucketAreaOfInterestManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ public BucketAreaOfInterestManager(int chunkSize)
/// <inheritdoc/>
public void AddObject(ILocateable obj)
{
this.Map[obj.X, obj.Y].Add(obj);
var newBucket = this.Map[obj.X, obj.Y];
if (obj is IHasBucketInformation bucketInfo)
{
bucketInfo.OldBucket = null;
bucketInfo.NewBucket = this.Map[obj.X, obj.Y];
bucketInfo.NewBucket = newBucket;
}

newBucket.Add(obj);

if (obj is IBucketMapObserver observingPlayer)
{
this.UpdateObservingBuckets(obj.X, obj.Y, observingPlayer);
Expand Down

0 comments on commit dbb2c9d

Please sign in to comment.