コード例 #1
0
        /// <summary>
        /// Returns true if there was a change between meta entity and the entity group, false otherwise.
        /// If true is returned, it is assumed the metaentity's appearance has changed to reflect the difference (though clients haven't been updated).
        /// </summary>
        public bool MarkWithDifferences(SceneObjectGroup sceneEntityGroup)
        {
            SceneObjectPart sceneEntityPart;
            SceneObjectPart metaEntityPart;
            Diff differences;
            bool changed = false;

            // Use "UnchangedEntity" to do comparisons because its text, transparency, and other attributes will be just as the user
            // had originally saved.
            // m_Entity will NOT necessarily be the same entity as the user had saved.
            foreach (SceneObjectPart UnchangedPart in m_UnchangedEntity.Parts)
            {
                //This is the part that we use to show changes.
                metaEntityPart = m_Entity.GetLinkNumPart(UnchangedPart.LinkNum);
                if (sceneEntityGroup.ContainsPart(UnchangedPart.UUID))
                {
                    sceneEntityPart = sceneEntityGroup.GetChildPart(UnchangedPart.UUID);
                    differences = Difference.FindDifferences(UnchangedPart, sceneEntityPart);
                    if (differences != Diff.NONE)
                        metaEntityPart.Text = "CHANGE: " + differences.ToString();
                    if (differences != 0)
                    {
                        // Root Part that has been modified
                        if ((differences & Diff.POSITION) > 0)
                        {
                            // If the position of any part has changed, make sure the RootPart of the
                            // meta entity is pointing with a beam particle system
                            if (m_BeamEntities.ContainsKey(m_UnchangedEntity.RootPart.UUID))
                            {
                                m_BeamEntities[m_UnchangedEntity.RootPart.UUID].HideFromAll();
                                m_BeamEntities.Remove(m_UnchangedEntity.RootPart.UUID);
                            }
                            BeamMetaEntity beamGroup = new BeamMetaEntity(m_Entity.Scene,
                                                                          m_UnchangedEntity.RootPart.GetWorldPosition(),
                                                                          MetaEntity.TRANSLUCENT,
                                                                          sceneEntityPart,
                                                                          new Vector3(0, 0, 254)
                                                                          );
                            m_BeamEntities.Add(m_UnchangedEntity.RootPart.UUID, beamGroup);
                        }

                        if (m_AuraEntities.ContainsKey(UnchangedPart.UUID))
                        {
                            m_AuraEntities[UnchangedPart.UUID].HideFromAll();
                            m_AuraEntities.Remove(UnchangedPart.UUID);
                        }
                        AuraMetaEntity auraGroup = new AuraMetaEntity(m_Entity.Scene,
                                                                      UnchangedPart.GetWorldPosition(),
                                                                      MetaEntity.TRANSLUCENT,
                                                                      new Vector3(0, 0, 254),
                                                                      UnchangedPart.Scale
                                                                      );
                        m_AuraEntities.Add(UnchangedPart.UUID, auraGroup);
                        SetPartTransparency(metaEntityPart, MetaEntity.TRANSLUCENT);

                        DiffersFromSceneGroup = true;
                    }
                    else // no differences between scene part and meta part
                    {
                        if (m_BeamEntities.ContainsKey(m_UnchangedEntity.RootPart.UUID))
                        {
                            m_BeamEntities[m_UnchangedEntity.RootPart.UUID].HideFromAll();
                            m_BeamEntities.Remove(m_UnchangedEntity.RootPart.UUID);
                        }
                        if (m_AuraEntities.ContainsKey(UnchangedPart.UUID))
                        {
                            m_AuraEntities[UnchangedPart.UUID].HideFromAll();
                            m_AuraEntities.Remove(UnchangedPart.UUID);
                        }
                        SetPartTransparency(metaEntityPart, MetaEntity.NONE);
                    }
                }
                else  //The entity currently in the scene is missing parts from the metaentity saved, so mark parts red as deleted.
                {
                    if (m_AuraEntities.ContainsKey(UnchangedPart.UUID))
                    {
                        m_AuraEntities[UnchangedPart.UUID].HideFromAll();
                        m_AuraEntities.Remove(UnchangedPart.UUID);
                    }
                    AuraMetaEntity auraGroup = new AuraMetaEntity(m_Entity.Scene,
                                                                  UnchangedPart.GetWorldPosition(),
                                                                  MetaEntity.TRANSLUCENT,
                                                                  new Vector3(254, 0, 0),
                                                                  UnchangedPart.Scale
                                                                  );
                    m_AuraEntities.Add(UnchangedPart.UUID, auraGroup);
                    SetPartTransparency(metaEntityPart, MetaEntity.TRANSLUCENT);

                    DiffersFromSceneGroup = true;
                }
            }
            
            return changed;
        }