Initial commit

This commit is contained in:
Dmitry Popov
2024-09-18 01:55:30 +04:00
parent 6a96a5f56e
commit 4136aaad76
1675 changed files with 124664 additions and 1 deletions

View File

@@ -0,0 +1,32 @@
import { MapData, useMapState } from '@/hooks/Mapper/components/map/MapProvider.tsx';
import { useCallback, useRef } from 'react';
import { CommandKillsUpdated, CommandMapUpdated } from '@/hooks/Mapper/types';
export const useMapCommands = () => {
const { update } = useMapState();
const ref = useRef({ update });
ref.current = { update };
const mapUpdated = useCallback(({ hubs }: CommandMapUpdated) => {
const out: Partial<MapData> = {};
if (hubs) {
out.hubs = hubs;
}
ref.current.update(out);
}, []);
const killsUpdated = useCallback((updated_kills: CommandKillsUpdated) => {
ref.current.update(({ kills }) => {
updated_kills.forEach(kill => {
kills[kill.solar_system_id] = kill.kills;
});
return { kills: { ...kills } };
});
}, []);
return { mapUpdated, killsUpdated };
};