diff --git a/src/controllers/CameraC.ts b/src/controllers/Camera/CameraC.ts similarity index 100% rename from src/controllers/CameraC.ts rename to src/controllers/Camera/CameraC.ts diff --git a/src/controllers/Presets/Movment/CameraMovment/FollowCamera.ts b/src/controllers/Camera/FollowCamera.ts similarity index 97% rename from src/controllers/Presets/Movment/CameraMovment/FollowCamera.ts rename to src/controllers/Camera/FollowCamera.ts index b244307..e796cd3 100644 --- a/src/controllers/Presets/Movment/CameraMovment/FollowCamera.ts +++ b/src/controllers/Camera/FollowCamera.ts @@ -1,7 +1,7 @@ import { Delegate, Helper, Template, UpdateController } from "@24tools/playable_template"; import { Object3D, Vector3 } from "three"; -import { ThreeC } from "../../../ThreeC"; -import { CameraC } from "../../../CameraC"; +import { ThreeC } from "../core/ThreeC"; +import { CameraC } from "./CameraC"; export class FollowCameraC { private static updateDelegate: Delegate; diff --git a/src/controllers/Presets/Enums/BaseAnimation.ts b/src/controllers/Enums/BaseAnimation.ts similarity index 100% rename from src/controllers/Presets/Enums/BaseAnimation.ts rename to src/controllers/Enums/BaseAnimation.ts diff --git a/src/controllers/Presets/Enums/MeshType.ts b/src/controllers/Enums/MeshType.ts similarity index 100% rename from src/controllers/Presets/Enums/MeshType.ts rename to src/controllers/Enums/MeshType.ts diff --git a/src/controllers/Map/PropType.ts b/src/controllers/Enums/PropType.ts similarity index 100% rename from src/controllers/Map/PropType.ts rename to src/controllers/Enums/PropType.ts diff --git a/src/controllers/Resources/ResourceType.ts b/src/controllers/Enums/ResourceType.ts similarity index 100% rename from src/controllers/Resources/ResourceType.ts rename to src/controllers/Enums/ResourceType.ts diff --git a/src/controllers/Presets/Enums/ResourcesType.ts b/src/controllers/Enums/ResourcesType.ts similarity index 100% rename from src/controllers/Presets/Enums/ResourcesType.ts rename to src/controllers/Enums/ResourcesType.ts diff --git a/src/controllers/Map/DepositZoneC.ts b/src/controllers/Map/DepositZoneC.ts index a999da9..fefb3a0 100644 --- a/src/controllers/Map/DepositZoneC.ts +++ b/src/controllers/Map/DepositZoneC.ts @@ -1,6 +1,6 @@ import { EasyEvent, UpdateController } from "@24tools/playable_template"; import { Box3, Object3D, Vector3 } from "three"; -import { Player } from "../Presets/Player"; +import { Player } from "../Player/Player"; import { findInteractiveZoneFromMap, INTERACTIVE_ZONE_NAME, diff --git a/src/controllers/Map/GatherC.ts b/src/controllers/Map/GatherC.ts index 3afae6b..1d7368c 100644 --- a/src/controllers/Map/GatherC.ts +++ b/src/controllers/Map/GatherC.ts @@ -1,8 +1,8 @@ import { EasyEvent, JoystickC, UpdateController } from "@24tools/playable_template"; import { Vector3 } from "three"; import { PhysicsTriggerC } from "./PhysicsTriggerC"; -import { PropC, PropRegistry } from "./PropC"; -import { Player } from "../Presets/Player"; +import { PropC, PropRegistry } from "../Props/PropC"; +import { Player } from "../Player/Player"; export class GatherC { static readonly onCombatIdle = new EasyEvent<{}>(); diff --git a/src/controllers/Map/Map.ts b/src/controllers/Map/Map.ts index ff4ad6d..19d09d8 100644 --- a/src/controllers/Map/Map.ts +++ b/src/controllers/Map/Map.ts @@ -1,10 +1,10 @@ import { Box3, BoxGeometry, Mesh, Object3D, Vector3 } from "three"; -import { ThreeC } from "../ThreeC"; -import { PhysicsBody, PhysicsLayer } from "../PhysicsC"; +import { ThreeC } from "../core/ThreeC"; +import { PhysicsBody, PhysicsLayer } from "../core/PhysicsC"; import { PhysicsTriggerC } from "./PhysicsTriggerC"; -import { PropC } from "./PropC"; -import { findDamageStateLayers } from "./PropDamageLayers"; -import { resolvePropType } from "../Resources/PropDropTable"; +import { PropC } from "../Props/PropC"; +import { findDamageStateLayers } from "../Props/PropDamageLayers"; +import { resolvePropType } from "../Props/PropDropTable"; import { InteractiveZoneC } from "./InteractiveZoneC"; import { ToolZoneC } from "./ToolZoneC"; diff --git a/src/controllers/Map/PhysicsTriggerC.ts b/src/controllers/Map/PhysicsTriggerC.ts index c7cdce7..b0ce1b2 100644 --- a/src/controllers/Map/PhysicsTriggerC.ts +++ b/src/controllers/Map/PhysicsTriggerC.ts @@ -4,7 +4,7 @@ import { } from "@24tools/playable_template"; import { Box3, Object3D, Vector3 } from "three"; import { Body } from "cannon-es"; -import { PLAYER_COLLIDER_RADIUS } from "../PhysicsC"; +import { PLAYER_COLLIDER_RADIUS } from "../core/PhysicsC"; const PLAYER_RADIUS = PLAYER_COLLIDER_RADIUS; diff --git a/src/controllers/Presets/Character/Character.ts b/src/controllers/Player/Character/Character.ts similarity index 99% rename from src/controllers/Presets/Character/Character.ts rename to src/controllers/Player/Character/Character.ts index 85ea62d..1e8967b 100644 --- a/src/controllers/Presets/Character/Character.ts +++ b/src/controllers/Player/Character/Character.ts @@ -1,7 +1,7 @@ import { EasyEvent, UpdateController } from "@24tools/playable_template"; import { AnimationAction, AnimationClip, AnimationMixer, LoopOnce, LoopRepeat, Object3D, Vector3 } from "three"; import { clone } from "three/examples/jsm/utils/SkeletonUtils"; -import { ThreeC } from "../../ThreeC"; +import { ThreeC } from "../../core/ThreeC"; import { GLTF } from "three/examples/jsm/loaders/GLTFLoader"; import { Easing, Group, Tween } from "@tweenjs/tween.js"; diff --git a/src/controllers/Presets/Input/MoveInput.ts b/src/controllers/Player/Input/MoveInput.ts similarity index 100% rename from src/controllers/Presets/Input/MoveInput.ts rename to src/controllers/Player/Input/MoveInput.ts diff --git a/src/controllers/Presets/Input/PlayerInput.ts b/src/controllers/Player/Input/PlayerInput.ts similarity index 97% rename from src/controllers/Presets/Input/PlayerInput.ts rename to src/controllers/Player/Input/PlayerInput.ts index 45d50ab..b00e0c8 100644 --- a/src/controllers/Presets/Input/PlayerInput.ts +++ b/src/controllers/Player/Input/PlayerInput.ts @@ -1,10 +1,30 @@ import { Delegate, JoystickC } from "@24tools/playable_template"; import { Vector3 } from "three"; import { IMoveInput } from "./MoveInput"; -import { FollowCameraC } from "../Movment/CameraMovment/FollowCamera"; +import { FollowCameraC } from "../../Camera/FollowCamera"; export class PlayerInput implements IMoveInput { private static threshold = 0.25; + protected currentDirection = new Vector3(); + private moveDelegate: Delegate; + private stopDelegate: Delegate; + private startDelegate: Delegate; + inputActive = false; + + constructor() { + this.moveDelegate = JoystickC.onJoysticMove.addDelegate(this.onTouchMove.bind(this)); + JoystickC.onJoysticDown.addListener(this.moveDelegate); + this.stopDelegate = JoystickC.onJoysticEnd.addDelegate(this.onTouchUp.bind(this)); + this.startDelegate = JoystickC.onJoysticStart.addDelegate(this.onTouchDown.bind(this)); + } + + get CurrentDirection() { + return this.currentDirection; + } + + get IsActive() { + return this.inputActive; + } public static initJoystick() { const screenSize = window.screenSize; @@ -21,28 +41,6 @@ export class PlayerInput implements IMoveInput { JoystickC.init(options); } - protected currentDirection = new Vector3(); - private moveDelegate: Delegate; - private stopDelegate: Delegate; - private startDelegate: Delegate; - - get CurrentDirection() { - return this.currentDirection; - } - - get IsActive() { - return this.inputActive; - } - - inputActive = false; - - constructor() { - this.moveDelegate = JoystickC.onJoysticMove.addDelegate(this.onTouchMove.bind(this)); - JoystickC.onJoysticDown.addListener(this.moveDelegate); - this.stopDelegate = JoystickC.onJoysticEnd.addDelegate(this.onTouchUp.bind(this)); - this.startDelegate = JoystickC.onJoysticStart.addDelegate(this.onTouchDown.bind(this)); - } - onTouchMove(payload: any) { this.getDirection(payload, this.currentDirection); if (this.currentDirection.length() <= PlayerInput.threshold) { diff --git a/src/controllers/Presets/Movment/MoveC.ts b/src/controllers/Player/Movement/MoveC.ts similarity index 99% rename from src/controllers/Presets/Movment/MoveC.ts rename to src/controllers/Player/Movement/MoveC.ts index 76ef2b3..48a38b6 100644 --- a/src/controllers/Presets/Movment/MoveC.ts +++ b/src/controllers/Player/Movement/MoveC.ts @@ -6,6 +6,11 @@ export class MoveC { private speed: number; private readonly moveDirection = new Vector3(); + constructor(input: IMoveInput, speed = 5) { + this.input = input; + this.speed = speed; + } + get Direction() { return this.moveDirection; } @@ -18,10 +23,6 @@ export class MoveC { this.speed = speed; } - constructor(input: IMoveInput, speed = 5) { - this.input = input; - this.speed = speed; - } update(_delta: number) { this.moveDirection.copy(this.input.CurrentDirection).multiplyScalar(this.speed); diff --git a/src/controllers/Presets/Movment/RotationC.ts b/src/controllers/Player/Movement/RotationC.ts similarity index 100% rename from src/controllers/Presets/Movment/RotationC.ts rename to src/controllers/Player/Movement/RotationC.ts diff --git a/src/controllers/Presets/Player.ts b/src/controllers/Player/Player.ts similarity index 94% rename from src/controllers/Presets/Player.ts rename to src/controllers/Player/Player.ts index b4dd4a7..49e8756 100644 --- a/src/controllers/Presets/Player.ts +++ b/src/controllers/Player/Player.ts @@ -1,18 +1,18 @@ import { Delegate, ResourcesC, Template, UpdateController } from "@24tools/playable_template"; import { Character } from "./Character/Character"; -import { ResourcesType } from "./Enums/ResourcesType"; -import { MeshType } from "./Enums/MeshType"; +import { ResourcesType } from "../Enums/ResourcesType"; +import { MeshType } from "../Enums/MeshType"; import { GLTF } from "three/examples/jsm/loaders/GLTFLoader"; -import { PhysicsBody, PhysicsLayer, PLAYER_COLLIDER_RADIUS } from "../PhysicsC"; +import { PhysicsBody, PhysicsLayer, PLAYER_COLLIDER_RADIUS } from "../core/PhysicsC"; import { Object3D, Vector3 } from "three"; -import { ThreeC } from "../ThreeC"; +import { ThreeC } from "../core/ThreeC"; import { PlayerInput } from "./Input/PlayerInput"; -import { MoveC } from "./Movment/MoveC"; -import { Vector3CToT } from "./Helper"; -import { RotationC } from "./Movment/RotationC"; -import { FollowCameraC } from "./Movment/CameraMovment/FollowCamera"; +import { MoveC } from "./Movement/MoveC"; +import { Vector3CToT } from "../utils/Helper"; +import { RotationC } from "./Movement/RotationC"; +import { FollowCameraC } from "../Camera/FollowCamera"; import { PhysicsTriggerC } from "../Map/PhysicsTriggerC"; -import { PropHpUIC } from "../Map/PropHpUIC"; +import { PropHpUIC } from "../Props/PropHpUIC"; import { PlayerContext } from "./PlayerState/PlayerContext"; import { PlayerStateMachine } from "./PlayerState/PlayerStateMachine"; import { PlayerStateType } from "./PlayerState/PlayerStateType"; diff --git a/src/controllers/Presets/PlayerState/IPlayerState.ts b/src/controllers/Player/PlayerState/IPlayerState.ts similarity index 100% rename from src/controllers/Presets/PlayerState/IPlayerState.ts rename to src/controllers/Player/PlayerState/IPlayerState.ts diff --git a/src/controllers/Presets/PlayerState/PlayerContext.ts b/src/controllers/Player/PlayerState/PlayerContext.ts similarity index 91% rename from src/controllers/Presets/PlayerState/PlayerContext.ts rename to src/controllers/Player/PlayerState/PlayerContext.ts index c25926e..2cfabb1 100644 --- a/src/controllers/Presets/PlayerState/PlayerContext.ts +++ b/src/controllers/Player/PlayerState/PlayerContext.ts @@ -1,11 +1,11 @@ import { Object3D, Vector3 } from "three"; import { Character } from "../Character/Character"; -import { MoveC } from "../Movment/MoveC"; -import { RotationC } from "../Movment/RotationC"; -import { PhysicsBody } from "../../PhysicsC"; +import { MoveC } from "../Movement/MoveC"; +import { RotationC } from "../Movement/RotationC"; +import { PhysicsBody } from "../../core/PhysicsC"; import { PlayerStateMachine } from "./PlayerStateMachine"; import { PlayerStateType } from "./PlayerStateType"; -import { BaseAnimation } from "../Enums/BaseAnimation"; +import { BaseAnimation } from "../../Enums/BaseAnimation"; import { COMBAT_EXIT_FADE } from "./combatConstants"; export class PlayerContext { diff --git a/src/controllers/Presets/PlayerState/PlayerStateMachine.ts b/src/controllers/Player/PlayerState/PlayerStateMachine.ts similarity index 99% rename from src/controllers/Presets/PlayerState/PlayerStateMachine.ts rename to src/controllers/Player/PlayerState/PlayerStateMachine.ts index 1ec0de7..8f42a5e 100644 --- a/src/controllers/Presets/PlayerState/PlayerStateMachine.ts +++ b/src/controllers/Player/PlayerState/PlayerStateMachine.ts @@ -6,11 +6,7 @@ export class PlayerStateMachine { private activeState: IPlayerState; private currentStateType: PlayerStateType; private readonly states: Map; - - get currentState(): PlayerStateType { - return this.currentStateType; - } - + constructor( private readonly context: PlayerContext, states: Map, @@ -22,6 +18,10 @@ export class PlayerStateMachine { this.activeState.enter(this.context); } + get currentState(): PlayerStateType { + return this.currentStateType; + } + setState(stateType: PlayerStateType) { if (this.currentStateType === stateType) return; diff --git a/src/controllers/Presets/PlayerState/PlayerStateType.ts b/src/controllers/Player/PlayerState/PlayerStateType.ts similarity index 100% rename from src/controllers/Presets/PlayerState/PlayerStateType.ts rename to src/controllers/Player/PlayerState/PlayerStateType.ts diff --git a/src/controllers/Presets/PlayerState/combatConstants.ts b/src/controllers/Player/PlayerState/combatConstants.ts similarity index 100% rename from src/controllers/Presets/PlayerState/combatConstants.ts rename to src/controllers/Player/PlayerState/combatConstants.ts diff --git a/src/controllers/Presets/PlayerState/states/IdleState.ts b/src/controllers/Player/PlayerState/states/IdleState.ts similarity index 92% rename from src/controllers/Presets/PlayerState/states/IdleState.ts rename to src/controllers/Player/PlayerState/states/IdleState.ts index 1b1979d..cd00575 100644 --- a/src/controllers/Presets/PlayerState/states/IdleState.ts +++ b/src/controllers/Player/PlayerState/states/IdleState.ts @@ -1,4 +1,4 @@ -import { BaseAnimation } from "../../Enums/BaseAnimation"; +import { BaseAnimation } from "../../../Enums/BaseAnimation"; import { IPlayerState } from "../IPlayerState"; import { PlayerContext } from "../PlayerContext"; import { PlayerStateType } from "../PlayerStateType"; diff --git a/src/controllers/Presets/PlayerState/states/LootState.ts b/src/controllers/Player/PlayerState/states/LootState.ts similarity index 97% rename from src/controllers/Presets/PlayerState/states/LootState.ts rename to src/controllers/Player/PlayerState/states/LootState.ts index 0be9646..13af5a7 100644 --- a/src/controllers/Presets/PlayerState/states/LootState.ts +++ b/src/controllers/Player/PlayerState/states/LootState.ts @@ -1,4 +1,4 @@ -import { BaseAnimation } from "../../Enums/BaseAnimation"; +import { BaseAnimation } from "../../../Enums/BaseAnimation"; import { ATTACK_STRIKE_MARKS, LOOT_ENTER_FADE, diff --git a/src/controllers/Presets/PlayerState/states/RunState.ts b/src/controllers/Player/PlayerState/states/RunState.ts similarity index 96% rename from src/controllers/Presets/PlayerState/states/RunState.ts rename to src/controllers/Player/PlayerState/states/RunState.ts index 7d4ef39..d9eb91b 100644 --- a/src/controllers/Presets/PlayerState/states/RunState.ts +++ b/src/controllers/Player/PlayerState/states/RunState.ts @@ -1,7 +1,7 @@ import { Vector3 } from "three"; -import { BaseAnimation } from "../../Enums/BaseAnimation"; -import { Vector3CToT, Vector3TToC } from "../../Helper"; -import { FollowCameraC } from "../../Movment/CameraMovment/FollowCamera"; +import { BaseAnimation } from "../../../Enums/BaseAnimation"; +import { Vector3CToT, Vector3TToC } from "../../../utils/Helper"; +import { FollowCameraC } from "../../../Camera/FollowCamera"; import { RUN_ENTER_FADE } from "../combatConstants"; import { IPlayerState } from "../IPlayerState"; import { PlayerContext } from "../PlayerContext"; diff --git a/src/controllers/Presets/PlayerState/states/TurnToTargetState.ts b/src/controllers/Player/PlayerState/states/TurnToTargetState.ts similarity index 92% rename from src/controllers/Presets/PlayerState/states/TurnToTargetState.ts rename to src/controllers/Player/PlayerState/states/TurnToTargetState.ts index 23cc3e6..67b2196 100644 --- a/src/controllers/Presets/PlayerState/states/TurnToTargetState.ts +++ b/src/controllers/Player/PlayerState/states/TurnToTargetState.ts @@ -1,4 +1,4 @@ -import { BaseAnimation } from "../../Enums/BaseAnimation"; +import { BaseAnimation } from "../../../Enums/BaseAnimation"; import { TURN_IDLE_FADE } from "../combatConstants"; import { IPlayerState } from "../IPlayerState"; import { PlayerContext } from "../PlayerContext"; diff --git a/src/controllers/Map/PropC.ts b/src/controllers/Props/PropC.ts similarity index 96% rename from src/controllers/Map/PropC.ts rename to src/controllers/Props/PropC.ts index 69aee83..9c6d3aa 100644 --- a/src/controllers/Map/PropC.ts +++ b/src/controllers/Props/PropC.ts @@ -1,10 +1,10 @@ import { EasyEvent, UpdateController } from "@24tools/playable_template"; import { Euler, Material, Mesh, Object3D, Vector3 } from "three"; -import { PhysicsBody } from "../PhysicsC"; -import { PropType } from "./PropType"; -import { PhysicsTriggerC } from "./PhysicsTriggerC"; -import { PROP_DROPS } from "../Resources/PropDropTable"; -import { createDropPlan, PropDropPlan } from "../Resources/PropDropPlanner"; +import { PhysicsBody } from "../core/PhysicsC"; +import { PropType } from "../Enums/PropType"; +import { PhysicsTriggerC } from "../Map/PhysicsTriggerC"; +import { PROP_DROPS } from "./PropDropTable"; +import { createDropPlan, PropDropPlan } from "./PropDropPlanner"; import { ResourceSpawnC } from "../Resources/ResourceSpawnC"; import { PropHpUIC } from "./PropHpUIC"; import { PropHpBar } from "./PropHpBar"; diff --git a/src/controllers/Map/PropDamageLayers.ts b/src/controllers/Props/PropDamageLayers.ts similarity index 100% rename from src/controllers/Map/PropDamageLayers.ts rename to src/controllers/Props/PropDamageLayers.ts diff --git a/src/controllers/Resources/PropDropPlanner.ts b/src/controllers/Props/PropDropPlanner.ts similarity index 96% rename from src/controllers/Resources/PropDropPlanner.ts rename to src/controllers/Props/PropDropPlanner.ts index d450137..3d618c0 100644 --- a/src/controllers/Resources/PropDropPlanner.ts +++ b/src/controllers/Props/PropDropPlanner.ts @@ -1,4 +1,4 @@ -import { ResourceType } from "./ResourceType"; +import { ResourceType } from "../Enums/ResourceType"; function randomInt(min: number, max: number) { return Math.floor(Math.random() * (max - min + 1)) + min; diff --git a/src/controllers/Resources/PropDropTable.ts b/src/controllers/Props/PropDropTable.ts similarity index 87% rename from src/controllers/Resources/PropDropTable.ts rename to src/controllers/Props/PropDropTable.ts index 2268b67..8742a72 100644 --- a/src/controllers/Resources/PropDropTable.ts +++ b/src/controllers/Props/PropDropTable.ts @@ -1,5 +1,5 @@ -import { PropType } from "../Map/PropType"; -import { ResourceType } from "./ResourceType"; +import { PropType } from "../Enums/PropType"; +import { ResourceType } from "../Enums/ResourceType"; export type DropRule = { resource: ResourceType; diff --git a/src/controllers/Map/PropHpBar.ts b/src/controllers/Props/PropHpBar.ts similarity index 98% rename from src/controllers/Map/PropHpBar.ts rename to src/controllers/Props/PropHpBar.ts index 8bc3b34..f1c78a4 100644 --- a/src/controllers/Map/PropHpBar.ts +++ b/src/controllers/Props/PropHpBar.ts @@ -13,8 +13,8 @@ import { } from "three"; import { ResourcesC } from "@24tools/playable_template"; import { GLTF } from "three/examples/jsm/loaders/GLTFLoader"; -import { ThreeC } from "../ThreeC"; -import { ResourcesType } from "../Presets/Enums/ResourcesType"; +import { ThreeC } from "../core/ThreeC"; +import { ResourcesType } from "../Enums/ResourcesType"; import { PropC } from "./PropC"; const HP_BAR_MESH = "hpBar"; @@ -61,14 +61,6 @@ export class PropHpBar { private visible = false; private hasTakenDamage = false; - static getPrefab(): Object3D | null { - const fromScene = ThreeC.getObject(HP_BAR_MESH); - if (fromScene) return fromScene; - - const gltf = ResourcesC.getResource(ResourcesType.Mesh, HP_BAR_MESH); - return gltf?.scene ?? null; - } - constructor(prop: PropC, parent: Object3D) { const template = PropHpBar.getPrefab(); if (!template) { @@ -108,6 +100,14 @@ export class PropHpBar { this.applyWidths(); } + static getPrefab(): Object3D | null { + const fromScene = ThreeC.getObject(HP_BAR_MESH); + if (fromScene) return fromScene; + + const gltf = ResourcesC.getResource(ResourcesType.Mesh, HP_BAR_MESH); + return gltf?.scene ?? null; + } + onDamage() { this.hasTakenDamage = true; diff --git a/src/controllers/Map/PropHpUIC.ts b/src/controllers/Props/PropHpUIC.ts similarity index 98% rename from src/controllers/Map/PropHpUIC.ts rename to src/controllers/Props/PropHpUIC.ts index 9568662..b63e8e1 100644 --- a/src/controllers/Map/PropHpUIC.ts +++ b/src/controllers/Props/PropHpUIC.ts @@ -1,6 +1,6 @@ import { Object3D } from "three"; import { UpdateController } from "@24tools/playable_template"; -import { ThreeC } from "../ThreeC"; +import { ThreeC } from "../core/ThreeC"; import { PropC } from "./PropC"; import { PropHpBar } from "./PropHpBar"; diff --git a/src/controllers/Map/PropVfxC.ts b/src/controllers/Props/PropVfxC.ts similarity index 94% rename from src/controllers/Map/PropVfxC.ts rename to src/controllers/Props/PropVfxC.ts index a06643e..6d7b81b 100644 --- a/src/controllers/Map/PropVfxC.ts +++ b/src/controllers/Props/PropVfxC.ts @@ -1,10 +1,10 @@ import { BatchedRenderer, QuarksLoader, QuarksUtil } from "three.quarks"; import { Object3D, Euler, Vector3 } from "three"; import { ResourcesC, UpdateController } from "@24tools/playable_template"; -import { ThreeC } from "../ThreeC"; +import { ThreeC } from "../core/ThreeC"; import { TimeC } from "../Timers/TimeC"; import { VFXType } from "../Enums/VFXType"; -import { ResourcesType } from "../Presets/Enums/ResourcesType"; +import { ResourcesType } from "../Enums/ResourcesType"; export class PropVfxC { static batchRenderer: BatchedRenderer; diff --git a/src/controllers/Resources/ResourceConfig.ts b/src/controllers/Resources/ResourceConfig.ts index fb6abad..624542c 100644 --- a/src/controllers/Resources/ResourceConfig.ts +++ b/src/controllers/Resources/ResourceConfig.ts @@ -1,4 +1,4 @@ -import { ResourceType } from "./ResourceType"; +import { ResourceType } from "../Enums/ResourceType"; export const RESOURCE_PLACEHOLDER_COLORS: Record = { [ResourceType.Wood]: "#6b4423", diff --git a/src/controllers/Resources/ResourceDepositC.ts b/src/controllers/Resources/ResourceDepositC.ts index 1a02188..ebe6109 100644 --- a/src/controllers/Resources/ResourceDepositC.ts +++ b/src/controllers/Resources/ResourceDepositC.ts @@ -5,12 +5,12 @@ import { GatherC } from "../Map/GatherC"; import { DepositZoneC } from "../Map/DepositZoneC"; import { InteractiveZoneC } from "../Map/InteractiveZoneC"; import { ToolZoneC } from "../Map/ToolZoneC"; -import { Player } from "../Presets/Player"; -import { ThreeC } from "../ThreeC"; +import { Player } from "../Player/Player"; +import { ThreeC } from "../core/ThreeC"; import { TickScheduler, ScheduledCall } from "../Timers/TickScheduler"; import { ResourceInventoryC } from "./ResourceInventoryC"; import { ResourceScreenFly } from "./ResourceScreenFly"; -import { ResourceType } from "./ResourceType"; +import { ResourceType } from "../Enums/ResourceType"; import { ResourceUIC } from "./ResourceUIC"; /** Screen-space flight duration (icon → deposit zone). Сповільнено для ефекту «поглинання». */ diff --git a/src/controllers/Resources/ResourceFlyC.ts b/src/controllers/Resources/ResourceFlyC.ts index b8df592..5668607 100644 --- a/src/controllers/Resources/ResourceFlyC.ts +++ b/src/controllers/Resources/ResourceFlyC.ts @@ -1,11 +1,11 @@ import { UpdateController } from "@24tools/playable_template"; import { Easing, Group, Tween } from "@tweenjs/tween.js"; import { Object3D, Vector3 } from "three"; -import { ThreeC } from "../ThreeC"; +import { ThreeC } from "../core/ThreeC"; import { TickScheduler, ScheduledCall } from "../Timers/TickScheduler"; import { ResourceInventoryC } from "./ResourceInventoryC"; import { ResourceScreenFly } from "./ResourceScreenFly"; -import { ResourceType } from "./ResourceType"; +import { ResourceType } from "../Enums/ResourceType"; import { ResourceUIC } from "./ResourceUIC"; const FALL_MS = 300; diff --git a/src/controllers/Resources/ResourceInventoryC.ts b/src/controllers/Resources/ResourceInventoryC.ts index 7f827c2..5a06260 100644 --- a/src/controllers/Resources/ResourceInventoryC.ts +++ b/src/controllers/Resources/ResourceInventoryC.ts @@ -1,5 +1,5 @@ import { EasyEvent } from "@24tools/playable_template"; -import { ResourceType } from "./ResourceType"; +import { ResourceType } from "../Enums/ResourceType"; export class ResourceInventoryC { private static amounts = new Map(); diff --git a/src/controllers/Resources/ResourceScreenFly.ts b/src/controllers/Resources/ResourceScreenFly.ts index 57928dd..b2644cb 100644 --- a/src/controllers/Resources/ResourceScreenFly.ts +++ b/src/controllers/Resources/ResourceScreenFly.ts @@ -7,10 +7,10 @@ import { Vector3, } from "three"; import { GLTF } from "three/examples/jsm/loaders/GLTFLoader"; -import { CameraC } from "../CameraC"; -import { ResourcesType } from "../Presets/Enums/ResourcesType"; -import { ThreeC } from "../ThreeC"; -import { ResourceType } from "./ResourceType"; +import { CameraC } from "../Camera/CameraC"; +import { ResourcesType } from "../Enums/ResourcesType"; +import { ThreeC } from "../core/ThreeC"; +import { ResourceType } from "../Enums/ResourceType"; export type ScreenPoint = { x: number; diff --git a/src/controllers/Resources/ResourceSpawnC.ts b/src/controllers/Resources/ResourceSpawnC.ts index e6992d1..1314160 100644 --- a/src/controllers/Resources/ResourceSpawnC.ts +++ b/src/controllers/Resources/ResourceSpawnC.ts @@ -1,7 +1,7 @@ import { Vector3 } from "three"; -import { PropC } from "../Map/PropC"; +import { PropC } from "../Props/PropC"; import { ResourceFlyC } from "./ResourceFlyC"; -import { ResourceType } from "./ResourceType"; +import { ResourceType } from "../Enums/ResourceType"; export class ResourceSpawnC { static spawnFromProp(prop: PropC, type: ResourceType, count: number) { diff --git a/src/controllers/Resources/ResourceUIC.ts b/src/controllers/Resources/ResourceUIC.ts index 831f650..5446653 100644 --- a/src/controllers/Resources/ResourceUIC.ts +++ b/src/controllers/Resources/ResourceUIC.ts @@ -1,6 +1,6 @@ import { UI_IMAGES } from "../../resources/images/uiImages"; import { ResourceInventoryC } from "./ResourceInventoryC"; -import { ResourceType } from "./ResourceType"; +import { ResourceType } from "../Enums/ResourceType"; import { RESOURCE_PLACEHOLDER_COLORS } from "./ResourceConfig"; type ResourceUIEntry = { diff --git a/src/controllers/TestSceneC.ts b/src/controllers/TestSceneC.ts deleted file mode 100644 index 3a50ff2..0000000 --- a/src/controllers/TestSceneC.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { ThreeC } from "./ThreeC"; -import { Player } from "./Presets/Player"; -import { Map } from "./Map/Map"; -import { GatherC } from "./Map/GatherC"; -import { DepositZoneC } from "./Map/DepositZoneC"; -import { ResourceUIC } from "./Resources/ResourceUIC"; -import { ResourceFlyC } from "./Resources/ResourceFlyC"; -import { ResourceDepositC } from "./Resources/ResourceDepositC"; -import { PropHpUIC } from "./Map/PropHpUIC"; -import { PropVfxC } from "./Map/PropVfxC"; -import { InvasionProgressUIC } from "./UI/InvasionProgressUIC"; -import { PreGameplayUIC } from "./UI/PreGameplayUIC"; - -export class TestSceneC { - static init() { - InvasionProgressUIC.init(); - ResourceUIC.init(); - PreGameplayUIC.init(); - ResourceFlyC.init(); - PropHpUIC.init(); - PropVfxC.Init(); - Map.init(); - PropHpUIC.bringOverlayToFront(); - GatherC.init(); - Player.init(); - PropHpUIC.bringOverlayToFront(); - - const mapObject = ThreeC.getObject("map"); - if (mapObject) { - DepositZoneC.init(mapObject); - } - - ResourceDepositC.init(); - } -} diff --git a/src/controllers/PhysicsC.ts b/src/controllers/core/PhysicsC.ts similarity index 75% rename from src/controllers/PhysicsC.ts rename to src/controllers/core/PhysicsC.ts index 63812e7..34ac83f 100644 --- a/src/controllers/PhysicsC.ts +++ b/src/controllers/core/PhysicsC.ts @@ -1,8 +1,4 @@ -import { - Delegate, - Physics_internal, - UpdateController, -} from "@24tools/playable_template"; +import { Physics_internal } from "@24tools/playable_template"; import { Box3, Mesh, Object3D, Quaternion as ThreeQuaternion, Vector3 } from "three"; import { Body, Box, Shape, Sphere, Vec3 } from "cannon-es"; @@ -18,7 +14,6 @@ export const PLAYER_COLLIDER_RADIUS = 0.5; export class PhysicsBody { private body: Body; - private pair: PhysicsObjPair | null = null; constructor( threeObj: Object3D, @@ -89,12 +84,6 @@ export class PhysicsBody { return this; } - disablePhysicsPair() { - if (this.pair) { - this.pair.destroyed = true; - } - } - getPhysicsBody() { return this.body; } @@ -106,32 +95,4 @@ export class PhysicsBody { (this.body as any) = null; } -} - -export class PhysicsObjPair { - threeObj: Object3D; - physicsObj: Body; - destroyed: boolean; - delegateId: null | Delegate; - - constructor(threeObj: Object3D, physicsObj: Body) { - this.threeObj = threeObj; - this.physicsObj = physicsObj; - this.destroyed = false; - - this.delegateId = UpdateController.Instance.onUpdate.addDelegate(() => { - this.update(); - }); - } - - update() { - if (this.destroyed) return; - - if (this.threeObj && this.physicsObj) { - // @ts-ignore - this.threeObj.position.copy(this.physicsObj.position); - // @ts-ignore - this.threeObj.quaternion.copy(this.physicsObj.quaternion); - } - } -} +} \ No newline at end of file diff --git a/src/controllers/core/TestSceneC.ts b/src/controllers/core/TestSceneC.ts new file mode 100644 index 0000000..46307a2 --- /dev/null +++ b/src/controllers/core/TestSceneC.ts @@ -0,0 +1,35 @@ +import { ThreeC } from "./ThreeC"; +import { Player } from "../Player/Player"; +import { Map } from "../Map/Map"; +import { GatherC } from "../Map/GatherC"; +import { DepositZoneC } from "../Map/DepositZoneC"; +import { ResourceUIC } from "../Resources/ResourceUIC"; +import { ResourceFlyC } from "../Resources/ResourceFlyC"; +import { ResourceDepositC } from "../Resources/ResourceDepositC"; +import { PropHpUIC } from "../Props/PropHpUIC"; +import { PropVfxC } from "../Props/PropVfxC"; +import { InvasionProgressUIC } from "../UI/InvasionProgressUIC"; +import { PreGameplayUIC } from "../UI/PreGameplayUIC"; + +export class TestSceneC { + static init() { + InvasionProgressUIC.init(); + ResourceUIC.init(); + PreGameplayUIC.init(); + ResourceFlyC.init(); + PropHpUIC.init(); + PropVfxC.Init(); + Map.init(); + PropHpUIC.bringOverlayToFront(); + GatherC.init(); + Player.init(); + PropHpUIC.bringOverlayToFront(); + + const mapObject = ThreeC.getObject("map"); + if (mapObject) { + DepositZoneC.init(mapObject); + } + + ResourceDepositC.init(); + } +} diff --git a/src/controllers/ThreeC.ts b/src/controllers/core/ThreeC.ts similarity index 100% rename from src/controllers/ThreeC.ts rename to src/controllers/core/ThreeC.ts diff --git a/src/controllers/Presets/Helper.ts b/src/controllers/utils/Helper.ts similarity index 100% rename from src/controllers/Presets/Helper.ts rename to src/controllers/utils/Helper.ts diff --git a/src/templateConfig/afterResourcesLoadedCb.ts b/src/templateConfig/afterResourcesLoadedCb.ts index eb346c6..575aeba 100644 --- a/src/templateConfig/afterResourcesLoadedCb.ts +++ b/src/templateConfig/afterResourcesLoadedCb.ts @@ -1,4 +1,4 @@ -import { TestSceneC } from "../controllers/TestSceneC"; +import { TestSceneC } from "../controllers/core/TestSceneC"; import { SoundC, Template } from "@24tools/playable_template"; export const afterResourcesLoadedCb: (() => void) | undefined = () => { diff --git a/src/templateConfig/beforeResourcesLoadedCb.ts b/src/templateConfig/beforeResourcesLoadedCb.ts index 1507cbe..b579c72 100644 --- a/src/templateConfig/beforeResourcesLoadedCb.ts +++ b/src/templateConfig/beforeResourcesLoadedCb.ts @@ -9,10 +9,10 @@ import { FilterScene, InstallBanner, } from "@24tools/playable_template"; -import { CameraC } from "../controllers/CameraC"; -import { ThreeC } from "../controllers/ThreeC"; -import { Player } from "../controllers/Presets/Player"; -import { PlayerInput } from "../controllers/Presets/Input/PlayerInput"; +import { CameraC } from "../controllers/Camera/CameraC"; +import { ThreeC } from "../controllers/core/ThreeC"; +import { Player } from "../controllers/Player/Player"; +import { PlayerInput } from "../controllers/Player/Input/PlayerInput"; import { Color } from "three"; import { Vec3 } from "cannon-es"; export const beforeResourcesLoadedCb = () => { diff --git a/src/templateConfig/resizeCb.ts b/src/templateConfig/resizeCb.ts index e4957b6..a98b9bd 100644 --- a/src/templateConfig/resizeCb.ts +++ b/src/templateConfig/resizeCb.ts @@ -1,5 +1,5 @@ import { Template3d } from "@24tools/playable_template"; -import { CameraC } from "../controllers/CameraC"; +import { CameraC } from "../controllers/Camera/CameraC"; export const resizeCb = () => { Template3d.resize(); diff --git a/stats.html b/stats.html index e19d6f6..73b9ec0 100644 --- a/stats.html +++ b/stats.html @@ -4929,7 +4929,7 @@ var drawChart = (function (exports) {