Skip to content

Commit

Permalink
consolidate packages (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderclarktx authored Jan 18, 2024
1 parent 5e11f7c commit a7725c7
Show file tree
Hide file tree
Showing 65 changed files with 102 additions and 142 deletions.
2 changes: 1 addition & 1 deletion docs/piggo-legends-min.js

Large diffs are not rendered by default.

48 changes: 0 additions & 48 deletions modules/contrib/main.ts

This file was deleted.

5 changes: 0 additions & 5 deletions modules/contrib/package.json

This file was deleted.

Empty file removed modules/contrib/readme.md
Empty file.
10 changes: 0 additions & 10 deletions modules/contrib/tsconfig.json

This file was deleted.

51 changes: 50 additions & 1 deletion modules/core/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,53 @@ export * from "./src/ecs/Component";
export * from "./src/net/rtc/RtcPeer";
export * from "./src/net/rtc/RtcPool";
export * from "./src/net/rtc/Compression";
export * from "./src/game/Game";
export * from "./src/Game";
export * from "./src/contrib/components/Actions";
export * from "./src/contrib/components/Actions";
export * from "./src/contrib/components/actions/VehicleMovement";
export * from "./src/contrib/components/actions/WASDMovement";
export * from "./src/contrib/components/actions/ZombieMovement";
export * from "./src/contrib/components/actions/util";
export * from "./src/contrib/components/Controller";
export * from "./src/contrib/components/Health";
export * from "./src/contrib/components/Clickable";
export * from "./src/contrib/components/Collider";
export * from "./src/contrib/components/Debug";
export * from "./src/contrib/components/Name";
export * from "./src/contrib/components/Networked";
export * from "./src/contrib/components/NPC";
export * from "./src/contrib/components/Player";
export * from "./src/contrib/components/Position";
export * from "./src/contrib/components/relationships/Controlling";
export * from "./src/contrib/components/Renderable";
export * from "./src/contrib/components/renderables/Button";
export * from "./src/contrib/components/renderables/Character";
export * from "./src/contrib/components/renderables/DebugBounds";
export * from "./src/contrib/components/renderables/HealthBar";
export * from "./src/contrib/components/renderables/TextBox";
export * from "./src/contrib/entities/Ball";
export * from "./src/contrib/entities/Chat";
export * from "./src/contrib/entities/Cursor";
export * from "./src/contrib/entities/DebugButton";
export * from "./src/contrib/entities/FpsText";
export * from "./src/contrib/entities/FullscreenButton";
export * from "./src/contrib/entities/Skelly";
export * from "./src/contrib/entities/SpaceBackground";
export * from "./src/contrib/entities/Spaceship";
export * from "./src/contrib/entities/TileFloor";
export * from "./src/contrib/entities/TilingSpriteFloor";
export * from "./src/contrib/entities/Wall";
export * from "./src/contrib/entities/Zombie";
export * from "./src/contrib/systems/ClickableSystem";
export * from "./src/contrib/systems/CommandSystem";
export * from "./src/contrib/systems/DebugSystem";
export * from "./src/contrib/systems/EnemySpawnSystem";
export * from "./src/contrib/systems/GuiSystem";
export * from "./src/contrib/systems/NPCSystem";
export * from "./src/contrib/systems/InputSystem";
export * from "./src/contrib/systems/PhysicsSystem";
export * from "./src/contrib/systems/PlayerSpawnSystem";
export * from "./src/contrib/systems/RenderSystem";
export * from "./src/contrib/systems/RtcNetcodeSystem";
export * from "./src/contrib/systems/WsNetcodeSystem";

8 changes: 5 additions & 3 deletions modules/core/src/game/Game.ts → modules/core/src/Game.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Renderer, Entity, System, RtcPool, SystemBuilder } from "@piggo-legends/core";

const hz30 = 1000 / 30;

