aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Regions/Region.cs
blob: e95d9dc075da31605983bd78f15b1fa940bbad02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System.Collections.Generic;
using libsecondlife;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Terrain;
using OpenSim.Framework.Interfaces;
using System;

namespace OpenSim.Region.Environment.Regions
{
    public class Region
    {
        // This is a temporary (and real ugly) construct to emulate us really having a separate list
        // of region subscribers. It should be removed ASAP, like.

        private readonly Scene m_scene;
        private Dictionary<LLUUID, RegionSubscription> m_regionSubscriptions
        {
            get
            {
                Dictionary<LLUUID, RegionSubscription> subscriptions = new Dictionary<LLUUID, RegionSubscription>( );

                foreach( ScenePresence presence in m_scene.GetScenePresences() )
                {
                    subscriptions.Add( presence.UUID, new RegionSubscription( presence.ControllingClient ));
                }

                return subscriptions;
            }
        }

        public Region( Scene scene )
        {
            m_scene = scene; // The Scene reference should be removed.
        }

        internal void Broadcast( Action<IClientAPI> whatToDo )
        {
            foreach (RegionSubscription subscription in m_regionSubscriptions.Values )
            {
                whatToDo(subscription.Client);                
            }
        }
    }
}