mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Implement color inverter building
This commit is contained in:
parent
a77911263d
commit
d75fb184a4
@ -38,8 +38,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.additionalOptions {
|
.additionalOptions {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
@include S(margin-top, 10px);
|
@include S(margin-top, 10px);
|
||||||
button {
|
button {
|
||||||
|
@include S(margin-bottom, 2px);
|
||||||
@include IncreasedClickArea(0px);
|
@include IncreasedClickArea(0px);
|
||||||
@include SuperSmallText;
|
@include SuperSmallText;
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@ export const enumColors = {
|
|||||||
|
|
||||||
white: "white",
|
white: "white",
|
||||||
uncolored: "uncolored",
|
uncolored: "uncolored",
|
||||||
|
|
||||||
|
black: "black",
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
@ -24,6 +26,8 @@ export const enumColorToShortcode = {
|
|||||||
|
|
||||||
[enumColors.white]: "w",
|
[enumColors.white]: "w",
|
||||||
[enumColors.uncolored]: "u",
|
[enumColors.uncolored]: "u",
|
||||||
|
|
||||||
|
[enumColors.black]: "0",
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @enum {enumColors} */
|
/** @enum {enumColors} */
|
||||||
@ -50,9 +54,27 @@ export const enumColorsToHexCode = {
|
|||||||
// blue + green + red
|
// blue + green + red
|
||||||
[enumColors.white]: "#ffffff",
|
[enumColors.white]: "#ffffff",
|
||||||
|
|
||||||
|
[enumColors.black]: "#212428",
|
||||||
|
|
||||||
[enumColors.uncolored]: "#aaaaaa",
|
[enumColors.uncolored]: "#aaaaaa",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** @enum {enumColors} */
|
||||||
|
export const enumInvertedColors = {
|
||||||
|
[enumColors.red]: enumColors.cyan,
|
||||||
|
[enumColors.green]: enumColors.purple,
|
||||||
|
[enumColors.blue]: enumColors.yellow,
|
||||||
|
|
||||||
|
[enumColors.yellow]: enumColors.blue,
|
||||||
|
[enumColors.purple]: enumColors.green,
|
||||||
|
[enumColors.cyan]: enumColors.red,
|
||||||
|
|
||||||
|
[enumColors.white]: enumColors.black,
|
||||||
|
[enumColors.black]: enumColors.white,
|
||||||
|
|
||||||
|
[enumColors.uncolored]: enumColors.uncolored,
|
||||||
|
};
|
||||||
|
|
||||||
const c = enumColors;
|
const c = enumColors;
|
||||||
/** @enum {Object.<string, string>} */
|
/** @enum {Object.<string, string>} */
|
||||||
export const enumColorMixingResults = {
|
export const enumColorMixingResults = {
|
||||||
@ -66,6 +88,7 @@ export const enumColorMixingResults = {
|
|||||||
[c.cyan]: c.white,
|
[c.cyan]: c.white,
|
||||||
|
|
||||||
[c.white]: c.white,
|
[c.white]: c.white,
|
||||||
|
[c.black]: c.red,
|
||||||
},
|
},
|
||||||
|
|
||||||
// 0, 255, 0
|
// 0, 255, 0
|
||||||
@ -77,6 +100,7 @@ export const enumColorMixingResults = {
|
|||||||
[c.cyan]: c.cyan,
|
[c.cyan]: c.cyan,
|
||||||
|
|
||||||
[c.white]: c.white,
|
[c.white]: c.white,
|
||||||
|
[c.black]: c.green,
|
||||||
},
|
},
|
||||||
|
|
||||||
// 0, 255, 0
|
// 0, 255, 0
|
||||||
@ -86,17 +110,20 @@ export const enumColorMixingResults = {
|
|||||||
[c.cyan]: c.cyan,
|
[c.cyan]: c.cyan,
|
||||||
|
|
||||||
[c.white]: c.white,
|
[c.white]: c.white,
|
||||||
|
[c.black]: c.blue,
|
||||||
},
|
},
|
||||||
|
|
||||||
// 255, 255, 0
|
// 255, 255, 0
|
||||||
[c.yellow]: {
|
[c.yellow]: {
|
||||||
[c.purple]: c.white,
|
[c.purple]: c.white,
|
||||||
[c.cyan]: c.white,
|
[c.cyan]: c.white,
|
||||||
|
[c.black]: c.yellow,
|
||||||
},
|
},
|
||||||
|
|
||||||
// 255, 0, 255
|
// 255, 0, 255
|
||||||
[c.purple]: {
|
[c.purple]: {
|
||||||
[c.cyan]: c.white,
|
[c.cyan]: c.white,
|
||||||
|
[c.black]: c.purple,
|
||||||
},
|
},
|
||||||
|
|
||||||
// 0, 255, 255
|
// 0, 255, 255
|
||||||
@ -113,6 +140,13 @@ export const enumColorMixingResults = {
|
|||||||
[c.uncolored]: {
|
[c.uncolored]: {
|
||||||
// auto
|
// auto
|
||||||
},
|
},
|
||||||
|
|
||||||
|
[c.black]: {
|
||||||
|
// auto
|
||||||
|
[c.white]: c.white,
|
||||||
|
[c.cyan]: c.cyan,
|
||||||
|
[c.uncolored]: c.uncolored,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create same color lookups
|
// Create same color lookups
|
||||||
|
@ -48,6 +48,7 @@ export class HUDSandboxController extends BaseHUDPart {
|
|||||||
|
|
||||||
<div class="additionalOptions">
|
<div class="additionalOptions">
|
||||||
<button class="styledButton giveBlueprints">Fill blueprint shapes</button>
|
<button class="styledButton giveBlueprints">Fill blueprint shapes</button>
|
||||||
|
<button class="styledButton maxOutAll">Max out all</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
@ -56,6 +57,7 @@ export class HUDSandboxController extends BaseHUDPart {
|
|||||||
const bind = (selector, handler) => this.trackClicks(this.element.querySelector(selector), handler);
|
const bind = (selector, handler) => this.trackClicks(this.element.querySelector(selector), handler);
|
||||||
|
|
||||||
bind(".giveBlueprints", this.giveBlueprints);
|
bind(".giveBlueprints", this.giveBlueprints);
|
||||||
|
bind(".maxOutAll", this.maxOutAll);
|
||||||
bind(".levelToggle .minus", () => this.modifyLevel(-1));
|
bind(".levelToggle .minus", () => this.modifyLevel(-1));
|
||||||
bind(".levelToggle .plus", () => this.modifyLevel(1));
|
bind(".levelToggle .plus", () => this.modifyLevel(1));
|
||||||
|
|
||||||
@ -76,6 +78,13 @@ export class HUDSandboxController extends BaseHUDPart {
|
|||||||
this.root.hubGoals.storedShapes[blueprintShape] += 1e4;
|
this.root.hubGoals.storedShapes[blueprintShape] += 1e4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maxOutAll() {
|
||||||
|
this.modifyUpgrade("belt", 100);
|
||||||
|
this.modifyUpgrade("miner", 100);
|
||||||
|
this.modifyUpgrade("processors", 100);
|
||||||
|
this.modifyUpgrade("painting", 100);
|
||||||
|
}
|
||||||
|
|
||||||
modifyUpgrade(id, amount) {
|
modifyUpgrade(id, amount) {
|
||||||
const handle = UPGRADES[id];
|
const handle = UPGRADES[id];
|
||||||
const maxLevel = handle.tiers.length;
|
const maxLevel = handle.tiers.length;
|
||||||
|
@ -5,7 +5,13 @@ import { DrawParameters } from "../core/draw_parameters";
|
|||||||
import { createLogger } from "../core/logging";
|
import { createLogger } from "../core/logging";
|
||||||
import { Vector } from "../core/vector";
|
import { Vector } from "../core/vector";
|
||||||
import { BasicSerializableObject, types } from "../savegame/serialization";
|
import { BasicSerializableObject, types } from "../savegame/serialization";
|
||||||
import { enumColors, enumColorsToHexCode, enumColorToShortcode, enumShortcodeToColor } from "./colors";
|
import {
|
||||||
|
enumColors,
|
||||||
|
enumColorsToHexCode,
|
||||||
|
enumColorToShortcode,
|
||||||
|
enumShortcodeToColor,
|
||||||
|
enumInvertedColors,
|
||||||
|
} from "./colors";
|
||||||
import { THEME } from "./theme";
|
import { THEME } from "./theme";
|
||||||
|
|
||||||
const rusha = require("rusha");
|
const rusha = require("rusha");
|
||||||
@ -566,6 +572,23 @@ export class ShapeDefinition extends BasicSerializableObject {
|
|||||||
return new ShapeDefinition({ layers: newLayers });
|
return new ShapeDefinition({ layers: newLayers });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clones the shape and inverts all colors
|
||||||
|
*/
|
||||||
|
cloneAndInvertColors() {
|
||||||
|
const newLayers = this.internalCloneLayers();
|
||||||
|
for (let layerIndex = 0; layerIndex < newLayers.length; ++layerIndex) {
|
||||||
|
const quadrants = newLayers[layerIndex];
|
||||||
|
for (let quadrantIndex = 0; quadrantIndex < 4; ++quadrantIndex) {
|
||||||
|
const item = quadrants[quadrantIndex];
|
||||||
|
if (item) {
|
||||||
|
item.color = enumInvertedColors[item.color];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ShapeDefinition({ layers: newLayers });
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clones the shape and colors everything in the given colors
|
* Clones the shape and colors everything in the given colors
|
||||||
* @param {[enumColors, enumColors, enumColors, enumColors]} colors
|
* @param {[enumColors, enumColors, enumColors, enumColors]} colors
|
||||||
|
@ -161,6 +161,22 @@ export class ShapeDefinitionManager extends BasicSerializableObject {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a definition for inverting all colors on that shape
|
||||||
|
* @param {ShapeDefinition} definition
|
||||||
|
* @returns {ShapeDefinition}
|
||||||
|
*/
|
||||||
|
shapeActionInvertColors(definition) {
|
||||||
|
const key = "invert:" + definition.getHash();
|
||||||
|
if (this.operationCache[key]) {
|
||||||
|
return /** @type {ShapeDefinition} */ (this.operationCache[key]);
|
||||||
|
}
|
||||||
|
const inverted = definition.cloneAndInvertColors();
|
||||||
|
return /** @type {ShapeDefinition} */ (this.operationCache[key] = this.registerOrReturnHandle(
|
||||||
|
inverted
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a definition for painting it with the 4 colors
|
* Generates a definition for painting it with the 4 colors
|
||||||
* @param {ShapeDefinition} definition
|
* @param {ShapeDefinition} definition
|
||||||
|
@ -348,8 +348,11 @@ export class ItemProcessorSystem extends GameSystemWithFilter {
|
|||||||
// ADVANCED PROCESSING
|
// ADVANCED PROCESSING
|
||||||
|
|
||||||
case enumItemProcessorTypes.advancedProcessor: {
|
case enumItemProcessorTypes.advancedProcessor: {
|
||||||
|
const shapeItem = /** @type {ShapeItem} */ (items[0].item);
|
||||||
|
const newItem = this.root.shapeDefinitionMgr.shapeActionInvertColors(shapeItem.definition);
|
||||||
|
|
||||||
outItems.push({
|
outItems.push({
|
||||||
item: items[0].item,
|
item: new ShapeItem(newItem),
|
||||||
requiredSlot: 0,
|
requiredSlot: 0,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
@ -301,6 +301,7 @@ ingame:
|
|||||||
purple: Purple
|
purple: Purple
|
||||||
cyan: Cyan
|
cyan: Cyan
|
||||||
white: White
|
white: White
|
||||||
|
black: Black
|
||||||
uncolored: No color
|
uncolored: No color
|
||||||
|
|
||||||
# Everything related to placing buildings (I.e. as soon as you selected a building
|
# Everything related to placing buildings (I.e. as soon as you selected a building
|
||||||
|
Loading…
Reference in New Issue
Block a user