From b072ed63f56d9dc9abd9194acc241b1203fda5a2 Mon Sep 17 00:00:00 2001 From: DarkWeird Date: Fri, 9 Jul 2021 16:53:16 +0300 Subject: [PATCH 1/2] fix(ecs-gestalt): Migrate Components to gestalt's Components. --- .../oreGeneration/OreGenRegistry.java | 19 ++----- .../components/BasePocketOreGenComponent.java | 42 +++++++++------- .../components/BaseVeinsOreGenComponent.java | 49 +++++++++++++------ .../DepthPocketOreGenComponent.java | 26 ++++------ .../components/OreGenDefinitionComponent.java | 21 ++------ .../PocketDensityOreGenComponent.java | 28 ++++------- .../VeinsDensityOreGenComponent.java | 28 +++++------ .../systems/OreGenRegistrySystem.java | 19 ++----- 8 files changed, 100 insertions(+), 132 deletions(-) diff --git a/src/main/java/org/terasology/oreGeneration/OreGenRegistry.java b/src/main/java/org/terasology/oreGeneration/OreGenRegistry.java index 249a116..4f33847 100644 --- a/src/main/java/org/terasology/oreGeneration/OreGenRegistry.java +++ b/src/main/java/org/terasology/oreGeneration/OreGenRegistry.java @@ -1,21 +1,8 @@ -/* - * Copyright 2015 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.oreGeneration; -import org.terasology.engine.entitySystem.Component; +import org.terasology.gestalt.entitysystem.component.Component; import java.util.function.Function; diff --git a/src/main/java/org/terasology/oreGeneration/components/BasePocketOreGenComponent.java b/src/main/java/org/terasology/oreGeneration/components/BasePocketOreGenComponent.java index 93b4677..ac0fcf3 100644 --- a/src/main/java/org/terasology/oreGeneration/components/BasePocketOreGenComponent.java +++ b/src/main/java/org/terasology/oreGeneration/components/BasePocketOreGenComponent.java @@ -1,23 +1,10 @@ -/* - * Copyright 2015 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.oreGeneration.components; -import org.terasology.engine.entitySystem.Component; +import org.terasology.gestalt.entitysystem.component.Component; -public class BasePocketOreGenComponent implements Component { +public class BasePocketOreGenComponent> implements Component { public String block; // frequency for every 10 cubed blocks public float frequency = 1f; @@ -36,4 +23,25 @@ public class BasePocketOreGenComponent implements Component { public float noiseLevelRange = 0.2f; public float noiseCutoff; public float noiseCutoffRange; + + @Override + public void copy(T other) { + this.block = other.block; + this.frequency = other.frequency; + this.frequencyRange = other.frequencyRange; + this.radius = other.radius; + this.radiusRange = other.radiusRange; + this.thickness = other.thickness; + this.thicknessRange = other.thicknessRange; + this.angle = other.angle; + this.angleRange = other.angleRange; + this.multiplier = other.multiplier; + this.multiplierRange = other.multiplierRange; + this.density = other.density; + this.densityRange = other.densityRange; + this.noiseLevel = other.noiseLevel; + this.noiseLevelRange = other.noiseLevelRange; + this.noiseCutoff = other.noiseCutoff; + this.noiseCutoffRange = other.noiseCutoffRange; + } } diff --git a/src/main/java/org/terasology/oreGeneration/components/BaseVeinsOreGenComponent.java b/src/main/java/org/terasology/oreGeneration/components/BaseVeinsOreGenComponent.java index 565056e..dac452c 100644 --- a/src/main/java/org/terasology/oreGeneration/components/BaseVeinsOreGenComponent.java +++ b/src/main/java/org/terasology/oreGeneration/components/BaseVeinsOreGenComponent.java @@ -1,18 +1,5 @@ -/* - * Copyright 2015 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.oreGeneration.components; public abstract class BaseVeinsOreGenComponent { @@ -62,4 +49,36 @@ public abstract class BaseVeinsOreGenComponent { public float blockRadiusMultiplier = 1f; public float blockRadiusMultiplierRange = 0.1f; */ + + protected void copy(BaseVeinsOreGenComponent other) { + this.block = other.block; + this.frequency = other.frequency; + this.frequencyRange = other.frequencyRange; + this.motherLodeRadius = other.motherLodeRadius; + this.motherLodeRadiusRange = other.motherLodeRadiusRange; + this.motherlodeRangeLimit = other.motherlodeRangeLimit; + this.motherlodeRangeLimitRange = other.motherlodeRangeLimitRange; + this.branchFrequency = other.branchFrequency; + this.branchFrequencyRange = other.branchFrequencyRange; + this.branchInclination = other.branchInclination; + this.branchInclinationRange = other.branchInclinationRange; + this.branchLength = other.branchLength; + this.branchLengthRange = other.branchLengthRange; + this.branchHeightLimit = other.branchHeightLimit; + this.branchHeightLimitRange = other.branchHeightLimitRange; + this.density = other.density; + this.densityRange = other.densityRange; + this.segmentForkFrequency = other.segmentForkFrequency; + this.segmentForkFrequencyRange = other.segmentForkFrequencyRange; + this.segmentForkLengthMultiplier = other.segmentForkLengthMultiplier; + this.segmentForkLengthMultiplierRange = other.segmentForkLengthMultiplierRange; + this.segmentLength = other.segmentLength; + this.segmentLengthRange = other.segmentLengthRange; + this.segmentAngle = other.segmentAngle; + this.segmentAngleRange = other.segmentAngleRange; + this.segmentRadius = other.segmentRadius; + this.segmentRadiusRange = other.segmentRadiusRange; + this.blockRadiusMultiplier = other.blockRadiusMultiplier; + this.blockRadiusMultiplierRange = other.blockRadiusMultiplierRange; + } } diff --git a/src/main/java/org/terasology/oreGeneration/components/DepthPocketOreGenComponent.java b/src/main/java/org/terasology/oreGeneration/components/DepthPocketOreGenComponent.java index 086cde1..19eface 100644 --- a/src/main/java/org/terasology/oreGeneration/components/DepthPocketOreGenComponent.java +++ b/src/main/java/org/terasology/oreGeneration/components/DepthPocketOreGenComponent.java @@ -1,21 +1,15 @@ -/* - * 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.oreGeneration.components; -public class DepthPocketOreGenComponent extends BasePocketOreGenComponent { +public class DepthPocketOreGenComponent extends BasePocketOreGenComponent { public int minDepth; public int maxDepth; + + @Override + public void copy(DepthPocketOreGenComponent other) { + super.copy(other); + this.minDepth = other.minDepth; + this.maxDepth = other.maxDepth; + } } diff --git a/src/main/java/org/terasology/oreGeneration/components/OreGenDefinitionComponent.java b/src/main/java/org/terasology/oreGeneration/components/OreGenDefinitionComponent.java index 7ae6f47..a3f0385 100644 --- a/src/main/java/org/terasology/oreGeneration/components/OreGenDefinitionComponent.java +++ b/src/main/java/org/terasology/oreGeneration/components/OreGenDefinitionComponent.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.oreGeneration.components; -import org.terasology.engine.entitySystem.Component; +import org.terasology.gestalt.entitysystem.component.EmptyComponent; /** * Add this to a prefab to allow import of all CustomOreGen component triggers into the registry */ -public class OreGenDefinitionComponent implements Component { +public class OreGenDefinitionComponent extends EmptyComponent { } diff --git a/src/main/java/org/terasology/oreGeneration/components/PocketDensityOreGenComponent.java b/src/main/java/org/terasology/oreGeneration/components/PocketDensityOreGenComponent.java index 97999dc..a0a3ecd 100644 --- a/src/main/java/org/terasology/oreGeneration/components/PocketDensityOreGenComponent.java +++ b/src/main/java/org/terasology/oreGeneration/components/PocketDensityOreGenComponent.java @@ -1,23 +1,15 @@ -/* - * 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.oreGeneration.components; -import org.terasology.engine.entitySystem.Component; - -public class PocketDensityOreGenComponent extends BasePocketOreGenComponent implements Component { +public class PocketDensityOreGenComponent extends BasePocketOreGenComponent { public int minDensity = 2; public int maxDensity = Integer.MAX_VALUE; + + @Override + public void copy(PocketDensityOreGenComponent other) { + super.copy(other); + this.minDensity = other.minDensity; + this.maxDensity = other.maxDensity; + } } diff --git a/src/main/java/org/terasology/oreGeneration/components/VeinsDensityOreGenComponent.java b/src/main/java/org/terasology/oreGeneration/components/VeinsDensityOreGenComponent.java index 28ed077..8a08e1c 100644 --- a/src/main/java/org/terasology/oreGeneration/components/VeinsDensityOreGenComponent.java +++ b/src/main/java/org/terasology/oreGeneration/components/VeinsDensityOreGenComponent.java @@ -1,23 +1,17 @@ -/* - * Copyright 2015 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.oreGeneration.components; -import org.terasology.engine.entitySystem.Component; +import org.terasology.gestalt.entitysystem.component.Component; -public class VeinsDensityOreGenComponent extends BaseVeinsOreGenComponent implements Component { +public class VeinsDensityOreGenComponent extends BaseVeinsOreGenComponent implements Component { public int minDensity = 2; public int maxDensity = Integer.MAX_VALUE; + + @Override + public void copy(VeinsDensityOreGenComponent other) { + super.copy(other); + this.minDensity = other.minDensity; + this.maxDensity = other.maxDensity; + } } diff --git a/src/main/java/org/terasology/oreGeneration/systems/OreGenRegistrySystem.java b/src/main/java/org/terasology/oreGeneration/systems/OreGenRegistrySystem.java index e94bf13..7cb8e29 100644 --- a/src/main/java/org/terasology/oreGeneration/systems/OreGenRegistrySystem.java +++ b/src/main/java/org/terasology/oreGeneration/systems/OreGenRegistrySystem.java @@ -1,24 +1,10 @@ -/* - * Copyright 2020 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.oreGeneration.systems; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import com.google.common.collect.Sets; -import org.terasology.engine.entitySystem.Component; import org.terasology.engine.entitySystem.prefab.Prefab; import org.terasology.engine.entitySystem.prefab.PrefabManager; import org.terasology.engine.entitySystem.systems.BaseComponentSystem; @@ -27,6 +13,7 @@ import org.terasology.engine.registry.In; import org.terasology.engine.registry.InjectionHelper; import org.terasology.engine.registry.Share; +import org.terasology.gestalt.entitysystem.component.Component; import org.terasology.oreGeneration.CustomOreGen; import org.terasology.oreGeneration.OreGenRegistry; import org.terasology.oreGeneration.components.OreGenDefinitionComponent; From 8a893fd57ef5eab601a9e5b46fdb3769e7715e4a Mon Sep 17 00:00:00 2001 From: Tobias Nett Date: Sat, 14 Aug 2021 12:18:58 +0200 Subject: [PATCH 2/2] chore: rename copy >>> copyFrom (as per MovingBlocks/gestalt#123) --- .../oreGeneration/components/BasePocketOreGenComponent.java | 2 +- .../oreGeneration/components/DepthPocketOreGenComponent.java | 4 ++-- .../components/PocketDensityOreGenComponent.java | 4 ++-- .../oreGeneration/components/VeinsDensityOreGenComponent.java | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/terasology/oreGeneration/components/BasePocketOreGenComponent.java b/src/main/java/org/terasology/oreGeneration/components/BasePocketOreGenComponent.java index ac0fcf3..f0396a1 100644 --- a/src/main/java/org/terasology/oreGeneration/components/BasePocketOreGenComponent.java +++ b/src/main/java/org/terasology/oreGeneration/components/BasePocketOreGenComponent.java @@ -25,7 +25,7 @@ public class BasePocketOreGenComponent> i public float noiseCutoffRange; @Override - public void copy(T other) { + public void copyFrom(T other) { this.block = other.block; this.frequency = other.frequency; this.frequencyRange = other.frequencyRange; diff --git a/src/main/java/org/terasology/oreGeneration/components/DepthPocketOreGenComponent.java b/src/main/java/org/terasology/oreGeneration/components/DepthPocketOreGenComponent.java index 19eface..99dd114 100644 --- a/src/main/java/org/terasology/oreGeneration/components/DepthPocketOreGenComponent.java +++ b/src/main/java/org/terasology/oreGeneration/components/DepthPocketOreGenComponent.java @@ -7,8 +7,8 @@ public class DepthPocketOreGenComponent extends BasePocketOreGenComponent