private void UpdateRegion()
        {
            var region = PoE.GetRegionByWorldCoordinate(X, Y) ?? throw new ArgumentNullException(nameof(PoE.GetRegionByWorldCoordinate));

            if (Region == region)
            {
                return;
            }

            Region?.RemoveEntity(Parent.GetTransform());
            Region = region;
            Region.AddEntity(this);
        }
示例#2
0
    public static void Add(Entity entity)
    {
        if (_entityRegionLookup.ContainsKey(entity))
        {
            Poll(entity);
            return;
        }

        Region region = RegionManager.GetRegion(entity.CellPosition);

        if (region == null)
        {
            throw new System.NullReferenceException("Cannot find region for entity");
        }

        entity.SetRegion(region);
        region.AddEntity(entity);
        _entityRegionLookup.Add(entity, region);
    }