private void ConnectToEventstore() { latestPosition = Position.Start; var subs = connection.SubscribeToAllFrom(latestPosition,true, HandleEvent); //subscribe to the stream of fraud alert connection.SubscribeToStreamFrom("PossiblyStolenCardClients", 0, true, (sub, e) => { var jsonString = Encoding.UTF8.GetString(e.Event.Data); JObject o = JObject.Parse(jsonString); var clientID = (string)o["ClientID"]; Bus.Publish(new ClientPossiblyStolen() { ClientID = clientID}); var ci = indexer.Get<ClientInformation>(clientID); if (ci == null) ci = new ClientInformation() { ID = clientID }; ci.PossiblyStolen = true; indexer.Index(ci); } ); Console.WriteLine("Indexing service started"); }
private void ConnectToEventstore() { _latestPosition = Position.Start; _connection = EventStoreConnectionWrapper.Connect(); _connection.Connected += (sender, args) => _connection.SubscribeToAllFrom(_latestPosition, false, HandleEvent); Console.WriteLine("Indexing service started"); }
protected Token(Symbol Parent, Position? position, bool isTerminal) { if ((Parent.Type != SymbolType.Nonterminal) ^ isTerminal) { throw new ParserException("Unexpected SymbolType"); } m_Parent = Parent; m_Position = position; }
public void Start() { HasLoaded = false; _connection = EventStore.ClientAPI.EventStoreConnection.Create(_endpoint); var ct = _connection.ConnectAsync(); ct.Wait(); _checkPoint = Position.Start; if (string.IsNullOrEmpty(_streamName)) _subscription = _connection.SubscribeToAllFrom(_checkPoint, false, EventAppeared, Live, SubscriptionDropped, _credentials); else _subscription = _connection.SubscribeToStreamFrom(_streamName, _lastEventNumber, true, EventAppeared, Live, SubscriptionDropped, _credentials); }
public override void Tick(RealmTime time) { if (pos == null) pos = new Position() { X = X, Y = Y }; if (!init) { Owner.EnemiesCollision.Insert(this); init = true; } if (!stat && HasConditionEffect(ConditionEffects.Bleeding)) { if (bleeding > 1) { HP -= (int)bleeding; bleeding -= (int)bleeding; UpdateCount++; } bleeding += 28 * (time.thisTickTimes / 1000f); } base.Tick(time); }
public override void Run() { Table table = new Table(4, 5); table.AddEntries(new [] { new KeyValuePair <Position, TableEntry>(new Position(0, 0), new FigureName(table, "")), new KeyValuePair <Position, TableEntry>(new Position(1, 0), new FigureName(table, "Jan")), new KeyValuePair <Position, TableEntry>(new Position(2, 0), new FigureName(table, "Feb")), new KeyValuePair <Position, TableEntry>(new Position(3, 0), new FigureName(table, "March")), new KeyValuePair <Position, TableEntry>(new Position(0, 1), new FigureName(table, "Bob")), new KeyValuePair <Position, TableEntry>(new Position(1, 1), new FigureEntry(table, 4)), new KeyValuePair <Position, TableEntry>(new Position(2, 1), new FigureEntry(table, 6)), new KeyValuePair <Position, TableEntry>(new Position(3, 1), new FigureEntry(table, 4)), new KeyValuePair <Position, TableEntry>(new Position(0, 2), new FigureName(table, "Pete")), new KeyValuePair <Position, TableEntry>(new Position(1, 2), new FigureEntry(table, 6)), new KeyValuePair <Position, TableEntry>(new Position(2, 2), new FigureEntry(table, 3)), new KeyValuePair <Position, TableEntry>(new Position(3, 2), new FigureEntry(table, 5)), new KeyValuePair <Position, TableEntry>(new Position(0, 3), new FigureName(table, "Jill")), new KeyValuePair <Position, TableEntry>(new Position(1, 3), new FigureEntry(table, 8)), new KeyValuePair <Position, TableEntry>(new Position(2, 3), new FigureEntry(table, 4)), new KeyValuePair <Position, TableEntry>(new Position(3, 3), new FigureEntry(table, 5)), new KeyValuePair <Position, TableEntry>(new Position(0, 4), new FigureName(table, "Jack")), new KeyValuePair <Position, TableEntry>(new Position(1, 4), new FigureEntry(table, 10)), new KeyValuePair <Position, TableEntry>(new Position(2, 4), new FigureEntry(table, 8)), new KeyValuePair <Position, TableEntry>(new Position(3, 4), new FigureEntry(table, 5)) }); Console.WriteLine("3) Code the following menu options:\n" + " a. Output the array\n" + " i. Use a nested For Loop output the entire contents of the array to be formatted as above.\n" + " b. Month to Output\n" + " i. Let the user enter a month number and it will only output all of that particular months details. I.e.\n" + " e.g. User enters 2\n" + " Feb\n" + " Bob 6\n" + " Pete 3\n" + " Jill 4\n" + " Jack 8\n" + " c. Search for name\n" + " i. Output that persons sales for the quarter if the user types in name\n" + " d. Work out the total sales for each person for the quarter\n" + " e. Work out the total sales for each month\n" + " \n" + " q. quit"); char selection = Utils.AskUserChar("Selection"); if (selection == 'a') { Console.WriteLine(table.GetDisplay()); } else if (selection == 'b') { int selectedMonth = Utils.AskUserInteger("Month Number to output"); if (Enumerable.Range(1, 3).Contains(selectedMonth)) { Console.WriteLine(table.GetRows(new[] { 0, selectedMonth })); } else { Console.WriteLine("Invalid Month"); } } else if (selection == 'c') { Position?position = table.SearchPositionRow(Utils.AskUserString("Search Name"), 0); if (position.HasValue) { Console.WriteLine(table.GetColumns(new[] { 0, position.Value.Y })); } else { Console.WriteLine("Could not find entry"); } } else if (selection == 'd') { for (int y = 1; y < table.Height; y++) { double total = 0; foreach (TableEntry tableEntry in table.GetEntriesInColumn(y)) { if (tableEntry.GetType() == typeof(FigureEntry)) { total += ((FigureEntry)tableEntry).Score; } } table.TableEntries.TryGetValue(new Position(0, y), out TableEntry entry); Console.WriteLine("{0}: {1:0}", entry.GetDisplay(), total); } } else if (selection == 'e') { for (int x = 1; x < table.Width; x++) { double total = 0; foreach (TableEntry tableEntry in table.GetEntriesInRow(x)) { if (tableEntry.GetType() == typeof(FigureEntry)) { total += ((FigureEntry)tableEntry).Score; } } table.TableEntries.TryGetValue(new Position(x, 0), out TableEntry entry); Console.WriteLine("{0}: {1:0}", entry.GetDisplay(), total); } } if (selection != 'q') { Run(); } }
public override void Tick(RealmTime time) { if (spawn == null) spawn = new Position(X, Y); base.Tick(time); }
internal ResolvedEvent(ClientMessage.ResolvedIndexedEvent evnt) { Event = evnt.Event == null ? null : new RecordedEvent(evnt.Event); Link = evnt.Link == null ? null : new RecordedEvent(evnt.Link); OriginalPosition = null; }
public abstract bool TryMapToProjectedDocumentOrNextCSharpPosition(RazorCodeDocument codeDocument, int absoluteIndex, [NotNullWhen(true)] out Position?projectedPosition, out int projectedIndex);
public AllSubscriptionFiltered(IPublisher bus, Position?startPosition, bool resolveLinks, IEventFilter eventFilter, ClaimsPrincipal user, bool requiresLeader, IReadIndex readIndex, uint?maxSearchWindow, uint checkpointIntervalMultiplier, Func <Position, Task> checkpointReached, CancellationToken cancellationToken) { if (bus == null) { throw new ArgumentNullException(nameof(bus)); } if (eventFilter == null) { throw new ArgumentNullException(nameof(eventFilter)); } if (readIndex == null) { throw new ArgumentNullException(nameof(readIndex)); } if (checkpointReached == null) { throw new ArgumentNullException(nameof(checkpointReached)); } if (checkpointIntervalMultiplier == 0) { throw new ArgumentOutOfRangeException(nameof(checkpointIntervalMultiplier)); } _subscriptionId = Guid.NewGuid(); _bus = bus; _resolveLinks = resolveLinks; _eventFilter = eventFilter; _user = user; _requiresLeader = requiresLeader; _maxSearchWindow = maxSearchWindow ?? ReadBatchSize; _checkpointReached = checkpointReached; _cancellationToken = cancellationToken; _subscriptionStarted = new TaskCompletionSource <bool>(); _channel = Channel.CreateBounded <(ResolvedEvent?, Position?)>(BoundedChannelOptions); _checkpointInterval = checkpointIntervalMultiplier * _maxSearchWindow; _semaphore = new SemaphoreSlim(1, 1); _lastCheckpoint = Position.Start; SubscriptionId = _subscriptionId.ToString(); var lastIndexedPosition = readIndex.LastIndexedPosition; var startPositionExclusive = startPosition == Position.End ? Position.FromInt64(lastIndexedPosition, lastIndexedPosition) : startPosition ?? Position.Start; _startPositionExclusive = new TFPos((long)startPositionExclusive.CommitPosition, (long)startPositionExclusive.PreparePosition); Subscribe(startPositionExclusive, startPosition != Position.End); }
private Task <ICollection <Post> > GetPostsAsync(string?tags, int?limit, int?page, Position?position) { Guard.Argument(limit, nameof(limit)).InRange(1, PostsMaximumLimit); Page.Validate(page, nameof(page), PostsMaximumPage, position); var splitTags = TagHelper.ParseSearchString(tags); if (splitTags.Length > PostsMaximumTagSearchCount) { throw new ArgumentException($"Only {PostsMaximumTagSearchCount} tags can be searched for at once. You provided {splitTags.Length} tags."); } return(RequestAsync("/posts.json", request => request.SetQueryParams(new { limit, tags = splitTags.Length == 0 ? null : string.Join(' ', splitTags) }) .SetPagination(page, position) .AuthenticatedIfPossible(this) .GetJsonAsync(token => token["posts"].ToObject <ICollection <Post> >()))); }
public Projectile(Position size, Position directionAndSpeed, Action actionToUseOnHit, EntityLiving caster, List <EventType> usedEventTypes, Position?renderSize = null, string spriteId = null, string name = null, bool passable = true, List <TagType> tagsToIgnore = null) : base(size, renderSize, spriteId, name, renderPriority: WorldRenderer.RenderPriority.PROJECTILE, tag: passable ? TagType.PROJECTILE_PASSABLE : TagType.PROJECTILE_SOLID, tagsToIgnore: tagsToIgnore, isTrigger: true) { direction = directionAndSpeed; this.actionToUseOnHit = actionToUseOnHit; this.caster = caster; this.usedEventTypes = usedEventTypes; }
public LexingException(string message, Exception innerException, Position?position) : base(message, innerException) { this.Position = position; }
public EventStoreAllFilteredCatchUpSubscription FilteredSubscribeToAllFrom(Position?lastCheckpoint, Filter filter, CatchUpSubscriptionFilteredSettings settings, Func <EventStoreCatchUpSubscription, ResolvedEvent, Task> eventAppeared, Action <EventStoreCatchUpSubscription> liveProcessingStarted = null, Action <EventStoreCatchUpSubscription, SubscriptionDropReason, Exception> subscriptionDropped = null, UserCredentials userCredentials = null) { throw new NotImplementedException(); }
public bool Equals(Position?other) => other is not null &&
public static async Task AssertCompletion(Server s, TextDocumentIdentifier document, IEnumerable <string> contains, IEnumerable <string> excludes, Position?position = null, CompletionContext?context = null, Func <CompletionItem, string> cmpKey = null, string expr = null) { var res = await s.Completion(new CompletionParams { textDocument = document, position = position ?? new Position(), context = context, _expr = expr }); DumpDetails(res); cmpKey = cmpKey ?? (c => c.insertText); AssertUtil.CheckCollection( res.items?.Select(cmpKey), contains, excludes ); }
public void GetFittingPosition_ReturnsCorrectResult(Position current, Position previous, Position?expectedResult) { Position?result = PositionUtilities.GetFittingPosition(current, previous); result.Should().Be(expectedResult); }
/// <summary> /// Generates a suitable Diagnostic from the given CompilerDiagnostic returned by the Q# compiler. /// The message range contained in the given CompilerDiagnostic is first converted to a Position object, /// and then added to the given positionOffset if the latter is not null. /// </summary> /// <exception cref="ArgumentOutOfRangeException">The contained range contains zero or negative entries, or its Start is bigger than its End.</exception> internal static Diagnostic Generate(string filename, QsCompilerDiagnostic msg, Position?positionOffset = null) => new Diagnostic { Severity = Severity(msg), Code = Code(msg), Source = filename, Message = msg.Message, Range = ((positionOffset ?? Position.Zero) + msg.Range).ToLsp() };
internal ResolvedEvent(ClientMessage.ResolvedEvent evnt) { Event = evnt.Event == null ? null : new RecordedEvent(evnt.Event); Link = evnt.Link == null ? null : new RecordedEvent(evnt.Link); OriginalPosition = new Position(evnt.CommitPosition, evnt.PreparePosition); }
public UpdateEmployee(Guid id, Position?position, string avatar) { Id = id; Position = position; Avatar = avatar; }
void EventAppeared(EventStoreCatchUpSubscription sub, ResolvedEvent evnt) { if (evnt.OriginalStreamId.StartsWith("$")) return; dynamic ev = _adapter.TryGetDomainEvent(evnt); if (ev == null) return; try { lock (this) { Dispatch(ev); _succeded++; _checkPoint = evnt.OriginalPosition.GetValueOrDefault(); _lastEventNumber = evnt.OriginalEventNumber; if(ev.Timestamp > LastUpdate) LastUpdate = ev.Timestamp; } } catch (Exception) { Debugger.Break(); } }
private async void EditDetails_Click(object sender, EventArgs e) { bool hasError = false; if (string.IsNullOrWhiteSpace(_firstName.Text)) { _firstName.Error = "Въведете Вашето име"; hasError = true; } if (string.IsNullOrWhiteSpace(_lastName.Text)) { _lastName.Error = "Въведете Вашата фамилия"; hasError = true; } Role role = (Role)Enum.Parse(typeof(Role), _account.Properties["roles"]); int selectedPosition = _positionsSpinner.SelectedItemPosition + 1; Position?position = string.Compare(role.ToString(), Role.Player.ToString(), true) == 0 ? (Position)selectedPosition : default(Position?); double.TryParse(_weight.Text, out double weightValue); double.TryParse(_height.Text, out double heightValue); if (weightValue == 0 && role == Role.Player) { _weight.Error = "Това поле е задължително за играчи"; hasError = true; } if (heightValue == 0 && role == Role.Player) { _height.Error = "Това поле е задължително за играчи"; hasError = true; } if (hasError) { return; } var editMemberDetails = new EditMemberDetails { Email = _account.Username, FirstName = _firstName.Text, LastName = _lastName.Text, PreferedPosition = position, Weight = position.HasValue ? weightValue : default(double?), Height = position.HasValue ? heightValue : default(double?), File = _imageStream, DateOfBirth = _dateOfBirth.DateTime }; AndHUD.Shared.Show(this, "Промяна…"); HttpResponseMessage httpResponse = await RestManager.EditMemberDetails(editMemberDetails); string response = await httpResponse.Content.ReadAsStringAsync(); if (httpResponse.IsSuccessStatusCode) { Intent intent = new Intent(this, typeof(UserProfileActivity)); AndHUD.Shared.Dismiss(this); StartActivity(intent); } else { AndHUD.Shared.Dismiss(this); Toast.MakeText(this, response, ToastLength.Long).Show(); } }
public override void Run() { Table table = new Table(2, 12); table.AddEntries(new [] { new KeyValuePair <Position, TableEntry>(new Position(0, 0), new FigureName(table, "Partridge in a pear tree")), new KeyValuePair <Position, TableEntry>(new Position(0, 1), new FigureName(table, "Turtle Dove")), new KeyValuePair <Position, TableEntry>(new Position(0, 2), new FigureName(table, "French Hen")), new KeyValuePair <Position, TableEntry>(new Position(0, 3), new FigureName(table, "Calling Bird")), new KeyValuePair <Position, TableEntry>(new Position(0, 4), new FigureName(table, "Gold Ring")), new KeyValuePair <Position, TableEntry>(new Position(0, 5), new FigureName(table, "Geese-a-laying")), new KeyValuePair <Position, TableEntry>(new Position(0, 6), new FigureName(table, "Swan-a-swimming")), new KeyValuePair <Position, TableEntry>(new Position(0, 7), new FigureName(table, "Maid-a-walking")), new KeyValuePair <Position, TableEntry>(new Position(0, 8), new FigureName(table, "Lady dancing")), new KeyValuePair <Position, TableEntry>(new Position(0, 9), new FigureName(table, "Lord-a-leeping")), new KeyValuePair <Position, TableEntry>(new Position(0, 10), new FigureName(table, "Piper Piping")), new KeyValuePair <Position, TableEntry>(new Position(0, 11), new FigureName(table, "Drummer Drumming")), new KeyValuePair <Position, TableEntry>(new Position(1, 0), new CurrencyFigureEntry(table, 25)), new KeyValuePair <Position, TableEntry>(new Position(1, 1), new CurrencyFigureEntry(table, 25)), new KeyValuePair <Position, TableEntry>(new Position(1, 2), new CurrencyFigureEntry(table, 12)), new KeyValuePair <Position, TableEntry>(new Position(1, 3), new CurrencyFigureEntry(table, 18)), new KeyValuePair <Position, TableEntry>(new Position(1, 4), new CurrencyFigureEntry(table, 60)), new KeyValuePair <Position, TableEntry>(new Position(1, 5), new CurrencyFigureEntry(table, 48)), new KeyValuePair <Position, TableEntry>(new Position(1, 6), new CurrencyFigureEntry(table, 480)), new KeyValuePair <Position, TableEntry>(new Position(1, 7), new CurrencyFigureEntry(table, 120)), new KeyValuePair <Position, TableEntry>(new Position(1, 8), new CurrencyFigureEntry(table, 202)), new KeyValuePair <Position, TableEntry>(new Position(1, 9), new CurrencyFigureEntry(table, 292 * 0.9)), new KeyValuePair <Position, TableEntry>(new Position(1, 10), new CurrencyFigureEntry(table, 97.75 * 0.89)), new KeyValuePair <Position, TableEntry>(new Position(1, 11), new CurrencyFigureEntry(table, 205 * 0.88)) }); Console.WriteLine("1) Output total cost of all gifts"); Console.WriteLine("2) Output a day you received a gift from your true love"); Console.WriteLine("3) Search how many of a gift have been brought"); Console.WriteLine("4) Quit"); int selection = Utils.AskUserInteger("Selection"); if (selection == 1) { double total = 0; foreach (TableEntry tableEntry in table.GetEntriesInRow(1)) { if (tableEntry.GetType() == typeof(CurrencyFigureEntry)) { total += ((CurrencyFigureEntry)tableEntry).Score; } } Console.WriteLine("Total: {0:C}", total); } else if (selection == 2) { int day = Utils.AskUserInteger("Day"); if (Enumerable.Range(1, table.Height).Contains(day)) { Table editedTable = table; editedTable.Height = day; for (; day <= table.Height; day++) { editedTable.TableEntries.Remove(new Position(0, day)); editedTable.TableEntries.Remove(new Position(1, day)); } Console.WriteLine(editedTable.GetDisplay()); } else { Console.WriteLine("Invalid day"); } } else if (selection == 3) { Position?position = table.SearchPositionRow(Utils.AskUserString("Search"), 0); if (position.HasValue) { Console.WriteLine("{0} have been sold.", position.Value.Y + 1); } else { Console.WriteLine("Could not find that value"); } } if (selection != 4) { Run(); } else { Console.WriteLine("Merry Christmas"); } }
public void ParserShouldParsePosition(string input, Position?result) { Assert.That(parser.TryParse(input), Is.EqualTo(result)); }
public LexingException(string message, Position?position) : base(message) { this.Position = position; }
public static IEnumerable <Position> EnumeratePositions <T>(this IIndexAccessor2D <T> source, int start0, int length0, int start1, int length1, Func <T, bool>?predicate = null, Position?after = null, Position?before = null, bool screenMode = false) { if (screenMode) { Position a = after ?? (start0, start0 - 1); Position b = before ?? (length0 + start0 - 1, length1 + start1); for (int y = a.Y; y <= b.Y; y++) { for (int x = y == a.Y ? a.X + 1 : start0; x < (y == b.Y ? b.X : length0 + start0); x++) { if (predicate?.Invoke(source[x, y]) ?? true) { yield return(x, y); } } } } else { Position a = after ?? (start0, start0 - 1); Position b = before ?? (length0 + start0 - 1, length1 + start1); for (int x = a.X; x <= b.X; x++) { for (int y = x == a.X ? a.Y + 1 : start1; y < (x == b.X ? b.Y : length1 + start1); y++) { if (predicate?.Invoke(source[x, y]) ?? true) { yield return(x, y); } } } } }
public EventStoreAllCatchUpSubscription SubscribeToAllFrom(Position?lastCheckpoint, bool resolveLinkTos, Action <EventStoreCatchUpSubscription, ResolvedEvent> eventAppeared, Action <EventStoreCatchUpSubscription> liveProcessingStarted = null, Action <EventStoreCatchUpSubscription, SubscriptionDropReason, Exception> subscriptionDropped = null, UserCredentials userCredentials = null, int readBatchSize = 500) { throw new NotImplementedException(); }
public void SelectPosition(Position position) { this.Fields[position.X, position.Y].SetBorderColor(BorderColor.Select); this.selectedPosition = position; }
public TeleportDescriptionBuilder SetLandingSpot(Position landingSpot) { _landingSpot = landingSpot; return(this); }
public abstract bool TryMapFromProjectedDocumentPosition(RazorCodeDocument codeDocument, int csharpAbsoluteIndex, [NotNullWhen(true)] out Position?originalPosition, out int originalIndex);
private Task <ICollection <Tag> > GetTagsByNamesAsync(IEnumerable <string> names, int?page, Position?position, int?limit, TagCategory?category, TagOrder?order, bool?hideEmpty, bool?hasWiki) { var filteredNames = names .Select(name => name.Trim()) .Where(name => !string.IsNullOrWhiteSpace(name)); string namesQuery = string.Join(',', filteredNames); return(GetTagsWithParameterAsync(("search[name]", namesQuery), page, position, limit, category, order, hideEmpty, hasWiki)); }
/// <summary> /// Update a light box for a change originating at the supplied position. Some logic is used to limit the size of the light box where possible. /// Update is performed by blanking out all of the existing light in an inner box area, resetting all light emitting sources in the inner box and then /// looping through an outer box that is one larger on each side so that light can be pulled back in from the edges where applicable. /// </summary> /// <remarks>Further logic could be added for more cases where the size of the light box could be decreased, however this is not a big bottleck now (chunk rebuild time is far more worthwhile to optimize).</remarks> /// <param name="position">Position the light change is centered at (the block that is changing).</param> /// <param name="positionCuboid">Null when only a single block is changing. End of the cuboid when the change is a cuboid.</param> /// <param name="isBlockChange">Is this change for a block add or remove. Any other changes, such as item lights, have no need for full vertical updates.</param> /// <param name="isRemove">Is this update for a block removal.</param> /// <returns>Queue of affected chunks with the chunk where the change originated queued first if this is a single block change.</returns> internal static Queue <Chunk> UpdateLightBox(ref Position position, Position?positionCuboid, bool isBlockChange, bool isRemove) { const int MAX_LIGHT_SPREAD_DISTANCE = SkyHost.BRIGHTEST_SKYLIGHT_STRENGTH; var stopwatch = new Stopwatch(); stopwatch.Start(); //use a queue to ensure the chunk where the change originates gets queued first for a single block change var chunksAffected = new Queue <Chunk>(); //inner box depends on if this is a single block or cuboid int x1Inner; int y1Inner; int z1Inner; int x2Inner; int y2Inner; int z2Inner; if (!positionCuboid.HasValue) //single block change { var chunkContainingChange = WorldData.Chunks[position]; //determine if a full vertical update is required; //-not required if the block directly under the change is NOT transparent (this is because sunlight couldnt travel down) //-not required if this change is below the heightmap because sunlight stops at the heightmap (sunlight is the only light that can travel > than the max spread distance) //-not required if this is NOT a block change, item lights etc. cannot affect sunlight //(cuts the light rebuild time by approx 60% in these cases) bool fullVerticalRequired = isBlockChange && position.Y > 0 && WorldData.GetBlock(position.X, position.Y - 1, position.Z).IsTransparent&& position.Y >= chunkContainingChange.HeightMap[position.X % Chunk.CHUNK_SIZE, position.Z % Chunk.CHUNK_SIZE]; x1Inner = Math.Max(position.X - MAX_LIGHT_SPREAD_DISTANCE, 0); y1Inner = fullVerticalRequired ? 0 : Math.Max(position.Y - MAX_LIGHT_SPREAD_DISTANCE, 0); z1Inner = Math.Max(position.Z - MAX_LIGHT_SPREAD_DISTANCE, 0); x2Inner = Math.Min(position.X + MAX_LIGHT_SPREAD_DISTANCE, WorldData.SizeInBlocksX - 1); y2Inner = fullVerticalRequired ? Chunk.CHUNK_HEIGHT - 1 : Math.Min(position.Y + MAX_LIGHT_SPREAD_DISTANCE, Chunk.CHUNK_HEIGHT - 1); z2Inner = Math.Min(position.Z + MAX_LIGHT_SPREAD_DISTANCE, WorldData.SizeInBlocksZ - 1); //figure out the chunk at each bottom corner of the light box (this will be at most 4, and will usually be the full 4 unless change is near a world edge or very close to the center of a chunk) //-this works because the chunk size is 32 therefore we know no more than 4 chunks can be affected when the max light spread distance is 15 var chunkBackLeft = WorldData.Chunks[x1Inner / Chunk.CHUNK_SIZE, z1Inner / Chunk.CHUNK_SIZE]; var chunkFrontLeft = WorldData.Chunks[x1Inner / Chunk.CHUNK_SIZE, z2Inner / Chunk.CHUNK_SIZE]; var chunkFrontRight = WorldData.Chunks[x2Inner / Chunk.CHUNK_SIZE, z2Inner / Chunk.CHUNK_SIZE]; var chunkBackRight = WorldData.Chunks[x2Inner / Chunk.CHUNK_SIZE, z1Inner / Chunk.CHUNK_SIZE]; chunksAffected.Enqueue(chunkContainingChange); //queue the chunk containing the changing block first, this makes the change seem more responsive to the user if (!chunksAffected.Contains(chunkBackLeft)) { chunksAffected.Enqueue(chunkBackLeft); } if (!chunksAffected.Contains(chunkFrontLeft)) { chunksAffected.Enqueue(chunkFrontLeft); } if (!chunksAffected.Contains(chunkFrontRight)) { chunksAffected.Enqueue(chunkFrontRight); } if (!chunksAffected.Contains(chunkBackRight)) { chunksAffected.Enqueue(chunkBackRight); } //adjacent chunks need to be queued first for block removes on a chunk border, otherwise we would briefly see a blank face on the adjacent block if (isRemove && position.IsOnChunkBorder) { chunksAffected.Enqueue(chunksAffected.Dequeue()); //dequeue the first chunk and requeue it last } } else //cuboid change { //determine 2 diagonal corners of the cuboid on the bottom plane int x1 = Math.Min(position.X, positionCuboid.Value.X); int z1 = Math.Min(position.Z, positionCuboid.Value.Z); int x2 = Math.Max(position.X, positionCuboid.Value.X); int z2 = Math.Max(position.Z, positionCuboid.Value.Z); x1Inner = Math.Max(x1 - MAX_LIGHT_SPREAD_DISTANCE, 0); y1Inner = 0; z1Inner = Math.Max(z1 - MAX_LIGHT_SPREAD_DISTANCE, 0); x2Inner = Math.Min(x2 + MAX_LIGHT_SPREAD_DISTANCE, WorldData.SizeInBlocksX - 1); y2Inner = Chunk.CHUNK_HEIGHT - 1; z2Inner = Math.Min(z2 + MAX_LIGHT_SPREAD_DISTANCE, WorldData.SizeInBlocksZ - 1); var chunk1 = WorldData.Chunks[x1Inner / Chunk.CHUNK_SIZE, z1Inner / Chunk.CHUNK_SIZE]; var chunk2 = WorldData.Chunks[x2Inner / Chunk.CHUNK_SIZE, z2Inner / Chunk.CHUNK_SIZE]; //loop through and add every chunk contained in the inner light box to the queue of affected chunks for (int x = chunk1.Coords.X; x <= chunk2.Coords.X; x++) { for (int z = chunk1.Coords.Z; z <= chunk2.Coords.Z; z++) { chunksAffected.Enqueue(WorldData.Chunks[x, z]); } } } //outer box is the same for single block or cuboid int x1Outer = Math.Max(x1Inner - 1, 0); int y1Outer = Math.Max(y1Inner - 1, 0); int z1Outer = Math.Max(z1Inner - 1, 0); int x2Outer = Math.Min(x2Inner + 1, WorldData.SizeInBlocksX - 1); int y2Outer = Math.Min(y2Inner + 1, Chunk.CHUNK_HEIGHT - 1); int z2Outer = Math.Min(z2Inner + 1, WorldData.SizeInBlocksZ - 1); ResetLightBoxSources(x1Inner, x2Inner, y1Inner, y2Inner, z1Inner, z2Inner, null, WorldData.SkyLightMap, WorldData.ItemLightMap); //loop through the outer light box to re-propagate, this pulls back in surrounding light as needed because the outer box is one larger for (int x = x1Outer; x < x2Outer; x++) { for (int y = y1Outer; y < y2Outer; y++) { for (int z = z1Outer; z < z2Outer; z++) { //propagate sky light byte skyLightStrength = WorldData.SkyLightMap[x, y, z]; if (skyLightStrength > 1) { PropagateLightDynamic(x, y, z, skyLightStrength, WorldData.SkyLightMap); //if strength > 1, check 6 adjacent neighbors and propagate recursively as needed } //propagate item light byte itemLightStrength = WorldData.ItemLightMap[x, y, z]; if (itemLightStrength > 1) { PropagateLightDynamic(x, y, z, itemLightStrength, WorldData.ItemLightMap); //if strength > 1, check 6 adjacent neighbors and propagate recursively as needed } } } } Debug.WriteLine("UpdateLightBox took {0}ms for {1} (Y range {2}) Queueing {3} chunks", stopwatch.ElapsedMilliseconds, position, y2Inner - y1Inner + 1, chunksAffected.Count); return(chunksAffected); }
private Task <ICollection <Tag> > GetTagsByNames(string query, int?id, Position?position, int?limit, TagCategory?category, TagOrder?order, bool?hideEmpty, bool?hasWiki) { return(GetTagsWithParameterAsync(("search[name_matches]", query), id, position, limit, category, order, hideEmpty, hasWiki)); }
public void MovePacManTo(Position position) { if (!IsValidMove(position)) { throw new InvalidMoveException(); } _pacManPosition = position; _visitedCells.Add(position); }
private static string GetChampionURL(int championId, Position?pos = null) => $"https://champion.gg/champion/{Riot.GetChampion(championId).Key}/" + (pos != null ? PositionToName[pos.Value] : "");
private void HandleEvent(EventStoreCatchUpSubscription arg1, ResolvedEvent arg2) { var @event = EventSerialization.DeserializeEvent(arg2.OriginalEvent); if (@event != null) { var eventType = @event.GetType(); if (_eventHandlerMapping.ContainsKey(eventType)) { _eventHandlerMapping[eventType](@event); } } _latestPosition = arg2.OriginalPosition; }
public Attribute(Position Position) { this.Position = Position; }
public override void Tick(RealmTime time) { if (pos == null) pos = new Position() { X = X, Y = Y }; if (!stat && HasConditionEffect(ConditionEffects.Bleeding)) { if (bleeding > 1) { HP -= (int)bleeding; bleeding -= (int)bleeding; UpdateCount++; } bleeding += 28 * (time.thisTickTimes / 1000f); } base.Tick(time); }
public bool Equals(Position?other) { return(other != null && this.X == other.X && this.Y == other.Y); }
public override RubyTag?Decode(AtTag tag) { if (!tag.Name.ToLower().StartsWith("ruby")) { return(null); } var values = tag.Value.Split(','); var parent = values[0]; var ruby = values[1]; Position?startPosition = null; Position?endPosition = null; // Filter duplicated if ruby == parent's text if (_filterDuplicated && ruby == parent) { return(null); } // TODO : have a better way to deal time tag in ruby. ruby = string.Join("", TimeTagExtension.SeparateKaraokeLine(ruby).Select(x => x.Word)); // Has start time and end time if (values.Length >= 3) { startPosition = FindPositionByTimeTag(values[2]); } if (values.Length > 3) { endPosition = FindPositionByTimeTag(values[3]); } return(new RubyTag { Parent = parent, Ruby = ruby, StartPosition = startPosition, EndPosition = endPosition }); Position?FindPositionByTimeTag(string timeTagText) { if (string.IsNullOrEmpty(timeTagText)) { return(null); } var milliSecond = TimeTagExtension.TimeTagToMillionSecond(timeTagText); for (var i = 0; i < _lyric.Lines.Length; i++) { var line = _lyric.Lines[i]; for (var j = 0; j < line.TimeTags.Length; j++) { var timeTag = line.TimeTags[j]; if (timeTag.Time == milliSecond) { return(new Position { Line = i, Index = (int)Math.Ceiling((float)(j - 1) / 2) }); } } } return(null); } }