Skip to content

Commit

Permalink
fix(ecs-gestalt): Migrate Components to gestalt's Components. (#56)
Browse files Browse the repository at this point in the history
Ref: MovingBlocks/Terasology#4753

Co-authored-by: Tobias Nett <[email protected]>
  • Loading branch information
DarkWeird and skaldarnar authored Aug 25, 2021
1 parent c7d9604 commit f29f2be
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 78 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// Copyright 2020 The Terasology Foundation
// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0

package org.terasology.climateConditions;

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

/**
* Provides Body Temperature to entity attached with BodyTemperatureComponent.
* Is managed by {@link BodyTemperatureSystem}
*/
public class BodyTemperatureComponent implements Component {
public class BodyTemperatureComponent implements Component<BodyTemperatureComponent> {

/**
* Body Temperature Levels corresponding to value ranges:
Expand All @@ -32,4 +32,10 @@ public class BodyTemperatureComponent implements Component {
/** Stores the current body temperature level.*/
@Replicate
BodyTemperatureLevel currentLevel = BodyTemperatureLevel.NORMAL;

@Override
public void copyFrom(BodyTemperatureComponent other) {
this.current = other.current;
this.currentLevel = other.currentLevel;
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
/*
* 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.climateConditions;

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

@ForceBlockActive
public class HumidityGeneratorComponent implements Component {
public class HumidityGeneratorComponent implements Component<HumidityGeneratorComponent> {
public float humidity;
public float flatRange;
public float maxRange;
public boolean humidifier;

@Override
public void copyFrom(HumidityGeneratorComponent other) {
this.humidity = other.humidity;
this.flatRange = other.flatRange;
this.maxRange = other.maxRange;
this.humidifier = other.humidifier;
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +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.climateConditions;

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

public class HyperthermiaComponent implements Component {
public class HyperthermiaComponent implements Component<HyperthermiaComponent> {
public float walkSpeedMultiplier = 0.7f;
public float jumpSpeedMultiplier = 0.85f;
public float regenMultiplier = 0.8f;
Expand All @@ -41,4 +28,14 @@ public class HyperthermiaComponent implements Component {
HyperthermiaComponent(int level) {
this.level = level;
}

@Override
public void copyFrom(HyperthermiaComponent other) {
this.walkSpeedMultiplier = other.walkSpeedMultiplier;
this.jumpSpeedMultiplier = other.jumpSpeedMultiplier;
this.regenMultiplier = other.regenMultiplier;
this.maxHealthMultiplier = other.maxHealthMultiplier;
this.thirstMultiplier = other.thirstMultiplier;
this.level = other.level;
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
/*
* 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.climateConditions;

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

/**
* Increases the game difficulty in locations with extreme cold climate.
* Is added/removed by the {@link HypothermiaSystem} when the player enters/leaves a "danger zone".
*/
public class HypothermiaComponent implements Component {
public class HypothermiaComponent implements Component<HypothermiaComponent> {
public float walkSpeedMultiplier = 0.6f;
public float jumpSpeedMultiplier = 0.7f;
/**
Expand All @@ -42,4 +29,11 @@ public class HypothermiaComponent implements Component {
HypothermiaComponent(int level) {
this.level = level;
}

@Override
public void copyFrom(HypothermiaComponent other) {
this.walkSpeedMultiplier = other.walkSpeedMultiplier;
this.jumpSpeedMultiplier = other.jumpSpeedMultiplier;
this.level = other.level;
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
/*
* 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.climateConditions;

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

@ForceBlockActive
public class TemperatureGeneratorComponent implements Component {
public class TemperatureGeneratorComponent implements Component<TemperatureGeneratorComponent> {
public float temperature;
public float flatRange;
public float maxRange;
public boolean heater;

@Override
public void copyFrom(TemperatureGeneratorComponent other) {
this.temperature = other.temperature;
this.flatRange = other.flatRange;
this.maxRange = other.maxRange;
this.heater = other.heater;
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0

package org.terasology.climateConditions;

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

/**
* Augments the world with a visible breath particle effect. Has a desired effect only if the entity has a {@link
* org.terasology.engine.logic.location.LocationComponent} which determines the location and direction of the effect.
* Is added/updated by the {@link VisibleBreathingSystem} periodically.
*/
public class VisibleBreathComponent implements Component {
public class VisibleBreathComponent implements Component<VisibleBreathComponent> {
public EntityRef particleEntity = EntityRef.NULL;

@Override
public void copyFrom(VisibleBreathComponent other) {
this.particleEntity = other.particleEntity;
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright 2020 The Terasology Foundation
// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0

package org.terasology.climateConditions.alterationEffects;

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

/**
* This is the component added to entities with the body temperature alteration effect.
*/
public class AffectBodyTemperatureComponent implements Component {
public class AffectBodyTemperatureComponent implements Component<AffectBodyTemperatureComponent> {
public float postMultiplier;
/**
* Stores information regarding condition for body temperature change alteration -
Expand All @@ -18,4 +18,10 @@ public class AffectBodyTemperatureComponent implements Component {
* 3. ALWAYS - modifies the change irrespective of whether it is positive or negative.
*/
TemperatureAlterationCondition condition;

@Override
public void copyFrom(AffectBodyTemperatureComponent other) {
this.postMultiplier = other.postMultiplier;
this.condition = other.condition;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// Copyright 2020 The Terasology Foundation
// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0

package org.terasology.climateConditions.alterationEffects;
Expand All @@ -9,14 +9,14 @@
import org.terasology.alterationEffects.OnEffectRemoveEvent;
import org.terasology.climateConditions.AffectBodyTemperatureEvent;
import org.terasology.engine.context.Context;
import org.terasology.engine.entitySystem.Component;
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.DelayedActionTriggeredEvent;
import org.terasology.engine.registry.In;
import org.terasology.gestalt.entitysystem.component.Component;

import java.util.HashMap;
import java.util.Map;
Expand Down

0 comments on commit f29f2be

Please sign in to comment.