~ruther/NosSmooth

1082d874b4ce55707ff4b7216a9bb58e5fd595ff — Rutherther 2 years ago 8f2380c
fix(game): do not replace character with player in map entities
1 files changed, 14 insertions(+), 1 deletions(-)

M Core/NosSmooth.Game/Data/Maps/MapEntities.cs
M Core/NosSmooth.Game/Data/Maps/MapEntities.cs => Core/NosSmooth.Game/Data/Maps/MapEntities.cs +14 -1
@@ 5,6 5,7 @@
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Collections.Concurrent;
using NosSmooth.Game.Data.Characters;
using NosSmooth.Game.Data.Entities;
using NosSmooth.Packets.Enums;



@@ 69,7 70,19 @@ public class MapEntities
    /// <param name="entity">The entity to add.</param>
    internal void AddEntity(IEntity entity)
    {
        _entities.AddOrUpdate(entity.Id, _ => entity, (i, e) => entity);
        _entities.AddOrUpdate
        (
            entity.Id,
            _ => entity,
            (_, e) =>
            {
                if (entity is Player && e is Character)
                { // Do not replace Character with Player!
                    return e;
                }
                return entity;
            }
        );
    }

    /// <summary>

Do not follow this link