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

fix(ecs-gestalt): Migrate Components to gestalt's Components. #15

Merged
merged 2 commits into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 3 additions & 16 deletions src/main/java/org/terasology/oreGeneration/OreGenRegistry.java
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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<T extends BasePocketOreGenComponent<T>> implements Component<T> {
public String block;
// frequency for every 10 cubed blocks
public float frequency = 1f;
Expand All @@ -36,4 +23,25 @@ public class BasePocketOreGenComponent implements Component {
public float noiseLevelRange = 0.2f;
public float noiseCutoff;
public float noiseCutoffRange;

@Override
public void copyFrom(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;
}
}
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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<DepthPocketOreGenComponent> {
public int minDepth;
public int maxDepth;

@Override
public void copyFrom(DepthPocketOreGenComponent other) {
super.copyFrom(other);
this.minDepth = other.minDepth;
this.maxDepth = other.maxDepth;
}
}
Original file line number Diff line number Diff line change
@@ -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<OreGenDefinitionComponent> {
}
Original file line number Diff line number Diff line change
@@ -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<PocketDensityOreGenComponent> {
public int minDensity = 2;
public int maxDensity = Integer.MAX_VALUE;

@Override
public void copyFrom(PocketDensityOreGenComponent other) {
super.copyFrom(other);
this.minDensity = other.minDensity;
this.maxDensity = other.maxDensity;
}
}
Original file line number Diff line number Diff line change
@@ -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<VeinsDensityOreGenComponent> {
public int minDensity = 2;
public int maxDensity = Integer.MAX_VALUE;

@Override
public void copyFrom(VeinsDensityOreGenComponent other) {
super.copy(other);
this.minDensity = other.minDensity;
this.maxDensity = other.maxDensity;
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down