示例#1
0
        private void EntMapIdChanged(EntMapIdChangedMessage ev)
        {
            // Nullspace is a valid map ID for stuff to have but we also aren't gonna bother indexing it.
            // So that's why there's a GetValueOrDefault.
            var oldMapTrees = _mapTrees.GetValueOrDefault(ev.OldMapId);
            var newMapTrees = _mapTrees.GetValueOrDefault(ev.Entity.Transform.MapID);

            if (ev.Entity.TryGetComponent(out SpriteComponent? sprite))
            {
                oldMapTrees?.SpriteTree.Remove(sprite);

                newMapTrees?.SpriteTree.AddOrUpdate(sprite);
            }

            if (ev.Entity.TryGetComponent(out ClientOccluderComponent? occluder))
            {
                oldMapTrees?.OccluderTree.Remove(occluder);

                newMapTrees?.OccluderTree.AddOrUpdate(occluder);
            }

            if (ev.Entity.TryGetComponent(out PointLightComponent? light))
            {
                oldMapTrees?.LightTree.Remove(light);

                newMapTrees?.LightTree.AddOrUpdate(light);
            }
        }
示例#2
0
        private void EntMapIdChanged(EntMapIdChangedMessage ev)
        {
            if (ev.Entity.TryGetComponent(out OccluderComponent? occluder))
            {
                // Nullspace is a valid map ID for stuff to have but we also aren't gonna bother indexing it.
                // So that's why there's a GetValueOrDefault.
                var oldTree = _mapTrees.GetValueOrDefault(ev.OldMapId);
                var newTree = _mapTrees.GetValueOrDefault(ev.Entity.Transform.MapID);

                oldTree?.Remove(occluder);
                newTree?.AddOrUpdate(occluder);
            }
        }