Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
splican committed Jan 9, 2024
2 parents 5bf42a0 + a57cfc5 commit a45e16e
Show file tree
Hide file tree
Showing 42 changed files with 1,322 additions and 1,044 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ export default class MockBackendAdapter implements IBackendPort {
spaceDescription: "rdescription4",
spaceGoals: ["rgoals4"],
spaceSlotContents: [4],
requiredPointsToComplete: 3,
requiredPointsToComplete: 0,
requiredSpacesToEnter: "(3)v((2)^(1))",
spaceTemplate: "arcade",
spaceTemplateStyle: "",
Expand All @@ -1101,7 +1101,7 @@ export default class MockBackendAdapter implements IBackendPort {
spaceDescription: "rdescription5",
spaceGoals: ["rgoals5"],
spaceSlotContents: [5],
requiredPointsToComplete: 1,
requiredPointsToComplete: 0,
requiredSpacesToEnter: "4",
spaceTemplate: "suburb",
spaceTemplateStyle: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const BUILDER_TYPES = {
IBreakTimeNotificationBuilder: Symbol("IBreakTimeNotificationBuilder"),
ILoadingScreenBuilder: Symbol("ILoadingScreenBuilder"),
IStoryElementBuilder: Symbol("IStoryElementBuilder"),
IStoryNPCBuilder: Symbol("IStoryNPCBuilder"),
};

export default BUILDER_TYPES;
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import HelpDeskButtonBuilder from "~ReactComponents/GeneralComponents/HelpDeskBu
import AdaptivityElementBuilder from "../../Presentation/Adaptivity/AdaptivityElement/AdaptivityElementBuilder";
import BreakTimeNotificationBuilder from "../../Presentation/Adaptivity/BreakTimeNotification/BreakTimeNotificationBuilder";
import LoadingScreenBuilder from "~ReactComponents/GeneralComponents/LoadingScreen/LoadingScreenBuilder";
import StoryNPCBuilder from "../../Presentation/Babylon/StoryNPC/StoryNPCBuilder";
import StoryElementBuilder from "~ReactComponents/LearningSpaceDisplay/StoryElement/StoryElementBuilder";

const BuilderDIContainer = new ContainerModule((bind) => {
Expand Down Expand Up @@ -137,6 +138,9 @@ const BuilderDIContainer = new ContainerModule((bind) => {
bind<IPresentationBuilder>(BUILDER_TYPES.IStoryElementBuilder).to(
StoryElementBuilder
);
bind<IPresentationBuilder>(BUILDER_TYPES.IStoryNPCBuilder).to(
StoryNPCBuilder
);
});

export default BuilderDIContainer;
43 changes: 13 additions & 30 deletions src/Components/Core/Presentation/Babylon/Avatar/AvatarController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import {
EventState,
KeyboardEventTypes,
KeyboardInfo,
LinesMesh,
MeshBuilder,
Nullable,
PointerEventTypes,
PointerInfo,
Expand All @@ -14,7 +12,6 @@ import bind from "bind-decorator";
import SCENE_TYPES, {
ScenePresenterFactory,
} from "~DependencyInjection/Scenes/SCENE_TYPES";
import { config } from "../../../../../config";
import CoreDIContainer from "../../../DependencyInjection/CoreDIContainer";
import CORE_TYPES from "../../../DependencyInjection/CoreTypes";
import INavigation from "../Navigation/INavigation";
Expand All @@ -31,7 +28,6 @@ export default class AvatarController implements IAvatarController {

private scenePresenter: IScenePresenter;
private navigation: INavigation;
private pathLine: LinesMesh;

private keyMovementTarget: Nullable<Vector3> = null;
private pointerMovementTarget: Nullable<Vector3> = null;
Expand All @@ -57,32 +53,33 @@ export default class AvatarController implements IAvatarController {
@bind
private applyInputs(): void {
if (this.keyMovementTarget !== null) {
this.navigation.Crowd.agentGoto(
this.viewModel.agentIndex,
this.keyMovementTarget
);
this.viewModel.movementTarget.Value = this.keyMovementTarget;

this.debug_drawPath(this.keyMovementTarget);
this.viewModel.characterNavigator.startMovement(
this.keyMovementTarget,
this.onMovementTargetReached
);
} else if (this.pointerMovementTarget !== null) {
const movementDistance = this.pointerMovementTarget
.subtract(this.viewModel.parentNode.position)
.length();

if (movementDistance > this.viewModel.pointerMovementThreshold) {
this.navigation.Crowd.agentGoto(
this.viewModel.agentIndex,
this.pointerMovementTarget
);
this.viewModel.movementTarget.Value = this.pointerMovementTarget;

this.debug_drawPath(this.pointerMovementTarget);
this.viewModel.characterNavigator.startMovement(
this.pointerMovementTarget,
this.onMovementTargetReached
);
}
}
this.pointerMovementTarget = null;
this.keyMovementTarget = null;
}

@bind
private onMovementTargetReached(): void {
this.viewModel.movementTarget.Value = null;
}

@bind
private processKeyboardEvent(
eventData: KeyboardInfo,
Expand Down Expand Up @@ -152,18 +149,4 @@ export default class AvatarController implements IAvatarController {
this.lastFramePosition = this.viewModel.parentNode.position;
}
}

private debug_drawPath(target: Vector3): void {
if (config.isDebug === false) return;

let pathPoints = this.navigation.Plugin.computePath(
this.navigation.Crowd.getAgentPosition(this.viewModel.agentIndex),
target
);
this.pathLine = MeshBuilder.CreateDashedLines(
"navigation path",
{ points: pathPoints, updatable: true, instance: this.pathLine },
this.scenePresenter.Scene
);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { injectable } from "inversify";
import AvatarViewModel, { AvatarAnimationAction } from "./AvatarViewModel";
import AvatarViewModel from "./AvatarViewModel";
import IAvatarPresenter from "./IAvatarPresenter";
import LearningElementTO from "src/Components/Core/Application/DataTransferObjects/LearningElementTO";
import CharacterAnimationActions from "../CharacterAnimator/CharacterAnimationActions";

/**
* @class AvatarPresenter
Expand All @@ -16,8 +17,8 @@ export default class AvatarPresenter implements IAvatarPresenter {
}

public onLearningElementLoaded(learningElementTO: LearningElementTO): void {
this.viewModel.animationStateMachine.applyAction(
AvatarAnimationAction.InteractionStarted
this.viewModel.characterAnimator.transition(
CharacterAnimationActions.InteractionStarted
);
}
}
Loading

0 comments on commit a45e16e

Please sign in to comment.