Skip to content

Commit 6e6fcc2

Browse files
committed
Changed init cleanup to attach detach
1 parent c11cf48 commit 6e6fcc2

File tree

6 files changed

+25
-78
lines changed

6 files changed

+25
-78
lines changed

src/main/java/engine/components/AbstractComponent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ public void setOwner(SceneNode owner) {
3737
public SceneNode getOwner() {
3838
return owner;
3939
}
40-
40+
4141
}

src/main/java/engine/components/CinematicBlackBarsRenderer.java

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -192,28 +192,12 @@ private void renderBottomBar(Graphics g) {
192192
(int) currentSize);
193193
}
194194

195-
/**
196-
* Initialization logic for this renderer.
197-
* <p>
198-
* Currently unimplemented but provided as a placeholder for any setup
199-
* required when initializing this component in a larger system.
200-
* </p>
201-
*/
202195
@Override
203-
public void initialize() {
204-
// Placeholder for initialization logic.
196+
public void onAttach() {
205197
}
206198

207-
/**
208-
* Cleans up resources when the renderer is no longer needed.
209-
* <p>
210-
* Currently unimplemented but can be used to clean up graphics resources,
211-
* listeners, or other allocated resources in a larger system.
212-
* </p>
213-
*/
214199
@Override
215-
public void cleanup() {
216-
// Placeholder for cleanup logic.
200+
public void onDetach() {
217201
}
218202

219203
}

src/main/java/engine/components/CircularAnimationComponent.java

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,28 +99,12 @@ public void update(float tpf) {
9999
transform.setPosition(x, transform.getPosition().y, z);
100100
}
101101

102-
/**
103-
* Handles any initialization logic required before the animation starts.
104-
* <p>
105-
* Currently, this is left blank but can be implemented if preconditions need
106-
* to be set before the animation begins.
107-
* </p>
108-
*/
109102
@Override
110-
public void initialize() {
111-
// Placeholder for potential initialization logic
103+
public void onAttach() {
112104
}
113105

114-
/**
115-
* Handles any cleanup logic when the animation component is no longer needed.
116-
* <p>
117-
* Currently, this is left blank but can be implemented if resources need to
118-
* be released or reset during cleanup.
119-
* </p>
120-
*/
121106
@Override
122-
public void cleanup() {
123-
// Placeholder for potential cleanup logic
107+
public void onDetach() {
124108
}
125109

126110
}

src/main/java/engine/components/ControlWASD.java

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,6 @@ public ControlWASD(Input input, float speed) {
7373
this.speed = speed;
7474
}
7575

76-
/**
77-
* Initializes the component. Currently no initialization logic is required,
78-
* but this is provided as a placeholder for future logic.
79-
*/
80-
@Override
81-
public void initialize() {
82-
// No additional initialization logic required at this stage.
83-
}
84-
8576
/**
8677
* Updates the movement of the owning node based on keyboard input.
8778
* <p>
@@ -113,12 +104,16 @@ public void update(float tpf) {
113104
*/
114105
private Vector3f handleInput() {
115106
Vector3f velocity = new Vector3f();
116-
107+
117108
// Check for movement inputs
118-
if (input.isKeyPressed(Key.W)) velocity.addLocal(0, 0, -1);
119-
if (input.isKeyPressed(Key.A)) velocity.addLocal(-1, 0, 0);
120-
if (input.isKeyPressed(Key.S)) velocity.addLocal(0, 0, 1);
121-
if (input.isKeyPressed(Key.D)) velocity.addLocal(1, 0, 0);
109+
if (input.isKeyPressed(Key.W))
110+
velocity.addLocal(0, 0, -1);
111+
if (input.isKeyPressed(Key.A))
112+
velocity.addLocal(-1, 0, 0);
113+
if (input.isKeyPressed(Key.S))
114+
velocity.addLocal(0, 0, 1);
115+
if (input.isKeyPressed(Key.D))
116+
velocity.addLocal(1, 0, 0);
122117

123118
// Normalize diagonal movement to prevent unintended speed boosts
124119
if (velocity.length() > 0) {
@@ -127,16 +122,6 @@ private Vector3f handleInput() {
127122
return velocity;
128123
}
129124

130-
/**
131-
* Cleans up resources when the component is removed or the application is
132-
* shutting down. Currently, there is no cleanup logic necessary, but this is
133-
* a placeholder for extensibility.
134-
*/
135-
@Override
136-
public void cleanup() {
137-
// Cleanup logic placeholder
138-
}
139-
140125
/**
141126
* Retrieves the current movement speed multiplier.
142127
*
@@ -167,4 +152,12 @@ public void setSpeed(float speed) {
167152
this.speed = speed;
168153
}
169154

155+
@Override
156+
public void onAttach() {
157+
}
158+
159+
@Override
160+
public void onDetach() {
161+
}
162+
170163
}

src/main/java/engine/components/Geometry.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,24 +153,12 @@ public void update(float tpf) {
153153
// Placeholder for potential mesh state updates
154154
}
155155

156-
/**
157-
* Called when the component is attached to a parent object in the scene. This
158-
* method is a hook for additional initialization or setup when the component
159-
* is added.
160-
*/
161156
@Override
162157
public void onAttach() {
163-
// Hook for additional setup on attachment
164158
}
165159

166-
/**
167-
* Called when the component is detached from its parent object in the scene.
168-
* This method is a hook for cleanup or other actions when the component is
169-
* removed.
170-
*/
171160
@Override
172161
public void onDetach() {
173-
// Hook for cleanup on detachment
174162
}
175163

176164
}

src/main/java/engine/components/RotationComponent.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,11 @@ public float getAngularSpeed() {
112112
}
113113

114114
@Override
115-
public void initialize() {
116-
// Initialization logic if needed
115+
public void onAttach() {
117116
}
118117

119118
@Override
120-
public void cleanup() {
121-
// Cleanup logic if needed
119+
public void onDetach() {
122120
}
123-
121+
124122
}

0 commit comments

Comments
 (0)