Skip to content

Commit

Permalink
fix: Tween component used in the actions (#102)
Browse files Browse the repository at this point in the history
* fix: Tween component used in the actions

* fix: Tween component used in the triggers
  • Loading branch information
cyaiox authored Mar 25, 2024
1 parent 7701aaa commit 657ac72
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export function createActionsSystem(engine: IEngine) {
UiText,
UiBackground,
Name,
Tween: TweenComponent,
} = getExplorerComponents(engine)
const { Actions, States, Counter, Triggers } = getComponents(engine)

Expand Down Expand Up @@ -495,7 +496,7 @@ export function createActionsSystem(engine: IEngine) {
const end = Vector3.create(tween.end.x, tween.end.y, tween.end.z)
const endPosition = relative ? Vector3.add(transform.position, end) : end

Tween.createOrReplace(entity, {
TweenComponent.createOrReplace(entity, {
mode: Tween.Mode.Move({
start: transform.position,
end: endPosition,
Expand All @@ -521,7 +522,7 @@ export function createActionsSystem(engine: IEngine) {
? Quaternion.multiply(transform.rotation, end)
: end

Tween.createOrReplace(entity, {
TweenComponent.createOrReplace(entity, {
mode: Tween.Mode.Rotate({
start: transform.rotation,
end: endRotation,
Expand All @@ -541,7 +542,7 @@ export function createActionsSystem(engine: IEngine) {
const end = Vector3.create(tween.end.x, tween.end.y, tween.end.z)
const endScale = relative ? Vector3.add(transform.scale, end) : end

Tween.createOrReplace(entity, {
TweenComponent.createOrReplace(entity, {
mode: Tween.Mode.Scale({
start: transform.scale,
end: endScale,
Expand Down
2 changes: 1 addition & 1 deletion src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
Billboard as defineBillboard,
Name as defineName,
Tween as defineTween,
TweenSequence as defineTweenSequence
TweenSequence as defineTweenSequence,
} from '@dcl/ecs/dist/components'
import { IEngine } from '@dcl/sdk/ecs'
import { EngineComponents } from './definitions'
Expand Down
8 changes: 5 additions & 3 deletions src/triggers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
InputAction,
LastWriteWinElementSetComponentDefinition,
DeepReadonlyObject,
Tween,
PointerEventsSystem,
TweenSystem,
} from '@dcl/sdk/ecs'
Expand Down Expand Up @@ -58,7 +57,7 @@ export function createTriggersSystem(
pointerEventsSystem: PointerEventsSystem,
tweenSystem: TweenSystem,
) {
const { Transform } = components
const { Transform, Tween: TweenComponent } = components
const { Actions, States, Counter, Triggers } = getComponents(engine)

// save reference to the init function
Expand Down Expand Up @@ -394,7 +393,10 @@ export function createTriggersSystem(

// ON_TWEEN_END
function handleOnTweenEnd(entity: Entity) {
if (Tween.getOrNull(entity) && tweenSystem.tweenCompleted(entity)) {
if (
TweenComponent.getOrNull(entity) &&
tweenSystem.tweenCompleted(entity)
) {
const triggerEvents = getTriggerEvents(entity)
triggerEvents.emit(TriggerType.ON_TWEEN_END)
}
Expand Down

0 comments on commit 657ac72

Please sign in to comment.