Skip to content

Commit

Permalink
物流配送器参数面板
Browse files Browse the repository at this point in the history
  • Loading branch information
huww98 committed Dec 31, 2023
1 parent c80cf16 commit e460fd6
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 7 deletions.
39 changes: 38 additions & 1 deletion src/blueprint/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,42 @@ const MonitorParamParser: ParamParser<MonitorParameters> = {
}
}

export enum DispenserPlayerMode {
NONE = 0,
RECYCLE = 1,
BOTH = 2,
SUPPLY = 3,
}
export enum DispenserStorageMode {
NONE = 0,
SUPPLY = 1,
DEMAND = 2,
}
export interface DispenserParameters {
playerMode: DispenserPlayerMode;
storageMode: DispenserStorageMode;
workEnergyPerTick: number;
courierAutoReplenish: boolean;
}

const dispenserParamParser: ParamParser<DispenserParameters> = {
encodedSize() { return 128; },
encode(p, a) {
setParam(a, 0, p.playerMode);
setParam(a, 1, p.storageMode);
setParam(a, 2, p.workEnergyPerTick);
setParam(a, 3, p.courierAutoReplenish ? 1 : 0);
},
decode(a) {
return {
playerMode: getParam(a, 0),
storageMode: getParam(a, 1),
workEnergyPerTick: getParam(a, 2),
courierAutoReplenish: getParam(a, 3) > 0,
}
}
}

interface UnknownParamerters {
parameters: Int32Array,
}
Expand All @@ -722,7 +758,7 @@ type AllParameters = AssembleParamerters | StationParameters | AdvancedMiningMac
SplitterParameters | LabParamerters | BeltParameters | InserterParameters |
TankParameters | StorageParameters | EjectorParameters |
PowerGeneratorParameters | ArtifacialStarParameters | EnergyExchangerParameters |
MonitorParameters | BattleBaseParameters | UnknownParamerters;
MonitorParameters | BattleBaseParameters | DispenserParameters | UnknownParamerters;

