mirror of
https://github.com/wanderer-industries/wanderer
synced 2025-11-18 15:16:16 +00:00
* feat(signatures): Add custom info to system signatures * feat(connections): Add custom info to system connections * feat(Map): Add system signature type * feat(Map): Update wormhole types info * feat(Map): Add undo action for removed systems * feat(Map): Delete systems on Backspace hotkey * feat(Map): Update k-space systems background & styles * feat(Map): Update systems status background styles * feat(Map): add support for new wh type data. add signatures settings modal menu; reworked signatures widget - was added info of wormhole; --------- Co-authored-by: achichenkov <aleksei.chichenkov@telleqt.ai>
69 lines
1.6 KiB
TypeScript
69 lines
1.6 KiB
TypeScript
import { useCallback } from 'react';
|
|
import { CommandInit } from '@/hooks/Mapper/types';
|
|
import { MapRootData, useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
|
import { useLoadSystemStatic } from '@/hooks/Mapper/mapRootProvider/hooks/useLoadSystemStatic.ts';
|
|
|
|
export const useMapInit = () => {
|
|
const { update } = useMapRootState();
|
|
|
|
const { addSystemStatic } = useLoadSystemStatic({ systems: [] });
|
|
|
|
return useCallback(
|
|
({
|
|
systems,
|
|
connections,
|
|
effects,
|
|
wormholes,
|
|
system_static_infos,
|
|
characters,
|
|
user_characters,
|
|
present_characters,
|
|
hubs,
|
|
}: CommandInit) => {
|
|
const updateData: Partial<MapRootData> = {};
|
|
|
|
if (wormholes) {
|
|
updateData.wormholesData = wormholes.reduce((acc, x) => ({ ...acc, [x.name]: x }), {});
|
|
updateData.wormholes = wormholes;
|
|
}
|
|
|
|
if (effects) {
|
|
updateData.effects = effects.reduce((acc, x) => ({ ...acc, [x.name]: x }), {});
|
|
}
|
|
|
|
if (characters) {
|
|
updateData.characters = characters.slice();
|
|
}
|
|
|
|
if (user_characters) {
|
|
updateData.userCharacters = user_characters;
|
|
}
|
|
|
|
if (present_characters) {
|
|
updateData.presentCharacters = present_characters;
|
|
}
|
|
|
|
if (systems) {
|
|
updateData.systems = systems;
|
|
}
|
|
|
|
if (connections) {
|
|
updateData.connections = connections;
|
|
}
|
|
|
|
if (hubs) {
|
|
updateData.hubs = hubs;
|
|
}
|
|
|
|
if (system_static_infos) {
|
|
system_static_infos.forEach(static_info => {
|
|
addSystemStatic(static_info);
|
|
});
|
|
}
|
|
|
|
update(updateData);
|
|
},
|
|
[update, addSystemStatic],
|
|
);
|
|
};
|