MCPcopy
hub / github.com/4ian/GDevelop / tweenSetterFactory

Function tweenSetterFactory

Extensions/TweenBehavior/tweentools.ts:65–132  ·  view source on GitHub ↗
(runtimeScene: RuntimeScene)

Source from the content-addressed store, hash-verified

63 // Factory to get the tween setter based on type and options
64 export const tweenSetterFactory =
65 (runtimeScene: RuntimeScene) =>
66 (tweenInformation: TweenInformationNetworkSyncData) => {
67 const type = tweenInformation.type;
68 const layerName = tweenInformation.layerName;
69 const variablePath = tweenInformation.variablePath;
70 const effectName = tweenInformation.effectName;
71 const propertyName = tweenInformation.propertyName;
72
73 if (type === 'variable' && variablePath) {
74 const variable = runtimeScene
75 .getVariables()
76 .getVariableFromPath(variablePath);
77 if (!variable) {
78 return () => {};
79 }
80 return getTweenVariableSetter(variable);
81 }
82 if (type === 'cameraZoom' && layerName !== undefined) {
83 const layer = runtimeScene.getLayer(layerName);
84 return getTweenLayerCameraZoomSetter(layer);
85 }
86 if (type === 'cameraRotation' && layerName !== undefined) {
87 const layer = runtimeScene.getLayer(layerName);
88 return getTweenLayerCameraRotationSetter(layer);
89 }
90 if (type === 'cameraPosition' && layerName !== undefined) {
91 const layer = runtimeScene.getLayer(layerName);
92 return getTweenLayerCameraPositionSetter(layer);
93 }
94 if (
95 type === 'colorEffectProperty' &&
96 layerName !== undefined &&
97 effectName &&
98 propertyName
99 ) {
100 const layer = runtimeScene.getLayer(layerName);
101 const effect = layer.getRendererEffects()[effectName];
102 if (!effect) {
103 logger.error(
104 `The layer "${layerName}" doesn't have any effect called "${effectName}"`
105 );
106 }
107
108 return getTweenColorEffectPropertySetter(effect, propertyName);
109 }
110 if (
111 type === 'numberEffectProperty' &&
112 layerName !== undefined &&
113 effectName &&
114 propertyName
115 ) {
116 const layer = runtimeScene.getLayer(layerName);
117 const effect = layer.getRendererEffects()[effectName];
118 if (!effect) {
119 logger.error(
120 `The layer "${layerName}" doesn't have any effect called "${effectName}"`
121 );
122 }

Callers

nothing calls this directly

Calls 11

getVariableFromPathMethod · 0.80
getRendererEffectsMethod · 0.80
getTweenVariableSetterFunction · 0.70
errorMethod · 0.65
getVariablesMethod · 0.45
getLayerMethod · 0.45

Tested by

no test coverage detected