Skip to content
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

gestalt v7 #13

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions assets/ui/apiary.ui
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"widget": "content",
"offset": -10
},
"position-bottom" : {
"position-bottom": {
"target": "BOTTOM",
"widget": "content",
"offset": -10
Expand Down Expand Up @@ -45,20 +45,20 @@
"columns": 2,
"contents": [
{
"type" : "ColumnLayout",
"contents" : [
"type": "ColumnLayout",
"contents": [
{
"type" : "RelativeLayout",
"contents" : [
"type": "RelativeLayout",
"contents": [
{
"type" : "InventoryGrid",
"layoutInfo" : {
"use-content-width" : true,
"use-content-height" : true,
"position-vertical-center" : {},
"position-horizontal-center" : {}
"type": "InventoryGrid",
"layoutInfo": {
"use-content-width": true,
"use-content-height": true,
"position-vertical-center": {},
"position-horizontal-center": {}
},
"id" : "female"
"id": "female"
},
{
"type": "LifespanBar",
Expand All @@ -77,17 +77,17 @@
]
},
{
"type" : "RelativeLayout",
"contents" : [
"type": "RelativeLayout",
"contents": [
{
"type" : "InventoryGrid",
"layoutInfo" : {
"use-content-width" : true,
"use-content-height" : true,
"position-vertical-center" : {},
"position-horizontal-center" : {}
"type": "InventoryGrid",
"layoutInfo": {
"use-content-width": true,
"use-content-height": true,
"position-vertical-center": {},
"position-horizontal-center": {}
},
"id" : "male"
"id": "male"
}
]
}
Expand Down
4 changes: 2 additions & 2 deletions assets/ui/extractor.ui
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"widget": "content",
"offset": -10
},
"position-bottom" : {
"position-bottom": {
"target": "BOTTOM",
"widget": "content",
"offset": -10
Expand Down Expand Up @@ -110,5 +110,5 @@
}
]
}
}
}
}
4 changes: 2 additions & 2 deletions assets/ui/injector.ui
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"widget": "content",
"offset": -10
},
"position-bottom" : {
"position-bottom": {
"target": "BOTTOM",
"widget": "content",
"offset": -10
Expand Down Expand Up @@ -110,5 +110,5 @@
}
]
}
}
}
}
134 changes: 60 additions & 74 deletions src/main/java/org/terasology/apiculture/TempBeeRegistry.java
Original file line number Diff line number Diff line change
@@ -1,34 +1,21 @@
/*
* 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.
*/
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.apiculture;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.terasology.assets.management.AssetManager;
import org.terasology.entitySystem.entity.EntityManager;
import org.terasology.entitySystem.entity.EntityRef;
import org.terasology.logic.common.DisplayNameComponent;
import org.terasology.logic.inventory.ItemComponent;
import org.terasology.apiculture.components.BeeComponent;
import org.terasology.genetics.components.GeneticsComponent;
import org.terasology.apiculture.systems.ApiarySystem;
import org.terasology.registry.CoreRegistry;
import org.terasology.rendering.assets.texture.TextureRegionAsset;
import org.terasology.utilities.random.MersenneRandom;
import org.terasology.world.generator.WorldGenerator;
import org.terasology.engine.entitySystem.entity.EntityManager;
import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.engine.logic.common.DisplayNameComponent;
import org.terasology.engine.logic.inventory.ItemComponent;
import org.terasology.engine.registry.CoreRegistry;
import org.terasology.engine.rendering.assets.texture.TextureRegionAsset;
import org.terasology.engine.utilities.random.MersenneRandom;
import org.terasology.engine.world.generator.WorldGenerator;
import org.terasology.gestalt.assets.management.AssetManager;
import org.terasology.soundygenetics.components.GeneticsComponent;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -39,16 +26,55 @@
* A temporary class providing helpers intended to be provided by a future bee registry.
*/
public final class TempBeeRegistry {
private static Map<Integer, Integer> lifespans = new HashMap<>();
private static Map<Integer, Long> tickspeeds = new HashMap<>();
private static Map<Integer, Production> productions = new HashMap<>();
private static Map<Integer, Map<Integer, String>> genotypeNames = new HashMap<>();

private static final Map<Integer, Integer> lifespans = new HashMap<>();
private static final Map<Integer, Long> tickspeeds = new HashMap<>();
private static final Map<Integer, Production> productions = new HashMap<>();
private static final Map<Integer, Map<Integer, String>> genotypeNames = new HashMap<>();
private static final Logger logger = LoggerFactory.getLogger(TempBeeRegistry.class);
private static MersenneRandom random;

private static Logger logger = LoggerFactory.getLogger(TempBeeRegistry.class);
static { // TODO: Down with static!
lifespans.put(0, 3);
lifespans.put(1, 6);
lifespans.put(2, 9);

Map<Integer, String> map = new HashMap<>();
map.put(0, "Short Life");
map.put(1, "Normal Life");
map.put(2, "Long Life");

genotypeNames.put(ApiarySystem.LOCUS_LIFESPAN, map);

tickspeeds.put(0, 100000L);
tickspeeds.put(1, 75000L);
tickspeeds.put(2, 50000L);

map = new HashMap<>();
map.put(0, "Slow Speed");
map.put(1, "Normal Speed");
map.put(2, "Fast Speed");

genotypeNames.put(ApiarySystem.LOCUS_SPEED, map);

map = new HashMap<>();
map.put(1, "Single Offspring");
map.put(2, "Double Offspring");
map.put(4, "Quadruple Offspring");
genotypeNames.put(ApiarySystem.LOCUS_OFFSPRING_COUNT, map);

map = new HashMap<>();
map.put(0, "Species A");
map.put(1, "Species B");
map.put(2, "Species C");
genotypeNames.put(ApiarySystem.LOCUS_SPECIES, map);

productions.put(0, new Production(0.25f, "Apiculture:comb"));
productions.put(1, new Production(0.25f, "Apiculture:comb"));
productions.put(2, new Production(0.5f, "Apiculture:comb"));
}

private TempBeeRegistry() { }
private TempBeeRegistry() {
}

public static EntityRef modifyItemForSpeciesAndType(EntityRef entity) {
if (!entity.hasComponent(BeeComponent.class)) {
Expand All @@ -59,7 +85,7 @@ public static EntityRef modifyItemForSpeciesAndType(EntityRef entity) {
BeeComponent.BeeType type = entity.getComponent(BeeComponent.class).type;

String typeName = "NULL";
switch(type) {
switch (type) {
case DRONE:
typeName = "Drone";
break;
Expand Down Expand Up @@ -96,7 +122,7 @@ public static EntityRef modifyItemForSpeciesAndType(EntityRef entity) {
entity.addOrSaveComponent(itemComponent);

DisplayNameComponent displayNameComponent = new DisplayNameComponent();
displayNameComponent.name = new String[] {"A", "B", "C"}[species] + " " + typeName;
displayNameComponent.name = new String[]{"A", "B", "C"}[species] + " " + typeName;

entity.addOrSaveComponent(displayNameComponent);

Expand Down Expand Up @@ -152,44 +178,4 @@ public Production(float chance, String prefab) {
this.chance = chance;
}
}

static { // TODO: Down with static!
lifespans.put(0, 3);
lifespans.put(1, 6);
lifespans.put(2, 9);

Map<Integer, String> map = new HashMap<>();
map.put(0, "Short Life");
map.put(1, "Normal Life");
map.put(2, "Long Life");

genotypeNames.put(ApiarySystem.LOCUS_LIFESPAN, map);

tickspeeds.put(0, 100000L);
tickspeeds.put(1, 75000L);
tickspeeds.put(2, 50000L);

map = new HashMap<>();
map.put(0, "Slow Speed");
map.put(1, "Normal Speed");
map.put(2, "Fast Speed");

genotypeNames.put(ApiarySystem.LOCUS_SPEED, map);

map = new HashMap<>();
map.put(1, "Single Offspring");
map.put(2, "Double Offspring");
map.put(4, "Quadruple Offspring");
genotypeNames.put(ApiarySystem.LOCUS_OFFSPRING_COUNT, map);

map = new HashMap<>();
map.put(0, "Species A");
map.put(1, "Species B");
map.put(2, "Species C");
genotypeNames.put(ApiarySystem.LOCUS_SPECIES, map);

productions.put(0, new Production(0.25f, "Apiculture:comb"));
productions.put(1, new Production(0.25f, "Apiculture:comb"));
productions.put(2, new Production(0.5f, "Apiculture:comb"));
}
}
42 changes: 15 additions & 27 deletions src/main/java/org/terasology/apiculture/commands/BeeCommands.java
Original file line number Diff line number Diff line change
@@ -1,33 +1,20 @@
/*
* 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.
*/
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.apiculture.commands;

import org.terasology.entitySystem.entity.EntityManager;
import org.terasology.entitySystem.entity.EntityRef;
import org.terasology.entitySystem.systems.BaseComponentSystem;
import org.terasology.entitySystem.systems.RegisterSystem;
import org.terasology.logic.characters.CharacterHeldItemComponent;
import org.terasology.logic.console.commandSystem.annotations.Command;
import org.terasology.logic.console.commandSystem.annotations.Sender;
import org.terasology.logic.permission.PermissionManager;
import org.terasology.network.ClientComponent;
import org.terasology.apiculture.components.BeeComponent;
import org.terasology.apiculture.components.MatedComponent;
import org.terasology.genetics.components.GeneticsComponent;
import org.terasology.registry.In;
import org.terasology.engine.entitySystem.entity.EntityManager;
import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.engine.entitySystem.systems.BaseComponentSystem;
import org.terasology.engine.entitySystem.systems.RegisterSystem;
import org.terasology.engine.logic.characters.CharacterHeldItemComponent;
import org.terasology.engine.logic.console.commandSystem.annotations.Command;
import org.terasology.engine.logic.console.commandSystem.annotations.Sender;
import org.terasology.engine.logic.permission.PermissionManager;
import org.terasology.engine.network.ClientComponent;
import org.terasology.engine.registry.In;
import org.terasology.soundygenetics.components.GeneticsComponent;

@RegisterSystem
public class BeeCommands extends BaseComponentSystem {
Expand All @@ -40,7 +27,8 @@ public class BeeCommands extends BaseComponentSystem {
runOnServer = true,
requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String dumpGenes(@Sender EntityRef client) {
EntityRef item = client.getComponent(ClientComponent.class).character.getComponent(CharacterHeldItemComponent.class).selectedItem;
EntityRef item =
client.getComponent(ClientComponent.class).character.getComponent(CharacterHeldItemComponent.class).selectedItem;
if (!item.hasComponent(BeeComponent.class)) {
return "Held item is not a bee.";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
/*
* 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.
*/
// Copyright 2020 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0
package org.terasology.apiculture.components;

import org.terasology.entitySystem.Component;
import org.terasology.engine.entitySystem.Component;

/**
* Indicates that a block entity is an apiary.
Expand Down
Loading