-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Water/Thirst system improvements and modifications #69
Merged
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8c4d6ec
Add empty water cup & WaterCupComponent
AndyTechGuy f423c5e
Change well operation mechanics to allow refilling of containers
AndyTechGuy 0cc9f5b
Add empty water cups to market
AndyTechGuy c4b4b92
Add water limit to city wells
AndyTechGuy 3f60fa2
Include tooltips for well status
AndyTechGuy e9b94f6
Adjust thirst rate levels
AndyTechGuy b39e727
Various well system fixes & documentation
AndyTechGuy dfdf7f6
Fix well drink limits
AndyTechGuy 3ab6172
Fix well tooltips
AndyTechGuy 85a8fde
Fix merge conflicts in water well system
AndyTechGuy d52da7b
Apply changes from skaldarnar's review of Water Well System
AndyTechGuy 601f352
Remove logic from well source component
AndyTechGuy 4eaaae3
Rearrange logic in onActivate water well system event
AndyTechGuy 00da1ae
Fix merge conflicts in water well system
AndyTechGuy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,6 @@ | |
}, | ||
"InteractionTarget": {}, | ||
"UnbreathableBlock": {}, | ||
"WellSource": {}, | ||
"WellBlock": {}, | ||
"Network": {} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,9 @@ | |
}, | ||
"SimpleSource": { | ||
"needType": "WATER" | ||
}, | ||
"WellSource": { | ||
"refillsLeft": 5, | ||
"capacity": 5 | ||
} | ||
} |
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,15 @@ | ||
{ | ||
"parent": "engine:iconItem", | ||
"DisplayName": { | ||
"name": "Empty Cup" | ||
}, | ||
"Item": { | ||
"stackId": "MetalRenegades:emptyCup", | ||
"icon" : "MetalRenegades:emptyCup", | ||
"cooldownTime": 500, | ||
"maxStackSize": 1 | ||
}, | ||
"WaterCup": { | ||
"filled": false | ||
} | ||
} |
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,18 @@ | ||
{ | ||
"parent": "engine:iconItem", | ||
"DisplayName": { | ||
"name": "Filled Cup" | ||
}, | ||
"Item": { | ||
"stackId": "MetalRenegades:filledCup", | ||
"icon" : "MetalRenegades:filledCup", | ||
"cooldownTime": 500, | ||
"maxStackSize": 1 | ||
}, | ||
"Drink": { | ||
"filling": 100 | ||
}, | ||
"WaterCup": { | ||
"filled": true | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
17 changes: 17 additions & 0 deletions
17
src/main/java/org/terasology/metalrenegades/interaction/component/WaterCupComponent.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,17 @@ | ||
// Copyright 2020 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.terasology.metalrenegades.interaction.component; | ||
|
||
import org.terasology.entitySystem.Component; | ||
|
||
/** | ||
* Component describing the status of particular water cup. | ||
*/ | ||
public class WaterCupComponent implements Component { | ||
|
||
/** | ||
* True if the cup contains water, false otherwise. | ||
*/ | ||
public boolean filled; | ||
|
||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/org/terasology/metalrenegades/interaction/component/WellBlockComponent.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,12 @@ | ||
// Copyright 2020 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.terasology.metalrenegades.interaction.component; | ||
|
||
import org.terasology.entitySystem.Component; | ||
|
||
/** | ||
* Indicates a water source block inside of a well entity, which the player interacts with to gather water. | ||
*/ | ||
public class WellBlockComponent implements Component { | ||
|
||
} |
29 changes: 13 additions & 16 deletions
29
src/main/java/org/terasology/metalrenegades/interaction/component/WellSourceComponent.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 |
---|---|---|
@@ -1,25 +1,22 @@ | ||
/* | ||
* Copyright 2018 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. | ||
*/ | ||
// Copyright 2020 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.terasology.metalrenegades.interaction.component; | ||
|
||
import org.terasology.entitySystem.Component; | ||
|
||
/** | ||
* Indicates a water cup source block, to be used inside wells. | ||
* Indicates a water well entity, that the player can drink from. | ||
*/ | ||
public class WellSourceComponent implements Component { | ||
|
||
/** | ||
* The number of water refills remaining in this well. Replenishes after a certain period of time. | ||
*/ | ||
public int refillsLeft; | ||
|
||
/** | ||
* The maximum number of refills that this well can have. | ||
*/ | ||
public int capacity; | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/org/terasology/metalrenegades/interaction/events/CupFilledEvent.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,36 @@ | ||
// Copyright 2020 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.terasology.metalrenegades.interaction.events; | ||
|
||
import org.terasology.entitySystem.entity.EntityRef; | ||
import org.terasology.entitySystem.event.Event; | ||
|
||
/** | ||
* Fires when a cup item is filled from a well. | ||
*/ | ||
public class CupFilledEvent implements Event { | ||
|
||
/** | ||
* The entity gathering the water. Assumed to be a player entity. | ||
*/ | ||
private final EntityRef gatheringCharacter; | ||
|
||
/** | ||
* The new cup item given to the player upon refilling. | ||
*/ | ||
private final EntityRef cupItem; | ||
|
||
public CupFilledEvent(EntityRef gatheringCharacter, EntityRef cupItem) { | ||
this.gatheringCharacter = gatheringCharacter; | ||
this.cupItem = cupItem; | ||
} | ||
|
||
public EntityRef getGatheringCharacter() { | ||
return gatheringCharacter; | ||
} | ||
|
||
public EntityRef getCupItem() { | ||
return cupItem; | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/org/terasology/metalrenegades/interaction/events/WellDrinkEvent.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,26 @@ | ||
// Copyright 2020 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.terasology.metalrenegades.interaction.events; | ||
|
||
import org.terasology.entitySystem.entity.EntityRef; | ||
import org.terasology.entitySystem.event.Event; | ||
|
||
/** | ||
* Fires when a player drinks directly from a well. | ||
*/ | ||
public class WellDrinkEvent implements Event { | ||
|
||
/** | ||
* The entity drinking the water. Assumed to be a player entity. | ||
*/ | ||
private final EntityRef gatheringCharacter; | ||
|
||
public WellDrinkEvent(EntityRef gatheringCharacter) { | ||
this.gatheringCharacter = gatheringCharacter; | ||
} | ||
|
||
public EntityRef getGatheringCharacter() { | ||
return gatheringCharacter; | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/org/terasology/metalrenegades/interaction/events/WellRefilledEvent.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,11 @@ | ||
// Copyright 2020 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.terasology.metalrenegades.interaction.events; | ||
|
||
import org.terasology.entitySystem.event.Event; | ||
|
||
/** | ||
* Fires when a well gains one more refill. | ||
*/ | ||
public class WellRefilledEvent implements Event { | ||
} |
73 changes: 73 additions & 0 deletions
73
src/main/java/org/terasology/metalrenegades/interaction/systems/WellTooltipSystem.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,73 @@ | ||
// Copyright 2020 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.terasology.metalrenegades.interaction.systems; | ||
|
||
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.nameTags.NameTagComponent; | ||
import org.terasology.metalrenegades.interaction.component.WellSourceComponent; | ||
import org.terasology.metalrenegades.interaction.events.CupFilledEvent; | ||
import org.terasology.metalrenegades.interaction.events.WellDrinkEvent; | ||
import org.terasology.metalrenegades.interaction.events.WellRefilledEvent; | ||
import org.terasology.registry.In; | ||
import org.terasology.rendering.nui.Color; | ||
import org.terasology.world.time.WorldTimeEvent; | ||
|
||
/** | ||
* Adds tooltips to wells about the number of thirst refills available. | ||
*/ | ||
@RegisterSystem(value = RegisterMode.AUTHORITY) | ||
public class WellTooltipSystem extends BaseComponentSystem { | ||
|
||
@In | ||
private EntityManager entityManager; | ||
|
||
@ReceiveEvent | ||
public void onWorldTimeEvent(WorldTimeEvent worldTimeEvent, EntityRef entityRef) { | ||
for (EntityRef waterSource : entityManager.getEntitiesWith(WellSourceComponent.class)) { | ||
if (waterSource.hasComponent(NameTagComponent.class)) { | ||
continue; | ||
} | ||
|
||
NameTagComponent nameTagComponent = new NameTagComponent(); | ||
waterSource.addComponent(nameTagComponent); | ||
updateNameTag(waterSource); | ||
} | ||
} | ||
|
||
@ReceiveEvent(components = {WellSourceComponent.class, NameTagComponent.class}) | ||
public void onCupFilled(CupFilledEvent cupFilledEvent, EntityRef wellEntity) { | ||
updateNameTag(wellEntity); | ||
} | ||
|
||
@ReceiveEvent(components = {WellSourceComponent.class, NameTagComponent.class}) | ||
public void onWellDrink(WellDrinkEvent wellDrinkEvent, EntityRef wellEntity) { | ||
updateNameTag(wellEntity); | ||
} | ||
|
||
@ReceiveEvent(components = {WellSourceComponent.class, NameTagComponent.class}) | ||
public void onWellRefill(WellRefilledEvent wellRefilledEvent, EntityRef wellEntity) { | ||
updateNameTag(wellEntity); | ||
} | ||
|
||
/** | ||
* Updates the name tag above a well entity to show the number of remaining water refills. | ||
* | ||
* @param wellEntity The well entity to update. | ||
*/ | ||
private void updateNameTag(EntityRef wellEntity) { | ||
WellSourceComponent wellSourceComponent = wellEntity.getComponent(WellSourceComponent.class); | ||
NameTagComponent nameTagComponent = wellEntity.getComponent(NameTagComponent.class); | ||
AndyTechGuy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
nameTagComponent.text = String.format("Drinks: %d/%d", wellSourceComponent.refillsLeft, wellSourceComponent.capacity); | ||
nameTagComponent.textColor = Color.BLUE; | ||
nameTagComponent.yOffset = 2f; | ||
nameTagComponent.scale = 1f; | ||
wellEntity.saveComponent(nameTagComponent); | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like that we copy-paste the cup icon around - we should find a way to share this between JS (ManualLabor?) and MetalRenegades. Please have a look at the discussion in Terasology/ManualLabor#31
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it would be very nice to be able to take some of the more useful parts of ManualLabor without needing to use the more complicated portions of that module. If the fluid containers portion of ML could be separated into it's own module that would be fantastic.
If I remember right I think that a lot of the texture assets in ManualLabor come from a Spritesheet (I had to crop it out of the sheet myself). I don't know how easy that would be to separate into different modules.