export type GameProps = {
net?: RtcPool,
renderer?: Renderer,
Expand Down Expand Up @@ -33,7 +35,7 @@ export abstract class Game<T extends GameProps = GameProps> {
if (this.runtimeMode === "client") {
requestAnimationFrame(this.onTick);
} else {
setInterval(this.onTick, 1000 / 30);
setInterval(this.onTick, hz30);
}
}

Expand Down Expand Up @@ -78,13 +80,13 @@ export abstract class Game<T extends GameProps = GameProps> {
onTick = (time: DOMHighResTimeStamp) => {

// skip if 1000 / 30 ms has not passed
if (this.runtimeMode === "client" && (time - this.lastTick) < (1000 / 30)) {
if (this.runtimeMode === "client" && (time - this.lastTick) < hz30) {
if (requestAnimationFrame) requestAnimationFrame(this.onTick);
return;
}

// update the last tick time
this.lastTick = this.lastTick + (1000 / 30);
this.lastTick = this.lastTick + hz30;

// increment tick
this.tick += 1;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ActionMap, Position } from "@piggo-legends/contrib";
import { Entity } from "@piggo-legends/core";
import { Entity, ActionMap, Position } from "@piggo-legends/core";

const TURN_SPEED = 0.1;
const SLIDE_FACTOR = 1.5;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ActionMap, AnimationKeys, Character, Position } from "@piggo-legends/contrib"
import { Entity } from "@piggo-legends/core";
import { ActionMap, AnimationKeys, Character, Entity, Position } from "@piggo-legends/core";

const speed = 2.5;
const speedDiagonal = speed / Math.sqrt(2);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ActionMap, Character, Controlling, Position, Renderable } from "@piggo-legends/contrib";
import { Entity, Game } from "@piggo-legends/core";
import { ActionMap, Character, Entity, Game, Position, Renderable } from "@piggo-legends/core";

const speed = 0.9;
const t = (Math.PI * 2) / 16; // 16th of tau
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Action, Controlled, Controlling } from "@piggo-legends/contrib";
import { Entity, Game, GameProps } from "@piggo-legends/core";
import { Action, Controlled, Controlling, Entity, Game } from "@piggo-legends/core";

export const playerControlsEntity: Action = (entity: Entity, game: Game, player: string) => {
// check that the entity isn't already being controlled
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Graphics, Text } from "pixi.js";
import { Renderable, RenderableProps } from "@piggo-legends/contrib";
import { Renderable, RenderableProps } from "@piggo-legends/core";

export type ButtonProps = RenderableProps & {
dims: { w: number, textX: number, textY: number },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AnimatedSprite, SCALE_MODES } from "pixi.js";
import { Renderable, RenderableProps } from "@piggo-legends/contrib";
import { Renderable, RenderableProps } from "@piggo-legends/core";

export type CharacterProps = RenderableProps & {
animations: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Graphics } from "pixi.js";
import { Renderable, RenderableProps } from "@piggo-legends/contrib";
import { Renderable, RenderableProps } from "@piggo-legends/core";

export type DebugBoundsProps = RenderableProps & {
debugRenderable: Renderable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Health, Renderable, RenderableProps } from "@piggo-legends/contrib";
import { Health, Renderable, RenderableProps } from "@piggo-legends/core";
import { Graphics, Container } from "pixi.js";

export type HealthBarProps = RenderableProps & {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Text } from "pixi.js";
import { Renderable, RenderableProps } from "@piggo-legends/contrib";
import { Renderable, RenderableProps } from "@piggo-legends/core";

export type TextBoxProps = RenderableProps & {
text?: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Clickable, Collider, Debug, Networked, Position, Renderable } from "@piggo-legends/contrib";
import { Clickable, Collider, Debug, Networked, Position, Renderable } from "@piggo-legends/core";
import { Entity } from "@piggo-legends/core";
import { Text } from "pixi.js";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Entity } from "@piggo-legends/core";
import { Position, Renderable, TextBox, chatBuffer, chatHistory, chatIsOpen } from "@piggo-legends/contrib";
import { Position, Renderable, TextBox, chatBuffer, chatHistory, chatIsOpen } from "@piggo-legends/core";
import { Text } from "pixi.js";

export const Chat = (): Entity => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Entity, Renderer } from "@piggo-legends/core";
import { Position, Renderable } from "@piggo-legends/contrib";
import { Position, Renderable } from "@piggo-legends/core";
import { Graphics } from "pixi.js";

