-
Notifications
You must be signed in to change notification settings - Fork 13
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
feature(ecs-gestalt): Migrate Components to gestalt's Components #82
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a9dcfa0
feature(ecs-gestalt): Migrate Components to gestalt's Components
pollend 57e1159
Merge branch 'develop' into feature/migrate-ecs-to-gestalt
skaldarnar d838bb6
chore: rename copy >>> copyFrom (as per MovingBlocks/gestalt#123)
skaldarnar 0b2d3e9
chore: rename 'FactionList' >>> 'Faction' and add docstrings
skaldarnar 81c3ca5
chore: remove unnecessary constructor, add docstrings
skaldarnar 05bf16f
chore: make marker components extend EmptyComponent + add some docstr…
skaldarnar bd5b84e
chore: implement deep 'copy()' for 'AddSwitchDoorsComponent.DoorsToSp…
skaldarnar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FactionList
is just an interface 🤔 not sure how to do a deep copy of instances of that in the end ... not even sure what the design decision here was...