-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(ecs-gestalt): Migrate Components to gestalt's Components (#82)
Ref: MovingBlocks/Terasology#4753 Co-authored-by: Michael Pollind <mpollind@gmail.com>
- Loading branch information
1 parent
6e636f3
commit dfb4934
Showing
33 changed files
with
371 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2021 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.terasology.combatSystem; | ||
|
||
/** | ||
* Interface used to specify different types of faction lists. | ||
* <p> | ||
* Classes implementing this interface should be <b>immutable</b>. This is to allow for a safe reuse when copying the faction in | ||
* components. | ||
*/ | ||
public interface Faction { | ||
//NOTE: if we identify the need to make the faction implementations mutable, or observe any other issues with only doing a shallow copy | ||
// of properties of this type in components, we may add a 'copy()' method to this interface. | ||
} |
This file was deleted.
Oops, something went wrong.
5 changes: 4 additions & 1 deletion
5
...ology/combatSystem/PlanetFactionList.java → ...rasology/combatSystem/PlanetFactions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 12 additions & 5 deletions
17
src/main/java/org/terasology/combatSystem/components/FactionComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
// Copyright 2021 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.terasology.combatSystem.components; | ||
|
||
import org.terasology.combatSystem.FactionList; | ||
import org.terasology.combatSystem.PlanetFactionList; | ||
import org.terasology.engine.entitySystem.Component; | ||
import org.terasology.combatSystem.Faction; | ||
import org.terasology.combatSystem.PlanetFactions; | ||
import org.terasology.engine.network.Replicate; | ||
import org.terasology.gestalt.entitysystem.component.Component; | ||
|
||
/** | ||
* Makes the entity belong to a specific faction. | ||
*/ | ||
public class FactionComponent implements Component{ | ||
public class FactionComponent implements Component<FactionComponent> { | ||
@Replicate | ||
public FactionList faction = PlanetFactionList.EARTH; | ||
public Faction faction = PlanetFactions.EARTH; | ||
|
||
@Override | ||
public void copyFrom(FactionComponent other) { | ||
this.faction = other.faction; | ||
} | ||
} |
15 changes: 11 additions & 4 deletions
15
src/main/java/org/terasology/combatSystem/hurting/CritDamageComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,27 @@ | ||
// Copyright 2021 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.terasology.combatSystem.hurting; | ||
|
||
import org.terasology.engine.entitySystem.Component; | ||
import org.terasology.engine.network.Replicate; | ||
import org.terasology.gestalt.entitysystem.component.Component; | ||
|
||
/** | ||
* Damages an entity critically. | ||
* <p> | ||
* Damaging critically means multiplying the original damage by <b>critFactor</b>. | ||
* The critical damage has <b>critChance</b>/100 probability of occurring. | ||
*/ | ||
public class CritDamageComponent implements Component{ | ||
public class CritDamageComponent implements Component<CritDamageComponent> { | ||
|
||
@Replicate | ||
public int critChance = 10; // in percentage out of 100 | ||
|
||
@Replicate | ||
public float critFactor = 2; // factor to multiply damage with | ||
|
||
@Override | ||
public void copyFrom(CritDamageComponent other) { | ||
this.critChance = other.critChance; | ||
this.critFactor = other.critFactor; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 14 additions & 5 deletions
19
src/main/java/org/terasology/combatSystem/hurting/RandomDamageComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,27 @@ | ||
// Copyright 2021 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.terasology.combatSystem.hurting; | ||
|
||
import org.terasology.engine.entitySystem.Component; | ||
import org.terasology.engine.network.Replicate; | ||
import org.terasology.gestalt.entitysystem.component.Component; | ||
|
||
/** | ||
* To generate a random damage amount between <b>minDamage</b> and <b>maxDamage</b> (both inclusive). | ||
*/ | ||
public class RandomDamageComponent implements Component{ | ||
//inclusive | ||
public class RandomDamageComponent implements Component<RandomDamageComponent> { | ||
|
||
/** The minimal damage (inclusive). */ | ||
@Replicate | ||
public int minDamage = 2; | ||
//inclusive | ||
|
||
/** The maximum damage (inclusive). */ | ||
@Replicate | ||
public int maxDamage = 4; | ||
|
||
@Override | ||
public void copyFrom(RandomDamageComponent other) { | ||
this.minDamage = other.minDamage; | ||
this.maxDamage = other.maxDamage; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 12 additions & 4 deletions
16
src/main/java/org/terasology/combatSystem/physics/components/FrictionComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,28 @@ | ||
// Copyright 2021 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.terasology.combatSystem.physics.components; | ||
|
||
import org.terasology.engine.entitySystem.Component; | ||
import org.terasology.engine.network.Replicate; | ||
import org.terasology.gestalt.entitysystem.component.Component; | ||
|
||
/** | ||
* Adds <b>friction</b>. | ||
* <p> | ||
* <b>this</b> can be used to implement <b>Fluid Viscosity</b> as well. | ||
* | ||
* | ||
* TODO implement this component and its code. | ||
*/ | ||
public class FrictionComponent implements Component{ | ||
public class FrictionComponent implements Component<FrictionComponent> { | ||
@Replicate | ||
float friction = 20.0f; | ||
|
||
@Replicate | ||
float velocity = 20.0f; | ||
|
||
@Override | ||
public void copyFrom(FrictionComponent other) { | ||
this.friction = other.friction; | ||
this.velocity = other.velocity; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 7 additions & 3 deletions
10
src/main/java/org/terasology/combatSystem/traps/components/ActivateOnPlaceComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
// Copyright 2021 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.terasology.combatSystem.traps.components; | ||
|
||
import org.terasology.engine.entitySystem.Component; | ||
import org.terasology.gestalt.entitysystem.component.EmptyComponent; | ||
|
||
public class ActivateOnPlaceComponent implements Component{ | ||
|
||
/** | ||
* Marker component to indicate that the combat effect of an entity should activate when the entity is placed (as a block) in the world. | ||
*/ | ||
public class ActivateOnPlaceComponent extends EmptyComponent<ActivateOnPlaceComponent> { | ||
} |
19 changes: 14 additions & 5 deletions
19
src/main/java/org/terasology/combatSystem/traps/components/BaseLauncherComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,29 @@ | ||
// Copyright 2021 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.terasology.combatSystem.traps.components; | ||
|
||
import org.terasology.engine.entitySystem.Component; | ||
import org.terasology.engine.entitySystem.prefab.Prefab; | ||
import org.terasology.engine.network.Replicate; | ||
import org.terasology.gestalt.entitysystem.component.Component; | ||
|
||
public class BaseLauncherComponent implements Component{ | ||
public class BaseLauncherComponent implements Component<BaseLauncherComponent> { | ||
@Replicate | ||
public Prefab entityInBase; | ||
|
||
@Replicate | ||
public int amountOfEntityInBase; | ||
|
||
@Replicate | ||
public int coolDownTime = 1000; | ||
|
||
@Replicate | ||
public float lastLaunchTime = -1.0f; | ||
|
||
@Override | ||
public void copyFrom(BaseLauncherComponent other) { | ||
this.entityInBase = other.entityInBase; | ||
this.amountOfEntityInBase = other.amountOfEntityInBase; | ||
this.coolDownTime = other.coolDownTime; | ||
this.lastLaunchTime = other.lastLaunchTime; | ||
} | ||
} |
10 changes: 8 additions & 2 deletions
10
src/main/java/org/terasology/combatSystem/traps/components/BeaconComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
// Copyright 2021 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.terasology.combatSystem.traps.components; | ||
|
||
import org.terasology.engine.entitySystem.Component; | ||
import org.terasology.engine.entitySystem.entity.EntityRef; | ||
import org.terasology.engine.network.Replicate; | ||
import org.terasology.gestalt.entitysystem.component.Component; | ||
|
||
public class BeaconComponent implements Component{ | ||
public class BeaconComponent implements Component<BeaconComponent> { | ||
@Replicate | ||
public EntityRef base = EntityRef.NULL; | ||
|
||
@Override | ||
public void copyFrom(BeaconComponent other) { | ||
this.base = other.base; | ||
} | ||
} |
Oops, something went wrong.