-
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
Implementing names for characters #49
Changes from 3 commits
772286f
a414ce0
60caaa4
5843960
c71ae52
3dfd71b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -28,6 +28,7 @@ | |||||
import org.terasology.entitySystem.systems.RegisterMode; | ||||||
import org.terasology.entitySystem.systems.RegisterSystem; | ||||||
import org.terasology.entitySystem.systems.UpdateSubscriberSystem; | ||||||
import org.terasology.logic.common.DisplayNameComponent; | ||||||
import org.terasology.logic.inventory.InventoryManager; | ||||||
import org.terasology.logic.inventory.events.GiveItemEvent; | ||||||
import org.terasology.logic.location.LocationComponent; | ||||||
|
@@ -40,10 +41,15 @@ | |||||
import org.terasology.metalrenegades.economy.TraderComponent; | ||||||
import org.terasology.metalrenegades.economy.actions.ShowTradingScreenAction; | ||||||
import org.terasology.metalrenegades.minimap.events.AddCharacterToOverlayEvent; | ||||||
import org.terasology.namegenerator.creature.CreatureAssetTheme; | ||||||
import org.terasology.namegenerator.creature.CreatureNameProvider; | ||||||
import org.terasology.registry.In; | ||||||
|
||||||
import java.util.ArrayList; | ||||||
import java.util.Collection; | ||||||
import java.util.Random; | ||||||
|
||||||
import static org.terasology.namegenerator.creature.CreatureAssetTheme.COUNTRY; | ||||||
|
||||||
/** | ||||||
* Spawns new citizens inside of available buildings with {@link PotentialHomeComponent}. | ||||||
|
@@ -65,6 +71,8 @@ public class CitizenSpawnSystem extends BaseComponentSystem implements UpdateSub | |||||
@In | ||||||
private InventoryManager inventoryManager; | ||||||
|
||||||
private Random random = new Random(); | ||||||
|
||||||
@Override | ||||||
public void update(float delta) { | ||||||
spawnTimer += delta; | ||||||
|
@@ -126,6 +134,12 @@ private EntityRef spawnCitizen(EntityRef homeEntity) { | |||||
|
||||||
EntityRef entityRef = entityBuilder.build(); | ||||||
|
||||||
if(entityRef.hasComponent(DisplayNameComponent.class)) { | ||||||
DisplayNameComponent displayNameComponent = entityRef.getComponent(DisplayNameComponent.class); | ||||||
CreatureNameProvider creatureNameProvider = new CreatureNameProvider(random.nextLong(), CreatureAssetTheme.COUNTRY); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
displayNameComponent.name = creatureNameProvider.generateName(); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you also need to save the component again? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, will add that. However, I feel like it doesn't really make a difference here. |
||||||
} | ||||||
|
||||||
if (entityRef.hasComponent(TraderComponent.class)) { | ||||||
entityRef.addComponent(createTradeDialogComponent()); | ||||||
setupStartInventory(entityRef); | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -33,16 +33,20 @@ | |||||
import org.terasology.entitySystem.prefab.Prefab; | ||||||
import org.terasology.entitySystem.systems.BaseComponentSystem; | ||||||
import org.terasology.entitySystem.systems.RegisterSystem; | ||||||
import org.terasology.logic.common.DisplayNameComponent; | ||||||
import org.terasology.math.geom.Rect2i; | ||||||
import org.terasology.math.geom.Vector3f; | ||||||
import org.terasology.metalrenegades.economy.actions.ShowMarketScreenAction; | ||||||
import org.terasology.metalrenegades.economy.events.TransactionType; | ||||||
import org.terasology.metalrenegades.minimap.events.AddCharacterToOverlayEvent; | ||||||
import org.terasology.namegenerator.creature.CreatureAssetTheme; | ||||||
import org.terasology.namegenerator.creature.CreatureNameProvider; | ||||||
import org.terasology.registry.In; | ||||||
import org.terasology.utilities.Assets; | ||||||
|
||||||
import java.util.ArrayList; | ||||||
import java.util.Optional; | ||||||
import java.util.Random; | ||||||
|
||||||
/** | ||||||
* Spawns a market citizen in all markets | ||||||
|
@@ -55,6 +59,8 @@ public class MarketCitizenSpawnSystem extends BaseComponentSystem { | |||||
|
||||||
private Logger logger = LoggerFactory.getLogger(MarketCitizenSpawnSystem.class); | ||||||
|
||||||
Random random = new Random(); | ||||||
|
||||||
@ReceiveEvent(components = GenericBuildingComponent.class) | ||||||
public void onMarketPlaceSpawn(BuildingEntitySpawnedEvent event, EntityRef entityRef) { | ||||||
GenericBuildingComponent genericBuildingComponent = entityRef.getComponent(GenericBuildingComponent.class); | ||||||
|
@@ -70,6 +76,11 @@ public void onMarketPlaceSpawn(BuildingEntitySpawnedEvent event, EntityRef entit | |||||
SettlementRefComponent settlementRefComponent = entityRef.getComponent(SettlementRefComponent.class); | ||||||
trader.addComponent(settlementRefComponent); | ||||||
MarketComponent marketComponent = settlementRefComponent.settlement.getComponent(MarketComponent.class); | ||||||
if(entityRef.hasComponent(DisplayNameComponent.class)) { | ||||||
DisplayNameComponent displayNameComponent = entityRef.getComponent(DisplayNameComponent.class); | ||||||
CreatureNameProvider creatureNameProvider = new CreatureNameProvider(random.nextLong(), CreatureAssetTheme.COUNTRY); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
displayNameComponent.name = "shopkeeper " + creatureNameProvider.generateName(); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here - save the component after modifying it? |
||||||
} | ||||||
|
||||||
|
||||||
DialogComponent dialogComponent = new DialogComponent(); | ||||||
|
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.
As I've requested to change the name list prefix to "Old West" this (and probably other spots) need changes now... 🙄 I'm eager to merge Terasology/NameGenerator#23, though (after renames) 👍