public LastSeenTarget(LastSeen seen, IMyCubeBlock block = null) { m_lastSeen = seen; m_block = block; m_lastPostion = m_lastSeen.LastKnownPosition; m_lastPositionUpdate = m_lastSeen.LastSeenAt; m_targetType = TargetingOptions.GetTargetType(seen.Entity); }
public override string ToString() { string peer = isHub ? "Hub" : "Peer"; string seen = LastSeen.ToString(); //connection == null ? "Connection Not Set" : (connection.Connected ? "Connected " : "Non Connected"); return("[" + peer + ": " + Address + ":" + Port + " " + seen + " ]"); }
//To order by last seen in bucket public int CompareTo(Node other) { if (other == null) { return(1); } return(LastSeen.CompareTo(other.LastSeen)); }
public override string ToString() { var movieSB = new StringBuilder(); movieSB.AppendLine($"ID: {TitleId.ToString()}"); movieSB.AppendLine($"LastSeen: {LastSeen.ToString()}"); movieSB.AppendLine($"Soon: {Soon}"); return(movieSB.ToString()); }
private void OnDraw(EventArgs args) { if (!DrawGlobal.CurrentValue) { // Complete drawing turned off return; } foreach (var enemy in EntityManager.Heroes.Enemies.Where(o => !o.IsDead || o.IsInRange(EnemySpawnPoint, 250))) { // Get the minimap position var pos = enemy.ServerPosition.WorldToMinimap(); if (LastSeen.ContainsKey(enemy.NetworkId)) { // Update the position pos = LastSeenPosition[enemy.NetworkId].WorldToMinimap(); // Get the time being invisible in seconds var invisibleTime = (Core.GameTickCount - LastSeen[enemy.NetworkId]) / 1000f; // Predicted movement circle if (DrawMovementCircle.CurrentValue) { // Get the radius the champ could have walked var radius = LastSeenRange.ContainsKey(enemy.NetworkId) ? LastSeenRange[enemy.NetworkId] : (enemy.MoveSpeed > 1 ? enemy.MoveSpeed : 540) * invisibleTime; // Don't roast toasters if (radius < RangeCircleDisableRange.CurrentValue * 10) { Utilities.DrawCricleMinimap(pos, radius * Utilities.MinimapMultiplicator, Color.Red, 1, 500); } } // Draw the minimap icon ChampionSprites[enemy.Hero].Draw(pos + MinimapIconOffset); // Draw the time being invisible if (DrawInvisibleTime.CurrentValue && invisibleTime >= DelayInvisibleTime.CurrentValue) { var text = Math.Floor(invisibleTime).ToString(CultureInfo.InvariantCulture); var bounding = TimerText.MeasureBounding(text); TimerText.Draw(text, TimerText.Color, pos - (new Vector2(bounding.Width, bounding.Height) / 2) + 1); } } // Draw recall circle if (DrawRecallCircle.CurrentValue && RecallingHeroes.ContainsKey(enemy.NetworkId)) { var startTime = RecallingHeroes[enemy.NetworkId].Item1; var duration = RecallingHeroes[enemy.NetworkId].Item2; Utilities.DrawArc(pos, (MinimapIconSize + 4) / 2f, Color.Aqua, 3.1415f, Utilities.PI2 * ((Core.GameTickCount - startTime) / (float)duration), 2f, 100); } } }
public void RecordStore(int threadIdx, long threadClock, MemoryOrder mo, T payload) { LastSeen.SetAllClocks(VectorClock.MaxTime); LastSeen[threadIdx] = threadClock; LastStoredThreadId = threadIdx; LastStoredThreadClock = threadClock; LastStoreWasSequentiallyConsistent = mo == MemoryOrder.SequentiallyConsistent; IsInitialized = true; Payload = payload; }
private bool CanTarget(LastSeen seen) { try { // if it is too far from start, cannot target if (MaximumRange > 1f && Vector3.DistanceSquared(m_startPosition, seen.GetPosition()) > MaximumRange * MaximumRange) { Log.DebugLog("out of range: " + seen.Entity.getBestName()); if (m_reason < ReasonCannotTarget.Too_Far) { m_reason = ReasonCannotTarget.Too_Far; m_bestGrid = seen; } return(false); } // if it is too fast, cannot target float speedTarget = m_navSet.Settings_Task_NavEngage.SpeedTarget - 1f; if (seen.GetLinearVelocity().LengthSquared() >= speedTarget * speedTarget) { Log.DebugLog("too fast to target: " + seen.Entity.getBestName() + ", speed: " + seen.GetLinearVelocity().Length() + ", my speed: " + m_navSet.Settings_Task_NavEngage.SpeedTarget); if (m_reason < ReasonCannotTarget.Too_Fast) { m_reason = ReasonCannotTarget.Too_Fast; m_bestGrid = seen; } return(false); } if (GridCondition != null && !GridCondition(seen.Entity as IMyCubeGrid)) { Log.DebugLog("Failed grid condition: " + seen.Entity.getBestName()); if (m_reason < ReasonCannotTarget.Grid_Condition) { m_reason = ReasonCannotTarget.Grid_Condition; m_bestGrid = seen; } return(false); } m_bestGrid = seen; return(true); } catch (NullReferenceException nre) { Log.AlwaysLog("Exception: " + nre, Logger.severity.ERROR); if (!seen.Entity.Closed) { throw; } Log.DebugLog("Caught exception caused by grid closing, ignoring."); return(false); } }
private void OnTick(EventArgs args) { // Time elapsed since last update var elapsed = Core.GameTickCount - LastUpdate; LastUpdate = Core.GameTickCount; foreach (var enemy in EntityManager.Heroes.Enemies) { // Check if hero is dead if (enemy.IsDead && !DeadHeroes.Contains(enemy.NetworkId)) { DeadHeroes.Add(enemy.NetworkId); } // Check if hero was dead but respawned if (!enemy.IsDead && DeadHeroes.Contains(enemy.NetworkId)) { DeadHeroes.Remove(enemy.NetworkId); LastSeen[enemy.NetworkId] = Core.GameTickCount; LastSeenPosition[enemy.NetworkId] = EnemySpawnPoint; LastSeenRange[enemy.NetworkId] = 0; } // Update last seen range if (elapsed > 0 && LastSeenRange.ContainsKey(enemy.NetworkId) && !RecallingHeroes.ContainsKey(enemy.NetworkId)) { LastSeenRange[enemy.NetworkId] = LastSeenRange[enemy.NetworkId] + (enemy.MoveSpeed > 1 ? enemy.MoveSpeed : 540) * elapsed / 1000f; } if (enemy.IsInRange(EnemySpawnPoint, 250)) { LastSeenPosition[enemy.NetworkId] = EnemySpawnPoint; } if (enemy.IsHPBarRendered) { // Remove from last seen LastSeen.Remove(enemy.NetworkId); LastSeenPosition.Remove(enemy.NetworkId); } else { if (!LastSeen.ContainsKey(enemy.NetworkId)) { // Add to last seen LastSeen.Add(enemy.NetworkId, Core.GameTickCount); LastSeenPosition[enemy.NetworkId] = enemy.ServerPosition; LastSeenRange[enemy.NetworkId] = 0; } } } }
private double OrderValue(LastSeen seen) { int numTargeting = m_targetTracker.GetCount(seen.Entity.EntityId); if (m_currentTarget != null && m_currentTarget.Entity.EntityId == seen.Entity.EntityId) { numTargeting--; } return(seen.Entity.WorldAABB.Distance(m_controlBlock.CubeBlock.GetPosition()) + 1000d * numTargeting); }
public void Update(LastSeen seen, IMyCubeBlock block = null) { Logger.DebugLog("Different entity", Logger.severity.ERROR, condition: seen.Entity != m_lastSeen.Entity); m_lastSeen = seen; if (block != null) { m_block = block; } m_lastPostion = m_lastSeen.LastKnownPosition; m_lastPositionUpdate = m_lastSeen.LastSeenAt; }
protected override string[] GetContent() { return(new[] { ID.ToString("X"), ClientStatuses.GetStatusName(Status), LastSeen.ToString(), SentMsgCount.ToString(), ReceivedMsgCount.ToString() }); }
public async Task <bool> CheckLastSeen(VkNet.Model.LastSeen lastSeen, LastSeen lastSeenParams) { if (lastSeen.Time == null || lastSeen.Time < lastSeenParams.Min) { GetNextUser().BlackList = true; GetNextUser().BlackListReason = BlackListReason.NotMatch; await DB.SaveChangesAsync(); throw new Exception(); } return(true); }
public List <Claim> ToClaims() { var claims = new List <Claim>(); claims.Add(new Claim("username", UserName)); claims.Add(new Claim("creation-date", CreationDate.ToString("o"))); claims.Add(new Claim("last-seen", LastSeen.ToString("o"))); claims.Add(new Claim("last-edit", LastEdit.ToString("o"))); claims.Add(new Claim("account-type", AccountType.ToString())); claims.Add(new Claim("account-status", AccountStatus.ToString())); claims.Add(new Claim("recovery-email", Email ?? string.Empty)); claims.Add(new Claim("recovery-verified", EmailConfirmed.ToString())); claims.Add(new Claim("2fa-enabled", TwoFactorEnabled.ToString())); claims.Add(new Claim("pgp-public-key", PGPPublicKey ?? string.Empty)); return(claims); }
public GridDestination(LastSeen gridLastSeen, IMyCubeBlock destBlock, IMyCubeBlock seenBy, Navigator owner) { this.myNav = owner; this.Entity = gridLastSeen.Entity; //this.gridLastSeen = gridLastSeen; if (!RemoteControl.TryGet(seenBy, out this.seenBy)) { alwaysLog("failed to get ARRemoteControl", ".ctor()", Logger.severity.ERROR); } this.Grid = gridLastSeen.Entity as IMyCubeGrid; if (Grid == null) { (new Logger(null, "GridDestination")).log(Logger.severity.FATAL, ".ctor()", "Entity is not a grid"); } this.Block = destBlock; }
/// <summary> /// Finds a last seen hostile ordered by distance(in metres) + time since last seen(in millis). /// </summary> /// <returns></returns> public bool lastSeenHostile(out LastSeen bestMatchGrid, out IMyCubeBlock bestMatchBlock, string blockContains = null) { bestMatchGrid = null; bestMatchBlock = null; double bestMatchValue = -1; RemoteControl myAR; if (!RemoteControl.TryGet(owner.currentRCblock, out myAR)) { alwaysLog("failed to get ARRemoteControl for currentRC(" + owner.currentRCblock.DisplayNameText + ")", "lastSeenHostile()", Logger.severity.WARNING); log("needs update is " + owner.currentRCblock.NeedsUpdate, "lastSeenFriendly()", Logger.severity.DEBUG); return(false); } IEnumerator <LastSeen> allLastSeen = myAR.lastSeenEnumerator(); while (allLastSeen.MoveNext()) { IMyCubeGrid grid = allLastSeen.Current.Entity as IMyCubeGrid; if (grid == null || grid == owner.myGrid || !owner.currentRCblock.canConsiderHostile(grid)) { continue; } IMyCubeBlock matchBlock = null; if (!string.IsNullOrEmpty(blockContains) && !findBestHostile(grid, out matchBlock, blockContains)) // grid does not contain at least one matching block { continue; } TimeSpan timeSinceSeen = DateTime.UtcNow - allLastSeen.Current.LastSeenAt; double distance = owner.myGrid.WorldAABB.Distance(allLastSeen.Current.predictPosition(timeSinceSeen)); if (owner.CNS.lockOnRangeEnemy > 0 && distance > owner.CNS.lockOnRangeEnemy) { continue; } double matchValue = distance + timeSinceSeen.TotalMilliseconds; if (bestMatchGrid == null || matchValue < bestMatchValue) // if better grid match { bestMatchGrid = allLastSeen.Current; bestMatchValue = matchValue; bestMatchBlock = matchBlock; } } return(bestMatchGrid != null); }
static void ConsumeAndRecordLastSeen( LastSeen lastSeen, RecentNotifications recentNotifications, IEnumerable <TypeContract> contracts, Action <IEnumerable <IDomainEvent> > publish, RecordLastSeen recordLastSeen) { var id = Consume ( lastSeen: lastSeen, recentNotifications: recentNotifications, contracts: contracts, publish: publish )(); recordLastSeen(id); }
public void UpdateTarget(LastSeen enemy) { if (enemy == null) { Log.DebugLog("lost target", Logger.severity.DEBUG, condition: m_currentTarget != null); m_currentTarget = null; m_orbiter = null; return; } if (m_currentTarget == null || m_currentTarget.Entity != enemy.Entity) { Log.DebugLog("new target: " + enemy.Entity.getBestName(), Logger.severity.DEBUG); m_currentTarget = enemy; m_navSet.Settings_Task_NavEngage.DestinationEntity = m_currentTarget.Entity; } }
public Checkpoint AddToAggregated(Checkpoint cp) { if (!Aggregated) { throw new InvalidOperationException("This checkpoint is not aggregated"); } if (RiderId != cp.RiderId) { throw new ArgumentException($"Found checkpoints with different RiderIds {RiderId} {cp.RiderId}", nameof(cp)); } Timestamp = Timestamp.TakeSmaller(cp.Timestamp); LastSeen = LastSeen.TakeLarger(cp.Timestamp); Count += cp.Count; IsManual |= cp.IsManual; UpdateRps(); return(this); }
public override void Move() { m_finder.Update(); m_mover.StopMove(); if (m_finder.Grid == null) { m_mover.StopMove(); m_currentGrid = null; if (Globals.UpdateCount >= m_timeoutAt) { Log.DebugLog("Search timed out", Logger.severity.INFO); m_navSet.OnTaskComplete_NavMove(); } return; } if (m_currentGrid == null || m_finder.Grid.Entity != m_currentGrid.Entity) { Log.DebugLog("grid changed from " + m_finder.Grid.Entity.getBestName() + " to " + m_finder.Grid.Entity.getBestName(), Logger.severity.INFO); m_currentGrid = m_finder.Grid; GetDamagedBlocks(); } IMySlimBlock repairable = FindClosestRepairable(); if (repairable == null) { Log.DebugLog("failed to find a repairable block", Logger.severity.DEBUG); GetDamagedBlocks(); if (m_shopAfter) { CreateShopper(); } m_navSet.OnTaskComplete_NavMove(); m_navSet.WelderUnfinishedBlocks = m_damagedBlocks.Count + m_projectedBlocks.Count; m_navSet.Settings_Commands.Complaint |= InfoString.StringId.WelderNotFinished; return; } m_damagedBlocks.Remove(repairable); new WeldBlock(m_pathfinder, m_navSet, m_navWeld, repairable); }
/// <summary> /// Search by best match (shortest string matching gridNameContains). /// </summary> /// <param name="gridNameContains"></param> public bool lastSeenFriendly(string gridNameContains, out LastSeen bestMatchGrid, out IMyCubeBlock bestMatchBlock, string blockContains = null) { log("entered lastSeenFriendly(" + gridNameContains + ", " + blockContains + ")", "lastSeenFriendly()", Logger.severity.TRACE); bestMatchGrid = null; bestMatchBlock = null; int bestMatchLength = -1; RemoteControl myAR; if (!RemoteControl.TryGet(owner.currentRCblock, out myAR)) { alwaysLog("failed to get ARRemoteControl for currentRC(" + owner.currentRCblock.getNameOnly() + ")", "lastSeenFriendly()", Logger.severity.WARNING); //log("needs update is " + owner.currentRCblock.NeedsUpdate, "lastSeenFriendly()", Logger.severity.DEBUG); return(false); } IEnumerator <LastSeen> allLastSeen = myAR.lastSeenEnumerator(); while (allLastSeen.MoveNext()) { IMyCubeGrid grid = allLastSeen.Current.Entity as IMyCubeGrid; if (grid == null || grid == owner.myGrid) { continue; } //log("testing " + grid.DisplayName + " contains " + gridNameContains, "lastSeenFriendly()", Logger.severity.TRACE); if (grid.DisplayName.looseContains(gridNameContains)) { log("compare match " + grid.DisplayName + "(" + grid.DisplayName.Length + ") to " + bestMatchLength, "lastSeenFriendly()", Logger.severity.TRACE); if (bestMatchGrid == null || grid.DisplayName.Length < bestMatchLength) // if better grid match { IMyCubeBlock matchBlock = null; if (!string.IsNullOrEmpty(blockContains) && !findBestFriendly(grid, out matchBlock, blockContains)) // grid does not contain at least one matching block { log("no matching block in " + grid.DisplayName, "lastSeenFriendly()", Logger.severity.TRACE); continue; } bestMatchGrid = allLastSeen.Current; bestMatchLength = grid.DisplayName.Length; bestMatchBlock = matchBlock; } } } return(bestMatchGrid != null); }
static LastSeen Consume( LastSeen lastSeen, RecentNotifications recentNotifications, IEnumerable <TypeContract> contracts, Action <IEnumerable <IDomainEvent> > publish) { return(() => PublishAndReturnLastSeen ( recentNotifications ( lastSeen(), contracts.Select(x => new EventName { Value = x.Value }).ToArray() ), publish )); }
public void ChangeTarget(LastSeen oldTarget, LastSeen newTarget, long entityTargeting) { if (oldTarget != null && newTarget != null && oldTarget.Entity.EntityId == newTarget.Entity.EntityId) { return; } if (oldTarget != null) { Logger.DebugLog("old target is not null, remove"); RemoveTarget(oldTarget.Entity.EntityId, entityTargeting); } if (newTarget != null) { Logger.DebugLog("new target is not null, add"); AddTarget(newTarget.Entity.EntityId, entityTargeting); } }
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { LastSeen lastseen = null; if (controllerContext.HttpContext.Session != null) { lastseen = (LastSeen)controllerContext.HttpContext.Session[sessionkey]; } if (lastseen == null) { lastseen = new LastSeen(); lastseen.lastSeen = new List <Product>(5); if (controllerContext.HttpContext.Session != null) { controllerContext.HttpContext.Session[sessionkey] = lastseen; } } return(lastseen); }
public void InvokeStatus(User user, string statusOrStrDate) { var lastSeen = lastSeenDao.FindByUniqueID("User", user.ToRef()); if (lastSeen == null) { var model = new LastSeen { User = user, LongDateString = statusOrStrDate }; lastSeenDao.Insert(model); } else { lastSeen.LongDateString = statusOrStrDate; lastSeenDao.Update(lastSeen, new string[] { "LongDateString" }); } }
private async Task <CharacterV1DataEntry> UpdateEntryFor(DatabaseContext context, int id) { var statistics = Task.Factory.StartNew(() => _killboard.GetStatistics(id), TaskCreationOptions.LongRunning); var kills = await GetAllKills(id, context); var result = GetAnalysisFromCollection(id, kills); AddSpecialTags(context, id, result); try { result.Statistics = await statistics; } catch (Exception e) { LOGGER.Warn(string.Format("Could not get statistics for {0}", id), e); } result.LastSeen = LastSeen.GetValueFromCollection(context, id, kills); return(result); }
//------------------------------------------------- #region Ordinary Method's Region protected StrongString PlayerInfoGetForServer() { return (PlayerName + CharSeparater + // 1 PlayerLevel.ToString() + CharSeparater + // 2 PlayerLVLRanking.ToString() + CharSeparater + // 3 PlayerPowerRanking.ToString() + CharSeparater + // 4 PlayerGuildName + CharSeparater + // 5 ((uint)GuildPosition).ToString() + CharSeparater + // 6 LastSeen.GetForServer() + CharSeparater + // 7 PlayerPower.GetForServer() + CharSeparater + // 8 PlayerIntro + CharSeparater + // 9 PlayerAvatar.GetForServer() + CharSeparater + // 10 PlayerAvatarFrame.GetForServer() + CharSeparater + // 11 PlayerVIPlvl.ToString() + CharSeparater + // 12 PlayerCurrentExp.GetForServer() + CharSeparater + // 13 PlayerTotalExp.GetForServer() + CharSeparater + // 14 PlayerCurrentVIPExp.GetForServer() + CharSeparater + // 15 ((int)ThePlayerElement).ToString() + CharSeparater + // 16 ((int)PlayerKingdom).ToString() + CharSeparater + // 17 SocialPosition.GetForServer() + CharSeparater); // 18 }
private void UpdateLastSeen() { RelayStorage store = m_controlBlock.NetworkStorage; if (store == null) { Log.DebugLog("failed to get storage", Logger.severity.INFO); m_character = null; return; } if (m_character != null) { if (store.TryGetLastSeen(m_character.Entity.EntityId, out m_character)) { Log.DebugLog("got updated last seen"); return; } else { Log.DebugLog("failed to update last seen", Logger.severity.WARNING); m_character = null; m_timeoutAt = Globals.ElapsedTime + timeout; } } store.SearchLastSeen((LastSeen seen) => { Log.DebugLog("seen: " + seen.Entity.getBestName()); if (seen.Entity is IMyCharacter && seen.Entity.DisplayName.LowerRemoveWhitespace().Contains(m_charName)) { Log.DebugLog("found a last seen for character"); m_character = seen; return(true); } return(false); }); Log.DebugLog("failed to find a character from last seen", condition: m_character == null); }
public void AddToLastSeenProduct(int itemID, LastSeen lastSeen) { var isExist = lastSeen.lastSeen.Any(x => x.ProductID == itemID); var product = productRepository.Items.FirstOrDefault(x => x.ProductID == itemID); if (isExist) { lastSeen.lastSeen.Remove(lastSeen.lastSeen.Find(x => x.ProductID == itemID)); lastSeen.lastSeen.Add(product); } else { if (lastSeen.lastSeen.Count <= 4) { lastSeen.lastSeen.Add(product); } else { lastSeen.lastSeen.RemoveAt(0); lastSeen.lastSeen.Add(product); } } }
/// <summary> /// Attempts to choose a targetable block from a LastSeen. /// </summary> /// <returns>True iff the LastSeen can be targeted, either because it has no blocks or because a block was found.</returns> private bool ChooseBlock(LastSeen seen, out IMyCubeBlock block) { block = null; if (SEAD) { throw new NotImplementedException(); //float powerLevel; //return RadarEquipment_old.GetRadarEquipment(seen, out block, out powerLevel); } if (!seen.RadarInfoIsRecent()) { return(true); } IMyCubeGrid grid = seen.Entity as IMyCubeGrid; if (grid == null) { return(true); } if (Options.blocksToTarget.IsNullOrEmpty() && (Options.CanTarget & TargetType.Destroy) == 0) { return(true); } double distValue; if (!GetTargetBlock(grid, Options.CanTarget, out block, out distValue, false)) { return(false); } return(true); }
public PartialViewResult LastSeenProduct(LastSeen lastSeen) { return(PartialView(lastSeen)); }
public void SetOffline() { _online = 0; last_seen = new LastSeen() { time = Helpers.Time.EpochNow, platform = ( OnlineMobile ? 1 : 7) }; }