CMView.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #region Header
  28. // CMView.cs created with MonoDevelop
  29. // User: bongiojp at 11:57 AM 7/3/2008
  30. //
  31. // To change standard headers go to Edit->Preferences->Coding->Standard Headers
  32. //
  33. #endregion Header
  34. using System;
  35. using System.Collections;
  36. using System.Collections.Generic;
  37. using OpenMetaverse;
  38. using OpenSim;
  39. using OpenSim.Framework;
  40. using OpenSim.Region.Framework.Interfaces;
  41. using OpenSim.Region.Framework.Scenes;
  42. using OpenSim.Region.Physics.Manager;
  43. using log4net;
  44. namespace OpenSim.Region.OptionalModules.ContentManagement
  45. {
  46. public class CMView
  47. {
  48. #region Static Fields
  49. private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  50. #endregion Static Fields
  51. #region Fields
  52. CMModel m_model = null;
  53. #endregion Fields
  54. #region Constructors
  55. public CMView()
  56. {
  57. }
  58. #endregion Constructors
  59. #region Public Methods
  60. // Auras To
  61. public void DisplayAuras(CMEntityCollection auraCollection)
  62. {
  63. foreach (Object ent in auraCollection.Auras.Values)
  64. ((AuraMetaEntity)ent).SendFullUpdateToAll();
  65. }
  66. // Auras To Client
  67. public void DisplayAuras(CMEntityCollection auraCollection, IClientAPI client)
  68. {
  69. foreach (Object ent in auraCollection.Auras.Values)
  70. ((AuraMetaEntity)ent).SendFullUpdate(client);
  71. }
  72. // Auras from List To ALL
  73. public void DisplayAuras(ArrayList list)
  74. {
  75. foreach (Object ent in list)
  76. {
  77. m_log.Debug("[CONTENT MANAGEMENT] displaying new aura riiiiiiiiiiiight NOW");
  78. ((AuraMetaEntity)ent).SendFullUpdateToAll();
  79. }
  80. }
  81. // Entities to ALL
  82. public void DisplayEntities(CMEntityCollection entityCollection)
  83. {
  84. foreach (Object ent in entityCollection.Entities.Values)
  85. ((ContentManagementEntity)ent).SendFullDiffUpdateToAll();
  86. }
  87. // Entities to Client
  88. public void DisplayEntities(CMEntityCollection entityCollection, IClientAPI client)
  89. {
  90. foreach (Object ent in entityCollection.Entities.Values)
  91. ((ContentManagementEntity)ent).SendFullDiffUpdate(client);
  92. }
  93. // Entities from List to ALL
  94. public void DisplayEntities(ArrayList list)
  95. {
  96. foreach (Object ent in list)
  97. ((ContentManagementEntity)ent).SendFullDiffUpdateToAll();
  98. }
  99. // Entity to ALL
  100. public void DisplayEntity(ContentManagementEntity ent)
  101. {
  102. ent.SendFullDiffUpdateToAll();
  103. }
  104. public void DisplayHelpMenu(Scene scene)
  105. {
  106. string menu = "Menu:\n";
  107. menu += "commit (ci) - saves current state of the region to a database on the server\n";
  108. menu += "diff-mode (dm) - displays those aspects of region that have not been saved but changed since the very last revision. Will dynamically update as you change environment.\n";
  109. SendSimChatMessage(scene, menu);
  110. }
  111. public void DisplayMetaEntity(UUID uuid)
  112. {
  113. ContentManagementEntity group = m_model.GetMetaGroupByPrim(uuid);
  114. if (group != null)
  115. group.SendFullDiffUpdateToAll();
  116. }
  117. /// <summary>
  118. /// update all clients of red/green/blue auras and meta entities that the model knows about.
  119. /// </summary>
  120. public void DisplayRecentChanges()
  121. {
  122. m_log.Debug("[CONTENT MANAGEMENT] Sending update to clients for " + m_model.MetaEntityCollection.Entities.Count + " objects.");
  123. DisplayEntities(m_model.MetaEntityCollection);
  124. DisplayAuras(m_model.MetaEntityCollection);
  125. }
  126. public void Hide(ContentManagementEntity ent)
  127. {
  128. ent.HideFromAll();
  129. }
  130. public void HideAllAuras()
  131. {
  132. foreach (Object obj in m_model.MetaEntityCollection.Auras.Values)
  133. ((MetaEntity)obj).HideFromAll();
  134. }
  135. public void HideAllMetaEntities()
  136. {
  137. foreach (Object obj in m_model.MetaEntityCollection.Entities.Values)
  138. ((ContentManagementEntity)obj).HideFromAll();
  139. }
  140. public void Initialise(CMModel model)
  141. {
  142. m_model = model;
  143. }
  144. /// <summary>
  145. /// Figures out if the part deleted was a new scene object part or a revisioned part that's been deleted.
  146. /// If it's a new scene object, any green aura attached to it is deleted.
  147. /// If a revisioned part is deleted, a new full update is sent to the environment of the meta entity, which will
  148. /// figure out that there should be a red aura and not a blue aura/beam.
  149. /// </summary>
  150. public void RemoveOrUpdateDeletedEntity(SceneObjectGroup group)
  151. {
  152. // Deal with revisioned parts that have been deleted.
  153. if (m_model.MetaEntityCollection.Entities.ContainsKey(group.UUID))
  154. ((ContentManagementEntity)m_model.MetaEntityCollection.Entities[group.UUID]).SendFullDiffUpdateToAll();
  155. // Deal with new parts not revisioned that have been deleted.
  156. foreach (SceneObjectPart part in group.Children.Values)
  157. if (m_model.MetaEntityCollection.Auras.ContainsKey(part.UUID))
  158. ((AuraMetaEntity)m_model.MetaEntityCollection.Auras[part.UUID]).HideFromAll();
  159. }
  160. public void SendMetaEntitiesToNewClient(IClientAPI client)
  161. {
  162. }
  163. public void SendSimChatMessage(Scene scene, string message)
  164. {
  165. scene.SimChat(Utils.StringToBytes(message),
  166. ChatTypeEnum.Broadcast, 0, new Vector3(0,0,0), "Content Manager", UUID.Zero, false);
  167. }
  168. #endregion Public Methods
  169. }
  170. }