public static void Postfix(Deaths __instance) { DuplicantLifeCyclePatches.oldAgeDeath = new Death( id: "DuplicantLifecycles.Aging.OldAgeDeath", parent: (ResourceSet)Db.Get().Deaths, name: "Old Age", description: DuplicantLifecycleStrings.DeathMessage, pre_anim: "death_suffocation", loop_anim: "dead_on_back" ); __instance.Add(oldAgeDeath); }
/// <summary> /// Restore player's data from a Player object /// </summary> /// <param name="player"></param> public void BackupFromPlayer(Player player) { Kills.Clear(); foreach (KillEvent e in player.Kills) { Kills.Add(e); } Deaths.Clear(); foreach (KillEvent e in player.Deaths) { Deaths.Add(e); } Assists.Clear(); foreach (KillEvent e in player.Assists) { Assists.Add(e); } Clutches.Clear(); foreach (ClutchEvent e in player.Clutches) { Clutches.Add(e); } EntryHoldKills.Clear(); foreach (EntryHoldKillEvent e in player.EntryHoldKills) { EntryHoldKills.Add(e); } EntryKills.Clear(); foreach (EntryKillEvent e in player.EntryKills) { EntryKills.Add(e); } PlayersHurted.Clear(); foreach (PlayerHurtedEvent e in player.PlayersHurted) { PlayersHurted.Add(e); } RoundsMoneyEarned.Clear(); foreach (KeyValuePair <int, int> kvp in player.RoundsMoneyEarned) { RoundsMoneyEarned.Add(kvp.Key, kvp.Value); } StartMoneyRounds.Clear(); foreach (KeyValuePair <int, int> kvp in player.StartMoneyRounds) { StartMoneyRounds.Add(kvp.Key, kvp.Value); } EquipementValueRounds.Clear(); foreach (KeyValuePair <int, int> kvp in player.EquipementValueRounds) { EquipementValueRounds.Add(kvp.Key, kvp.Value); } AssistCount = player.AssistCount; BombDefusedCount = player.BombDefusedCount; BombExplodedCount = player.BombExplodedCount; BombPlantedCount = player.BombPlantedCount; CrouchKillCount = player.CrouchKillCount; DeathCount = player.DeathCount; DecoyThrownCount = player.DecoyThrownCount; EseaRws = player.EseaRws; EseaRwsPointCount = player.EseaRwsPointCount; FiveKillCount = player.FiveKillCount; FlashbangThrownCount = player.FlashbangThrownCount; FlashDurationTemp = player.FlashDurationTemp; FourKillCount = player.FourKillCount; HasBomb = player.HasBomb; HasEntryHoldKill = player.HasEntryHoldKill; HasEntryKill = player.HasEntryKill; HeadshotCount = player.HeadshotCount; HeGrenadeThrownCount = player.HeGrenadeThrownCount; IsAlive = player.IsAlive; IncendiaryThrownCount = player.IncendiaryThrownCount; IsConnected = player.IsConnected; IsControllingBot = player.IsControllingBot; JumpKillCount = player.JumpKillCount; KillCount = player.KillCount; MolotovThrownCount = player.MolotovThrownCount; OneKillCount = player.OneKillCount; RatingHltv = player.RatingHltv; RoundMvpCount = player.RoundMvpCount; RoundPlayedCount = player.RoundPlayedCount; Score = player.Score; Side = player.Side; SmokeThrownCount = player.SmokeThrownCount; TeamKillCount = player.TeamKillCount; TeamName = player.TeamName; ThreeKillCount = player.ThreeKillCount; TradeDeathCount = player.TradeDeathCount; TradeKillCount = player.TradeKillCount; TwoKillCount = player.TwoKillCount; }
public override async Task PerformAction() { if (NeedsToReset) { while (true && this.playerReader.PlayerBitValues.DeadStatus) { this.corpseLocation = new WowPoint(playerReader.CorpseX, playerReader.CorpseY); if (this.corpseLocation.X > 0) { break; } logger.LogInformation($"Waiting for corpse location to update {playerReader.CorpseX},{playerReader.CorpseY}"); await Task.Delay(1000); } logger.LogInformation($"Corpse location is {playerReader.CorpseX},{playerReader.CorpseY}"); await Reset(); this.stuckDetector.SetTargetLocation(points.Peek()); Deaths.Add(this.corpseLocation); } await Task.Delay(200); if (!this.playerReader.PlayerBitValues.DeadStatus) { return; } var location = new WowPoint(playerReader.XCoord, playerReader.YCoord); double distance = 0; double heading = 0; if (points.Count == 0) { points.Push(this.playerReader.CorpseLocation); distance = DistanceTo(location, corpseLocation); heading = DirectionCalculator.CalculateHeading(location, corpseLocation); this.logger.LogInformation("no more points, heading to corpse"); await playerDirection.SetDirection(heading, this.playerReader.CorpseLocation, "Heading to corpse"); wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "WalkToCorpse"); this.stuckDetector.SetTargetLocation(points.Peek()); } else { distance = DistanceTo(location, points.Peek()); heading = DirectionCalculator.CalculateHeading(location, points.Peek()); } if (lastDistance < distance) { await playerDirection.SetDirection(heading, points.Peek(), "Further away"); } else if (!this.stuckDetector.IsGettingCloser()) { // stuck so jump wowProcess.SetKeyState(ConsoleKey.UpArrow, true, false, "WalkToCorpseAction"); await Task.Delay(100); if (HasBeenActiveRecently()) { await stuckDetector.Unstick(); } else { await Task.Delay(1000); logger.LogInformation("Resuming movement"); } } else // distance closer { var diff1 = Math.Abs(RADIAN + heading - playerReader.Direction) % RADIAN; var diff2 = Math.Abs(heading - playerReader.Direction - RADIAN) % RADIAN; if (Math.Min(diff1, diff2) > 0.3) { await playerDirection.SetDirection(heading, points.Peek(), "Correcting direction"); } } lastDistance = distance; if (distance < 40 && points.Any()) { logger.LogInformation($"Move to next point"); points.Pop(); lastDistance = 999; if (points.Count > 0) { heading = DirectionCalculator.CalculateHeading(location, points.Peek()); await playerDirection.SetDirection(heading, points.Peek(), "Move to next point"); this.stuckDetector.SetTargetLocation(points.Peek()); } } LastActive = DateTime.Now; }
public void AddData(IEntity data, EntityType entityType) { switch (entityType) { case EntityType.Person: { Persons.Add((Person)data); break; } case EntityType.Death: { Deaths.Add((Death)data); break; } case EntityType.PayerPlanPeriod: { PayerPlanPeriods.Add((PayerPlanPeriod)data); break; } case EntityType.ConditionOccurrence: { ConditionOccurrences.Add((ConditionOccurrence)data); break; } case EntityType.DrugExposure: { DrugExposures.Add((DrugExposure)data); break; } case EntityType.ProcedureOccurrence: { ProcedureOccurrences.Add((ProcedureOccurrence)data); break; } case EntityType.Observation: { Observations.Add((Observation)data); break; } case EntityType.VisitOccurrence: { VisitOccurrences.Add((VisitOccurrence)data); break; } case EntityType.VisitDetail: { VisitDetails.Add((VisitDetail)data); break; } case EntityType.Cohort: { Cohort.Add((Cohort)data); break; } case EntityType.Measurement: { Measurements.Add((Measurement)data); break; } case EntityType.DeviceExposure: { DeviceExposure.Add((DeviceExposure)data); break; } case EntityType.ObservationPeriod: { ObservationPeriods.Add((ObservationPeriod)data); break; } case EntityType.DrugEra: { DrugEra.Add((EraEntity)data); break; } case EntityType.ConditionEra: { ConditionEra.Add((EraEntity)data); break; } case EntityType.Note: { Note.Add((Note)data); break; } } }
public override async Task PerformAction() { // is corpse visible if (this.playerReader.CorpseX < 1 && this.playerReader.CorpseX < 1) { await this.stopMoving.Stop(); logger.LogInformation($"Waiting for corpse location to update update before performing action. Corpse is @ {playerReader.CorpseX},{playerReader.CorpseY}"); await Task.Delay(5000); NeedsToReset = true; return; } if (NeedsToReset) { await this.stopMoving.Stop(); while (this.playerReader.PlayerBitValues.DeadStatus) { this.corpseLocation = new WowPoint(playerReader.CorpseX, playerReader.CorpseY); if (this.corpseLocation.X >= 1 || this.corpseLocation.Y > 0) { break; } logger.LogInformation($"Waiting for corpse location to update {playerReader.CorpseX},{playerReader.CorpseY}"); await Task.Delay(1000); } logger.LogInformation($"Corpse location is {playerReader.CorpseX},{playerReader.CorpseY}"); await Reset(); Deaths.Add(this.corpseLocation); } var timeSinceResetSeconds = (DateTime.Now - LastReset).TotalSeconds; if (timeSinceResetSeconds > 80) { await this.stopMoving.Stop(); logger.LogInformation("We have been dead for over 1 minute, trying to path a new route."); await this.Reset(); } await Task.Delay(200); if (!this.playerReader.PlayerBitValues.DeadStatus) { return; } var location = new WowPoint(playerReader.XCoord, playerReader.YCoord); double distance = 0; double heading = 0; if (points.Count == 0) { await Reset(); if (!points.Any()) { points.Push(this.playerReader.CorpseLocation); distance = DistanceTo(location, corpseLocation); heading = DirectionCalculator.CalculateHeading(location, corpseLocation); this.logger.LogInformation("no more points, heading to corpse"); await playerDirection.SetDirection(heading, this.playerReader.CorpseLocation, "Heading to corpse"); input.SetKeyState(ConsoleKey.UpArrow, true, false, "WalkToCorpse"); this.stuckDetector.SetTargetLocation(points.Peek()); } } else { distance = DistanceTo(location, points.Peek()); heading = DirectionCalculator.CalculateHeading(location, points.Peek()); } if (lastDistance < distance) { await playerDirection.SetDirection(heading, points.Peek(), "Further away"); } else if (!this.stuckDetector.IsGettingCloser()) { // stuck so jump input.SetKeyState(ConsoleKey.UpArrow, true, false, "WalkToCorpseAction"); await Task.Delay(100); if (HasBeenActiveRecently()) { await stuckDetector.Unstick(); // give up if we have been dead for 10 minutes var timeDeadSeconds = (DateTime.Now - LastEventReceived).TotalSeconds; if (timeDeadSeconds > 600) { logger.LogInformation("We have been dead for 10 minutes and seem to be stuck."); SendActionEvent(new ActionEventArgs(GOAP.GoapKey.abort, true)); await Task.Delay(10000); return; } distance = DistanceTo(location, points.Peek()); } else { await Task.Delay(1000); logger.LogInformation("Resuming movement"); } } else // distance closer { var diff1 = Math.Abs(RADIAN + heading - playerReader.Direction) % RADIAN; var diff2 = Math.Abs(heading - playerReader.Direction - RADIAN) % RADIAN; if (Math.Min(diff1, diff2) > 0.3) { await playerDirection.SetDirection(heading, points.Peek(), "Correcting direction"); } } lastDistance = distance; if (distance < PointReachedDistance() && points.Any()) { while (distance < PointReachedDistance() && points.Any()) { points.Pop(); if (points.Any()) { distance = WowPoint.DistanceTo(location, points.Peek()); } } lastDistance = 999; if (points.Count > 0) { heading = DirectionCalculator.CalculateHeading(location, points.Peek()); await playerDirection.SetDirection(heading, points.Peek(), "Move to next point"); this.stuckDetector.SetTargetLocation(points.Peek()); } } LastActive = DateTime.Now; }
public void CountDeath() => Deaths.Add((int)RegionManager.Main.TimeElapsed);