diff --git a/assets/ui/apiary.ui b/assets/ui/apiary.ui index cb10f69..ba5c992 100644 --- a/assets/ui/apiary.ui +++ b/assets/ui/apiary.ui @@ -12,7 +12,7 @@ "widget": "content", "offset": -10 }, - "position-bottom" : { + "position-bottom": { "target": "BOTTOM", "widget": "content", "offset": -10 @@ -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", @@ -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" } ] } diff --git a/assets/ui/extractor.ui b/assets/ui/extractor.ui index 932ed8c..a1c8fdb 100644 --- a/assets/ui/extractor.ui +++ b/assets/ui/extractor.ui @@ -12,7 +12,7 @@ "widget": "content", "offset": -10 }, - "position-bottom" : { + "position-bottom": { "target": "BOTTOM", "widget": "content", "offset": -10 @@ -110,5 +110,5 @@ } ] } - } +} } \ No newline at end of file diff --git a/assets/ui/injector.ui b/assets/ui/injector.ui index 0a96416..b190499 100644 --- a/assets/ui/injector.ui +++ b/assets/ui/injector.ui @@ -12,7 +12,7 @@ "widget": "content", "offset": -10 }, - "position-bottom" : { + "position-bottom": { "target": "BOTTOM", "widget": "content", "offset": -10 @@ -110,5 +110,5 @@ } ] } - } +} } \ No newline at end of file diff --git a/src/main/java/org/terasology/apiculture/TempBeeRegistry.java b/src/main/java/org/terasology/apiculture/TempBeeRegistry.java index 2a65268..af7413a 100644 --- a/src/main/java/org/terasology/apiculture/TempBeeRegistry.java +++ b/src/main/java/org/terasology/apiculture/TempBeeRegistry.java @@ -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; @@ -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 lifespans = new HashMap<>(); - private static Map tickspeeds = new HashMap<>(); - private static Map productions = new HashMap<>(); - private static Map> genotypeNames = new HashMap<>(); - + private static final Map lifespans = new HashMap<>(); + private static final Map tickspeeds = new HashMap<>(); + private static final Map productions = new HashMap<>(); + private static final Map> 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 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)) { @@ -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; @@ -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); @@ -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 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")); - } } diff --git a/src/main/java/org/terasology/apiculture/commands/BeeCommands.java b/src/main/java/org/terasology/apiculture/commands/BeeCommands.java index be568bd..f357f39 100644 --- a/src/main/java/org/terasology/apiculture/commands/BeeCommands.java +++ b/src/main/java/org/terasology/apiculture/commands/BeeCommands.java @@ -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 { @@ -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."; } diff --git a/src/main/java/org/terasology/apiculture/components/ApiaryComponent.java b/src/main/java/org/terasology/apiculture/components/ApiaryComponent.java index 5c49b0d..ef0a175 100644 --- a/src/main/java/org/terasology/apiculture/components/ApiaryComponent.java +++ b/src/main/java/org/terasology/apiculture/components/ApiaryComponent.java @@ -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. diff --git a/src/main/java/org/terasology/apiculture/components/BeeComponent.java b/src/main/java/org/terasology/apiculture/components/BeeComponent.java index ea20b7d..5d08b25 100644 --- a/src/main/java/org/terasology/apiculture/components/BeeComponent.java +++ b/src/main/java/org/terasology/apiculture/components/BeeComponent.java @@ -1,22 +1,9 @@ -/* - * 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.logic.inventory.ItemDifferentiating; +import org.terasology.engine.entitySystem.Component; +import org.terasology.inventory.logic.ItemDifferentiating; import java.util.Objects; @@ -29,12 +16,6 @@ public final class BeeComponent implements Component, ItemDifferentiating { */ public BeeType type; - public enum BeeType { - DRONE, - PRINCESS, - QUEEN - } - public boolean equals(Object o) { if (!(o instanceof BeeComponent)) { return false; @@ -45,4 +26,10 @@ public boolean equals(Object o) { public int hashCode() { return Objects.hash(type); } + + public enum BeeType { + DRONE, + PRINCESS, + QUEEN + } } diff --git a/src/main/java/org/terasology/apiculture/components/ExtractorComponent.java b/src/main/java/org/terasology/apiculture/components/ExtractorComponent.java index dfb3a8f..bc6cc4a 100644 --- a/src/main/java/org/terasology/apiculture/components/ExtractorComponent.java +++ b/src/main/java/org/terasology/apiculture/components/ExtractorComponent.java @@ -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 extractor. diff --git a/src/main/java/org/terasology/apiculture/components/InjectorComponent.java b/src/main/java/org/terasology/apiculture/components/InjectorComponent.java index 82794e1..9ca380b 100644 --- a/src/main/java/org/terasology/apiculture/components/InjectorComponent.java +++ b/src/main/java/org/terasology/apiculture/components/InjectorComponent.java @@ -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 injector. diff --git a/src/main/java/org/terasology/apiculture/components/LocusSampleComponent.java b/src/main/java/org/terasology/apiculture/components/LocusSampleComponent.java index de4282d..871a80f 100644 --- a/src/main/java/org/terasology/apiculture/components/LocusSampleComponent.java +++ b/src/main/java/org/terasology/apiculture/components/LocusSampleComponent.java @@ -1,22 +1,9 @@ -/* - * 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.logic.inventory.ItemDifferentiating; +import org.terasology.engine.entitySystem.Component; +import org.terasology.inventory.logic.ItemDifferentiating; import java.util.Objects; @@ -34,7 +21,8 @@ public class LocusSampleComponent implements Component, ItemDifferentiating { */ public int genotype; - public LocusSampleComponent() { } + public LocusSampleComponent() { + } public LocusSampleComponent(int locus, int genotype) { this.locus = locus; diff --git a/src/main/java/org/terasology/apiculture/components/MatedComponent.java b/src/main/java/org/terasology/apiculture/components/MatedComponent.java index 8cc7d0a..a52808b 100644 --- a/src/main/java/org/terasology/apiculture/components/MatedComponent.java +++ b/src/main/java/org/terasology/apiculture/components/MatedComponent.java @@ -1,25 +1,12 @@ -/* - * 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.entitySystem.entity.EntityManager; -import org.terasology.entitySystem.entity.EntityRef; -import org.terasology.logic.inventory.ItemDifferentiating; -import org.terasology.genetics.components.GeneticsComponent; +import org.terasology.engine.entitySystem.Component; +import org.terasology.engine.entitySystem.entity.EntityManager; +import org.terasology.engine.entitySystem.entity.EntityRef; +import org.terasology.inventory.logic.ItemDifferentiating; +import org.terasology.soundygenetics.components.GeneticsComponent; import java.util.Objects; @@ -42,7 +29,8 @@ public final class MatedComponent implements Component, ItemDifferentiating { */ public int lifespan; - public MatedComponent() { } + public MatedComponent() { + } public MatedComponent(GeneticsComponent geneticsComponent, int lifespan, EntityManager entityManager) { container = entityManager.create(geneticsComponent); diff --git a/src/main/java/org/terasology/apiculture/components/ProcessingComponent.java b/src/main/java/org/terasology/apiculture/components/ProcessingComponent.java index 9dabfa4..c55fe32 100644 --- a/src/main/java/org/terasology/apiculture/components/ProcessingComponent.java +++ b/src/main/java/org/terasology/apiculture/components/ProcessingComponent.java @@ -1,30 +1,18 @@ -/* - * 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 to screens that processes are occurring in an apiary, extractor, or injector, and at what game time they will - * complete. + * Indicates to screens that processes are occurring in an apiary, extractor, or injector, and at what game time they + * will complete. */ public final class ProcessingComponent implements Component { public long finishTime; - public ProcessingComponent() { } + public ProcessingComponent() { + } public ProcessingComponent(long finishTime) { this.finishTime = finishTime; diff --git a/src/main/java/org/terasology/apiculture/systems/ApiarySystem.java b/src/main/java/org/terasology/apiculture/systems/ApiarySystem.java index e3f529f..22738e9 100644 --- a/src/main/java/org/terasology/apiculture/systems/ApiarySystem.java +++ b/src/main/java/org/terasology/apiculture/systems/ApiarySystem.java @@ -1,42 +1,29 @@ -/* - * 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.systems; -import org.terasology.engine.Time; -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.delay.DelayManager; -import org.terasology.logic.delay.DelayedActionTriggeredEvent; -import org.terasology.logic.inventory.InventoryComponent; -import org.terasology.logic.inventory.InventoryManager; -import org.terasology.logic.inventory.events.BeforeItemPutInInventory; -import org.terasology.logic.inventory.events.InventorySlotChangedEvent; import org.terasology.apiculture.TempBeeRegistry; import org.terasology.apiculture.components.ApiaryComponent; -import org.terasology.apiculture.components.ProcessingComponent; import org.terasology.apiculture.components.BeeComponent; import org.terasology.apiculture.components.MatedComponent; -import org.terasology.genetics.Genome; -import org.terasology.genetics.components.GeneticsComponent; -import org.terasology.registry.In; -import org.terasology.world.generator.WorldGenerator; +import org.terasology.apiculture.components.ProcessingComponent; +import org.terasology.engine.core.Time; +import org.terasology.engine.entitySystem.entity.EntityManager; +import org.terasology.engine.entitySystem.entity.EntityRef; +import org.terasology.engine.entitySystem.event.ReceiveEvent; +import org.terasology.engine.entitySystem.systems.BaseComponentSystem; +import org.terasology.engine.entitySystem.systems.RegisterMode; +import org.terasology.engine.entitySystem.systems.RegisterSystem; +import org.terasology.engine.logic.delay.DelayManager; +import org.terasology.engine.logic.delay.DelayedActionTriggeredEvent; +import org.terasology.engine.registry.In; +import org.terasology.engine.world.generator.WorldGenerator; +import org.terasology.inventory.logic.InventoryComponent; +import org.terasology.inventory.logic.InventoryManager; +import org.terasology.inventory.logic.events.BeforeItemPutInInventory; +import org.terasology.inventory.logic.events.InventorySlotChangedEvent; +import org.terasology.soundygenetics.Genome; +import org.terasology.soundygenetics.components.GeneticsComponent; import java.util.Arrays; import java.util.Collections; @@ -48,37 +35,57 @@ */ @RegisterSystem(RegisterMode.ALWAYS) // TODO: Authority public class ApiarySystem extends BaseComponentSystem { - /** The delayed action id for life ticks. */ + /** + * The delayed action id for life ticks. + */ public static final String LIFE_TICK_EVENT = "life_tick"; - /** The delayed action id for the completion of mating. */ + /** + * The delayed action id for the completion of mating. + */ public static final String MATING_EVENT = "mating"; - /** The slot index for the princess/queen bee slot in an apiary's inventory. */ + /** + * The slot index for the princess/queen bee slot in an apiary's inventory. + */ public static final int SLOT_FEMALE = 0; - /** The slot index for the drone bee slot in an apiary's inventory. */ + /** + * The slot index for the drone bee slot in an apiary's inventory. + */ public static final int SLOT_MALE = 1; - /** A list of slot indices for the otuput slots in an apiary's inventory. */ + /** + * A list of slot indices for the otuput slots in an apiary's inventory. + */ public static final List SLOTS_OUT = Collections.unmodifiableList(Arrays.asList(2, 3, 4, 5, 6, 7, 8)); - /** The locus in a bee's genetics indicating the species of a bee. */ + /** + * The locus in a bee's genetics indicating the species of a bee. + */ public static final int LOCUS_SPECIES = 0; - /** The locus in a bee's genetics indicating the speed at which a bee's life ticks down. */ + /** + * The locus in a bee's genetics indicating the speed at which a bee's life ticks down. + */ public static final int LOCUS_SPEED = 1; - /** The locus in a bee's genetics indicating the length of a bee's lifespan. */ + /** + * The locus in a bee's genetics indicating the length of a bee's lifespan. + */ public static final int LOCUS_LIFESPAN = 2; - /** The locus in a bee's genetics indicating the number of drone offspring a bee will have. */ + /** + * The locus in a bee's genetics indicating the number of drone offspring a bee will have. + */ public static final int LOCUS_OFFSPRING_COUNT = 3; - /** The time, in milliseconds, that mating takes in an apiary. */ + /** + * The time, in milliseconds, that mating takes in an apiary. + */ public static final long MATING_TIME = 1000L; @In @@ -100,9 +107,9 @@ public class ApiarySystem extends BaseComponentSystem { /** * Consumes BeforeItemPutInInventory events, handling inventory access controls. - * - * Prevents non-bees from being placed into the apiary, bees being placed - * into the slot inappropriate for its sex, and any items being placed into the output. + *

+ * Prevents non-bees from being placed into the apiary, bees being placed into the slot inappropriate for its sex, + * and any items being placed into the output. */ @ReceiveEvent public void beforeItemPutIntoApiary(BeforeItemPutInInventory event, EntityRef entity, ApiaryComponent component) { @@ -121,7 +128,7 @@ public void beforeItemPutIntoApiary(BeforeItemPutInInventory event, EntityRef en /** * Receives inventory change events, scheduling appropriate functional events. - * + *

* Schedules a lifespan tick if a queen is placed into the top slot, a mating end event if a princess-drone pair is * completed, and cancels appropriate scheduled events if the queen is removed or the princess-drone pair is broken * before mating is complete. @@ -138,7 +145,8 @@ public void onApiaryInventoryChanged(InventorySlotChangedEvent event, EntityRef delayManager.cancelDelayedAction(entity, LIFE_TICK_EVENT); } } else if (event.getNewItem().getComponent(BeeComponent.class).type == BeeComponent.BeeType.PRINCESS) { - BeeComponent maleBee = entity.getComponent(InventoryComponent.class).itemSlots.get(SLOT_MALE).getComponent(BeeComponent.class); + BeeComponent maleBee = + entity.getComponent(InventoryComponent.class).itemSlots.get(SLOT_MALE).getComponent(BeeComponent.class); if (maleBee != null) { entity.addOrSaveComponent(new ProcessingComponent(time.getGameTimeInMs() + MATING_TIME)); delayManager.addDelayedAction(entity, MATING_EVENT, MATING_TIME); @@ -154,7 +162,8 @@ public void onApiaryInventoryChanged(InventorySlotChangedEvent event, EntityRef delayManager.cancelDelayedAction(entity, MATING_EVENT); } } else { - BeeComponent femaleBee = entity.getComponent(InventoryComponent.class).itemSlots.get(SLOT_FEMALE).getComponent(BeeComponent.class); + BeeComponent femaleBee = + entity.getComponent(InventoryComponent.class).itemSlots.get(SLOT_FEMALE).getComponent(BeeComponent.class); if (femaleBee != null) { if (femaleBee.type == BeeComponent.BeeType.PRINCESS) { entity.addOrSaveComponent(new ProcessingComponent(time.getGameTimeInMs() + MATING_TIME)); @@ -179,8 +188,9 @@ public void onApiaryEvent(DelayedActionTriggeredEvent event, EntityRef entity, A /** * Handles a lifespan tick for a queen in a given apiary. - * - * Generates produce, updates the remaining lifespan, and triggers birthing if the end of lifespan has been reached. + *

+ * Generates produce, updates the remaining lifespan, and triggers birthing if the end of lifespan has been + * reached. * * @param entity The apiary containing the queen for which a lifespan tick is to be completed. */ @@ -188,7 +198,9 @@ private void onLifeTick(EntityRef entity) { EntityRef queenBee = entity.getComponent(InventoryComponent.class).itemSlots.get(SLOT_FEMALE); GeneticsComponent queenGenetics = queenBee.getComponent(GeneticsComponent.class); - inventoryManager.giveItem(entity, entity, TempBeeRegistry.getProduceForSpeciesWithChance(queenGenetics.activeGenes.get(LOCUS_SPECIES)), SLOTS_OUT); + inventoryManager.giveItem(entity, entity, + TempBeeRegistry.getProduceForSpeciesWithChance(queenGenetics.activeGenes.get(LOCUS_SPECIES)), + SLOTS_OUT); MatedComponent matedComponent = queenBee.getComponent(MatedComponent.class); matedComponent.ticksRemaining--; @@ -204,14 +216,15 @@ private void onLifeTick(EntityRef entity) { /** * Handles queen birthing in a given apiary. - * + *

* Generates offspring, placing them into the apiary's output if room is present, and destroys the queen. * * @param entity The apiary contianing the queen to give birth. */ private void birth(EntityRef entity) { EntityRef queenBee = entity.getComponent(InventoryComponent.class).itemSlots.get(SLOT_FEMALE); - Iterator offspringGenetics = getGenome().combine(queenBee.getComponent(GeneticsComponent.class), + Iterator offspringGenetics = + getGenome().combine(queenBee.getComponent(GeneticsComponent.class), queenBee.getComponent(MatedComponent.class).container.getComponent(GeneticsComponent.class)); EntityRef offspring = entityManager.create("Apiculture:bee_princess"); @@ -238,7 +251,7 @@ private void birth(EntityRef entity) { /** * Handles mating for a given apiary. - * + *

* Turns the princess in an apiary into a queen containing the drone's genetics, destroying the drone, and schedules * the first lifespan tick. * @@ -259,7 +272,8 @@ private void onMatingFinished(EntityRef entity) { TempBeeRegistry.modifyItemForSpeciesAndType(femaleBee); maleBee.destroy(); - delayManager.addDelayedAction(entity, ApiarySystem.LIFE_TICK_EVENT, TempBeeRegistry.getTickTimeFromGenome(femaleGenetics.activeGenes.get(ApiarySystem.LOCUS_SPEED))); + delayManager.addDelayedAction(entity, ApiarySystem.LIFE_TICK_EVENT, + TempBeeRegistry.getTickTimeFromGenome(femaleGenetics.activeGenes.get(ApiarySystem.LOCUS_SPEED))); } private Genome getGenome() { @@ -268,7 +282,8 @@ private Genome getGenome() { GeneticsComponent beeCComponent = new GeneticsComponent(4); - beeCComponent.activeGenes.add(2); // TODO: (Soundwave) This is bad, both because the size isn't ensured, and because it's messy. + beeCComponent.activeGenes.add(2); // TODO: (Soundwave) This is bad, both because the size isn't ensured, + // and because it's messy. beeCComponent.activeGenes.add(2); beeCComponent.activeGenes.add(2); beeCComponent.activeGenes.add(4); diff --git a/src/main/java/org/terasology/apiculture/systems/ExtractorSystem.java b/src/main/java/org/terasology/apiculture/systems/ExtractorSystem.java index 4bedbdf..35e564e 100644 --- a/src/main/java/org/terasology/apiculture/systems/ExtractorSystem.java +++ b/src/main/java/org/terasology/apiculture/systems/ExtractorSystem.java @@ -1,79 +1,70 @@ -/* - * 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.systems; -import org.terasology.engine.Time; -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.common.DisplayNameComponent; -import org.terasology.logic.delay.DelayManager; -import org.terasology.logic.delay.DelayedActionTriggeredEvent; -import org.terasology.logic.inventory.InventoryComponent; -import org.terasology.logic.inventory.InventoryManager; -import org.terasology.logic.inventory.events.BeforeItemPutInInventory; -import org.terasology.logic.inventory.events.InventorySlotChangedEvent; import org.terasology.apiculture.TempBeeRegistry; import org.terasology.apiculture.components.BeeComponent; import org.terasology.apiculture.components.ExtractorComponent; import org.terasology.apiculture.components.LocusSampleComponent; import org.terasology.apiculture.components.ProcessingComponent; -import org.terasology.genetics.components.GeneticsComponent; -import org.terasology.registry.In; -import org.terasology.utilities.random.MersenneRandom; +import org.terasology.engine.core.Time; +import org.terasology.engine.entitySystem.entity.EntityManager; +import org.terasology.engine.entitySystem.entity.EntityRef; +import org.terasology.engine.entitySystem.event.ReceiveEvent; +import org.terasology.engine.entitySystem.systems.BaseComponentSystem; +import org.terasology.engine.entitySystem.systems.RegisterMode; +import org.terasology.engine.entitySystem.systems.RegisterSystem; +import org.terasology.engine.logic.common.DisplayNameComponent; +import org.terasology.engine.logic.delay.DelayManager; +import org.terasology.engine.logic.delay.DelayedActionTriggeredEvent; +import org.terasology.engine.registry.In; +import org.terasology.engine.utilities.random.MersenneRandom; +import org.terasology.inventory.logic.InventoryComponent; +import org.terasology.inventory.logic.InventoryManager; +import org.terasology.inventory.logic.events.BeforeItemPutInInventory; +import org.terasology.inventory.logic.events.InventorySlotChangedEvent; +import org.terasology.soundygenetics.components.GeneticsComponent; @RegisterSystem(RegisterMode.ALWAYS) // TODO: Authority public class ExtractorSystem extends BaseComponentSystem { - /** The slot index for the input slot of the extractor. */ + /** + * The slot index for the input slot of the extractor. + */ public static final int SLOT_INPUT = 0; - /** The slot index for the output slot of the extractor. */ + /** + * The slot index for the output slot of the extractor. + */ public static final int SLOT_OUTPUT = 1; - /** The delayed action id for extraction completion. */ + /** + * The delayed action id for extraction completion. + */ public static final String EXTRACT_EVENT = "extract"; - /** The time, in milliseconds, that extraction takes. */ + /** + * The time, in milliseconds, that extraction takes. + */ public static final long EXTRACT_TIME = 60000L; - + private final MersenneRandom random = new MersenneRandom(); @In private DelayManager delayManager; - @In private Time time; - @In private EntityManager entityManager; - @In private InventoryManager inventoryManager; - private MersenneRandom random = new MersenneRandom(); - /** * Consumes BeforeItemPutInInventory events, handling inventory access controls. - * + *

* Prevents non-bees from being placed into the extractor, and any items being placed into the output. */ @ReceiveEvent - public void beforeItemPutIntoExtractor(BeforeItemPutInInventory event, EntityRef entity, ExtractorComponent component) { + public void beforeItemPutIntoExtractor(BeforeItemPutInInventory event, EntityRef entity, + ExtractorComponent component) { if (event.getSlot() == SLOT_INPUT) { if (!event.getItem().hasComponent(BeeComponent.class)) { event.consume(); @@ -85,11 +76,13 @@ public void beforeItemPutIntoExtractor(BeforeItemPutInInventory event, EntityRef /** * Receives inventory change events, scheduling appropriate functional events. - * - * Schedules an extraction end event if a bee is placed in the input, and cancels appropriate events if the input is removed. + *

+ * Schedules an extraction end event if a bee is placed in the input, and cancels appropriate events if the input is + * removed. */ @ReceiveEvent - public void onExtractorItemChanged(InventorySlotChangedEvent event, EntityRef entity, ExtractorComponent component) { + public void onExtractorItemChanged(InventorySlotChangedEvent event, EntityRef entity, + ExtractorComponent component) { if (event.getSlot() == SLOT_INPUT) { if (!event.getNewItem().hasComponent(BeeComponent.class)) { entity.removeComponent(ProcessingComponent.class); @@ -124,7 +117,8 @@ public void onExtractorEvent(DelayedActionTriggeredEvent event, EntityRef entity sample.addComponent(new LocusSampleComponent(locus, genotype)); DisplayNameComponent displayNameComponent = new DisplayNameComponent(); - displayNameComponent.name = "Sample: " + TempBeeRegistry.getDisplayNameComponentForLocusAndGenotype(locus, genotype); + displayNameComponent.name = "Sample: " + TempBeeRegistry.getDisplayNameComponentForLocusAndGenotype(locus, + genotype); sample.addComponent(displayNameComponent); inventoryManager.giveItem(entity, entity, sample, SLOT_OUTPUT); diff --git a/src/main/java/org/terasology/apiculture/systems/InjectorSystem.java b/src/main/java/org/terasology/apiculture/systems/InjectorSystem.java index 7de17f6..6c2f857 100644 --- a/src/main/java/org/terasology/apiculture/systems/InjectorSystem.java +++ b/src/main/java/org/terasology/apiculture/systems/InjectorSystem.java @@ -1,54 +1,49 @@ -/* - * 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.systems; -import org.terasology.engine.Time; -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.delay.DelayManager; -import org.terasology.logic.delay.DelayedActionTriggeredEvent; -import org.terasology.logic.inventory.InventoryComponent; -import org.terasology.logic.inventory.InventoryManager; -import org.terasology.logic.inventory.events.BeforeItemPutInInventory; -import org.terasology.logic.inventory.events.InventorySlotChangedEvent; import org.terasology.apiculture.TempBeeRegistry; import org.terasology.apiculture.components.BeeComponent; import org.terasology.apiculture.components.InjectorComponent; import org.terasology.apiculture.components.LocusSampleComponent; import org.terasology.apiculture.components.ProcessingComponent; -import org.terasology.genetics.components.GeneticsComponent; -import org.terasology.registry.In; +import org.terasology.engine.core.Time; +import org.terasology.engine.entitySystem.entity.EntityManager; +import org.terasology.engine.entitySystem.entity.EntityRef; +import org.terasology.engine.entitySystem.event.ReceiveEvent; +import org.terasology.engine.entitySystem.systems.BaseComponentSystem; +import org.terasology.engine.entitySystem.systems.RegisterMode; +import org.terasology.engine.entitySystem.systems.RegisterSystem; +import org.terasology.engine.logic.delay.DelayManager; +import org.terasology.engine.logic.delay.DelayedActionTriggeredEvent; +import org.terasology.engine.registry.In; +import org.terasology.inventory.logic.InventoryComponent; +import org.terasology.inventory.logic.InventoryManager; +import org.terasology.inventory.logic.events.BeforeItemPutInInventory; +import org.terasology.inventory.logic.events.InventorySlotChangedEvent; +import org.terasology.soundygenetics.components.GeneticsComponent; @RegisterSystem(RegisterMode.ALWAYS) // TODO: Authority public class InjectorSystem extends BaseComponentSystem { - /** The slot index for the sample input slot. */ + /** + * The slot index for the sample input slot. + */ public static final int SLOT_INPUT = 0; - /** The slot index for the bee input slot. */ + /** + * The slot index for the bee input slot. + */ public static final int SLOT_BEE = 1; - /** The delayed action id for injection completion. */ + /** + * The delayed action id for injection completion. + */ public static final String INJECT_EVENT = "inject"; - /** The time, in milliseconds, that injection takes. */ + /** + * The time, in milliseconds, that injection takes. + */ public static final long INJECT_TIME = 60000L; @In @@ -65,12 +60,13 @@ public class InjectorSystem extends BaseComponentSystem { /** * Consumes BeforeItemPutInInventory events, handling inventory access controls. - * - * Prevents non-bees from being placed into the bee input slot, and non-genetic sample items from being placed - * in the sample input slot. + *

+ * Prevents non-bees from being placed into the bee input slot, and non-genetic sample items from being placed in + * the sample input slot. */ @ReceiveEvent - public void beforeItemPutIntoInjector(BeforeItemPutInInventory event, EntityRef entity, InjectorComponent component) { + public void beforeItemPutIntoInjector(BeforeItemPutInInventory event, EntityRef entity, + InjectorComponent component) { if (event.getSlot() == SLOT_INPUT) { if (!event.getItem().hasComponent(LocusSampleComponent.class)) { event.consume(); @@ -84,9 +80,9 @@ public void beforeItemPutIntoInjector(BeforeItemPutInInventory event, EntityRef /** * Receives inventory change events, scheduling appropriate functional events. - * - * Schedules an injection end event if a bee and genetic sample are present in their respective slots, - * and cancels appropriate events if either input is removed. + *

+ * Schedules an injection end event if a bee and genetic sample are present in their respective slots, and cancels + * appropriate events if either input is removed. */ @ReceiveEvent public void onInjectorItemChanged(InventorySlotChangedEvent event, EntityRef entity, InjectorComponent component) { @@ -122,7 +118,8 @@ public void onInjectorEvent(DelayedActionTriggeredEvent event, EntityRef entity, EntityRef bee = entity.getComponent(InventoryComponent.class).itemSlots.get(SLOT_BEE); GeneticsComponent geneticsComponent = bee.getComponent(GeneticsComponent.class); - LocusSampleComponent locusSampleComponent = entity.getComponent(InventoryComponent.class).itemSlots.get(SLOT_INPUT).getComponent(LocusSampleComponent.class); + LocusSampleComponent locusSampleComponent = + entity.getComponent(InventoryComponent.class).itemSlots.get(SLOT_INPUT).getComponent(LocusSampleComponent.class); geneticsComponent.activeGenes.set(locusSampleComponent.locus, locusSampleComponent.genotype); geneticsComponent.inactiveGenes.set(locusSampleComponent.locus, locusSampleComponent.genotype); diff --git a/src/main/java/org/terasology/apiculture/systems/MatedComponentLifetimeSystem.java b/src/main/java/org/terasology/apiculture/systems/MatedComponentLifetimeSystem.java index 3cbd693..61433e8 100644 --- a/src/main/java/org/terasology/apiculture/systems/MatedComponentLifetimeSystem.java +++ b/src/main/java/org/terasology/apiculture/systems/MatedComponentLifetimeSystem.java @@ -1,27 +1,14 @@ -/* - * 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.systems; -import org.terasology.entitySystem.entity.EntityRef; -import org.terasology.entitySystem.entity.lifecycleEvents.BeforeRemoveComponent; -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.apiculture.components.MatedComponent; +import org.terasology.engine.entitySystem.entity.EntityRef; +import org.terasology.engine.entitySystem.entity.lifecycleEvents.BeforeRemoveComponent; +import org.terasology.engine.entitySystem.event.ReceiveEvent; +import org.terasology.engine.entitySystem.systems.BaseComponentSystem; +import org.terasology.engine.entitySystem.systems.RegisterMode; +import org.terasology.engine.entitySystem.systems.RegisterSystem; @RegisterSystem(RegisterMode.ALWAYS) // TODO: Try to make AUTHORITY public class MatedComponentLifetimeSystem extends BaseComponentSystem { diff --git a/src/main/java/org/terasology/apiculture/ui/ApiaryScreen.java b/src/main/java/org/terasology/apiculture/ui/ApiaryScreen.java index 3c61f72..8b225bc 100644 --- a/src/main/java/org/terasology/apiculture/ui/ApiaryScreen.java +++ b/src/main/java/org/terasology/apiculture/ui/ApiaryScreen.java @@ -2,19 +2,19 @@ // SPDX-License-Identifier: Apache-2.0 package org.terasology.apiculture.ui; -import org.terasology.engine.Time; -import org.terasology.entitySystem.entity.EntityRef; -import org.terasology.logic.inventory.InventoryComponent; -import org.terasology.logic.players.LocalPlayer; -import org.terasology.apiculture.components.ProcessingComponent; import org.terasology.apiculture.components.MatedComponent; +import org.terasology.apiculture.components.ProcessingComponent; import org.terasology.apiculture.systems.ApiarySystem; -import org.terasology.registry.CoreRegistry; -import org.terasology.registry.In; -import org.terasology.rendering.nui.BaseInteractionScreen; +import org.terasology.engine.core.Time; +import org.terasology.engine.entitySystem.entity.EntityRef; +import org.terasology.engine.logic.players.LocalPlayer; +import org.terasology.engine.registry.CoreRegistry; +import org.terasology.engine.registry.In; +import org.terasology.engine.rendering.nui.BaseInteractionScreen; +import org.terasology.inventory.logic.InventoryComponent; +import org.terasology.inventory.rendering.nui.layers.ingame.InventoryGrid; import org.terasology.nui.Color; import org.terasology.nui.databinding.ReadOnlyBinding; -import org.terasology.rendering.nui.layers.ingame.inventory.InventoryGrid; import java.util.Objects; @@ -86,7 +86,8 @@ public void update(float delta) { lifespanBar.setFill(Math.min(ApiarySystem.MATING_TIME + time.getGameTimeInMs() - matingComponent.finishTime, ApiarySystem.MATING_TIME) / (float) ApiarySystem.MATING_TIME); } else { - EntityRef femaleBee = interactionTarget.getComponent(InventoryComponent.class).itemSlots.get(ApiarySystem.SLOT_FEMALE); + EntityRef femaleBee = + interactionTarget.getComponent(InventoryComponent.class).itemSlots.get(ApiarySystem.SLOT_FEMALE); if (femaleBee.hasComponent(MatedComponent.class)) { lifespanBar.setColor(Color.YELLOW); MatedComponent matedComponent = femaleBee.getComponent(MatedComponent.class); @@ -103,7 +104,7 @@ public boolean isModal() { } private static class EntityRefBinding extends ReadOnlyBinding { - private EntityRef entityRef; + private final EntityRef entityRef; public EntityRefBinding(EntityRef entityRef) { this.entityRef = entityRef; diff --git a/src/main/java/org/terasology/apiculture/ui/ExtractorScreen.java b/src/main/java/org/terasology/apiculture/ui/ExtractorScreen.java index 85745aa..bfe6ea0 100644 --- a/src/main/java/org/terasology/apiculture/ui/ExtractorScreen.java +++ b/src/main/java/org/terasology/apiculture/ui/ExtractorScreen.java @@ -2,16 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 package org.terasology.apiculture.ui; -import org.terasology.engine.Time; -import org.terasology.entitySystem.entity.EntityRef; -import org.terasology.logic.players.LocalPlayer; import org.terasology.apiculture.components.ProcessingComponent; import org.terasology.apiculture.systems.ExtractorSystem; -import org.terasology.registry.CoreRegistry; -import org.terasology.registry.In; -import org.terasology.rendering.nui.BaseInteractionScreen; +import org.terasology.engine.core.Time; +import org.terasology.engine.entitySystem.entity.EntityRef; +import org.terasology.engine.logic.players.LocalPlayer; +import org.terasology.engine.registry.CoreRegistry; +import org.terasology.engine.registry.In; +import org.terasology.engine.rendering.nui.BaseInteractionScreen; +import org.terasology.inventory.rendering.nui.layers.ingame.InventoryGrid; import org.terasology.nui.databinding.ReadOnlyBinding; -import org.terasology.rendering.nui.layers.ingame.inventory.InventoryGrid; import java.util.Objects; @@ -71,7 +71,7 @@ public boolean isModal() { } private static class EntityRefBinding extends ReadOnlyBinding { - private EntityRef entityRef; + private final EntityRef entityRef; public EntityRefBinding(EntityRef entityRef) { this.entityRef = entityRef; diff --git a/src/main/java/org/terasology/apiculture/ui/InjectorScreen.java b/src/main/java/org/terasology/apiculture/ui/InjectorScreen.java index 2cfc073..6ad8195 100644 --- a/src/main/java/org/terasology/apiculture/ui/InjectorScreen.java +++ b/src/main/java/org/terasology/apiculture/ui/InjectorScreen.java @@ -2,16 +2,16 @@ // SPDX-License-Identifier: Apache-2.0 package org.terasology.apiculture.ui; -import org.terasology.engine.Time; -import org.terasology.entitySystem.entity.EntityRef; -import org.terasology.logic.players.LocalPlayer; import org.terasology.apiculture.components.ProcessingComponent; import org.terasology.apiculture.systems.ExtractorSystem; -import org.terasology.registry.CoreRegistry; -import org.terasology.registry.In; -import org.terasology.rendering.nui.BaseInteractionScreen; +import org.terasology.engine.core.Time; +import org.terasology.engine.entitySystem.entity.EntityRef; +import org.terasology.engine.logic.players.LocalPlayer; +import org.terasology.engine.registry.CoreRegistry; +import org.terasology.engine.registry.In; +import org.terasology.engine.rendering.nui.BaseInteractionScreen; +import org.terasology.inventory.rendering.nui.layers.ingame.InventoryGrid; import org.terasology.nui.databinding.ReadOnlyBinding; -import org.terasology.rendering.nui.layers.ingame.inventory.InventoryGrid; import java.util.Objects; @@ -71,7 +71,7 @@ public boolean isModal() { } private static class EntityRefBinding extends ReadOnlyBinding { - private EntityRef entityRef; + private final EntityRef entityRef; public EntityRefBinding(EntityRef entityRef) { this.entityRef = entityRef; diff --git a/src/main/java/org/terasology/apiculture/ui/LifespanBar.java b/src/main/java/org/terasology/apiculture/ui/LifespanBar.java index 146e24d..eecb0ef 100644 --- a/src/main/java/org/terasology/apiculture/ui/LifespanBar.java +++ b/src/main/java/org/terasology/apiculture/ui/LifespanBar.java @@ -4,7 +4,7 @@ import org.joml.Rectanglei; import org.joml.Vector2i; -import org.terasology.math.JomlUtil; +import org.terasology.engine.math.JomlUtil; import org.terasology.nui.Canvas; import org.terasology.nui.Color; import org.terasology.nui.CoreWidget; @@ -16,7 +16,8 @@ public class LifespanBar extends CoreWidget { @Override public void onDraw(Canvas canvas) { Rectanglei canvasRegion = canvas.getRegion(); - canvas.drawFilledRectangle(JomlUtil.rectangleiFromMinAndSize(canvasRegion.minX, canvasRegion.maxY - (int) (value * canvasRegion.lengthY()), canvasRegion.lengthX(), + canvas.drawFilledRectangle(JomlUtil.rectangleiFromMinAndSize(canvasRegion.minX, + canvasRegion.maxY - (int) (value * canvasRegion.lengthY()), canvasRegion.lengthX(), (int) (canvasRegion.lengthY() * value)), color); } @@ -36,7 +37,7 @@ public void setColor(Color color) { /** * Sets the amount the lifespan bar is filled, as a decimal. - * + *

* Fill fill is clamped between 0 and 1. * * @param fill The percentge of the lifespan bar fill, expressed as a decimal. diff --git a/src/main/java/org/terasology/apiculture/ui/VerticalFiller.java b/src/main/java/org/terasology/apiculture/ui/VerticalFiller.java index 9d071c2..f70f505 100644 --- a/src/main/java/org/terasology/apiculture/ui/VerticalFiller.java +++ b/src/main/java/org/terasology/apiculture/ui/VerticalFiller.java @@ -15,10 +15,11 @@ public class VerticalFiller extends CoreWidget { * The vertical height of this filler. */ @LayoutConfig - private int size = 1; + private final int size = 1; @Override - public void onDraw(Canvas canvas) { } + public void onDraw(Canvas canvas) { + } @Override public Vector2i getPreferredContentSize(Canvas canvas, Vector2i sizeHint) {