export const Cursor = (): Entity => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Entity, Game } from "@piggo-legends/core";
import { Actions, Button, Clickable, Position } from "@piggo-legends/contrib";
import { Actions, Button, Clickable, Position } from "@piggo-legends/core";
import { Text } from "pixi.js";

export const DebugButton = (): Entity => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Entity, Game } from "@piggo-legends/core";
import { Position, Renderable } from "@piggo-legends/contrib";
import { Position, Renderable } from "@piggo-legends/core";
import { Text } from "pixi.js";

export type FpsTextProps = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Entity, Game } from "@piggo-legends/core";
import { Actions, Button, Clickable, Position } from "@piggo-legends/contrib";
import { Actions, Button, Clickable, Position } from "@piggo-legends/core";
import { Text } from "pixi.js";

export const FullscreenButton = (id: string = "fullscreenButton"): Entity => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Entity } from "@piggo-legends/core";
import { Position, Networked, Clickable, Actions, Character, playerControlsEntity, Controller, WASDMovementCommands, Renderable, Health, Collider, WASDMovementPhysics, Debug } from "@piggo-legends/contrib";
import { Assets, AnimatedSprite, SCALE_MODES, Container, Graphics } from "pixi.js";
import { Bodies } from "matter-js";
import { Actions, Character, Clickable, Collider, Controller, Debug, Entity, Health, Networked, Position, Renderable, WASDMovementCommands, WASDMovementPhysics, playerControlsEntity } from "@piggo-legends/core";
import { AnimatedSprite, Assets, Container, Graphics, SCALE_MODES } from "pixi.js";

export const Skelly = async (id: string, tint?: number): Promise<Entity> => {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Entity } from "@piggo-legends/core";
import { Position, Renderable } from "@piggo-legends/contrib";
import { Entity, Position, Renderable } from "@piggo-legends/core";
import { Sprite, TilingSprite } from "pixi.js"

export const SpaceBackground = (): Entity => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Entity } from "@piggo-legends/core";
import { Position, Networked, Clickable, Actions, Character, VehicleMovement, playerControlsEntity, Controller, VehicleMovementCommands, Renderable, Collider, Debug } from "@piggo-legends/contrib";
import { Assets, AnimatedSprite } from "pixi.js";
import { Bodies } from "matter-js";
import { Actions, Character, Clickable, Collider, Controller, Debug, Entity, Networked, Position, Renderable, VehicleMovement, VehicleMovementCommands, playerControlsEntity } from "@piggo-legends/core";
import { AnimatedSprite, Assets } from "pixi.js";

export type SpaceshipProps = {
id?: string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Entity, Renderer } from "@piggo-legends/core";
import { Position, Renderable } from "@piggo-legends/contrib";
import { Entity, Renderer, Position, Renderable } from "@piggo-legends/core";
import { Assets, Texture, Resource, Matrix, Sprite, RenderTexture } from "pixi.js";

let index = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Position, Renderable } from "@piggo-legends/contrib";
import { Entity } from "@piggo-legends/core";
import { Entity, Position, Renderable } from "@piggo-legends/core";
import { Assets, TilingSprite } from "pixi.js";

export const TilingSpriteFloor = async (rows: number, cols: number): Promise<Entity> => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Collider, Debug, Position } from "@piggo-legends/contrib";
import { Entity } from "@piggo-legends/core";
import { Collider, Debug, Entity, Position } from "@piggo-legends/core";

export type WallProps = {
x: number,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Actions, Character, Clickable, Collider, Debug, Health, NPC, Networked, Position, Renderable, ZombieMovement, ZombieMovementCommands } from "@piggo-legends/contrib";
import { Entity, Game } from "@piggo-legends/core";
import { Actions, Character, Clickable, Collider, Debug, Entity, Game, Health, NPC, Networked, Position, Renderable, ZombieMovement, ZombieMovementCommands } from "@piggo-legends/core";
import { AnimatedSprite, Assets, SCALE_MODES } from "pixi.js";

let zombieId = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Entity, SystemBuilder } from "@piggo-legends/core";
import { Actions, Clickable, Position } from "@piggo-legends/contrib";
import { Entity, SystemBuilder, Actions, Clickable, Position } from "@piggo-legends/core";
import { FederatedPointerEvent } from "pixi.js";

