Vixen
c7401864
csharp
public sealed class CollectionRecord

One account's collection: what it has, and how far the rest has got.

Read the guide page for this →

Remarks

Account-wide, which is doc 28's word, and the reason there are two types here. Unlocks are "all account-wide, all durable" — a mount earned on one character is owned by all of them. What each character shows is not: two alts have different transmog and different titles from the same collection. So the durable set is this type and the presentation is Wardrobe, one per character, reading from it.

⚠ One subscription, and a watch is dropped the moment its criterion is done. A naive achievement system subscribes every criterion of every achievement and keeps them for ever, so a mature account pays for thousands of dead filters on every kill. Here the cost falls as an account completes things, which is the opposite curve and the one that matters: the accounts with the most live watches are the new ones, which generate the fewest events.

⚠ An earned achievement never un-earns. Requirements are checked on the way in and never again — a title revoked, an item sold or a patch that raises a threshold must not take back something somebody already did.

⚠ Earning cascades and terminates. An achievement grants a tag and unlocks collectibles, either of which can complete another achievement's requirements; that is resolved in a loop rather than by recursion, and it stops because nothing is ever earned twice.

Fields and properties (11)

  • public const string ValuePrefix

    The value naming how many of one kind they have — Collection.Mount.

  • public const string TotalValue

    The value naming how many things they have in all.

  • public const string PointsValue

    The value naming how many points they have.

  • public const string EarnedValue

    The value naming how many achievements they have earned.

  • public CollectionLibrary Library

    Where the collectibles and achievements come from.

  • public GameplayTagSet Tags

    The tags their unlocks and achievements have granted.

  • public int Count

    How many things they have.

  • public int Earned

    How many achievements they have earned.

  • public int Points

    What those achievements are worth.

  • public int Watching

    How many filters are still listening. Falls as an account completes things.

  • public IEnumerable<Unlock> Unlocks

    Everything they have, in the order they got it.

Events (2)

  • public Action<Collectible, Unlock>? Collected

    Raised when something is unlocked for the first time.

  • public Action<Achievement>? Achieved

    Raised when an achievement is earned.

Methods (16)

  • public CollectionRecord(CollectionLibrary library, IRequirementContext? context = null, GameplayTagSet? tags = null)

    Makes an empty collection.

  • public bool IsUnlocked(DefId collectible)

    Whether they have something.

  • public Unlock? SourceOf(DefId collectible)

    Where something came from.

  • public int CountOf(CollectibleKind kind)

    How many of one sort they have.

  • public bool Unlock(Collectible collectible, UnlockSource source = Unknown, DefId from = default(DefId))

    Gives them something.

  • public bool Revoke(Collectible collectible)

    Takes something back — a refund, a season ending, a mistake.

  • public bool IsEarned(Achievement achievement)

    Whether they have earned an achievement.

  • public int ProgressOf(Achievement achievement, int criterion)

    How far one criterion has got.

  • public IEnumerable<Achievement> Achievements()

    Everything they have earned, in the order they earned it.

  • public void Attach(GameplayEventBus bus)

    Starts listening for what its criteria count.

  • public bool Detach()

    Stops listening.

  • public void Observe(in GameplayEvent gameplayEvent)

    Counts an event against whatever is waiting for it.

  • public bool Note(Achievement achievement, int criterion, int amount = 1)

    Advances a criterion by hand.

  • public int Refresh()

    Re-checks every achievement whose criteria are done but whose requirements were not met.

  • public void Restore(IEnumerable<Unlock> saved, IEnumerable<DefId>? achievements = null, IEnumerable<CriterionProgress>? counters = null)

    Puts a saved collection back, as it was, with no checks.

  • public IEnumerable<CriterionProgress> Counters()

    How far everything unfinished has got, for a save.

Used by (3)

  • CollectionTestsVixen.Gameplay.Collections.Tests
  • WardrobeVixen.Gameplay.Collections
  • WardrobeSectionTestsVixen.Live.Gameplay.Tests