From 841e7318a7a26a4519cfb2b5c6b43955a5a6003b Mon Sep 17 00:00:00 2001 From: Nail Khanipov Date: Thu, 26 Aug 2021 00:03:01 +0300 Subject: [PATCH] fix(ecs-gestalt): Migrate Components to gestalt's Components. (#21) Ref: MovingBlocks/Terasology#4753 Co-authored-by: Tobias Nett --- .../component/GeneratedHerbComponent.java | 26 +++++--------- .../herbalism/component/HerbComponent.java | 21 +++--------- .../herbalism/component/HerbHueComponent.java | 27 ++++++--------- .../HerbalismStationRecipeComponent.java | 34 +++++++++---------- .../component/PollinatingHerbComponent.java | 21 +++--------- .../component/PredefinedHerbComponent.java | 26 +++++--------- 6 files changed, 53 insertions(+), 102 deletions(-) diff --git a/src/main/java/org/terasology/herbalism/component/GeneratedHerbComponent.java b/src/main/java/org/terasology/herbalism/component/GeneratedHerbComponent.java index a641305..6261287 100644 --- a/src/main/java/org/terasology/herbalism/component/GeneratedHerbComponent.java +++ b/src/main/java/org/terasology/herbalism/component/GeneratedHerbComponent.java @@ -1,26 +1,18 @@ -/* - * Copyright 2014 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 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.herbalism.component; -import org.terasology.engine.entitySystem.Component; +import org.terasology.gestalt.entitysystem.component.Component; /** * This component is used for storing the base genome of a generated herb. */ -public final class GeneratedHerbComponent implements Component { +public final class GeneratedHerbComponent implements Component { /** A string description of this herb's base genome. */ public String herbBaseGenome; + + @Override + public void copyFrom(GeneratedHerbComponent other) { + this.herbBaseGenome = other.herbBaseGenome; + } } diff --git a/src/main/java/org/terasology/herbalism/component/HerbComponent.java b/src/main/java/org/terasology/herbalism/component/HerbComponent.java index dfbfb4f..4382034 100644 --- a/src/main/java/org/terasology/herbalism/component/HerbComponent.java +++ b/src/main/java/org/terasology/herbalism/component/HerbComponent.java @@ -1,24 +1,11 @@ -/* - * Copyright 2014 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 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.herbalism.component; -import org.terasology.engine.entitySystem.Component; +import org.terasology.gestalt.entitysystem.component.EmptyComponent; /** * Add this component to an item to indicate that it is a herb. */ -public class HerbComponent implements Component { +public class HerbComponent extends EmptyComponent { } diff --git a/src/main/java/org/terasology/herbalism/component/HerbHueComponent.java b/src/main/java/org/terasology/herbalism/component/HerbHueComponent.java index 906df41..5adedb6 100644 --- a/src/main/java/org/terasology/herbalism/component/HerbHueComponent.java +++ b/src/main/java/org/terasology/herbalism/component/HerbHueComponent.java @@ -1,27 +1,20 @@ -/* - * Copyright 2014 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 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.herbalism.component; -import org.terasology.engine.entitySystem.Component; +import com.google.common.collect.Lists; +import org.terasology.gestalt.entitysystem.component.Component; import java.util.List; /** * This component is used for storing the hue ranges of a particular herb. */ -public class HerbHueComponent implements Component { +public class HerbHueComponent implements Component { public List hueRanges; + + @Override + public void copyFrom(HerbHueComponent other) { + this.hueRanges = Lists.newArrayList(other.hueRanges); + } } diff --git a/src/main/java/org/terasology/herbalism/component/HerbalismStationRecipeComponent.java b/src/main/java/org/terasology/herbalism/component/HerbalismStationRecipeComponent.java index f7eb071..1631250 100644 --- a/src/main/java/org/terasology/herbalism/component/HerbalismStationRecipeComponent.java +++ b/src/main/java/org/terasology/herbalism/component/HerbalismStationRecipeComponent.java @@ -1,21 +1,9 @@ -/* - * Copyright 2016 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 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.herbalism.component; -import org.terasology.engine.entitySystem.Component; +import com.google.common.collect.Lists; +import org.terasology.gestalt.entitysystem.component.Component; import java.util.List; @@ -23,7 +11,7 @@ * Add this Component to any recipe prefab that is supposed to be creatable in a HerbalismStation or similar. * Include in prefab along with CraftingStationRecipeComponent to work properly. */ -public class HerbalismStationRecipeComponent implements Component { +public class HerbalismStationRecipeComponent implements Component { // The following variables are unused. public String recipeId; public List recipeComponents; @@ -35,4 +23,16 @@ public class HerbalismStationRecipeComponent implements Component { public String itemResult; public String blockResult; + + @Override + public void copyFrom(HerbalismStationRecipeComponent other) { + this.recipeId = other.recipeId; + this.recipeComponents = Lists.newArrayList(other.recipeComponents); + this.recipeTools = Lists.newArrayList(other.recipeTools); + this.recipeFluids = Lists.newArrayList(other.recipeFluids); + this.requiredTemperature = other.requiredTemperature; + this.processingDuration = other.processingDuration; + this.itemResult = other.itemResult; + this.blockResult = other.blockResult; + } } diff --git a/src/main/java/org/terasology/herbalism/component/PollinatingHerbComponent.java b/src/main/java/org/terasology/herbalism/component/PollinatingHerbComponent.java index e1158a2..85ea399 100644 --- a/src/main/java/org/terasology/herbalism/component/PollinatingHerbComponent.java +++ b/src/main/java/org/terasology/herbalism/component/PollinatingHerbComponent.java @@ -1,24 +1,11 @@ -/* - * Copyright 2014 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 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.herbalism.component; -import org.terasology.engine.entitySystem.Component; +import org.terasology.gestalt.entitysystem.component.EmptyComponent; /** * Add this component to an item (specficially an herb) to indicate that it's pollinating. */ -public class PollinatingHerbComponent implements Component { +public class PollinatingHerbComponent extends EmptyComponent { } diff --git a/src/main/java/org/terasology/herbalism/component/PredefinedHerbComponent.java b/src/main/java/org/terasology/herbalism/component/PredefinedHerbComponent.java index 84757e3..123570a 100644 --- a/src/main/java/org/terasology/herbalism/component/PredefinedHerbComponent.java +++ b/src/main/java/org/terasology/herbalism/component/PredefinedHerbComponent.java @@ -1,26 +1,18 @@ -/* - * Copyright 2016 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 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.herbalism.component; -import org.terasology.engine.entitySystem.Component; +import org.terasology.gestalt.entitysystem.component.Component; /** * Add this component to an item to indicate that it is a predefined herb. That is, a prefab was directly used to generate * this. */ -public final class PredefinedHerbComponent implements Component { +public final class PredefinedHerbComponent implements Component { public String herbBaseGenome; + + @Override + public void copyFrom(PredefinedHerbComponent other) { + this.herbBaseGenome = other.herbBaseGenome; + } }