const parameterParsers = new Map<number, ParamParser<AllParameters>>([
[2103, stationParamsParser(stationDesc)],
Expand All @@ -745,6 +781,7 @@ const parameterParsers = new Map<number, ParamParser<AllParameters>>([
[2209, energyExchangerParamParser],
[2030, MonitorParamParser],
[3009, battleBaseParamParser()],
[2107, dispenserParamParser],
]);
for (const id of allAssemblers) {
parameterParsers.set(id, assembleParamParser);
Expand Down
6 changes: 2 additions & 4 deletions src/components/BattleBaseInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@
<label>{{ t('基站自动补充编队提示标题') }}</label>
<span class="v">{{ truth(p.autoReplenishFleet) }}</span>
</div>
<div>
<label>{{ t('最大充能功率') }}</label>
<span class="v">{{(p.workEnergyPerTick * 60 / 1_000_000).toLocaleString([], { minimumSignificantDigits: 3, maximumSignificantDigits: 3 })}} MW</span>
</div>
<WorkEnergyParam :per-tick="p.workEnergyPerTick"/>
</div>
</template>

Expand All @@ -37,6 +34,7 @@ import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { BattleBaseParameters, BlueprintBuilding, BattleBaseDroneConstructPriority } from '@/blueprint/parser';
import BuildingIcon from './BuildingIcon.vue';
import WorkEnergyParam from './WorkEnergyParam.vue';
import { itemIconId } from '@/data/icons';
import { truth } from '@/utils';
Expand Down
5 changes: 4 additions & 1 deletion src/components/BuildingInfoPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<SwitchDSP :opened="(bParams as TankParameters).output">{{ t('储液罐输出') }}</SwitchDSP>
<SwitchDSP :opened="(bParams as TankParameters).input">{{ t('储液罐输入') }}</SwitchDSP>
</div>
<DispenserInfo v-if="isDispenser(building.itemId)" :building="building" />
</template>

<script lang="ts">
Expand Down Expand Up @@ -90,7 +91,8 @@ import {
import { itemIconId } from '@/data/icons';
import {
isLab, allAssemblers, isBelt, isStation, itemsMap, isInserter, isStorage, isTank,
isEjector, isEnergyExchanger, isArtificialStar, isRayReciver, isMonitor, isSplitter, isBattleBase,
isEjector, isEnergyExchanger, isArtificialStar, isRayReciver, isMonitor, isSplitter,
isBattleBase, isDispenser,
} from '@/data/items';
import { commandQueueKey } from '@/define';
Expand All @@ -100,6 +102,7 @@ import StationInfo from './StationInfo.vue';
import MonitorInfo from './MonitorInfo.vue';
import BattleBaseInfo from './BattleBaseInfo.vue';
import StorageInfo from './StorageInfo.vue';
import DispenserInfo from './DispenserInfo.vue';
import SwitchDSP from './SwitchDSP.vue';
const SplitterInfo = defineAsyncComponent(() => import(/* webpackChunkName: "renderer" */'./SpitterInfo.vue'));
Expand Down
81 changes: 81 additions & 0 deletions src/components/DispenserInfo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<template>
<div class="building-params">
<div>
<label>{{ playerModeLabel }}</label>
<span class="v">{{ truth(p.playerMode !== DispenserPlayerMode.NONE) }}</span>
</div>
<div v-if="p.playerMode === DispenserPlayerMode.RECYCLE">
<label>{{ t('不限回收类型') }}</label>
<span class="v">{{ truth(props.building.filterId < 0) }}</span>
</div>
<div>
<label>{{ storageModeLabel }}</label>
<span class="v">{{ truth(p.storageMode !== DispenserStorageMode.NONE) }}</span>
</div>
<div>
<label>{{ t('自动补充提示') }}</label>
<span class="v">{{ truth(p.courierAutoReplenish) }}</span>
</div>
<WorkEnergyParam :per-tick="p.workEnergyPerTick"/>
</div>
</template>

<script lang="ts" setup>
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { BlueprintBuilding, DispenserParameters, DispenserPlayerMode, DispenserStorageMode } from '@/blueprint/parser';
import { truth } from '@/utils';
import WorkEnergyParam from './WorkEnergyParam.vue';
const { t } = useI18n();
const props = defineProps<{
building: BlueprintBuilding,
}>();
const p = computed(() => props.building.parameters as DispenserParameters);
const playerModeLabel = computed(() => {
switch (p.value.playerMode) {
case DispenserPlayerMode.NONE:
return t('向玩家配送模式0');
case DispenserPlayerMode.SUPPLY:
return t('向玩家配送模式1');
case DispenserPlayerMode.RECYCLE:
return t('向玩家配送模式2');
case DispenserPlayerMode.BOTH:
return t('向玩家配送模式3');
default:
return '??';
}
})
const storageModeLabel = computed(() => {
switch (p.value.storageMode) {
case DispenserStorageMode.NONE:
return t('向箱子配送模式0');
case DispenserStorageMode.SUPPLY:
return t('向箱子配送模式1');
case DispenserStorageMode.DEMAND:
return t('向箱子配送模式2');
default:
return '??';
}
})
</script>

<style lang="scss">
.fleet-grid {
display: grid;
grid-template-columns: repeat(6, 1fr);
grid-template-rows: repeat(2, 1fr);
gap: 2px;
grid-auto-flow: column;
.icon {
display: block;
padding: 2px;
background: #FFFFFF40;
}
}
</style>
3 changes: 2 additions & 1 deletion src/components/StationInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div v-if="inter"><label>{{ t('星际物流运输船') }}</label><span class="v">{{ truth(p.shipAutoReplenish) }}</span></div>
</div>
<div class="building-params">
<div v-if="!collector"><label>{{t('最大充能功率')}}</label><span class="v">{{(p.workEnergyPerTick * 60 / 1_000_000).toLocaleString([], { minimumFractionDigits: 1, maximumFractionDigits: 1 })}} MW</span></div>
<WorkEnergyParam v-if="!collector" :per-tick="p.workEnergyPerTick"/>
<div v-if="!collector"><label>{{t('运输机最远路程')}}</label><span class="v">{{(Math.acos(p.tripRangeOfDrones) / Math.PI * 180.0).toLocaleString([], { maximumFractionDigits: 0 })}}°</span></div>
<div v-if="inter"><label>{{t('运输船最远路程')}}</label><span class="v">{{tripRangeOfShips}}</span></div>
<div v-if="inter"><label>{{t('轨道采集器')}}</label><span class="v">{{truth(p.includeOrbitCollector)}}</span></div>
Expand All @@ -40,6 +40,7 @@ import { LogisticRole, BlueprintBuilding, StationParameters, BlueprintData } fro
import { Command, Updater } from '@/command';
import { BuildingInfo } from '@/blueprint/buildingInfo';
import { itemIconId } from '@/data/icons';
import WorkEnergyParam from './WorkEnergyParam.vue';
const roleText = new Map([
[LogisticRole.None, '仓储'],
Expand Down
16 changes: 16 additions & 0 deletions src/components/WorkEnergyParam.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<template>
<div>
<label>{{t('最大充能功率')}}</label>
<span class="v">{{(props.perTick * 60 / 1_000_000).toLocaleString([], { minimumSignificantDigits: 3, maximumSignificantDigits: 3 })}} MW</span>
</div>
</template>

<script lang="ts" setup>
import { useI18n } from 'vue-i18n';
const props = defineProps<{
perTick: number,
}>();
const { t } = useI18n();
</script>
4 changes: 4 additions & 0 deletions src/data/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ export function isBattleBase(id: number) {
return id === 3009;
}

export function isDispenser(id: number) {
return id === 2107;
}

export const allAssemblers = new Set([
2303, // 制造台
2304,
Expand Down
8 changes: 8 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
"齿轮": "Gear",
"不满足": "Fail",
"不选轨道": "None",
"不限回收类型": "Collect all types",
"低音贝斯": "Sub Bass",
"储液罐关": "OFF",
"储液罐开": "ON",
Expand All @@ -199,6 +200,13 @@
"包括轨道采集器": " Orbital Collector",
"十倍射速": "10x Speed",
"吉他": "Guitar",
"向玩家配送模式0": "Distribute to Icarus",
"向玩家配送模式1": "Provide to Icarus",
"向玩家配送模式2": "Collect from Icarus",
"向玩家配送模式3": "Provide to and collect from Icarus",
"向箱子配送模式0": "Distribute to other distributors",
"向箱子配送模式1": "Provide to other distributors",
"向箱子配送模式2": "Request from other distributors",
"周期秒": " seconds",
"图标布局": "Icon Layout",
"基站建设无人机提示标题": "Construction Drone",
Expand Down
8 changes: 8 additions & 0 deletions src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
"齿轮": "齿轮",
"不满足": "不满足",
"不选轨道": "",
"不限回收类型": "回收所有类型",
"低音贝斯": "低音贝斯",
"储液罐关": "",
"储液罐开": "",
Expand All @@ -199,6 +200,13 @@
"包括轨道采集器": " 轨道采集器",
"十倍射速": "十倍射速",
"吉他": "吉他",
"向玩家配送模式0": "向伊卡洛斯配送",
"向玩家配送模式1": "向伊卡洛斯供应",
"向玩家配送模式2": "从伊卡洛斯回收",
"向玩家配送模式3": "向伊卡洛斯供应和回收",
"向箱子配送模式0": "向其他配送器配送",
"向箱子配送模式1": "向其他配送器供应",
"向箱子配送模式2": "向其他配送器需求",
"周期秒": "",
"图标布局": "图标布局",
"基站建设无人机提示标题": "建设无人机",
Expand Down

0 comments on commit e460fd6

Please sign in to comment.