29 using System.Collections;
30 using System.Collections.Generic;
31 using System.Diagnostics;
32 using System.Reflection;
36 using OpenSim.Framework;
38 using OpenSim.Region.Framework.Interfaces;
39 using OpenSim.Region.Framework.Scenes;
40 using OpenSim.Services.Interfaces;
48 public int Others = 0;
49 public int Selected = 0;
50 public Dictionary <UUID, int> Users =
new Dictionary <UUID, int>();
53 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"PrimCountModule")]
58 private Scene m_Scene;
59 private Dictionary<UUID, PrimCounts> m_PrimCounts =
60 new Dictionary<UUID, PrimCounts>();
61 private Dictionary<UUID, UUID> m_OwnerMap =
62 new Dictionary<UUID, UUID>();
63 private Dictionary<UUID, int> m_SimwideCounts =
64 new Dictionary<UUID, int>();
65 private Dictionary<UUID, ParcelCounts> m_ParcelCounts =
66 new Dictionary<UUID, ParcelCounts>();
75 private bool m_Tainted =
true;
79 public Type ReplaceableInterface
94 m_Scene.EventManager.OnObjectAddedToScene += OnParcelPrimCountAdd;
95 m_Scene.EventManager.OnObjectBeingRemovedFromScene +=
96 OnObjectBeingRemovedFromScene;
97 m_Scene.EventManager.OnParcelPrimCountTainted +=
98 OnParcelPrimCountTainted;
99 m_Scene.EventManager.OnLandObjectAdded += delegate(
ILandObject lo) { OnParcelPrimCountTainted(); };
116 get {
return "PrimCountModule"; }
148 private void OnParcelPrimCountTainted()
183 Vector3 pos = obj.AbsolutePosition;
184 ILandObject landObject = m_Scene.LandChannel.GetLandObject(pos.X, pos.Y);
187 if (landObject == null)
196 LandData landData = landObject.LandData;
206 ParcelCounts parcelCounts;
207 if (m_ParcelCounts.TryGetValue(landData.
GlobalID, out parcelCounts))
209 UUID landOwner = landData.OwnerID;
210 int partCount = obj.GetPartCount();
212 m_SimwideCounts[landOwner] += partCount;
213 if (parcelCounts.Users.ContainsKey(obj.
OwnerID))
214 parcelCounts.Users[obj.
OwnerID] += partCount;
216 parcelCounts.Users[obj.
OwnerID] = partCount;
220 parcelCounts.Selected += partCount;
227 parcelCounts.Owner += partCount;
229 parcelCounts.Group += partCount;
231 parcelCounts.Others += partCount;
236 parcelCounts.Owner += partCount;
238 parcelCounts.Others += partCount;
261 if (m_PrimCounts.TryGetValue(parcelID, out primCounts))
265 m_PrimCounts[parcelID] = primCounts;
286 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
287 count = counts.
Owner;
312 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
313 count = counts.
Group;
338 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
364 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
391 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
393 count = counts.Owner;
394 count += counts.Group;
395 count += counts.Others;
396 count += counts.Selected;
422 if (m_OwnerMap.TryGetValue(parcelID, out owner))
425 if (m_SimwideCounts.TryGetValue(owner, out val))
453 if (m_ParcelCounts.TryGetValue(parcelID, out counts))
456 if (counts.Users.TryGetValue(userID, out val))
469 private void Recount()
474 m_SimwideCounts.Clear();
475 m_ParcelCounts.Clear();
477 List<ILandObject> land = m_Scene.LandChannel.AllParcels();
483 m_OwnerMap[landData.GlobalID] = landData.OwnerID;
484 m_SimwideCounts[landData.OwnerID] = 0;
491 m_Scene.ForEachSOG(AddObject);
495 List<UUID> primcountKeys =
new List<UUID>(m_PrimCounts.Keys);
496 foreach (UUID k
in primcountKeys)
498 if (!m_OwnerMap.ContainsKey(k))
499 m_PrimCounts.Remove(k);
510 private UUID m_ParcelID;
515 m_ParcelID = parcelID;
525 return m_Parent.GetOwnerCount(m_ParcelID);
533 return m_Parent.GetGroupCount(m_ParcelID);
541 return m_Parent.GetOthersCount(m_ParcelID);
549 return m_Parent.GetSelectedCount(m_ParcelID);
557 return m_Parent.GetTotalCount(m_ParcelID);
565 return m_Parent.GetSimulatorCount(m_ParcelID);
573 return m_UserPrimCounts;
579 return m_Parent.GetUserCount(m_ParcelID, userID);
592 public int this[
UUID userID]
596 return m_Parent.GetUserCount(userID);
IPrimCounts GetPrimCounts(UUID parcelID)
int GetTotalCount(UUID parcelID)
Get the total count of owner, group and others prims on the parcel. FIXME: Need to do selected prims ...
int GetSelectedCount(UUID parcelID)
Get the number of selected prims.
PrimCounts(UUID parcelID, PrimCountModule parent)
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
PrimFlags Flags
Property flags. See OpenMetaverse.PrimFlags
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
UUID GlobalID
Global ID for the parcel. (3rd Party Integration)
UUID GroupID
Unique ID of the Group that owns
UserPrimCounts(PrimCounts parent)
int GetSimulatorCount(UUID parcelID)
Get the number of prims that are in the entire simulator for the owner of this parcel.
void TaintPrimCount(int x, int y)
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
Details of a Parcel of land
int GetGroupCount(UUID parcelID)
Get the number of prims on the parcel that have been set to the group that owns the parcel...
void Initialise(IConfigSource source)
This is called to initialize the region module. For shared modules, this is called exactly once...
int GetUserCount(UUID parcelID, UUID userID)
Get the number of prims that a particular user owns on this parcel.
bool IsGroupOwned
Returns true if the Land Parcel is owned by a group
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
int GetOwnerCount(UUID parcelID)
Get the number of prims on the parcel that are owned by the parcel owner.
int GetUserCount(UUID userID)
int GetOthersCount(UUID parcelID)
Get the number of prims on the parcel that are not owned by the parcel owner or set to the parcel gro...
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
bool IsAttachment
Is this scene object acting as an attachment?
UUID OwnerID
Owner Avatar or Group of the parcel. Naturally, all land masses must be owned by someone ...