public void Draw(SpriteBatch spriteBatch, ItemTrackerState state) { ResetPosition(); using (spriteBatch.BeginUsing(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp)) { DrawItem(spriteBatch, state.Timestop, new ItemIdentifier(EInventoryRelicType.TimespinnerWheel)); DrawItem(spriteBatch, state.TimeSpindle, new ItemIdentifier(EInventoryRelicType.TimespinnerSpindle)); DrawItem(spriteBatch, state.TimeGear1, new ItemIdentifier(EInventoryRelicType.TimespinnerGear1)); DrawItem(spriteBatch, state.TimeGear2, new ItemIdentifier(EInventoryRelicType.TimespinnerGear2)); DrawItem(spriteBatch, state.TimeGear3, new ItemIdentifier(EInventoryRelicType.TimespinnerGear3)); DrawItem(spriteBatch, state.Dash, new ItemIdentifier(EInventoryRelicType.Dash)); DrawItem(spriteBatch, state.DoubleJump, new ItemIdentifier(EInventoryRelicType.DoubleJump)); DrawItem(spriteBatch, state.Lightwall, new ItemIdentifier(EInventoryOrbType.Barrier, EOrbSlot.Spell)); DrawItem(spriteBatch, state.CelestialSash, new ItemIdentifier(EInventoryRelicType.EssenceOfSpace)); DrawItem(spriteBatch, state.PyramidKeys, new ItemIdentifier(EInventoryRelicType.PyramidsKey)); DrawItem(spriteBatch, state.WaterMask, new ItemIdentifier(EInventoryRelicType.WaterMask)); DrawItem(spriteBatch, state.GasMask, new ItemIdentifier(EInventoryRelicType.AirMask)); DrawItem(spriteBatch, state.CardA, new ItemIdentifier(EInventoryRelicType.ScienceKeycardA)); DrawItem(spriteBatch, state.CardB, new ItemIdentifier(EInventoryRelicType.ScienceKeycardB)); DrawItem(spriteBatch, state.CardC, new ItemIdentifier(EInventoryRelicType.ScienceKeycardC)); DrawItem(spriteBatch, state.CardD, new ItemIdentifier(EInventoryRelicType.ScienceKeycardD)); DrawItem(spriteBatch, state.CardV, new ItemIdentifier(EInventoryRelicType.ScienceKeycardV)); DrawItem(spriteBatch, state.Tablet, new ItemIdentifier(EInventoryRelicType.Tablet)); DrawItem(spriteBatch, state.CardE, new ItemIdentifier(EInventoryRelicType.ElevatorKeycard)); DrawItem(spriteBatch, state.EyeRing, new ItemIdentifier(EInventoryOrbType.Eye, EOrbSlot.Passive)); DrawItem(spriteBatch, state.Kobo, new ItemIdentifier(EInventoryFamiliarType.Kobo)); DrawItem(spriteBatch, state.MerchantCrow, new ItemIdentifier(EInventoryFamiliarType.MerchantCrow)); DrawFireSource(spriteBatch, state); DrawPinkSource(spriteBatch, state); } }
void LoadObtainedProgressionItemsFromSave(Level level) { var itemsInMap = this.Select(l => l.ItemInfo.Identifier) .Distinct().ToHashSet(); var updateTracker = false; foreach (var progressionItem in UnlockingMap.AllProgressionItems) { if (level.GameSave.HasItem(progressionItem) && !itemsInMap.Contains(progressionItem)) { var item = new SingleItemInfo(UnlockingMap, progressionItem); item.OnPickup(level); Add(new ExternalItemLocation(item)); updateTracker = true; } } if (updateTracker) { ItemTrackerUplink.UpdateState(ItemTrackerState.FromItemLocationMap(this)); } }
public override void Initialize(ItemLocationMap _, GCM gameContentManager) { GameContentManager = gameContentManager; var saveFile = (GameSave)Dynamic.SaveFile; var seed = saveFile.GetSeed(); var fillingMethod = saveFile.GetFillingMethod(); if (!seed.HasValue) { seed = Seed.Zero; } Console.Out.WriteLine($"Seed: {seed}"); seedOptions = seed.Value.Options; ItemLocations = Randomizer.Randomize(seed.Value, fillingMethod); ItemLocations.BaseOnSave(Level.GameSave); ItemTrackerUplink.UpdateState(ItemTrackerState.FromItemLocationMap(ItemLocations)); LevelReflected._random = new DeRandomizer(LevelReflected._random, seed.Value); ItemManipulator.Initialize(ItemLocations); }
public void Parralel_read_and_writes_should_not_throw_exception() { var originalState = new ItemTrackerState { CardA = true, Dash = true, FireRing = true, DoubleJump = true, Timestop = false, CardB = false, PyramidKeys = false, DinsFire = false }; ItemTrackerUplink.UpdateState(originalState); ItemTrackerUplink.LoadState(); var writer = Task.Factory.StartNew(() => { for (int i = 0; i < 1000; i++) { ItemTrackerUplink.UpdateState(originalState); } }); var reader = Task.Factory.StartNew(() => { for (int i = 0; i < 1000; i++) { var retreivedState = ItemTrackerUplink.LoadState(); Assert.IsTrue(retreivedState.CardA); } }); Task.WaitAll(writer, reader); }
public void Should_save_and_read_item_tracker_state() { var originalState = new ItemTrackerState { CardA = true, Dash = true, FireRing = true, DoubleJump = true, Timestop = false, CardB = false, PyramidKeys = false, DinsFire = false }; ItemTrackerUplink.UpdateState(originalState); var retreivedState = ItemTrackerUplink.LoadState(); Assert.IsTrue(retreivedState.CardA); Assert.IsTrue(retreivedState.Dash); Assert.IsTrue(retreivedState.FireRing); Assert.IsTrue(retreivedState.DoubleJump); Assert.IsFalse(retreivedState.Timestop); Assert.IsFalse(retreivedState.CardB); Assert.IsFalse(retreivedState.PyramidKeys); Assert.IsFalse(retreivedState.DinsFire); }
public override void Initialize(ItemLocationMap itemLocationMap, GCM gameContentManager) { Action <GameSave> originalReloadSaveAction = Dynamic._reloadSaveAction; void ReloadSave(GameSave gameSave) { itemLocationMap.Initialize(gameSave); ItemTrackerUplink.UpdateState(ItemTrackerState.FromItemLocationMap(itemLocationMap)); originalReloadSaveAction(gameSave); } Dynamic._reloadSaveAction = (Action <GameSave>)ReloadSave; }
void ReceiveItem(NetworkItem networkItem, Level level) { if (TryGetLocation(networkItem, out var location) && networkItem.Player == slot) { //ignore message if its from my slot and a location i already picked up if (location.IsPickedUp && personalLocationItemKeys.Contains(location.Key)) { return; } } else { location = new ExternalItemLocation(); Add(location); } if (!TryGetItemIdentifier(networkItem, out var itemIdentifier)) { return; } // itemInfoProvider's cache is out of date here when it comes to pyramid unlocks var item = new SingleItemInfo(UnlockingMap, itemIdentifier); location.SetItem(item); location.IsPickedUp = true; item.OnPickup(level); level.GameSave.AddItem(level, itemIdentifier); if (itemIdentifier.LootType == LootType.ConstRelic) { level.AsDynamic().UnlockRelic(itemIdentifier.Relic); } if (!firstPass || item.IsProgression) { level.ShowItemAwardPopup(itemIdentifier); } if (item.IsProgression) { ItemTrackerUplink.UpdateState(ItemTrackerState.FromItemLocationMap(this)); } }
public void Should_load_state_from_itemLocationMap() { var itemlocations = new [] { GetPickedUpItemLocation(new SingleItemInfo(new ItemUnlockingMap(Seed.Zero), new ItemIdentifier(EInventoryOrbType.Flame, EOrbSlot.Spell))), GetPickedUpItemLocation(new SingleItemInfo(new ItemUnlockingMap(Seed.Zero), new ItemIdentifier(EInventoryRelicType.Dash))), GetPickedUpItemLocation(new SingleItemInfo(new ItemUnlockingMap(Seed.Zero), new ItemIdentifier(EInventoryRelicType.TimespinnerWheel))), GetPickedUpItemLocation(new SingleItemInfo(new ItemUnlockingMap(Seed.Zero), new ItemIdentifier(EInventoryOrbType.Barrier, EOrbSlot.Spell))) }; var state = ItemTrackerState.FromItemLocationMap(itemlocations); Assert.IsTrue(state.FireSpell); Assert.IsTrue(state.Dash); Assert.IsTrue(state.Timestop); Assert.IsTrue(state.Lightwall); Assert.IsFalse(state.CelestialSash); }
void DrawPinkSource(SpriteBatch spriteBatch, ItemTrackerState state) { if (state.PinkRing) { DrawItem(spriteBatch, state.PinkRing, new ItemIdentifier(EInventoryOrbType.Pink, EOrbSlot.Passive)); } else if (state.PinkSpell) { DrawItem(spriteBatch, state.PinkSpell, new ItemIdentifier(EInventoryOrbType.Pink, EOrbSlot.Spell)); } else if (state.PinkOrb) { DrawItem(spriteBatch, state.PinkOrb, new ItemIdentifier(EInventoryOrbType.Pink, EOrbSlot.Melee)); } else { DrawItem(spriteBatch, false, new ItemIdentifier(EInventoryOrbType.Pink, EOrbSlot.Passive)); } }
void DrawFireSource(SpriteBatch spriteBatch, ItemTrackerState state) { if (state.DinsFire) { DrawItem(spriteBatch, state.DinsFire, new ItemIdentifier(EInventoryOrbType.Book, EOrbSlot.Spell)); } else if (state.FireRing) { DrawItem(spriteBatch, state.FireRing, new ItemIdentifier(EInventoryOrbType.Flame, EOrbSlot.Passive)); } else if (state.FireOrb) { DrawItem(spriteBatch, state.FireOrb, new ItemIdentifier(EInventoryOrbType.Flame, EOrbSlot.Melee)); } else if (state.FireSpell) { DrawItem(spriteBatch, state.FireSpell, new ItemIdentifier(EInventoryOrbType.Flame, EOrbSlot.Spell)); } else { DrawItem(spriteBatch, false, new ItemIdentifier(EInventoryOrbType.Book, EOrbSlot.Spell)); } }
protected override void Update(GameTime gameTime) { if (oneTimeSetup) { Window.AllowUserResizing = true; Window.ClientSizeChanged += Window_ClientSizeChanged; oneTimeSetup = false; } if (IsActive) { mouseInputHandler.Update(gameTime); } trackerUpdateTimer += gameTime.ElapsedGameTime.TotalMilliseconds; if (trackerUpdateTimer > 1000) { trackerState = ItemTrackerUplink.LoadState(); trackerUpdateTimer = 0; } base.Update(gameTime); }
public override void Initialize(ItemLocationMap _, GCM gameContentManager) { GameContentManager = gameContentManager; var saveFile = Save; var seed = saveFile.GetSeed(); var fillingMethod = saveFile.GetFillingMethod(); var settings = saveFile.GetSettings(); ScreenManager.Log.SetSettings(settings); gameContentManager.UpdateMinimapColors(settings); if (!seed.HasValue) { seed = Seed.Zero; } Console.Out.WriteLine($"Seed: {seed}"); seedOptions = seed.Value.Options; Settings = settings; try { ItemLocations = Randomizer.Randomize(seed.Value, fillingMethod, Level.GameSave); } catch (ConnectionFailedException e) { SendBackToMainMenu(e.Message); return; } ItemLocations.Initialize(Level.GameSave); ItemTrackerUplink.UpdateState(ItemTrackerState.FromItemLocationMap(ItemLocations)); LevelReflected._random = new DeRandomizer(LevelReflected._random, seed.Value); ItemManipulator.Initialize(ItemLocations); if (settings.DamageRando.Value != "Off") { OrbDamageManager.PopulateOrbLookups(Level.GameSave, settings.DamageRando.Value, settings.DamageRandoOverrides.Value); } BestiaryManager.UpdateBestiary(Level, settings); if (!saveFile.GetSaveBool("IsFightingBoss")) { BestiaryManager.RefreshBossSaveFlags(Level); } if (seedOptions.Archipelago) { Client.SetStatus(ArchipelagoClientState.ClientPlaying); deathLinkService = new DeathLinker(settings, Client.GetDeathLinkService()); } #if DEBUG ScreenManager.Console.AddCommand(new TeleportCommand(() => Level)); ScreenManager.Console.AddCommand(new GiveRelicCommand(() => Level)); ScreenManager.Console.AddCommand(new GiveOrbCommand(() => Level)); ScreenManager.Console.AddCommand(new GiveFamiliarCommand(() => Level)); #endif }