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
|
// Add it to the regular toolbar
|
||||||
this.signals.hudElementInitialized.add(element => {
|
this.modInterface.addNewBuildingToToolbar({
|
||||||
if (element.constructor.name === "HUDBuildingsToolbar") {
|
toolbar: "regular",
|
||||||
element.primaryBuildings.push(MetaDemoModBuilding);
|
location: "primary",
|
||||||
}
|
metaClass: MetaDemoModBuilding,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -121,10 +121,10 @@ registerMod(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Add it to the regular toolbar
|
// Add it to the regular toolbar
|
||||||
this.signals.hudElementInitialized.add(element => {
|
this.modInterface.addNewBuildingToToolbar({
|
||||||
if (element.constructor.name === "HUDBuildingsToolbar") {
|
toolbar: "regular",
|
||||||
element.primaryBuildings.push(MetaModFlipperBuilding);
|
location: "primary",
|
||||||
}
|
metaClass: MetaModFlipperBuilding,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -188,11 +188,10 @@ registerMod(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Add it to the regular toolbar
|
// Add it to the regular toolbar
|
||||||
this.signals.hudElementInitialized.add(element => {
|
this.modInterface.addNewBuildingToToolbar({
|
||||||
if (element.constructor.name === "HUDBuildingsToolbar") {
|
toolbar: "regular",
|
||||||
// @ts-ignore
|
location: "primary",
|
||||||
element.primaryBuildings.push(MetaDemoModBuilding);
|
metaClass: MetaDemoModBuilding,
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Register keybinding
|
// Register keybinding
|
||||||
|
|||||||
@ -19,7 +19,6 @@ registerMod(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
console.log("CUSTOM GAME THEME NOW");
|
|
||||||
this.modInterface.registerGameTheme({
|
this.modInterface.registerGameTheme({
|
||||||
id: "my-theme",
|
id: "my-theme",
|
||||||
name: "My fancy 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