mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-13 18:21:51 +00:00
Add interface to register new buildings
This commit is contained in:
parent
22b619e8ab
commit
e4b8071c2f
@ -56,10 +56,10 @@ registerMod(() => {
|
||||
});
|
||||
|
||||
// Add it to the regular toolbar
|
||||
this.signals.hudElementInitialized.add(element => {
|
||||
if (element.constructor.name === "HUDBuildingsToolbar") {
|
||||
element.primaryBuildings.push(MetaDemoModBuilding);
|
||||
}
|
||||
this.modInterface.addNewBuildingToToolbar({
|
||||
toolbar: "regular",
|
||||
location: "primary",
|
||||
metaClass: MetaDemoModBuilding,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@ -121,10 +121,10 @@ registerMod(() => {
|
||||
});
|
||||
|
||||
// Add it to the regular toolbar
|
||||
this.signals.hudElementInitialized.add(element => {
|
||||
if (element.constructor.name === "HUDBuildingsToolbar") {
|
||||
element.primaryBuildings.push(MetaModFlipperBuilding);
|
||||
}
|
||||
this.modInterface.addNewBuildingToToolbar({
|
||||
toolbar: "regular",
|
||||
location: "primary",
|
||||
metaClass: MetaModFlipperBuilding,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@ -188,11 +188,10 @@ registerMod(() => {
|
||||
});
|
||||
|
||||
// Add it to the regular toolbar
|
||||
this.signals.hudElementInitialized.add(element => {
|
||||
if (element.constructor.name === "HUDBuildingsToolbar") {
|
||||
// @ts-ignore
|
||||
element.primaryBuildings.push(MetaDemoModBuilding);
|
||||
}
|
||||
this.modInterface.addNewBuildingToToolbar({
|
||||
toolbar: "regular",
|
||||
location: "primary",
|
||||
metaClass: MetaDemoModBuilding,
|
||||
});
|
||||
|
||||
// Register keybinding
|
||||
|
||||
@ -19,7 +19,6 @@ registerMod(() => {
|
||||
}
|
||||
|
||||
init() {
|
||||
console.log("CUSTOM GAME THEME NOW");
|
||||
this.modInterface.registerGameTheme({
|
||||
id: "my-theme",
|
||||
name: "My fancy theme",
|
||||
|
||||
@ -344,4 +344,21 @@ export class ModInterface {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} param0
|
||||
* @param {"regular"|"wires"} param0.toolbar
|
||||
* @param {"primary"|"secondary"} param0.location
|
||||
* @param {typeof MetaBuilding} param0.metaClass
|
||||
*/
|
||||
addNewBuildingToToolbar({ toolbar, location, metaClass }) {
|
||||
const hudElementName = toolbar === "wires" ? "HUDWiresToolbar" : "HUDBuildingsToolbar";
|
||||
const property = location === "secondary" ? "secondaryBuildings" : "primaryBuildings";
|
||||
|
||||
this.modLoader.signals.hudElementInitialized.add(element => {
|
||||
if (element.constructor.name === hudElementName) {
|
||||
element[property].push(metaClass);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user