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. #48

Merged
merged 3 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
package org.terasology.gookeeper.component;

public class AggressiveComponent extends FactorComponent {
public class AggressiveComponent extends FactorComponent<AggressiveComponent> {

}
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
/*
* Copyright 2017 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.gookeeper.component;

import org.terasology.engine.entitySystem.Component;
import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.gestalt.entitysystem.component.Component;

public class BreedingBlockComponent implements Component {
public class BreedingBlockComponent implements Component<BreedingBlockComponent> {
/**
* The gooey entity which is to be involved in mating
*/
public EntityRef parentGooey = EntityRef.NULL;

@Override
public void copyFrom(BreedingBlockComponent other) {
this.parentGooey = other.parentGooey;
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
/*
* Copyright 2018 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.gookeeper.component;

import org.terasology.engine.entitySystem.Component;
import org.terasology.gestalt.entitysystem.component.Component;

public class EconomyComponent implements Component {
public class EconomyComponent implements Component<EconomyComponent> {
public float playerWalletCredit = 2000f;

@Override
public void copyFrom(EconomyComponent other) {
this.playerWalletCredit = other.playerWalletCredit;
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
/*
* Copyright 2017 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.gookeeper.component;

import org.terasology.engine.entitySystem.Component;
import org.terasology.gestalt.entitysystem.component.Component;

abstract public class FactorComponent implements Component {
public abstract class FactorComponent<T extends FactorComponent> implements Component<T> {
public float magnitude;

@Override
public void copyFrom(T other) {
this.magnitude = other.magnitude;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
// SPDX-License-Identifier: Apache-2.0
package org.terasology.gookeeper.component;

public class FriendlyComponent extends FactorComponent {
public class FriendlyComponent extends FactorComponent<FriendlyComponent> {
@Override
public void copyFrom(FriendlyComponent other) {
super.copyFrom(other);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
package org.terasology.gookeeper.component;

import com.google.common.collect.Lists;
import org.terasology.engine.entitySystem.Component;
import org.terasology.engine.entitySystem.prefab.Prefab;
import org.terasology.gestalt.entitysystem.component.Component;

import java.util.List;
import java.util.Optional;

public class GooeyComponent implements Component {
public class GooeyComponent implements Component<GooeyComponent> {
/**
* The prefab corresponding to this gooey type
*/
public Optional<Prefab> prefab;
public Optional<Prefab> prefab = Optional.empty();

/**
* The profit factor. (i.e how much money does the player make from the visitors viewing the gooey)
Expand Down Expand Up @@ -85,4 +85,22 @@ public class GooeyComponent implements Component {
*/
public long lifeTime = 1800000;

@Override
public void copyFrom(GooeyComponent other) {
this.prefab = other.prefab;
this.profitPayOff = other.profitPayOff;
this.biome = other.biome;
this.blockBelow = other.blockBelow;
this.SPAWN_CHANCE = other.SPAWN_CHANCE;
this.MAX_GROUP_SIZE = other.MAX_GROUP_SIZE;
this.maxStunChargesReq = other.maxStunChargesReq;
this.stunChargesReq = other.stunChargesReq;
this.stunTime = other.stunTime;
this.stunFrequency = other.stunFrequency;
this.isStunned = other.isStunned;
this.isCaptured = other.isCaptured;
this.captureProbabiltyFactor = other.captureProbabiltyFactor;
this.penNumber = other.penNumber;
this.lifeTime = other.lifeTime;
}
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
/*
* Copyright 2018 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.gookeeper.component;

import org.terasology.engine.entitySystem.Component;
import com.google.common.collect.Lists;
import org.terasology.gestalt.entitysystem.component.Component;

import java.util.ArrayList;
import java.util.List;

public class HungerComponent implements Component {
public class HungerComponent implements Component<HungerComponent> {
/**
* The block items which are allowed to be consumed by the gooey entity
*/
Expand All @@ -40,4 +28,12 @@ public class HungerComponent implements Component {
* The amount of health lost every 'healthDecreaseInterval'
*/
public float healthDecreaseAmount = 2f;

@Override
public void copyFrom(HungerComponent other) {
this.food = Lists.newArrayList(other.food);
this.timeBeforeHungry = other.timeBeforeHungry;
this.healthDecreaseInterval = other.healthDecreaseInterval;
this.healthDecreaseAmount = other.healthDecreaseAmount;
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
/*
* Copyright 2018 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.gookeeper.component;

import org.terasology.engine.entitySystem.Component;
import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.gestalt.entitysystem.component.Component;

public class MatingComponent implements Component {
public class MatingComponent implements Component<MatingComponent> {
public EntityRef matingWithEntity = EntityRef.NULL;
public boolean selectedForMating = false;

@Override
public void copyFrom(MatingComponent other) {
this.matingWithEntity = other.matingWithEntity;
this.selectedForMating = other.selectedForMating;
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
/*
* Copyright 2018 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.gookeeper.component;

import org.terasology.engine.entitySystem.Component;
import org.terasology.engine.world.block.ForceBlockActive;
import org.terasology.gestalt.entitysystem.component.Component;

@ForceBlockActive
public class PenBlockComponent implements Component {
public class PenBlockComponent implements Component<PenBlockComponent> {
/**
* Defines the type of gooeys housed in a pen made up of this block
*/
Expand All @@ -36,4 +23,13 @@ public class PenBlockComponent implements Component {
public int penNumber = 0;

public boolean penIDSet = false;

@Override
public void copyFrom(PenBlockComponent other) {
this.type = other.type;
this.cutoffFactor = other.cutoffFactor;
this.penNumber = other.penNumber;
this.penIDSet = other.penIDSet;

}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
/*
* Copyright 2018 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.gookeeper.component;

import org.terasology.engine.entitySystem.Component;
import org.terasology.engine.entitySystem.prefab.Prefab;
import org.terasology.engine.logic.health.EngineDamageTypes;
import org.terasology.gestalt.entitysystem.component.Component;

public class PlazMasterComponent implements Component {
public class PlazMasterComponent implements Component<PlazMasterComponent> {
/**
* The max. distance till which the cannon is viable.
*/
Expand Down Expand Up @@ -61,4 +48,17 @@ public class PlazMasterComponent implements Component {
public int damageAmount = 6;

public Prefab damageType = EngineDamageTypes.PHYSICAL.get();

@Override
public void copyFrom(PlazMasterComponent other) {
this.maxDistance = other.maxDistance;
this.maxCharges = other.maxCharges;
this.charges = other.charges;
this.shotRecoveryTime = other.shotRecoveryTime;
this.rateOfFire = other.rateOfFire;
this.maxFrequency = other.maxFrequency;
this.frequency = other.frequency;
this.damageAmount = other.damageAmount;
this.damageType = other.damageType;
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
/*
* Copyright 2018 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.gookeeper.component;

import org.terasology.engine.entitySystem.Component;
import org.terasology.gestalt.entitysystem.component.Component;

public class PlazMasterShotComponent implements Component {
public class PlazMasterShotComponent implements Component<PlazMasterShotComponent> {
public float velocity = 0.7f;

@Override
public void copyFrom(PlazMasterShotComponent other) {
this.velocity = other.velocity;
}
}
Loading