-
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 2 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
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 copy(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
15 changes: 12 additions & 3 deletions
15
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 @@ | ||||||||
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{ | ||||||||
public class RandomDamageComponent implements Component<RandomDamageComponent> { | ||||||||
public RandomDamageComponent() { | ||||||||
|
||||||||
} | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to add the default constructor here if there are no other constructors.
Suggested change
|
||||||||
|
||||||||
//inclusive | ||||||||
@Replicate | ||||||||
public int minDamage = 2; | ||||||||
|
||||||||
//inclusive | ||||||||
@Replicate | ||||||||
public int maxDamage = 4; | ||||||||
|
||||||||
@Override | ||||||||
public void copy(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
13 changes: 9 additions & 4 deletions
13
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,25 @@ | ||
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 copy(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
13 changes: 10 additions & 3 deletions
13
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,14 @@ | ||
// Copyright 2021 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package org.terasology.combatSystem.traps.components; | ||
|
||
import org.terasology.engine.entitySystem.Component; | ||
|
||
public class ActivateOnPlaceComponent implements Component{ | ||
|
||
import org.terasology.gestalt.entitysystem.component.Component; | ||
|
||
public class ActivateOnPlaceComponent implements Component<ActivateOnPlaceComponent> { | ||
|
||
@Override | ||
public void copy(ActivateOnPlaceComponent other) { | ||
|
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should just extend |
||
} |
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 copy(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 copy(BeaconComponent other) { | ||
this.base = other.base; | ||
} | ||
} |
23 changes: 17 additions & 6 deletions
23
src/main/java/org/terasology/combatSystem/traps/components/HomingComponent.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,22 +1,33 @@ | ||
// 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 HomingComponent implements Component{ | ||
public class HomingComponent implements Component<HomingComponent> { | ||
@Replicate | ||
public EntityRef target = EntityRef.NULL; | ||
|
||
@Replicate | ||
public int initialSleepTime = 500; | ||
|
||
@Replicate | ||
public int updationTime = 200; | ||
|
||
@Replicate | ||
public float lastUpdateTime = -1.0f; | ||
|
||
@Replicate | ||
public float launchedTime = -1.0f; | ||
|
||
@Override | ||
public void copy(HomingComponent other) { | ||
this.target = other.target; | ||
this.initialSleepTime = other.initialSleepTime; | ||
this.updationTime = other.updationTime; | ||
this.lastUpdateTime = other.lastUpdateTime; | ||
this.launchedTime = other.launchedTime; | ||
} | ||
} |
10 changes: 7 additions & 3 deletions
10
src/main/java/org/terasology/combatSystem/traps/components/SwitchComponent.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,16 +1,20 @@ | ||
// Copyright 2021 The Terasology Foundation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package org.terasology.combatSystem.traps.components; | ||
|
||
import com.google.common.collect.Lists; | ||
import org.terasology.engine.entitySystem.Component; | ||
import org.terasology.engine.entitySystem.entity.EntityRef; | ||
import org.terasology.engine.world.block.ForceBlockActive; | ||
import org.terasology.gestalt.entitysystem.component.Component; | ||
|
||
import java.util.List; | ||
|
||
@ForceBlockActive | ||
public class SwitchComponent implements Component{ | ||
public class SwitchComponent implements Component<SwitchComponent> { | ||
public List<EntityRef> doors = Lists.newArrayList(); | ||
|
||
@Override | ||
public void copy(SwitchComponent other) { | ||
this.doors = Lists.newArrayList(other.doors); | ||
} | ||
} |
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...