Skip to content

Commit ed6e55e

Browse files
committed
fix(update): many updates
1 parent d00405b commit ed6e55e

8 files changed

Lines changed: 21 additions & 15 deletions

File tree

packages/app/lib/classes/App.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import InventoryAppModule from './appModule/Inventory';
2424
import ShopAppModule from './appModule/Shop';
2525
import TimeAppModule from './appModule/Time';
2626
import LightAppModule from './appModule/Light';
27-
import type { UnitIdentifier } from './Unit';
27+
import type { UnitIdentifier } from '../types/unit';
2828

2929
type AppModuleList = (
3030
| typeof CursorAppModule

packages/app/lib/classes/Unit.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,12 @@ import {
3737
ROTATION_TYPE,
3838
rotationDirections
3939
} from '../utils/rotation';
40-
import type { UnitDescription, UnitType } from '../types/unit';
40+
import type { UnitDescription, UnitIdentifier, UnitType } from '../types/unit';
4141
import type { TextureMaps } from '../types/textures';
4242
import type { ConditionDirectionsDescription } from '../utils/pathfindng';
4343
import { rotateVector2 } from '../utils/vector';
4444
import { prepareTexture } from '../utils/texture';
4545

46-
export type UnitIdentifier = string;
4746
declare module '../../lib/utils/object' {
4847
interface ObjectUserData {
4948
UNIT: string;

packages/app/lib/classes/appModule/Multiplayer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { Vector3 } from 'three';
2020
import CurrentPlayer from '../player/Current';
2121
import type App from '../App';
2222
import type { PlayerSettings } from '../../types/player';
23-
import type { UnitIdentifier } from '../Unit';
23+
import type { UnitIdentifier } from '../../types/unit';
2424

2525
export interface Message {
2626
id: string;

packages/app/lib/classes/appModule/Player.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { UnitIdentifier } from './../Unit';
1+
import type { UnitIdentifier } from '../../types/unit';
22
import { ReplaySubject, Subject } from 'rxjs';
33
import AppModule, {
44
type AppModuleObservables,

packages/app/lib/classes/appModule/Room.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ import { OBJECT_NAME } from '../../utils/object';
2626
import type Unit from '../Unit';
2727
import type { IntersectionListener } from '../rendererModule/Intersection';
2828
import CharacterUnitModule from '../unitModule/Character';
29-
import TeleporterUnit from '../unit/Teleporter';
30-
import type { UnitIdentifier } from '../Unit';
29+
import type TeleporterUnit from '../unit/Teleporter';
30+
import type { UnitIdentifier } from '../../types/unit';
3131
import BedUnitModule from '../unitModule/Bed';
3232
import ChairUnitModule from '../unitModule/Chair';
33-
import { TELEPORTER_TYPE } from '../unitModule/Teleporter';
33+
import TeleporterUnitModule, {
34+
TELEPORTER_TYPE
35+
} from '../unitModule/Teleporter';
3436
import BenchUnitModule from '../unitModule/Bench';
3537
import SlotUnitModule from '../unitModule/Slot';
3638

@@ -156,11 +158,12 @@ export default class RoomAppModule extends AppModule<State, Observables> {
156158
} else if (unit.getPosition().equals(new Vector3(0, 0, 0))) {
157159
const entranceTeleporter = room.modules.units
158160
.getUnits()
159-
.filter(unit => unit instanceof TeleporterUnit)
161+
.filter(unit => unit.hasModuleType(TeleporterUnitModule))
160162
.find(
161163
teleporterUnit =>
162-
teleporterUnit.modules.teleporter.state.type ==
163-
TELEPORTER_TYPE.ENTRANCE
164+
teleporterUnit.getModuleByType<TeleporterUnitModule>(
165+
TeleporterUnitModule
166+
).state.type == TELEPORTER_TYPE.ENTRANCE
164167
) as TeleporterUnit;
165168

166169
unitTeleporter = entranceTeleporter;

packages/app/lib/classes/unitModule/Movement.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { getRadByRotation, getRotationByPosition } from '../../utils/rotation';
3434
import TeleporterUnitModule, { TELEPORTER_TYPE } from './Teleporter';
3535
import CharacterUnitModule from './Character';
3636
import BedUnitModule, { type BedOptions } from './Bed';
37-
import TeleporterUnit from '../unit/Teleporter';
37+
import type TeleporterUnit from '../unit/Teleporter';
3838
import { ANIMATION_ACTION } from '../../types/animation';
3939
import SlotUnitModule from './Slot';
4040
import type { BenchUnitOptions } from '../unit/Bench';
@@ -345,8 +345,10 @@ export default class MovementUnitModule extends UnitModule<
345345
//#region teleporter
346346
if (
347347
targetUnit &&
348-
targetUnit instanceof TeleporterUnit &&
349-
targetUnit.modules.teleporter.getType() === TELEPORTER_TYPE.TELEPORTER
348+
targetUnit.hasModuleType(TeleporterUnitModule) &&
349+
targetUnit
350+
.getModuleByType<TeleporterUnitModule>(TeleporterUnitModule)
351+
.getType() === TELEPORTER_TYPE.TELEPORTER
350352
) {
351353
const teleporterUnit = targetUnit as TeleporterUnit;
352354
characterModule.useTeleporter(teleporterUnit);

packages/app/lib/classes/unitModule/Teleporter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import UnitModule, {
77
} from '../UnitModule';
88
import { UNIT_TYPE } from '../../types/unit';
99
import type Unit from '../Unit';
10-
import type { UnitIdentifier } from '../Unit';
10+
import type { UnitIdentifier } from '../../types/unit';
1111
import type TeleporterUnit from '../unit/Teleporter';
1212

1313
declare module '../../types/unit' {

packages/app/lib/types/unit.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import type { Vector3 } from 'three';
22
import type { UnitModuleState } from '../classes/UnitModule';
33
import type { ROTATION } from '../utils/rotation';
44

5+
export type UnitIdentifier = string;
6+
57
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
68
export interface UnitType {}
79

0 commit comments

Comments
 (0)