-
Notifications
You must be signed in to change notification settings - Fork 16
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
7 changed files
with
270 additions
and
7 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions
33
src/main/java/org/terasology/metalrenegades/quests/AddBeaconOverlayEvent.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,33 @@ | ||
/* | ||
* Copyright 2019 MovingBlocks | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.terasology.metalrenegades.quests; | ||
|
||
import org.terasology.entitySystem.entity.EntityRef; | ||
import org.terasology.entitySystem.event.Event; | ||
|
||
/** | ||
* Adds the beacon overlay to the minimap | ||
*/ | ||
public class AddBeaconOverlayEvent implements Event { | ||
public EntityRef beaconEntity; | ||
|
||
public AddBeaconOverlayEvent(EntityRef beaconEntity) { | ||
this.beaconEntity = beaconEntity; | ||
} | ||
|
||
public AddBeaconOverlayEvent() { | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/org/terasology/metalrenegades/quests/DestroyActiveEntityEvent.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,24 @@ | ||
/* | ||
* Copyright 2019 MovingBlocks | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.terasology.metalrenegades.quests; | ||
|
||
import org.terasology.entitySystem.event.Event; | ||
|
||
/** | ||
* Destroys the active quest entity | ||
*/ | ||
public class DestroyActiveEntityEvent implements Event { | ||
} |
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
30 changes: 30 additions & 0 deletions
30
src/main/java/org/terasology/metalrenegades/quests/RemoveBeaconOverlayEvent.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,30 @@ | ||
/* | ||
* Copyright 2019 MovingBlocks | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.terasology.metalrenegades.quests; | ||
|
||
import org.terasology.entitySystem.entity.EntityRef; | ||
import org.terasology.entitySystem.event.Event; | ||
|
||
/** | ||
* Removes the beacon overlay from the minimap | ||
*/ | ||
public class RemoveBeaconOverlayEvent implements Event { | ||
public EntityRef beaconEntity; | ||
|
||
public RemoveBeaconOverlayEvent(EntityRef beaconEntity) { | ||
this.beaconEntity = beaconEntity; | ||
} | ||
} |
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
89 changes: 89 additions & 0 deletions
89
src/main/java/org/terasology/metalrenegades/quests/TaskOverlaySystem.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,89 @@ | ||
/* | ||
* Copyright 2019 MovingBlocks | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.terasology.metalrenegades.quests; | ||
|
||
import org.terasology.entitySystem.entity.EntityManager; | ||
import org.terasology.entitySystem.entity.EntityRef; | ||
import org.terasology.entitySystem.event.ReceiveEvent; | ||
import org.terasology.entitySystem.systems.BaseComponentSystem; | ||
import org.terasology.entitySystem.systems.RegisterMode; | ||
import org.terasology.entitySystem.systems.RegisterSystem; | ||
import org.terasology.logic.players.LocalPlayer; | ||
import org.terasology.logic.players.MinimapSystem; | ||
import org.terasology.network.ClientComponent; | ||
import org.terasology.network.NetworkMode; | ||
import org.terasology.network.NetworkSystem; | ||
import org.terasology.registry.In; | ||
|
||
/** | ||
* Manages the beacon minimap overlay | ||
*/ | ||
@RegisterSystem(RegisterMode.CLIENT) | ||
public class TaskOverlaySystem extends BaseComponentSystem { | ||
|
||
@In | ||
private NetworkSystem networkSystem; | ||
|
||
@In | ||
private EntityManager entityManager; | ||
|
||
@In | ||
private MinimapSystem minimapSystem; | ||
|
||
@In | ||
private LocalPlayer localPlayer; | ||
|
||
private TaskOverlay overlay; | ||
private EntityRef clientEntity; | ||
private boolean isOverlayAdded = false; | ||
|
||
@Override | ||
public void initialise() { | ||
if (networkSystem.getMode() == NetworkMode.CLIENT) { | ||
clientEntity = networkSystem.getServer().getClientEntity(); | ||
} | ||
} | ||
|
||
@ReceiveEvent | ||
public void onAddBeaconOverlayEvent(AddBeaconOverlayEvent event, EntityRef character) { | ||
overlay = new TaskOverlay(event.beaconEntity); | ||
|
||
if (networkSystem.getMode() == NetworkMode.NONE) { | ||
minimapSystem.addOverlay(overlay); | ||
isOverlayAdded = true; | ||
} | ||
|
||
if (networkSystem.getMode() == NetworkMode.CLIENT) { | ||
if (clientEntity.getComponent(ClientComponent.class).character.getId() == character.getId() && !isOverlayAdded) { | ||
minimapSystem.addOverlay(overlay); | ||
isOverlayAdded = true; | ||
} | ||
} | ||
|
||
if (networkSystem.getMode() == NetworkMode.DEDICATED_SERVER && !isOverlayAdded) { | ||
if (localPlayer.getCharacterEntity() == character) { | ||
minimapSystem.addOverlay(overlay); | ||
} | ||
} | ||
} | ||
|
||
@ReceiveEvent | ||
public void onRemoveBeaconOverlayEvent(RemoveBeaconOverlayEvent event, EntityRef character) { | ||
minimapSystem.removeOverlay(overlay); | ||
isOverlayAdded = false; | ||
character.send(new DestroyActiveEntityEvent()); | ||
} | ||
} |