public ISnapshot GeneratePerPlayerSnapshot(int seq, EntityKey self, Vector3 position, Bin2DConfig config, IBin2DManager bin, List <IGameEntity> preEntitys, bool isAccountStage, bool isPrepareStage, SnapshotEntityInsert onInsert) { preEntityKeys.Clear(); sendSnapshotFilter.Init(self, position); snapshot = Snapshot.Allocate(); forPre = true; this.isPrepareStage = isPrepareStage; this.isAccountStage = isAccountStage; this.seq = seq; this.onInsert = onInsert; foreach (var gameEntity in preEntitys) { DoInsert(gameEntity); preEntityKeys.Add(gameEntity.EntityKey); } forPre = false; foreach (var bin2DState in bin.GetBin2Ds()) { Rect rect = new Rect(position.x - bin2DState.VisibleRadius, position.z - bin2DState.VisibleRadius, bin2DState.VisibleRadius * 2, bin2DState.VisibleRadius * 2); bin2DState.Retrieve(position, rect, gameEntity => DoInsert(gameEntity)); } return(snapshot); }
public ISnapshot GeneratePerPlayerSnapshot(int seq, EntityKey self, Vector3 position, Bin2DConfig config, IBin2DManager bin, List <IGameEntity> preEntitys, bool isAccountStage, bool isPrepareStage, SnapshotEntityInsert insertFun) { var helper = ObjectAllocatorHolder <SnapshotCreationHelper> .Allocate(); var snapshot = helper.GeneratePerPlayerSnapshot(seq, self, position, config, bin, preEntitys, isAccountStage, isPrepareStage, null); helper.ReleaseReference(); return(snapshot); }