public bool DetectDwell(Tracked positionData, int radius, TimeSpan time) { if (Point.IsInsideRaidus(Position, positionData.position, radius)) { //TODO: this does not have to be an int =] a bool will do if (!isAlreadyIn) { timeDwellDetected = DateTime.UtcNow; } isAlreadyIn = true; var timeDiff = (DateTime.UtcNow) - timeDwellDetected; if (timeDiff > time) { timeDwellDetected = DateTime.UtcNow; return(true); } } else { isAlreadyIn = false; timeDwellDetected = DateTime.UtcNow; return(false); } return(false); }
/// <inheritdoc /> public async Task <Task> CommandAsync(ICommand command) { if (command.GetType().IsClosedTypeOf(typeof(RetroactiveCommand <>))) { await _messageQueue.RetroactiveExecution.FirstAsync(b => b == false).Timeout(Configuration.Timeout); await _messageQueue.UncompletedMessages.FirstAsync(b => b == 0).Timeout(Configuration.Timeout); } command.Timeline = _timeline.Id; if (!command.Pure) { await _messageQueue.UncompleteMessage(command); } var tracked = new Tracked <ICommand>(command); var dispatcher = _dispatchers.GetOrAdd(_timeline.Id, CreateDispatcher); await dispatcher.SendAsync(tracked); // return tracked.Task; if (command.Pure) { return(tracked.Task); } return(tracked.Task.ContinueWith(_ => _messageQueue.CompleteMessage(command)).Unwrap()); }
public SnapshotFolder(string location, Tracked parent) { Location = location; this.parent = parent; ItemName = Path.GetFileName(location); foreach (string s in GetFolders(location, Properties.Settings.Default.FolderExcludes, SearchOption.TopDirectoryOnly)) { if (Properties.Settings.Default.IgnoreHiddenFolders && (File.GetAttributes(s) & FileAttributes.Hidden) == FileAttributes.Hidden) { continue; } else Items.Add(new SnapshotFolder(s, this)); } foreach (string s in GetFiles(location, Properties.Settings.Default.FileExcludes, SearchOption.TopDirectoryOnly)) { if (Properties.Settings.Default.IgnoreHiddenFolders && (File.GetAttributes(s) & FileAttributes.Hidden) == FileAttributes.Hidden) { continue; } else Items.Add(new SnapshotFile(s, this)); } Header = ToString(); }
public NoAllocDrawIndirectEntry(Tracked <DeviceBuffer> indirectBuffer, uint offset, uint drawCount, uint stride) { IndirectBuffer = indirectBuffer; Offset = offset; DrawCount = drawCount; Stride = stride; }
void DisableArrow(Tracked go) { if (go.ArrowImage != null) { go.ArrowImage.enabled = false; } }
public NoAllocCopyTextureEntry( Tracked <Texture> source, uint srcX, uint srcY, uint srcZ, uint srcMipLevel, uint srcBaseArrayLayer, Tracked <Texture> destination, uint dstX, uint dstY, uint dstZ, uint dstMipLevel, uint dstBaseArrayLayer, uint width, uint height, uint depth, uint layerCount) { Source = source; SrcX = srcX; SrcY = srcY; SrcZ = srcZ; SrcMipLevel = srcMipLevel; SrcBaseArrayLayer = srcBaseArrayLayer; Destination = destination; DstX = dstX; DstY = dstY; DstZ = dstZ; DstMipLevel = dstMipLevel; DstBaseArrayLayer = dstBaseArrayLayer; Width = width; Height = height; Depth = depth; LayerCount = layerCount; }
public NoAllocUpdateBufferEntry(Tracked <DeviceBuffer> buffer, uint bufferOffsetInBytes, Tracked <byte[]> stagingBlock, uint stagingBlockSize) { Buffer = buffer; BufferOffsetInBytes = bufferOffsetInBytes; StagingBlock = stagingBlock; StagingBlockSize = stagingBlockSize; }
/// <inheritdoc/> public override Grenade Spawn(Vector3 position, Vector3 velocity, float fuseTime = 3, ItemType grenadeType = ItemType.GrenadeFrag, Player player = null) { if (player == null) { player = Server.Host; } GrenadeManager grenadeManager = player.GrenadeManager; GrenadeSettings settings = grenadeManager.availableGrenades.FirstOrDefault(g => g.inventoryID == grenadeType); Grenade grenade = GameObject.Instantiate(settings.grenadeInstance).GetComponent <Grenade>(); grenade.FullInitData(grenadeManager, position, Quaternion.Euler(grenade.throwStartAngle), velocity, grenade.throwAngularVelocity, player == Server.Host ? Team.RIP : player.Team); grenade.NetworkfuseTime = NetworkTime.time + fuseTime; Tracked.Add(grenade.gameObject); GameObject grenadeObject = grenade.gameObject; UnityEngine.Object.Destroy(grenadeObject.GetComponent <Scp018Grenade>()); grenadeObject.AddComponent <Components.Rock>().Init(player.GameObject, player.Side, FriendlyFire, ThrownDamage); NetworkServer.Spawn(grenadeObject); if (ExplodeOnCollision) { grenade.gameObject.AddComponent <CollisionHandler>().Init(player.GameObject, grenade); } return(grenade); }
public void OnCommand(ITransport sender, Command command) { if (command != null) { if (command.IsResponse) { Object oo = null; lock (((ICollection)requestMap).SyncRoot) { int v = ((Response)command).CorrelationId; try { if (requestMap.ContainsKey(v)) { oo = requestMap[v]; requestMap.Remove(v); } } catch { } } Tracked t = oo as Tracked; if (t != null) { t.onResponses(); } } } this.Command(sender, command); }
public NoAllocCopyBufferEntry(Tracked <DeviceBuffer> source, uint sourceOffset, Tracked <DeviceBuffer> destination, uint destinationOffset, uint sizeInBytes) { Source = source; SourceOffset = sourceOffset; Destination = destination; DestinationOffset = destinationOffset; SizeInBytes = sizeInBytes; }
private async Task Process(Tracked <IStream> trackedStream) { var s = trackedStream.Value; if (s.Version == ExpectedVersion.NoStream) { trackedStream.Complete(); return; } if (trackedStream.Completed.IsCompleted) { return; } var version = _versions.GetOrAdd(s.Key, ExpectedVersion.EmptyStream); var origVersion = version; // read from latest snapshot var snapshotVersion = s.SnapshotVersion; if (version < snapshotVersion && _projection.Latest > s.SnapshotTimestamp) { version = snapshotVersion - 1; } if (s.Version <= ExpectedVersion.EmptyStream) { s.Version = 0; } if (version > s.Version) { _log?.Warn($"Stream {s.Key} update is version {s.Version}, behind projection version {version}", GetDetailedName()); } if (version < s.Version) { var t = await _eventStore.ReadStream <IEvent>(s, version + 1) .TakeWhile(_ => !_token.IsCancellationRequested) .Select(e => _projection.When(e)) .ToList() .Timeout(Configuration.Timeout) .LastOrDefaultAsync(); version += t.Count; await Task.WhenAll(t); _log?.Debug($"{s.Key}@{s.Version} <- {version}", $"{Parents.Select(p => p.Name).Aggregate((a, n) => a + n)}->{Name}"); if (!_versions.TryUpdate(s.Key, version, origVersion)) { throw new InvalidOperationException("Failed updating concurrent versions of projections"); } } trackedStream.Complete(); }
public void TestNotDwell() { var tgtPoint = new Point(100, 100); var tgt = new DwellableTarget(tgtPoint, "notDwell", 0, 0); var tracked = new Tracked(0, 100, 101); Thread.Sleep(1 * 1000); Assert.IsFalse(tgt.DetectDwell(tracked, 2, TimeSpan.FromSeconds(2))); }
void EnableArrow(Tracked go) { if (go.ArrowImage == null) { var arrow = (Image)Instantiate(arrowPrefab, trackerCanvas.transform); go.ArrowImage = arrow; } go.ArrowImage.enabled = true; }
public void TestTrueDwell() { var tgtPoint = new Point(100, 100); var tgt = new DwellableTarget(tgtPoint, "testDwell", 0, 0); var tracked = new Tracked(0, 100, 101); Thread.Sleep(3 * 1000); Assert.IsTrue(tgt.DetectDwell(tracked, 2, TimeSpan.FromSeconds(3))); }
public override async Task<T> Get(Id id) { var cacheId = $"{_parent.Stream.Bucket}.{_parent.BuildParentsString()}.{id}"; T root; if (!Tracked.TryGetValue(cacheId, out root)) Tracked[cacheId] = root = await GetUntracked(_parent.Stream.Bucket, id, _parent.BuildParents()).ConfigureAwait(false); return (T)root; }
public override IEventChecker <TEntity> Check(TestableId id) { var cacheId = $"{_parent.Bucket}.{_parent.Id}.{id}"; if (!Tracked.ContainsKey(cacheId)) { throw new ExistException(typeof(TEntity), _parent.Bucket, id); } return(new EventChecker <TEntity, TState>(_uow, _ids, _factory, Tracked[cacheId])); }
public void StopTracking(Tracked go) { DisableArrow(go); onCameraObjects.Remove(go); offCameraObjects.Remove(go); if (go.ArrowImage != null) { Destroy(go.ArrowImage); } }
public void StopTracking(Tracked go) { DisableArrow(go); visibleObjects.Remove(go); invisibleObjects.Remove(go); if (go.ArrowImage != null) { Destroy(go.ArrowImage); } }
internal PendingRequest <T> Request <T>(string methodName, object[] args, Func <object?, T> parser) { var id = System.Threading.Interlocked.Increment(ref msgid); var send = new JsonRpc.Request(id, methodName, args); var track = new Tracked <T>(parser); lock (pending) { pending.Add(id, track); } return(new PendingRequest <T>(send, track.Task)); }
public void OnCommand(ITransport sender, Command command) { if (command != null) { if (command.IsResponse) { Object oo = null; lock (((ICollection)requestMap).SyncRoot) { int v = ((Response)command).CorrelationId; try { if (requestMap.ContainsKey(v)) { oo = requestMap[v]; requestMap.Remove(v); } } catch { } } Tracked t = oo as Tracked; if (t != null) { t.onResponses(); } } if (!initialized) { if (command.IsBrokerInfo) { BrokerInfo info = (BrokerInfo)command; BrokerInfo[] peers = info.PeerBrokerInfos; if (peers != null) { for (int i = 0; i < peers.Length; i++) { String brokerString = peers[i].BrokerURL; Add(brokerString); } } initialized = true; } } } this.Command(sender, command); }
private void printTrackList() { Tracked = Tracked.Distinct().ToList(); foreach (string s in Tracked) { if (Ignored.Contains(s)) { continue; } UO.PrintError(s); } UO.PrintWarning("<*<*<|-|-|-|-|-|-|-|-|-|-|>*>*>"); }
void Proc() { var pt = NativeMethods.GetCursorPos(); var result = UiHitTest.GetUiHit(new Point(pt)); var arg = new AccessibleTrackedArgs() { Position = new Point(pt), Element = result.UiElement, RawHit = result.RawHit }; Tracked?.Invoke(this, arg); }
public ISubscription FindByName(string name) { var subscription = Tracked.FirstOrDefault(s => s.Name == name); if (subscription == null) { var message = string.Format( "Could not find a subscription with the name: {0}", name); throw new ChinchillaException(message); } return(subscription); }
public void DetectDwell(JsonData positionData) { foreach (var target in dwellableTargets) { foreach (var tracked in positionData.trackerData) { if (target.DetectDwell(tracked, radius, time)) { var t = new Tracked(target.Page, target.Position, "track", target.Label); OnDwellDetected?.Invoke(t); } } } }
public void UpdateTrackStatus(Tracked go) { if (go.IsOnCamera) { onCameraObjects.Add(go); offCameraObjects.Remove(go); DisableArrow(go); } else { onCameraObjects.Remove(go); offCameraObjects.Add(go); } }
void DrawArrow(Tracked go) { // convert from viewport range (spanning [0 to 1]) to [-1 to 1] var center = new Vector3(0.5f, 0.5f, 0); var viewPoint = (go.ViewportPoint - center) * 2; viewPoint.z = 0; viewPoint.Normalize(); var angle = Mathf.Atan2(viewPoint.y, viewPoint.x) * Mathf.Rad2Deg; var trans = go.ArrowImage.GetComponent <RectTransform> (); var canvasTrans = trackerCanvas.GetComponent <RectTransform> (); trans.rotation = Quaternion.AngleAxis(angle, Vector3.forward); trans.position = new Vector3(canvasTrans.rect.width / 2 * (1 + viewPoint.x), canvasTrans.rect.height / 2 * (1 + viewPoint.y), 0); }
public void ResolvedCreatesValue() { Tracker tracker = new Tracker(); ServiceCollection collection = new ServiceCollection(); collection.AddSingleton(_ => tracker.Create()); collection.EnableLazy(); using (ServiceProvider provider = collection.BuildServiceProvider()) { Lazy <Tracked> lazy = provider.GetRequiredService <Lazy <Tracked> >(); Assert.Equal(0, tracker.Created); Tracked t = lazy.Value; Assert.Equal(1, tracker.Created); Assert.Equal(1, t.Id); } }
public override async Task <TEntity> New(Id id) { var cacheId = $"{_parent.Bucket}.{_parent.Id}.{id}"; if (!Tracked.TryGetValue(cacheId, out var root)) { root = await NewUnTracked(_parent.Bucket, id, _parent).ConfigureAwait(false); if (!Tracked.TryAdd(cacheId, root)) { throw new InvalidOperationException($"Could not add cache key [{cacheId}] to repo tracked"); } } return(root); }
public void ResolvedCreatesValue() { Tracker tracker = new Tracker(); ServiceCollection collection = new ServiceCollection(); collection.AddSingleton(_ => tracker.Create()); collection.EnableLazy(); using (ServiceProvider provider = collection.BuildServiceProvider()) { Lazy <Tracked> lazy = provider.GetRequiredService <Lazy <Tracked> >(); tracker.Created.Should().Be(0); Tracked t = lazy.Value; tracker.Created.Should().Be(1); t.Id.Should().Be(1); } }
public override async Task <TEntity> Get(Id id) { var cacheId = $"{_parent.Bucket}.{_parent.BuildParentsString()}.{id}"; TEntity root; if (!Tracked.TryGetValue(cacheId, out root)) { root = await GetUntracked(_parent.Bucket, id, _parent.BuildParents()).ConfigureAwait(false); if (!Tracked.TryAdd(cacheId, root)) { throw new InvalidOperationException($"Could not add cache key [{cacheId}] to repo tracked"); } } return(root); }
public void ResolvesSameObject() { Tracker tracker = new Tracker(); ServiceCollection collection = new ServiceCollection(); collection.AddSingleton(_ => tracker.Create()); collection.EnableLazy(); using (ServiceProvider provider = collection.BuildServiceProvider()) { Lazy <Tracked> a = provider.GetRequiredService <Lazy <Tracked> >(); Tracked a1 = a.Value; Lazy <Tracked> b = provider.GetRequiredService <Lazy <Tracked> >(); Tracked b1 = b.Value; b1.Should().BeSameAs(a1); tracker.Created.Should().Be(1); } }