public void DoInsert(IGameEntity localEntity) { var entityKey = localEntity.EntityKey; var sendFilter = _filter; if (_preEntitys.Contains(entityKey)) { return; } if (sendFilter.IsIncludeEntity(localEntity)) { if (sendFilter.IsEntitySelf(localEntity)) { _snapshot.AddEntity(localEntity.GetSelfEntityCopy(_seq)); } else { if (localEntity.HasPositionFilter) { var positionFilter = localEntity.GetComponent <PositionFilterComponent>(); var position = localEntity.Position; if (!positionFilter.Filter(position.Value, _filter.Position)) { _snapshot.AddEntity(localEntity.GetNonSelfEntityCopy(_seq)); } } else { _snapshot.AddEntity(localEntity.GetNonSelfEntityCopy(_seq)); } } } }
private void DoInsert(IGameEntity gameEntity) { var entityKey = gameEntity.EntityKey; bool hasAdd = false; if (preEntityKeys.Contains(entityKey)) { hasAdd = true; } else if (sendSnapshotFilter.IsIncludeEntity(gameEntity)) { if (sendSnapshotFilter.IsEntitySelf(gameEntity)) {//获取自己的备份 snapshot.AddEntity(gameEntity.GetSelfEntityCopy(seq)); hasAdd = true; } else if (!isAccountStage) { if (isPrepareStage && gameEntity.EntityType != (int)EEntityType.Player) { return; } //获取别人的备份 if (gameEntity.HasPositionFilter) { var positionFilter = gameEntity.GetComponent <PositionFilterComponent>(); var position = gameEntity.Position; if (!positionFilter.Filter(position.Value, sendSnapshotFilter.Position)) { snapshot.AddEntity(gameEntity.GetNonSelfEntityCopy(seq)); hasAdd = true; } } else { snapshot.AddEntity(gameEntity.GetNonSelfEntityCopy(seq)); hasAdd = true; } } } if (hasAdd && onInsert != null) { onInsert(gameEntity, forPre); } }