-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
58 changed files
with
973 additions
and
456 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
engine-tests/src/main/resources/org/terasology/unittest/module.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"id" : "unittest", | ||
"version" : "5.0.0", | ||
"version" : "5.1.0", | ||
"displayName" : "Terasology Engine Test", | ||
"description" : "Engine unit test content" | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
engine/src/main/java/org/terasology/engine/core/modes/AbstractState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Copyright 2021 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.terasology.engine.core.modes; | ||
|
||
import org.terasology.engine.context.Context; | ||
import org.terasology.engine.core.ComponentSystemManager; | ||
import org.terasology.engine.core.bootstrap.EntitySystemSetupUtil; | ||
import org.terasology.engine.entitySystem.entity.EntityRef; | ||
import org.terasology.engine.entitySystem.entity.internal.EngineEntityManager; | ||
import org.terasology.engine.entitySystem.event.internal.EventSystem; | ||
import org.terasology.engine.logic.console.Console; | ||
import org.terasology.engine.logic.console.ConsoleImpl; | ||
import org.terasology.engine.logic.console.ConsoleSystem; | ||
import org.terasology.engine.logic.console.commands.CoreCommands; | ||
import org.terasology.engine.logic.players.LocalPlayer; | ||
import org.terasology.engine.network.ClientComponent; | ||
import org.terasology.engine.recording.DirectionAndOriginPosRecorderList; | ||
import org.terasology.engine.recording.RecordAndReplayCurrentStatus; | ||
import org.terasology.engine.registry.CoreRegistry; | ||
import org.terasology.engine.rendering.nui.NUIManager; | ||
import org.terasology.engine.rendering.nui.internal.NUIManagerInternal; | ||
import org.terasology.engine.rendering.nui.internal.TerasologyCanvasRenderer; | ||
import org.terasology.nui.canvas.CanvasRenderer; | ||
|
||
import static com.google.common.base.Verify.verifyNotNull; | ||
|
||
public abstract class AbstractState implements GameState { | ||
protected Context context; | ||
protected EngineEntityManager entityManager; | ||
protected EventSystem eventSystem; | ||
protected ComponentSystemManager componentSystemManager; | ||
|
||
protected void initEntityAndComponentManagers() { | ||
verifyNotNull(context); | ||
CoreRegistry.setContext(context); | ||
|
||
// let's get the entity event system running | ||
EntitySystemSetupUtil.addEntityManagementRelatedClasses(context); | ||
entityManager = context.get(EngineEntityManager.class); | ||
|
||
eventSystem = context.get(EventSystem.class); | ||
context.put(Console.class, new ConsoleImpl(context)); | ||
|
||
NUIManager nuiManager = new NUIManagerInternal((TerasologyCanvasRenderer) context.get(CanvasRenderer.class), context); | ||
context.put(NUIManager.class, nuiManager); | ||
|
||
componentSystemManager = new ComponentSystemManager(context); | ||
context.put(ComponentSystemManager.class, componentSystemManager); | ||
|
||
componentSystemManager.register(new ConsoleSystem(), "engine:ConsoleSystem"); | ||
componentSystemManager.register(new CoreCommands(), "engine:CoreCommands"); | ||
} | ||
|
||
protected static void createLocalPlayer(Context context) { | ||
EngineEntityManager entityManager = context.get(EngineEntityManager.class); | ||
EntityRef localPlayerEntity = entityManager.create(new ClientComponent()); | ||
LocalPlayer localPlayer = new LocalPlayer(); | ||
localPlayer.setRecordAndReplayClasses(context.get(DirectionAndOriginPosRecorderList.class), | ||
context.get(RecordAndReplayCurrentStatus.class)); | ||
context.put(LocalPlayer.class, localPlayer); | ||
localPlayer.setClientEntity(localPlayerEntity); | ||
} | ||
|
||
@Override | ||
public void dispose(boolean shuttingDown) { | ||
// Apparently this can be disposed of before it is completely initialized? Probably only during | ||
// crashes, but crashing again during shutdown complicates the diagnosis. | ||
if (eventSystem != null) { | ||
eventSystem.process(); | ||
} | ||
if (componentSystemManager != null) { | ||
componentSystemManager.shutdown(); | ||
} | ||
if (entityManager != null) { | ||
entityManager.clear(); | ||
} | ||
} | ||
|
||
@Override | ||
public Context getContext() { | ||
return context; | ||
} | ||
} |
Oops, something went wrong.