private void FastObjectListViewEggs_FormatCell(object sender, FormatCellEventArgs e) { var egg = (PokemonData)e.Model; var eggIncubator = new EggIncubator(); foreach (var inc in _manager.Incubators) { if (inc.PokemonId == egg.Id) { eggIncubator = inc; } } if (e.Column == olvColumnEggWalked) { if (eggIncubator.PokemonId != 0) { e.SubItem.Text = String.Format("{0:0.00} km", _manager.Stats.KmWalked - eggIncubator.StartKmWalked); } else { e.SubItem.Text = "0.00 km"; } } else if (e.Column == olvColumnEggDistance) { e.SubItem.Text = String.Format("{0:0.00}km", egg.EggKmWalkedTarget); } }
private static async Task <taskResponse> IncubateEgg(EggIncubator item, PokemonData egg) { taskResponse resp1 = new taskResponse(false, string.Empty); try { var client = Logic.Logic.Client; var resp2 = await client.Inventory.UseItemEggIncubator(item.Id, egg.Id); if (resp2.Result == UseItemEggIncubatorResponse.Types.Result.Success) { resp1.Status = true; } else { resp1.Message = item.ItemId.ToString(); } } catch (Exception e) { Logger.ColoredConsoleWrite(ConsoleColor.Red, "Error IncubateEgg: " + e.Message); await IncubateEgg(item, egg); } return(resp1); }
private MethodResult <EggIncubator> GetIncubator() { if (Incubators == null) { return(new MethodResult <EggIncubator>()); } EggIncubator unusedUnlimitedIncubator = Incubators.FirstOrDefault(x => x.ItemId == ItemId.ItemIncubatorBasicUnlimited && x.PokemonId == 0); if (unusedUnlimitedIncubator != null) { return(new MethodResult <EggIncubator> { Data = unusedUnlimitedIncubator, Success = true }); } IEnumerable <EggIncubator> incubators = Incubators.Where(x => x.ItemId == ItemId.ItemIncubatorBasic && x.PokemonId == 0); foreach (EggIncubator incubator in incubators) { return(new MethodResult <EggIncubator> { Data = incubator, Success = true }); } return(new MethodResult <EggIncubator> { Message = "No unused incubators" }); }
public void OnOperationalChanged(object data = null) { bool stored = base.gameObject.HasTag(GameTags.Stored); Storage storage = GetStorage(); EggIncubator eggIncubator = (!(bool)storage) ? null : storage.GetComponent <EggIncubator>(); UpdateIncubationState(stored, eggIncubator); }
public void OnStore(object data) { Storage storage = data as Storage; bool stored = (bool)storage || (data != null && (bool)data); EggIncubator eggIncubator = (!(bool)storage) ? null : storage.GetComponent <EggIncubator>(); UpdateIncubationState(stored, eggIncubator); }
protected override void OnCompleteWork(Worker worker) { EggIncubator component = GetComponent <EggIncubator>(); if ((bool)component && (bool)component.Occupant) { component.Occupant.GetSMI <IncubationMonitor.Instance>()?.ApplySongBuff(); } }
public static bool InIncubator(Instance smi) { if ((bool)smi.gameObject.transform.parent) { EggIncubator component = smi.gameObject.transform.parent.GetComponent <EggIncubator>(); return((Object)component != (Object)null); } return(false); }
public EggIncubatorViewModel(EggIncubator incubator, SessionViewModel session) { this.session = session; Id = incubator.Id; IsUnlimited = incubator.ItemId == POGOProtos.Inventory.Item.ItemId.ItemIncubatorBasicUnlimited; PokemonId = incubator.PokemonId; StartKmWalked = incubator.StartKmWalked; TargetKmWalked = incubator.TargetKmWalked; UsesRemaining = incubator.UsesRemaining; }
public IncubatorViewModel(EggIncubator incu) { Id = incu.Id; InUse = incu.PokemonId > 0; KM = incu.StartKmWalked; TotalKM = incu.TargetKmWalked; PokemonId = incu.PokemonId; UsesRemaining = incu.UsesRemaining; IsUnlimited = incu.ItemId == POGOProtos.Inventory.Item.ItemId.ItemIncubatorBasicUnlimited; }
public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag) { Prioritizable.AddRef(go); Storage storage = BuildingTemplates.CreateDefaultStorage(go, false); storage.SetDefaultStoredItemModifiers(IncubatorStorage); EggIncubator eggIncubator = go.AddOrGet <EggIncubator>(); eggIncubator.AddDepositTag(GameTags.Egg); eggIncubator.SetWorkTime(5f); }
public Incubators(EggIncubator incu) { GetPlayerStats().ConfigureAwait(false); Id = incu.Id; InUse = incu.PokemonId > 0; KM = kmWalked - incu.StartKmWalked; TotalKM = incu.TargetKmWalked - incu.StartKmWalked; PokemonId = incu.PokemonId; UsesRemaining = incu.UsesRemaining; IsUnlimited = incu.ItemId == POGOProtos.Inventory.Item.ItemId.ItemIncubatorBasicUnlimited; }
public override void SetTarget(GameObject target) { base.SetTarget(target); EggIncubator incubator = target.GetComponent <EggIncubator>(); continuousToggle.ChangeState((!incubator.autoReplaceEntity) ? 1 : 0); continuousToggle.onClick = delegate { incubator.autoReplaceEntity = !incubator.autoReplaceEntity; continuousToggle.ChangeState((!incubator.autoReplaceEntity) ? 1 : 0); }; }
private void UpdateIncubationState(bool stored, EggIncubator incubator) { this.incubator = incubator; base.smi.sm.inIncubator.Set((UnityEngine.Object)incubator != (UnityEngine.Object)null, base.smi); bool value = stored && !(bool)incubator; base.smi.sm.isSuppressed.Set(value, base.smi); Operational operational = (!(bool)incubator) ? null : incubator.GetComponent <Operational>(); bool value2 = (bool)incubator && ((UnityEngine.Object)operational == (UnityEngine.Object)null || operational.IsOperational); base.smi.sm.incubatorIsActive.Set(value2, base.smi); }
void ButtonOkClick(object sender, EventArgs e) { if (listView.SelectedItems.Count < 1) { MessageBox.Show(th.TS("Please Select an incubator.")); } else { selected = (EggIncubator)listView.SelectedItems[0].Tag; DialogResult = DialogResult.OK; this.Close(); } }
private void AddOrUpdateIncubator(EggIncubator incu) { var incuModel = new IncubatorViewModel(incu); var existing = Incubators.FirstOrDefault(x => x.Id == incu.Id); if (existing != null) { existing.UpdateWith(incuModel); } else { Incubators.Add(incuModel); } }
/// <summary> /// </summary> /// <param name="parameter">MapPokemonWrapper containing the Pokemon that we're trying to capture</param> /// <param name="mode"></param> /// <param name="suspensionState"></param> /// <returns></returns> public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> suspensionState) { if (suspensionState.Any()) { // Recovering the state SelectedEggIncubator = new EggIncubator(); CurrentEgg = JsonConvert.DeserializeObject <PokemonDataWrapper>((string)suspensionState[nameof(CurrentEgg)]); SelectedEggIncubator.MergeFrom(ByteString.FromBase64((string)suspensionState[nameof(SelectedEggIncubator)]).CreateCodedInput()); } else { // Navigating from game page, so we need to actually load the encounter CurrentEgg = (PokemonDataWrapper)NavigationHelper.NavigationState[nameof(CurrentEgg)]; } await Task.CompletedTask; }
/// <summary> /// Uses the selected incubator on the given egg /// </summary> /// <param name="incubator"></param> /// <param name="egg"></param> /// <returns></returns> public static async Task <UseItemEggIncubatorResponse> UseEggIncubator(EggIncubator incubator, PokemonData egg) { return(await _client.Inventory.UseItemEggIncubator(incubator.Id, egg.Id)); }
public async Task Execute() { try { var client = Logic.Logic.Client; if (client.readyToUse != false) { var items = await client.Inventory.GetEggs(); var incubators = await client.Inventory.GetEggIncubators(); var arrStats = await client.Inventory.GetPlayerStats(); var stats = arrStats.First(); listView.Items.Clear(); ListViewItem listViewItem; foreach (var item in items) { listViewItem = new ListViewItem(); listViewItem.Tag = item; listViewItem.Text = "" + item.EggKmWalkedStart; listViewItem.ImageKey = "egg"; //EggIncubator incubator = (incubators.Where(i => i.Id == item.EggIncubatorId)); EggIncubator incubator = GetIncubator(incubators, item.EggIncubatorId); if (incubator != null) { if (incubator.ItemId == ItemId.ItemIncubatorBasic) { listViewItem.ImageKey = "bincegg"; } else if (incubator.ItemId == ItemId.ItemIncubatorBasicUnlimited) { listViewItem.ImageKey = "unincegg"; } listViewItem.Text = "" + Math.Round(incubator.TargetKmWalked - stats.KmWalked, 2); } listViewItem.SubItems.Add("" + item.EggKmWalkedTarget); if (incubator != null) { if (pokemons != null) { var eggPoke = pokemons.FirstOrDefault(x => x.Id == incubator.PokemonId); if (eggPoke != null) { listViewItem.SubItems.Add(GetPokemonName(eggPoke.PokemonId)); } else { listViewItem.SubItems.Add("" + incubator.PokemonId); } } else { listViewItem.SubItems.Add("" + incubator.PokemonId); } } else { listViewItem.SubItems.Add("" + GetPokemonName(item.PokemonId)); } listViewItem.SubItems.Add(string.Format("{0}% {1}-{2}-{3}", PokemonInfo.CalculatePokemonPerfection(item).ToString("0"), item.IndividualAttack, item.IndividualDefense, item.IndividualStamina)); listViewItem.SubItems.Add(GetCreationTime(item.CreationTimeMs)); listViewItem.SubItems.Add(string.Format("{0}", item.Move1)); listViewItem.SubItems.Add(string.Format("{0} ({1})", item.Move2, PokemonInfo.GetAttack(item.Move2))); if (incubator != null) { listViewItem.SubItems.Add(string.Format("Uses:{0}", incubator.UsesRemaining)); } listView.Items.Add(listViewItem); } listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); } } catch (Exception e) { Logger.Error("[EggsList-Error] " + e.StackTrace); await Task.Delay(1000); // Lets the API make a little pause, so we dont get blocked Execute(); } }
public override int GetHashCode() { int hash = 1; if (ItemId != 0) { hash ^= ItemId.GetHashCode(); } if (ItemType != 0) { hash ^= ItemType.GetHashCode(); } if (Category != 0) { hash ^= Category.GetHashCode(); } if (DropFreq != 0F) { hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(DropFreq); } if (DropTrainerLevel != 0) { hash ^= DropTrainerLevel.GetHashCode(); } if (pokeball_ != null) { hash ^= Pokeball.GetHashCode(); } if (potion_ != null) { hash ^= Potion.GetHashCode(); } if (revive_ != null) { hash ^= Revive.GetHashCode(); } if (battle_ != null) { hash ^= Battle.GetHashCode(); } if (food_ != null) { hash ^= Food.GetHashCode(); } if (inventoryUpgrade_ != null) { hash ^= InventoryUpgrade.GetHashCode(); } if (xpBoost_ != null) { hash ^= XpBoost.GetHashCode(); } if (incense_ != null) { hash ^= Incense.GetHashCode(); } if (eggIncubator_ != null) { hash ^= EggIncubator.GetHashCode(); } if (fortModifier_ != null) { hash ^= FortModifier.GetHashCode(); } if (stardustBoost_ != null) { hash ^= StardustBoost.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public override int GetHashCode() { int hash = 1; if (ItemId != 0) { hash ^= ItemId.GetHashCode(); } if (ItemType != 0) { hash ^= ItemType.GetHashCode(); } if (Category != 0) { hash ^= Category.GetHashCode(); } if (DropFreq != 0F) { hash ^= DropFreq.GetHashCode(); } if (DropTrainerLevel != 0) { hash ^= DropTrainerLevel.GetHashCode(); } if (pokeball_ != null) { hash ^= Pokeball.GetHashCode(); } if (potion_ != null) { hash ^= Potion.GetHashCode(); } if (revive_ != null) { hash ^= Revive.GetHashCode(); } if (battle_ != null) { hash ^= Battle.GetHashCode(); } if (food_ != null) { hash ^= Food.GetHashCode(); } if (inventoryUpgrade_ != null) { hash ^= InventoryUpgrade.GetHashCode(); } if (xpBoost_ != null) { hash ^= XpBoost.GetHashCode(); } if (incense_ != null) { hash ^= Incense.GetHashCode(); } if (eggIncubator_ != null) { hash ^= EggIncubator.GetHashCode(); } if (fortModifier_ != null) { hash ^= FortModifier.GetHashCode(); } return(hash); }
public IncubatedEggDataWrapper(EggIncubator incubatorData, double playerWalkedKm, PokemonData incubatedEgg) : base(incubatedEgg) { _incubatorData = incubatorData; this.playerWalkedKm = playerWalkedKm; }
public void MergeFrom(ItemSettings other) { if (other == null) { return; } if (other.ItemId != 0) { ItemId = other.ItemId; } if (other.ItemType != 0) { ItemType = other.ItemType; } if (other.Category != 0) { Category = other.Category; } if (other.DropFreq != 0F) { DropFreq = other.DropFreq; } if (other.DropTrainerLevel != 0) { DropTrainerLevel = other.DropTrainerLevel; } if (other.pokeball_ != null) { if (pokeball_ == null) { pokeball_ = new global::POGOProtos.Settings.Master.Item.PokeballAttributes(); } Pokeball.MergeFrom(other.Pokeball); } if (other.potion_ != null) { if (potion_ == null) { potion_ = new global::POGOProtos.Settings.Master.Item.PotionAttributes(); } Potion.MergeFrom(other.Potion); } if (other.revive_ != null) { if (revive_ == null) { revive_ = new global::POGOProtos.Settings.Master.Item.ReviveAttributes(); } Revive.MergeFrom(other.Revive); } if (other.battle_ != null) { if (battle_ == null) { battle_ = new global::POGOProtos.Settings.Master.Item.BattleAttributes(); } Battle.MergeFrom(other.Battle); } if (other.food_ != null) { if (food_ == null) { food_ = new global::POGOProtos.Settings.Master.Item.FoodAttributes(); } Food.MergeFrom(other.Food); } if (other.inventoryUpgrade_ != null) { if (inventoryUpgrade_ == null) { inventoryUpgrade_ = new global::POGOProtos.Settings.Master.Item.InventoryUpgradeAttributes(); } InventoryUpgrade.MergeFrom(other.InventoryUpgrade); } if (other.xpBoost_ != null) { if (xpBoost_ == null) { xpBoost_ = new global::POGOProtos.Settings.Master.Item.ExperienceBoostAttributes(); } XpBoost.MergeFrom(other.XpBoost); } if (other.incense_ != null) { if (incense_ == null) { incense_ = new global::POGOProtos.Settings.Master.Item.IncenseAttributes(); } Incense.MergeFrom(other.Incense); } if (other.eggIncubator_ != null) { if (eggIncubator_ == null) { eggIncubator_ = new global::POGOProtos.Settings.Master.Item.EggIncubatorAttributes(); } EggIncubator.MergeFrom(other.EggIncubator); } if (other.fortModifier_ != null) { if (fortModifier_ == null) { fortModifier_ = new global::POGOProtos.Settings.Master.Item.FortModifierAttributes(); } FortModifier.MergeFrom(other.FortModifier); } if (other.stardustBoost_ != null) { if (stardustBoost_ == null) { stardustBoost_ = new global::POGOProtos.Settings.Master.Item.StardustBoostAttributes(); } StardustBoost.MergeFrom(other.StardustBoost); } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
public void Execute() { try { var client = Logic.Logic.objClient; if (client.ReadyToUse != false) { var items = client.Inventory.GetEggs(); var incubators = client.Inventory.GetEggIncubators(); var arrStats = client.Inventory.GetPlayerStats(); var stats = arrStats.First(); listView.Items.Clear(); ListViewItem listViewItem; foreach (var item in items) { listViewItem = new ListViewItem(); listViewItem.Tag = item; listViewItem.Text = "" + item.EggKmWalkedStart; listViewItem.ImageKey = "" + (item.EggKmWalkedTarget - item.EggKmWalkedStart) + "km"; EggIncubator incubator = GetIncubator(incubators, item.EggIncubatorId); if (incubator != null) { if (incubator.ItemId == ItemId.ItemIncubatorBasic) { listViewItem.ImageKey = "bincegg"; } else if (incubator.ItemId == ItemId.ItemIncubatorBasicUnlimited) { listViewItem.ImageKey = "unincegg"; } listViewItem.Text = "" + Math.Round(incubator.TargetKmWalked - stats.KmWalked, 2); } listViewItem.SubItems.Add("" + item.EggKmWalkedTarget); if (incubator != null) { listViewItem.SubItems.Add("" + incubator.PokemonId.ToString("X")); } else { listViewItem.SubItems.Add(th.TS(item.PokemonId.ToString())); } listViewItem.SubItems.Add(string.Format("{0}% {1}-{2}-{3}", PokemonGo.RocketAPI.PokemonInfo.CalculatePokemonPerfection(item).ToString("0"), item.IndividualAttack, item.IndividualDefense, item.IndividualStamina)); listViewItem.SubItems.Add(GetCreationTime(item.CreationTimeMs)); listViewItem.SubItems.Add(string.Format("{0}", item.Move1)); listViewItem.SubItems.Add(string.Format("{0} ({1})", item.Move2, PokemonGo.RocketAPI.PokemonInfo.GetAttack(item.Move2))); if (incubator != null) { listViewItem.SubItems.Add(string.Format("Uses:{0}", incubator.UsesRemaining)); } listView.Items.Add(listViewItem); } listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); RefreshTitle(); } } catch (Exception e) { Logger.Error("[EggsList-Error] " + e.StackTrace); RandomHelper.RandomSleep(1000, 1100); //Execute(); } }
public void AddOrUpdateIncubator(EggIncubator incu) { var incuModel = new Incubators(incu); Incubators.Add(incuModel); }