Skip to content

Commit

Permalink
Updated Multi client library
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarno458 committed Jul 26, 2022
1 parent 030ff5d commit adab5be
Show file tree
Hide file tree
Showing 31 changed files with 153 additions and 698 deletions.
4 changes: 2 additions & 2 deletions TsRandomizer.ItemTracker/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("77705356-2595-478C-B6BF-3BA82A887C8B")]
[assembly: AssemblyVersion("0.1.6.0")]
[assembly: AssemblyFileVersion("0.1.6.0")]
[assembly: AssemblyVersion("0.1.7.0")]
[assembly: AssemblyFileVersion("0.1.7.0")]
[assembly: InternalsVisibleTo("TsRandomizer.Tests")]
2 changes: 1 addition & 1 deletion TsRandomizer.ItemTracker/TrackerRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void Draw(SpriteBatch spriteBatch, ItemTrackerState state)
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.GassMask, 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));
Expand Down
58 changes: 58 additions & 0 deletions TsRandomizer.SeedGeneratah/LookupDictionary.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace TsRandomizer
{
class LookupDictionary<TLookup, TValue> : IEnumerable<TValue>
{
readonly Func<TValue, TLookup> keySelector;
readonly Dictionary<TLookup, TValue> lookupTable;

public LookupDictionary(Func<TValue, TLookup> keySelector) : this(0, keySelector)
{
}

public LookupDictionary(int capacity, Func<TValue, TLookup> keySelector)
{
lookupTable = new Dictionary<TLookup, TValue>(capacity);
this.keySelector = keySelector;
}

public TValue this[TLookup key] => lookupTable[key];

public int Count => lookupTable.Count;

public bool TryGetValue(TLookup key, out TValue value) =>
lookupTable.TryGetValue(key, out value);

public void Filter(IEnumerable<TLookup> intersectionFilter, Action<TValue> removeAction = null)
{
var keysToRemove = lookupTable.Keys
.Where(e => !intersectionFilter.Contains(e))
.ToList();

foreach (var key in keysToRemove)
{
removeAction?.Invoke(lookupTable[key]);
lookupTable.Remove(key);
}
}

public IEnumerator<TValue> GetEnumerator() =>
((IEnumerable<TValue>)lookupTable.Values).GetEnumerator();

IEnumerator IEnumerable.GetEnumerator() =>
lookupTable.Values.GetEnumerator();

public void Add(TValue value) =>
lookupTable.Add(keySelector(value), value);

public void AddOrUpdate(TValue value) =>
lookupTable[keySelector(value)] = value;

public bool Contains(TLookup key) =>
lookupTable.ContainsKey(key);
}
}
3 changes: 2 additions & 1 deletion TsRandomizer.SeedGeneratah/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using Timespinner.GameAbstractions.Saving;
using TsRandomizer;
using TsRandomizer.Randomisation;
using TsRandomizer.ReplacementObjects;
Expand Down Expand Up @@ -60,7 +61,7 @@ static LookupDictionary<Seed, GenerationResult> ReadKnownSeeds()

static void WriteSeed(GenerationResult result)
{
var itenLocationMap = Randomizer.Randomize(result.Seed, FillingMethod.Random);
var itenLocationMap = Randomizer.Randomize(result.Seed, FillingMethod.Random, GameSave.DemoSave, true);

var item1 = itenLocationMap[new ItemKey(1, 1, 1528, 144)];
var item2 = itenLocationMap[new ItemKey(1, 15, 264, 144)];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="LookupDictionary.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
Expand Down
49 changes: 0 additions & 49 deletions TsRandomizer.Tests/ForwardFillingRandomizerFixture.cs

This file was deleted.

25 changes: 0 additions & 25 deletions TsRandomizer.Tests/GateFixture.cs

This file was deleted.

41 changes: 0 additions & 41 deletions TsRandomizer.Tests/ItemInfoFixture.cs

This file was deleted.

61 changes: 0 additions & 61 deletions TsRandomizer.Tests/ItemLocationMapFixture.cs

This file was deleted.

Loading

0 comments on commit adab5be

Please sign in to comment.