mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-01-08 14:27:37 +01:00
working on The Myrian
This commit is contained in:
parent
974c1f5f11
commit
d0cb1c5a51
3
src/Myrian/Helpers.ts
Normal file
3
src/Myrian/Helpers.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { Myrian } from "./Myrian";
|
||||
|
||||
export let myrian = new Myrian();
|
5
src/Myrian/Myrian.ts
Normal file
5
src/Myrian/Myrian.ts
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
|
||||
export class Myrian {
|
||||
|
||||
}
|
45
src/Myrian/ui/MyrianRoot.tsx
Normal file
45
src/Myrian/ui/MyrianRoot.tsx
Normal file
@ -0,0 +1,45 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import Container from "@mui/material/Container";
|
||||
import PersonIcon from '@mui/icons-material/Person';
|
||||
import { Box } from "@mui/system";
|
||||
import { Paper, Typography } from "@mui/material";
|
||||
import BatteryFullIcon from '@mui/icons-material/BatteryFull';
|
||||
import { useRerender } from "src/ui/React/hooks";
|
||||
|
||||
|
||||
const width = 30;
|
||||
const height = 30;
|
||||
|
||||
const iterator = (i: number): number[] => {
|
||||
return Array(i).fill(0)
|
||||
}
|
||||
|
||||
const Cell = (): React.ReactElement => {
|
||||
const x = 20;
|
||||
const sx = {
|
||||
display: 'block',
|
||||
color: 'white',
|
||||
fontSize: x + 'px',
|
||||
}
|
||||
return <div style={{
|
||||
width: x + 'px', height: x + 'px', margin: '0px', padding: '0px'
|
||||
}}>{Math.random() > 0.5 ? <PersonIcon sx={sx} /> : <BatteryFullIcon sx={sx} />}</div>
|
||||
}
|
||||
|
||||
export function MyrianRoot(): React.ReactElement {
|
||||
console.log(new Date());
|
||||
const [render, setRerender] = useState(false);
|
||||
const rerender = () => setRerender((old) => !old);
|
||||
useEffect(() => {
|
||||
const intervalID = setInterval(rerender, 200);
|
||||
return () => clearInterval(intervalID);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Container maxWidth="lg" disableGutters sx={{ mx: 0 }}>
|
||||
<Paper sx={{ display: 'flex', flexDirection: 'column', m: 0, p: 0 }}>
|
||||
{iterator(height).map(() => <Box sx={{ display: 'flex', flexDirection: 'row' }}>{iterator(width).map(() => <Cell />)}</Box>)}
|
||||
</Paper>
|
||||
</Container>
|
||||
);
|
||||
}
|
32
src/NetscriptFunctions/Myrian.ts
Normal file
32
src/NetscriptFunctions/Myrian.ts
Normal file
@ -0,0 +1,32 @@
|
||||
|
||||
import { Myr as IMyrian } from "@nsdefs";
|
||||
import { InternalAPI } from "src/Netscript/APIWrapper";
|
||||
|
||||
export function NetscriptMyrian(): InternalAPI<IMyrian> {
|
||||
return {
|
||||
ianInteract:
|
||||
(ctx) =>
|
||||
(sleeveId, x, y) => { throw new Error("Unimplemented"); },
|
||||
ianMove:
|
||||
(ctx) =>
|
||||
(sleeveId, x, y) => { throw new Error("Unimplemented"); },
|
||||
ianGetTask:
|
||||
(ctx) =>
|
||||
(sleeveId) => { throw new Error("Unimplemented"); },
|
||||
ianCancelTask:
|
||||
(ctx) =>
|
||||
(sleeveId) => { throw new Error("Unimplemented"); },
|
||||
ianEnter:
|
||||
(ctx) =>
|
||||
(sleeveId?) => { throw new Error("Unimplemented"); },
|
||||
ianLeave:
|
||||
(ctx) =>
|
||||
(sleeveId?) => { throw new Error("Unimplemented"); },
|
||||
ianBuild:
|
||||
(ctx) =>
|
||||
(sleeveId, buildingId, x, y) => { throw new Error("Unimplemented"); },
|
||||
ianApplyPowerup:
|
||||
(ctx) =>
|
||||
(sleeveId, stat) => { throw new Error("Unimplemented"); },
|
||||
}
|
||||
}
|
96
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
96
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -2693,6 +2693,102 @@ export interface Hacknet {
|
||||
getTrainingMult(): number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Myrian API
|
||||
* @remarks
|
||||
* You need to have completed BN10 at least once and be in BitNode-14/15
|
||||
* or have Source-File 14/15 in order to use this API.
|
||||
* @public
|
||||
*/
|
||||
export interface Myr {
|
||||
/**
|
||||
* Interact with an object in The Myrian.
|
||||
* @remarks
|
||||
* RAM cost: 5.9 GB
|
||||
*
|
||||
* The effect is different depending on the object.
|
||||
* Interacting with an enemy will attack it.
|
||||
* With a resource node will mine it.
|
||||
* With a power up will collect it.
|
||||
* With a rock will try to break it.
|
||||
*
|
||||
* @returns Amount of milliseconds the operation will take.
|
||||
*/
|
||||
ianInteract(sleeveId: number, x: number, y: number): number;
|
||||
|
||||
/**
|
||||
* Move a sleeve in the Myrian.
|
||||
* @remarks
|
||||
* RAM cost: 3.4 GB
|
||||
*
|
||||
* The target tile must be 1 tile away from the sleeves current tile.
|
||||
*
|
||||
* @returns Amount of milliseconds the operation will take.
|
||||
*/
|
||||
ianMove(sleeveId: number, x: number, y: number): number;
|
||||
|
||||
/**
|
||||
* Get that sleeves current task in the Myrian.
|
||||
* @remarks
|
||||
* RAM cost: 1.1 GB
|
||||
*
|
||||
*
|
||||
* @returns The task currently being performed.
|
||||
*/
|
||||
ianGetTask(sleeveId): any;
|
||||
|
||||
/**
|
||||
* Cancel a sleeves current Myrian task.
|
||||
* @remarks
|
||||
* RAM cost: 1.2 GB
|
||||
*
|
||||
* @returns true if a task was cancelled.
|
||||
*/
|
||||
ianCancelTask(sleeveId): boolean;
|
||||
|
||||
/**
|
||||
* Makes the player or a sleeve enter The Myrian.
|
||||
* @remarks
|
||||
* RAM cost: 0.2 GB
|
||||
*
|
||||
* @returns true if the person is now in The Myrian.
|
||||
*/
|
||||
ianEnter(sleeveId?: number): boolean;
|
||||
|
||||
/**
|
||||
* Makes the player or a sleeve leave The Myrian.
|
||||
* @remarks
|
||||
* RAM cost: 0.2 GB
|
||||
*
|
||||
* Sleeves must be 1 tile away from the core.
|
||||
*
|
||||
* @returns true if the person is now in the simulated world.
|
||||
*/
|
||||
ianLeave(sleeveId?: number): boolean;
|
||||
|
||||
/**
|
||||
* Build an entity in The Myrian.
|
||||
* @remarks
|
||||
* RAM cost: 4.1 GB
|
||||
*
|
||||
* Sleeves must be 1 tile away from the target tile and the player must have enough resources to build the entity.
|
||||
*
|
||||
* @returns The amount of milliseconds needed to complete the operation. or -1 if failed.
|
||||
*/
|
||||
ianBuild(sleeveId: number, buildingId: number, x: number, y: number): number;
|
||||
|
||||
/**
|
||||
* Apply a Myrian powerup to a sleeve.
|
||||
* @remarks
|
||||
* RAM cost: 10.9 GB
|
||||
*
|
||||
* Must have at least 1 powerup to apply.
|
||||
*
|
||||
* @returns True if the powerup was applied.
|
||||
*/
|
||||
ianApplyPowerup(sleeveId: number, stat: string): boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bladeburner API
|
||||
* @remarks
|
||||
|
@ -78,6 +78,7 @@ import { MathJaxContext } from "better-react-mathjax";
|
||||
import { useRerender } from "./React/hooks";
|
||||
import { ScriptFilePath } from "src/Paths/ScriptFilePath";
|
||||
import { TextFilePath } from "src/Paths/TextFilePath";
|
||||
import { MyrianRoot } from "../Myrian/ui/MyrianRoot";
|
||||
|
||||
const htmlLocation = location;
|
||||
|
||||
@ -119,6 +120,7 @@ export let Router: IRouter = {
|
||||
};
|
||||
|
||||
function determineStartPage(): Page {
|
||||
return Page.Myrian; // WRONG
|
||||
if (RecoveryMode) return Page.Recovery;
|
||||
if (Player.currentWork !== null) return Page.Work;
|
||||
return Page.Terminal;
|
||||
@ -297,6 +299,10 @@ export function GameRoot(): React.ReactElement {
|
||||
mainPage = <StaneksGiftRoot staneksGift={staneksGift} />;
|
||||
break;
|
||||
}
|
||||
case Page.Myrian: {
|
||||
mainPage = <MyrianRoot />;
|
||||
break;
|
||||
}
|
||||
case Page.Stats: {
|
||||
mainPage = <CharacterStats />;
|
||||
break;
|
||||
|
@ -35,6 +35,7 @@ export enum SimplePage {
|
||||
Recovery = "Recovery",
|
||||
Achievements = "Achievements",
|
||||
ThemeBrowser = "Theme Browser",
|
||||
Myrian = "Myrian",
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user