Jump to content
Menü aufrufen
Toggle preferences menu
Persönliches Menü aufrufen
Nicht angemeldet
Ihre IP-Adresse wird öffentlich sichtbar sein, wenn Sie Änderungen vornehmen.
Modul Dokumentation[view][edit][history][purge]
Diese Dokumentation wird von Modul:Entity/Registry/doc aus übernommen. Änderungen können auf der Diskussionsseite vorgeschlagen werden.

Die deklarative Liste aller Entity-Arten und Facetten: p.kinds wird in Ordnung abgesucht, um die primäre Art einer Seite aufzulösen; p.facets werden additiv gematcht, unabhängig davon, welche Art traf. Eine Registrierung ist je ein Eintrag hier, das Komponentenmodul selbst und ein bestandener Konformitätstest.

Editoren rufen dieses Modul nie direkt auf; es läuft innerhalb von Vorlage:Entity, Vorlage:Vehicle und Vorlage:Location. Pipeline und Hook-Tabelle stehen auf Modul:Entity.

Für Modul-Editoren

Katalog

p.kinds, in dieser Ordnung abgesucht: Item, Vehicle, Commodity, Mission, Location. Die Ordnung ist nur eine Kostenoptimierung; jedes matches() muss für sich allein bestehen.

p.facets, additiv in Registrierungsreihenfolge; eine Seite kann mehrere zugleich treffen. Jeder Facetteneintrag listet als keys die Datensatzfelder, die seine Bedingung liest; eine Facette lädt nur auf einem Datensatz, der eines davon trägt. (Konsumierbar, Sitz, Messer, Granate, Gadget, Bergung, Heilung, Medizin, Hacking, Waffenmodifikator, Visier, Magazin, Laserpointer, Taschenlampe, Bergbau, Strahl, Panzerung, Umgebung, Schadensabfall, Inventar, Komponente, Dimensionen.)

Erweitern

Eine neue Art implementiert matches und getApiConfigs (Pflicht), einen nichtleeren, eindeutigen String p.name, optional resolveSubtype, und bekommt einen p.kinds-Eintrag mit name, einem load-Loader und als api eine Kopie ihres getApiConfigs()[1]. Die Sonde holt den Endpunkt, bevor sie die Art lädt, und lädt sie nur bei nichtleerem Datensatz — eine Ortsseite lädt also nie Vehicle. Eine neue Facette implementiert matches und getSections und bekommt einen Eintrag mit load und keys; die gemeinsamen Helfer stehen in Modul:Entity/Facet/Util, Ja/Nein-Zeilen laufen über Modul:Boolean. Das volle Hook-Spez steht auf Modul:Entity/Contract.

Die Registry-Suite lädt jeden Eintrag und prüft ihn strikt (Contract.validate, KIND_FIELDS, Namens- und API-Konsistenz, Eindeutigkeit). Eine neue Facette braucht zusätzlich einen Datensatz in FACET_MATCH_FIXTURES, der ihr matches akzeptiert — eines pro gelesenem Feld.

Stolperfallen

  • Jedes load bleibt ein literales require('Module:…') innerhalb seiner Funktion: eine Seite zeichnet jedes geladene Modul als Abhängigkeit auf und re-parst bei dessen Änderung — ein require zur Ladezeit re-parst bei jedem Modul-Edit jede Entity-Seite. Modul:Dependencies liest requires aus dem Quelltext und zeichnet für einen berechneten Namen nichts auf.
  • Subtypen sind hier nicht registriert: der Dispatch ist kindintern.
  • Eine Facette, die Items unter einem Schlüssel einer Kettenglied-Sektion hinzufügt (DamageFalloff in personal_weapon/vehicle_weapon), rendert an der Position des Kettenglieds, nicht an ihrer eigenen Stelle in p.facets.

require('strict')

--- @module Entity/Registry
--- The single declarative home for the Entity components that exist. Adding a
--- kind or facet is one entry here (plus the module file and a passing
--- conformance test — see Module:Entity/Contract and Module:Entity/doc).
---
--- Each entry loads its module through a closure, so a page loads only the
--- kinds and facets it uses. Every loaded module is recorded as a dependency of
--- the page, and an edit to it re-parses every page that loaded it. Keep the
--- `require` argument a literal string: Module:Dependencies finds requires by
--- reading source text and records nothing for a computed name.
---
--- Subtypes are intentionally NOT here: subtype dispatch is a kind-internal
--- concern owned by each kind's resolveSubtype. Both Item (via its
--- itemSubtypeMapping) and Vehicle (Ship/GroundVehicle/Gravlev) dispatch this
--- way, which is why their leaves aren't registered alongside the kinds below.

local p = {}

