Better Typing for Positions and Formats Code
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { HarvesterHandler, RoleHandler, UpgraderHandler } from "roleHandlers";
|
||||
import { PositionDelta } from "./source";
|
||||
import { PositionDelta } from "utils/positions";
|
||||
|
||||
export type RoleDefinition = {
|
||||
name: string;
|
||||
@@ -33,35 +33,29 @@ export type CreepRole = keyof typeof CreepRoles;
|
||||
|
||||
export type CreepRequisition = Record<CreepRole, number>;
|
||||
|
||||
|
||||
|
||||
|
||||
export type SpawnDestination = {
|
||||
id: string; // ID of the spawn
|
||||
type: "spawn";
|
||||
}
|
||||
};
|
||||
|
||||
export type SourceDestination = {
|
||||
id: string; // ID of the source
|
||||
type: "source";
|
||||
sourceSpot: PositionDelta; // Position delta for the source spot
|
||||
}
|
||||
};
|
||||
|
||||
export type ControllerDestination = {
|
||||
id: string; // ID of the controller
|
||||
type: "controller";
|
||||
}
|
||||
};
|
||||
|
||||
export type ConstructionSiteDestination = {
|
||||
id: string; // ID of the construction site
|
||||
type: "constructionSite";
|
||||
}
|
||||
|
||||
|
||||
export type CreepDestination = (
|
||||
SpawnDestination |
|
||||
SourceDestination |
|
||||
ControllerDestination |
|
||||
ConstructionSiteDestination
|
||||
);
|
||||
};
|
||||
|
||||
export type CreepDestination =
|
||||
| SpawnDestination
|
||||
| SourceDestination
|
||||
| ControllerDestination
|
||||
| ConstructionSiteDestination;
|
||||
|
||||
Reference in New Issue
Block a user