public override void OnEntityDestroy(EntityBase entity)
    {
        //Debug.Log("EntityRecordSystem OnEntityDestroy! " + entity.ID + " m_isCertainty " + m_world.m_isCertainty);

        //只记录预测时的操作
        if (m_world.IsCertainty)
        {
            return;
        }

        //Debug.Log(" 记录摧毁 ID: " + entity.ID + " frame " + entity.m_DestroyFrame);

        EntityRecordComponent erc = m_world.GetSingletonComp <EntityRecordComponent>();

        //如果此帧有这个ID的创建记录,把它抵消掉
        if (erc.GetReordIsExist(entity.m_DestroyFrame, entity.ID, EntityChangeType.Create))
        {
            EntityRecordInfo record = erc.GetReord(entity.m_DestroyFrame, entity.ID, EntityChangeType.Create);
            ////Debug.Log("抵消掉创建记录 " + entity.ID);
            erc.m_list.Remove(record);
        }
        else
        {
            EntityRecordInfo info = new EntityRecordInfo();
            info.changeType = EntityChangeType.Destroy;
            info.id         = entity.ID;
            info.frame      = entity.m_DestroyFrame;
            info.SaveComp(entity);

            erc.m_list.Add(info);
        }
    }
        /// <summary>
        /// Move the PendingValues to the CurrentValues for this record and all nested
        /// records.  We keep the pending values separate from the current ones because
        /// we may have a nested reader in the middle, and while we're reading forward
        /// on the nested reader we we'll blast over the pending values.
        /// 
        /// This should be called as part of the data reader's Read() method.
        /// </summary>
        internal void AcceptPendingValues()
        {
            var temp = CurrentColumnValues;
            CurrentColumnValues = PendingColumnValues;
            PendingColumnValues = temp;

            _currentEntityRecordInfo = _pendingEntityRecordInfo;
            _pendingEntityRecordInfo = null;

            _currentIsNull = _pendingIsNull;

            // CONSIDER: If additional perforamnce is needed, here's something 
            // we could probably optimize by building an expression and compiling it.
            if (RecordStateFactory.HasNestedColumns)
            {
                for (var ordinal = 0; ordinal < CurrentColumnValues.Length; ordinal++)
                {
                    if (RecordStateFactory.IsColumnNested[ordinal])
                    {
                        var recordState = CurrentColumnValues[ordinal] as RecordState;
                        if (null != recordState)
                        {
                            recordState.AcceptPendingValues();
                        }
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// Move the PendingValues to the CurrentValues for this record and all nested
        /// records.  We keep the pending values separate from the current ones because
        /// we may have a nested reader in the middle, and while we're reading forward
        /// on the nested reader we we'll blast over the pending values.
        /// 
        /// This should be called as part of the data reader's Read() method.
        /// </summary>
        internal void AcceptPendingValues()
        {
            object[] temp = CurrentColumnValues;
            CurrentColumnValues = PendingColumnValues;
            PendingColumnValues = temp;

            _currentEntityRecordInfo = _pendingEntityRecordInfo;
            _pendingEntityRecordInfo = null;

            _currentIsNull = _pendingIsNull;

            // 

            if (RecordStateFactory.HasNestedColumns)
            {
                for (int ordinal = 0; ordinal < CurrentColumnValues.Length; ordinal++)
                {
                    if (RecordStateFactory.IsColumnNested[ordinal])
                    {
                        RecordState recordState = CurrentColumnValues[ordinal] as RecordState;
                        if (null != recordState)
                        {
                            recordState.AcceptPendingValues();
                        }
                    }
                }
            }
        }
Example #4
0
        // <summary>
        // Move the PendingValues to the CurrentValues for this record and all nested
        // records.  We keep the pending values separate from the current ones because
        // we may have a nested reader in the middle, and while we're reading forward
        // on the nested reader we we'll blast over the pending values.
        // This should be called as part of the data reader's Read() method.
        // </summary>
        internal void AcceptPendingValues()
        {
            var temp = CurrentColumnValues;

            CurrentColumnValues = PendingColumnValues;
            PendingColumnValues = temp;

            _currentEntityRecordInfo = _pendingEntityRecordInfo;
            _pendingEntityRecordInfo = null;

            _currentIsNull = _pendingIsNull;

            // CONSIDER: If additional perforamnce is needed, here's something
            // we could probably optimize by building an expression and compiling it.
            if (RecordStateFactory.HasNestedColumns)
            {
                for (var ordinal = 0; ordinal < CurrentColumnValues.Length; ordinal++)
                {
                    if (RecordStateFactory.IsColumnNested[ordinal])
                    {
                        var recordState = CurrentColumnValues[ordinal] as RecordState;
                        if (null != recordState)
                        {
                            recordState.AcceptPendingValues();
                        }
                    }
                }
            }
        }
Example #5
0
        /// <summary>
        /// Move the PendingValues to the CurrentValues for this record and all nested
        /// records.  We keep the pending values separate from the current ones because
        /// we may have a nested reader in the middle, and while we're reading forward
        /// on the nested reader we we'll blast over the pending values.
        ///
        /// This should be called as part of the data reader's Read() method.
        /// </summary>
        internal void AcceptPendingValues()
        {
            object[] temp = CurrentColumnValues;
            CurrentColumnValues = PendingColumnValues;
            PendingColumnValues = temp;

            _currentEntityRecordInfo = _pendingEntityRecordInfo;
            _pendingEntityRecordInfo = null;

            _currentIsNull = _pendingIsNull;

            //

            if (RecordStateFactory.HasNestedColumns)
            {
                for (int ordinal = 0; ordinal < CurrentColumnValues.Length; ordinal++)
                {
                    if (RecordStateFactory.IsColumnNested[ordinal])
                    {
                        RecordState recordState = CurrentColumnValues[ordinal] as RecordState;
                        if (null != recordState)
                        {
                            recordState.AcceptPendingValues();
                        }
                    }
                }
            }
        }
    public override void OnEntityDestroy(EntityBase entity)
    {
        //只记录预测时的操作
        if (m_world.m_isRecalc)
        {
            return;
        }

        Debug.Log(" 记录摧毁 ID: " + entity.ID + " frame " + m_world.FrameCount);

        EntityRecordComponent erc = m_world.GetSingletonComp <EntityRecordComponent>();

        //如果此帧有这个ID的创建记录,把它抵消掉
        EntityRecordInfo record = erc.GetReord(m_world.FrameCount, entity.ID, EntityChangeType.Create);

        if (record != null)
        {
            Debug.Log("抵消掉创建记录 " + entity.ID);
            erc.m_list.Remove(record);
        }
        else
        {
            EntityRecordInfo info = new EntityRecordInfo();
            info.changeType = EntityChangeType.Destroy;
            info.id         = entity.ID;
            info.frame      = m_world.FrameCount;
            info.SaveComp(entity);

            erc.m_list.Add(info);
        }
    }
 internal RecordState SetNullRecord()
 {
     for (int index = 0; index < this.PendingColumnValues.Length; ++index)
     {
         this.PendingColumnValues[index] = (object)DBNull.Value;
     }
     this._pendingEntityRecordInfo = (EntityRecordInfo)null;
     this._pendingIsNull           = true;
     return(this);
 }
 void EntityRevertOneFrame(EntityRecordInfo data)
 {
     if (data.changeType == EntityChangeType.Create)
     {
         //Debug.Log("RevertRecord DestroyEntityNoDispatch " + data.id + " frame " + data.frame + " worldFrame " + FrameCount);
         RollbackCreateEntity(data.id, data.frame);
     }
     else
     {
         //Debug.Log("RevertRecord CreateEntityNoDispatch " + data.id + " frame " + data.frame + " worldFrame" + FrameCount);
         RollbackDestroyEntity(data.id, data.frame, data.compList.ToArray());
     }
 }
 public void RevertRecord(EntityRecordInfo data)
 {
     if (data.changeType == EntityChangeType.Create)
     {
         Debug.Log("DestroyEntityNoDispatch " + data.id + " frame " + m_world.FrameCount);
         m_world.RollbackCreateEntity(data.id);
     }
     else
     {
         Debug.Log("CreateEntityNoDispatch " + data.id + " frame " + m_world.FrameCount);
         m_world.RollbackDestroyEntity(data.id, data.compList.ToArray());
     }
 }
 public void RevertRecord(EntityRecordInfo data)
 {
     //if(data.changeType == EntityChangeType.Create)
     //{
     //    //Debug.Log("RevertRecord DestroyEntityNoDispatch " + data.id + " frame " + data.frame + " worldFrame " + m_world.FrameCount);
     //    m_world.RollbackCreateEntity(data.id, data.frame);
     //}
     //else
     //{
     //    //Debug.Log("RevertRecord CreateEntityNoDispatch " + data.id + " frame " + data.frame + " worldFrame" + m_world.FrameCount);
     //    m_world.RollbackDestroyEntity(data.id, data.frame, data.compList.ToArray());
     //}
 }
Example #11
0
 // <summary>
 // Called from the Element expression on the Coordinator to indicate that
 // the record should be NULL.
 // </summary>
 internal RecordState SetNullRecord()
 {
     // CONSIDER: If additional performance is needed, we could make these
     // singleton objects on the RecordStateFactory, but that has additional overhead
     // and working set that we may not want to have.
     for (var i = 0; i < PendingColumnValues.Length; i++)
     {
         PendingColumnValues[i] = DBNull.Value;
     }
     _pendingEntityRecordInfo = null; // the default is already setup correctly on the record state factory
     _pendingIsNull           = true;
     return(this);
 }
Example #12
0
        /// <summary>
        /// Called from the Element expression on the Coordinator to indicate that
        /// the record should be NULL.
        /// </summary>
        internal RecordState SetNullRecord(Shaper shaper)
        {
            //


            for (int i = 0; i < PendingColumnValues.Length; i++)
            {
                PendingColumnValues[i] = DBNull.Value;
            }
            _pendingEntityRecordInfo = null; // the default is already setup correctly on the record state factory
            _pendingIsNull           = true;
            return(this);
        }
 internal void AcceptPendingValues()
 {
     object[] currentColumnValues = this.CurrentColumnValues;
     this.CurrentColumnValues      = this.PendingColumnValues;
     this.PendingColumnValues      = currentColumnValues;
     this._currentEntityRecordInfo = this._pendingEntityRecordInfo;
     this._pendingEntityRecordInfo = (EntityRecordInfo)null;
     this._currentIsNull           = this._pendingIsNull;
     if (!this.RecordStateFactory.HasNestedColumns)
     {
         return;
     }
     for (int index = 0; index < this.CurrentColumnValues.Length; ++index)
     {
         if (this.RecordStateFactory.IsColumnNested[index])
         {
             (this.CurrentColumnValues[index] as RecordState)?.AcceptPendingValues();
         }
     }
 }
    void RecordEntityCreate(EntityBase entity)
    {
        if (!IsClient)
        {
            return;
        }

        //Debug.Log("EntityRecordSystem OnEntityCreate! " + entity.ID + " m_isCertainty " + m_isCertainty);

        //只记录预测时的操作
        if (IsCertainty)
        {
            return;
        }

        //Debug.Log(" 记录创建 ID: " + entity.ID + " frame " + entity.m_CreateFrame);

        EntityRecordComponent erc = GetSingletonComp <EntityRecordComponent>();

        //如果此帧有这个ID的摧毁记录,把它抵消掉
        if (erc.GetReordIsExist(entity.CreateFrame, entity.ID, /* systemName, timing,*/ EntityChangeType.Destroy))
        {
            EntityRecordInfo record = erc.GetReord(entity.CreateFrame, entity.ID, /*systemName, timing,*/ EntityChangeType.Destroy);
            //Debug.Log("抵消掉摧毁记录 " + entity.ID);
            erc.m_list.Remove(record);
        }
        else
        {
            EntityRecordInfo info = new EntityRecordInfo();
            info.changeType = EntityChangeType.Create;
            info.id         = entity.ID;
            info.frame      = entity.CreateFrame;
            //info.systemName = systemName;
            //info.timing = timing;
            info.SaveComp(entity);

            erc.m_list.Add(info);
        }
    }
Example #15
0
 protected BaseEntity()
 {
     RecordInfo = new EntityRecordInfo();
 }
 /// <summary>
 /// Called from the Element expression on the Coordinator to indicate that
 /// the record should be NULL.
 /// </summary>
 internal RecordState SetNullRecord()
 {
     // CONSIDER: If additional performance is needed, we could make these
     // singleton objects on the RecordStateFactory, but that has additional overhead 
     // and working set that we may not want to have.
     for (var i = 0; i < PendingColumnValues.Length; i++)
     {
         PendingColumnValues[i] = DBNull.Value;
     }
     _pendingEntityRecordInfo = null; // the default is already setup correctly on the record state factory
     _pendingIsNull = true;
     return this;
 }
 /// <summary>
 /// Called by the GatherData expression to set the data for the 
 /// EntityRecordInfo
 /// </summary>
 internal bool SetEntityRecordInfo(EntityKey entityKey, EntitySet entitySet)
 {
     _pendingEntityRecordInfo = new EntityRecordInfo(RecordStateFactory.DataRecordInfo, entityKey, entitySet);
     return true;
 }
 /// <summary>
 /// Called whenever we hand this record state out as the default state for
 /// a data reader; we will have already handled any existing data back to
 /// the previous group of records (that is, we couldn't be using it from two
 /// distinct readers at the same time).
 /// </summary>
 internal void ResetToDefaultState()
 {
     _currentEntityRecordInfo = null;
 }
Example #19
0
        /// <summary>
        /// Called from the Element expression on the Coordinator to indicate that
        /// the record should be NULL.
        /// </summary>
        internal RecordState SetNullRecord(Shaper shaper)
        {
            // 


            for (int i = 0; i < PendingColumnValues.Length; i++)
            {
                PendingColumnValues[i] = DBNull.Value;
            }
            _pendingEntityRecordInfo = null; // the default is already setup correctly on the record state factory
            _pendingIsNull = true;
            return this;
        }
Example #20
0
 /// <summary>
 /// Called by the GatherData expression to set the data for the
 /// EntityRecordInfo
 /// </summary>
 internal bool SetEntityRecordInfo(EntityKey entityKey, EntitySet entitySet)
 {
     _pendingEntityRecordInfo = new EntityRecordInfo(this.RecordStateFactory.DataRecordInfo, entityKey, entitySet);
     return(true);
 }
Example #21
0
 /// <summary>
 /// Called whenever we hand this record state out as the default state for
 /// a data reader; we will have already handled any existing data back to
 /// the previous group of records (that is, we couldn't be using it from two
 /// distinct readers at the same time).
 /// </summary>
 internal void ResetToDefaultState()
 {
     _currentEntityRecordInfo = null;
 }
 internal void ResetToDefaultState()
 {
     this._currentEntityRecordInfo = (EntityRecordInfo)null;
 }