In Bruen, the Supreme Court held that "when the Second Amendment's plain text covers an individual's conduct, the Constitution presumptively protects that conduct." To justify a regulation, "the government must demonstrate that the regulation is consistent with this Nation's historical tradition of firearm regulation." And that depends on whether there is a relevantly-similar historical analogue.
In assessing a modern restriction, "this historical inquiry that courts must conduct will often involve reasoning by analogy—a commonplace task for any lawyer or judge." A green truck is not relevantly similar to a green hat if the subject is things you can wear. I would add that an antebellum ban on carrying a Bowie knife concealed is not relevantly similar to a current ban on possession of a rifle or magazine. As Bruen instructs, we look at "how and why the [modern and historical] regulations burden a law-abiding citizen's right to armed self-defense." Under that test, a modern requirement to register all guns would not be analogous to a historical requirement that a militiaman must exhibit his musket at muster.
While a historical analogue need not be "a dead ringer," Bruen cautions courts not to "uphold every modern law that remotely resembles a historical analogue," because doing so "risk[s] endorsing outliers that our ancestors would never have accepted." The analogies must be from the Founding period and, if they confirm Founding history, from later periods—but not too much later. For example, there were at least some laws at the Founding restricting firearms in polling places, legislative assemblies, and courthouses. Later history can be looked at to confirm whether this matured into an enduring tradition or was instead a dead end that should not be used to define the scope of the right.