--- Ordered by probe precedence: Module:Entity/Data fetches each kind's primary
--- endpoint in this order until one matches, so Item goes first because it
--- dominates the page mix and short-circuits on the first fetch (kinds with a
--- facade — Vehicle, Location — declare themselves and skip the probe). Order
--- is a cost optimisation only, never a correctness guarantee: the declared-kind
--- gate offers a record of any kind to a single matches(), so each must stand on
--- its own.
---
--- `api` repeats the kind's own getApiConfigs()[1] (a test keeps the two equal)
--- so the probe can fetch before loading: a kind whose endpoint answers nothing
--- is never loaded.
--- @type EntityKindEntry[]
p.kinds = {
	{
		name = 'Item',
		api = {
			name = 'StarCitizenWikiAPI',
			endpoint = 'items/%s',
			params = { locale = 'de_DE', include = 'related_items,blueprints,vehicles,ports' },
			responseDataPath = 'data',
		},
		load = function()
			return require('Module:Entity/Item')
		end,
	},
	{
		name = 'Vehicle',
		api = {
			name = 'StarCitizenWikiAPI',
			endpoint = 'vehicles/%s',
			params = { locale = 'de_DE' },
			responseDataPath = 'data',
		},
		load = function()
			return require('Module:Entity/Vehicle')
		end,
	},
	{
		name = 'Commodity',
		api = {
			name = 'StarCitizenWikiAPI',
			endpoint = 'commodities/%s',
			params = { locale = 'de_DE', include = 'items' },
			responseDataPath = 'data',
		},
		load = function()
			return require('Module:Entity/Commodity')
		end,
	},
	{
		name = 'Mission',
		api = {
			name = 'StarCitizenWikiAPI',
			endpoint = 'missions/%s',
			responseDataPath = 'data',
		},
		load = function()
			return require('Module:Entity/Mission')
		end,
	},
	{
		name = 'Location',
		api = {
			name = 'StarCitizenWikiAPI',
			endpoint = 'locations/%s',
			params = { locale = 'de_DE' },
			responseDataPath = 'data',
		},
		load = function()
			return require('Module:Entity/Location')
		end,
	},
}

--- Every facet whose matches() is true contributes additively, regardless of
--- the primary kind. `keys` are the top-level record fields matches() reads:
--- Data loads the facet only when one of them is present, and
--- Module:Entity/Registry/testcases checks that no match survives without them.
--- @type EntityFacetEntry[]
p.facets = {
	{
		keys = { 'food' },
		load = function()
			return require('Module:Entity/Facet/Consumable')
		end,
	},
	{
		keys = { 'seat' },
		load = function()
			return require('Module:Entity/Facet/Seat')
		end,
	},
	{
		keys = { 'knife', 'melee_weapon' },
		load = function()
			return require('Module:Entity/Facet/Knife')
		end,
	},
	{
		keys = { 'grenade' },
		load = function()
			return require('Module:Entity/Facet/Grenade')
		end,
	},
	{
		keys = { 'sub_type' },
		load = function()
			return require('Module:Entity/Facet/Gadget')
		end,
	},
	{
		keys = { 'vehicle_weapon', 'personal_weapon' },
		load = function()
			return require('Module:Entity/Facet/Salvage')
		end,
	},
	{
		keys = { 'personal_weapon', 'vehicle_weapon' },
		load = function()
			return require('Module:Entity/Facet/Heal')
		end,
	},
	{
		keys = { 'medical' },
		load = function()
			return require('Module:Entity/Facet/Medical')
		end,
	},
	{
		keys = { 'hacking_chip' },
		load = function()
			return require('Module:Entity/Facet/Hacking')
		end,
	},
	{
		keys = { 'weapon_modifier' },
		load = function()
			return require('Module:Entity/Facet/WeaponModifier')
		end,
	},
	{
		keys = { 'iron_sight' },
		load = function()
			return require('Module:Entity/Facet/IronSight')
		end,
	},
	{
		keys = { 'magazine' },
		load = function()
			return require('Module:Entity/Facet/Magazine')
		end,
	},
	{
		keys = { 'laser_pointer' },
		load = function()
			return require('Module:Entity/Facet/LaserPointer')
		end,
	},
	{
		keys = { 'flashlight' },
		load = function()
			return require('Module:Entity/Facet/Flashlight')
		end,
	},
	{
		keys = { 'mining_modifier' },
		load = function()
			return require('Module:Entity/Facet/Mining')
		end,
	},
	{
		keys = { 'tractor_beam' },
		load = function()
			return require('Module:Entity/Facet/Beam')
		end,
	},
	{
		keys = { 'suit_armor' },
		load = function()
			return require('Module:Entity/Facet/Armor')
		end,
	},
	{
		keys = { 'temperature_resistance' },
		load = function()
			return require('Module:Entity/Facet/Environment')
		end,
	},
	{
		keys = { 'personal_weapon', 'vehicle_weapon' },
		load = function()
			return require('Module:Entity/Facet/DamageFalloff')
		end,
	},
	{
		keys = { 'inventory' },
		load = function()
			return require('Module:Entity/Facet/Inventory')
		end,
	},
	{
		keys = { 'durability' },
		load = function()
			return require('Module:Entity/Facet/Component')
		end,
	},
	{
		keys = { 'dimension' },
		load = function()
			return require('Module:Entity/Facet/Dimensions')
		end,
	},
}

return p
Cookies helfen uns bei der Bereitstellung dieses Wikis. Durch die Nutzung des Star Citizen Wiki erklärst du dich damit einverstanden, dass wir Cookies speichern.