protected override void InternalRefreshBackingDataHashSet()
        {
            try
            {
                if (m_rawDataHashSetResourceLock.Owned)
                {
                    return;
                }
                if (WorldManager.Instance.IsWorldSaving)
                {
                    return;
                }
                if (WorldManager.Instance.InternalGetResourceLock() == null)
                {
                    return;
                }
                if (WorldManager.Instance.InternalGetResourceLock().Owned)
                {
                    return;
                }

                m_rawDataHashSetResourceLock.AcquireExclusive();

                var rawValue = BaseObject.InvokeStaticMethod(InternalType, ObjectManagerGetEntityHashSet);
                if (rawValue == null)
                {
                    return;
                }

                //Create/Clear the hash set
                if (m_rawDataHashSet == null)
                {
                    m_rawDataHashSet = new HashSet <object>();
                }
                else
                {
                    m_rawDataHashSet.Clear();
                }

                //Only allow valid entities in the hash set
                foreach (var entry in UtilityFunctions.ConvertHashSet(rawValue))
                {
                    if (!IsValidEntity(entry))
                    {
                        continue;
                    }

                    m_rawDataHashSet.Add(entry);
                }

                m_rawDataHashSetResourceLock.ReleaseExclusive();
            }
            catch (Exception ex)
            {
                LogManager.ErrorLog.WriteLine(ex);
                m_rawDataHashSetResourceLock.ReleaseExclusive();
            }
        }
Example #2
0
        protected override void InternalRefreshBackingDataHashSet( )
        {
            try
            {
                if (!CanRefresh)
                {
                    return;
                }

                m_rawDataHashSetResourceLock.AcquireExclusive( );

                object rawValue = BaseObject.InvokeStaticMethod(InternalType, ObjectManagerGetEntityHashSet);
                if (rawValue == null)
                {
                    return;
                }

                //Create/Clear the hash set
                if (m_rawDataHashSet == null)
                {
                    m_rawDataHashSet = new HashSet <object>( );
                }
                else
                {
                    m_rawDataHashSet.Clear( );
                }

                //Only allow valid entities in the hash set
                foreach (object entry in UtilityFunctions.ConvertHashSet(rawValue))
                {
                    if (!IsValidEntity(entry))
                    {
                        continue;
                    }

                    m_rawDataHashSet.Add(entry);
                }

                m_rawDataHashSetResourceLock.ReleaseExclusive( );
            }
            catch (Exception ex)
            {
                ApplicationLog.BaseLog.Error(ex);
                if (m_rawDataHashSetResourceLock.Owned)
                {
                    m_rawDataHashSetResourceLock.ReleaseExclusive( );
                }
            }
        }