export type Click = { x: number, y: number };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Collider, DebugBounds, Position, Renderable, TextBox, worldToScreen } from "@piggo-legends/contrib";
import { Entity, SystemBuilder } from "@piggo-legends/core";
import { Collider, DebugBounds, Entity, Position, Renderable, SystemBuilder, TextBox, worldToScreen } from "@piggo-legends/core";
import { Graphics, Text } from 'pixi.js';

// DebugSystem adds visual debug information to renderered entities
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Zombie } from "@piggo-legends/contrib";
import { Entity, SystemBuilder } from "@piggo-legends/core";
import { Entity, SystemBuilder, Zombie } from "@piggo-legends/core";

// EnemySpawnSystem spawns waves of enemies
export const EnemySpawnSystem: SystemBuilder = ({ game }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Health, HealthBar, Position, Renderable } from "@piggo-legends/contrib";
import { Entity, SystemBuilder } from "@piggo-legends/core";
import { Entity, SystemBuilder, Health, HealthBar, Position, Renderable } from "@piggo-legends/core";

// GuiSystem displays gui elements
export const GuiSystem: SystemBuilder = ({ game, renderer, thisPlayerId, mode }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Entity, Game, SystemBuilder } from "@piggo-legends/core";
import { Actions, Ball, Controlled, Controller, Spaceship, Zombie, localCommandBuffer } from "@piggo-legends/contrib";
import { Actions, Ball, Controlled, Controller, Entity, Game, Spaceship, SystemBuilder, Zombie, localCommandBuffer } from "@piggo-legends/core";

export var chatBuffer: string[] = [];
export var chatHistory: string[] = [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Actions, NPC, localCommandBuffer } from "@piggo-legends/contrib";
import { Entity, SystemBuilder } from "@piggo-legends/core";
import { Entity, SystemBuilder, Actions, NPC, localCommandBuffer } from "@piggo-legends/core";

// NPCSystem invokes ai logic for NPCs
export const NPCSystem: SystemBuilder = ({ game }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Collider, Position } from "@piggo-legends/contrib";
import { Entity, SystemBuilder } from '@piggo-legends/core';
import { Entity, SystemBuilder, Collider, Position } from '@piggo-legends/core';
import { Body, Composite, Engine } from "matter-js";

// PhysicsSystem handles the movement of entities
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Entity, Game, SystemBuilder } from "@piggo-legends/core";
import { Controlled, Controlling, Skelly } from "@piggo-legends/contrib";
import { Entity, Game, SystemBuilder, Controlled, Controlling, Skelly } from "@piggo-legends/core";

// PlayerSpawnSystem handles spawning characters for players
export const PlayerSpawnSystem: SystemBuilder = ({ game, thisPlayerId }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Position, Renderable } from "@piggo-legends/contrib";
import { Entity, SystemBuilder } from '@piggo-legends/core';
import { Entity, SystemBuilder, Position, Renderable } from '@piggo-legends/core';

// RenderSystem handles rendering entities in isometric or cartesian space
export const RenderSystem: SystemBuilder = ({ renderer, mode, game }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Entity, Game, RtcPeer, SystemBuilder } from "@piggo-legends/core";
import { Player, SerializedPosition } from "@piggo-legends/contrib";
import { Entity, Game, RtcPeer, SystemBuilder, Player, SerializedPosition } from "@piggo-legends/core";

type TickData = {
type: "game",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Entity, Game, SystemBuilder } from "@piggo-legends/core";
import { Command, SerializedPosition, localCommandBuffer } from "@piggo-legends/contrib";
import { Entity, Game, SystemBuilder, Command, SerializedPosition, localCommandBuffer } from "@piggo-legends/core";

export type TickData = {
type: "game"
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/ecs/Entity.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Actions, Clickable, Collider, Controlled, Controller, Controlling, Debug, Health, NPC, Name, Networked, Player, Position, Renderable } from "@piggo-legends/contrib";
import { Actions, Clickable, Collider, Controlled, Controller, Controlling, Debug, Health, NPC, Name, Networked, Player, Position, Renderable } from "@piggo-legends/core";

// TODO how to make this extendable
type ComponentTypes =
Expand Down
Loading

0 comments on commit a7725c7

Please sign in to comment.