diff --git a/src/main/java/org/terasology/alterationEffects/AlterationEffect.java b/src/main/java/org/terasology/alterationEffects/AlterationEffect.java index 7bd4d1a..25c4661 100644 --- a/src/main/java/org/terasology/alterationEffects/AlterationEffect.java +++ b/src/main/java/org/terasology/alterationEffects/AlterationEffect.java @@ -1,18 +1,5 @@ -/* - * 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.alterationEffects; import org.terasology.engine.entitySystem.entity.EntityRef; diff --git a/src/main/java/org/terasology/alterationEffects/AlterationEffects.java b/src/main/java/org/terasology/alterationEffects/AlterationEffects.java index 4e01731..a399ba1 100644 --- a/src/main/java/org/terasology/alterationEffects/AlterationEffects.java +++ b/src/main/java/org/terasology/alterationEffects/AlterationEffects.java @@ -1,18 +1,5 @@ -/* - * 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.alterationEffects; /** diff --git a/src/main/java/org/terasology/alterationEffects/ComponentBasedAlterationEffect.java b/src/main/java/org/terasology/alterationEffects/ComponentBasedAlterationEffect.java index d43e3d6..7200729 100644 --- a/src/main/java/org/terasology/alterationEffects/ComponentBasedAlterationEffect.java +++ b/src/main/java/org/terasology/alterationEffects/ComponentBasedAlterationEffect.java @@ -1,6 +1,5 @@ // Copyright 2021 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 - package org.terasology.alterationEffects; import org.terasology.engine.context.Context; diff --git a/src/main/java/org/terasology/alterationEffects/EffectContext.java b/src/main/java/org/terasology/alterationEffects/EffectContext.java index 65ceead..8b2164f 100644 --- a/src/main/java/org/terasology/alterationEffects/EffectContext.java +++ b/src/main/java/org/terasology/alterationEffects/EffectContext.java @@ -1,6 +1,5 @@ -// Copyright 2020 The Terasology Foundation +// Copyright 2021 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 - package org.terasology.alterationEffects; import org.terasology.engine.entitySystem.entity.EntityRef; diff --git a/src/main/java/org/terasology/alterationEffects/EffectsAuthoritySystem.java b/src/main/java/org/terasology/alterationEffects/EffectsAuthoritySystem.java index f9b2753..c323b30 100644 --- a/src/main/java/org/terasology/alterationEffects/EffectsAuthoritySystem.java +++ b/src/main/java/org/terasology/alterationEffects/EffectsAuthoritySystem.java @@ -26,7 +26,6 @@ import org.terasology.alterationEffects.speed.WalkSpeedComponent; import org.terasology.engine.context.Context; 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.RegisterSystem; import org.terasology.engine.logic.console.commandSystem.annotations.Command; @@ -37,6 +36,7 @@ import org.terasology.engine.network.ClientComponent; import org.terasology.engine.registry.In; import org.terasology.gestalt.entitysystem.component.Component; +import org.terasology.gestalt.entitysystem.event.ReceiveEvent; import java.util.HashMap; import java.util.Map; diff --git a/src/main/java/org/terasology/alterationEffects/OnEffectModifyEvent.java b/src/main/java/org/terasology/alterationEffects/OnEffectModifyEvent.java index 5bfa86a..f5ad232 100644 --- a/src/main/java/org/terasology/alterationEffects/OnEffectModifyEvent.java +++ b/src/main/java/org/terasology/alterationEffects/OnEffectModifyEvent.java @@ -1,18 +1,5 @@ -/* - * Copyright 2016 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.alterationEffects; import gnu.trove.iterator.TDoubleIterator; @@ -30,64 +17,96 @@ * created or a new modifier is added. */ public class OnEffectModifyEvent implements ConsumableEvent { - /** Flags whether this event been consumed or not. */ + /** + * Flags whether this event been consumed or not. + */ private boolean consumed; - /** The instigator entity that instigated this effect modification. */ + /** + * The instigator entity that instigated this effect modification. + */ private EntityRef instigator; - /** A reference to the entity being affected this by effect. */ + /** + * A reference to the entity being affected this by effect. + */ private EntityRef entity; - /** Reference to the original alteration effect that spawned this effect. */ + /** + * Reference to the original alteration effect that spawned this effect. + */ private AlterationEffect alterationEffect; - /** Used to distinguish different effects under the same parent type. Like DOT or Resist ones. */ + /** + * Used to distinguish different effects under the same parent type. Like DOT or Resist ones. + */ private String id; - /** Base magnitude of this effect. */ + /** + * Base magnitude of this effect. + */ private float baseMagnitude = 0f; - /** Base duration of this effect. */ + /** + * Base duration of this effect. + */ private long baseDuration = 0; - /** The current shortest duration of all the effects of this same type that are currently running. */ + /** + * The current shortest duration of all the effects of this same type that are currently running. + */ private long shortestDuration = Long.MAX_VALUE; - /** ID of the item or entity that has the current shortest duration left for its effect being applied. */ + /** + * ID of the item or entity that has the current shortest duration left for its effect being applied. + */ private String effectIDWithShortestDuration = ""; - /** Flag for checking if at least one modifier has infinite duration. */ + /** + * Flag for checking if at least one modifier has infinite duration. + */ private boolean hasInfDuration = false; - /** String that stores the effectID with infinite duration. */ + /** + * String that stores the effectID with infinite duration. + */ private String effectIDWithInfiniteDuration = ""; /* Flag for checking if at least one modifier has zero duration. */ private boolean hasZeroDuration = false; - /** String that stores the effectID with zero duration. */ + /** + * String that stores the effectID with zero duration. + */ private String effectIDWithZeroDuration = ""; - /** A list of all the multipliers for this alteration effect's magnitude. */ + /** + * A list of all the multipliers for this alteration effect's magnitude. + */ private TFloatList magnitudeMultipliers = new TFloatArrayList(); - /** A list of all the multipliers for this alteration effect's duration. */ + /** + * A list of all the multipliers for this alteration effect's duration. + */ private TFloatList durationMultipliers = new TFloatArrayList(); - /** A list of all the modifiers for this alteration effect's magnitude. */ + /** + * A list of all the modifiers for this alteration effect's magnitude. + */ private TFloatList magnitudeModifiers = new TFloatArrayList(); - /** A list of all the modifiers for this alteration effect's duration. */ + /** + * A list of all the modifiers for this alteration effect's duration. + */ private TDoubleList durationModifiers = new TDoubleArrayList(); /** * Create an instance of this event with the minimum number of required parameters. Only use this for debugging. * - * @param instigator The entity that caused this effect to be applied or modified. - * @param entity The entity that the effect is currently on. - * @param baseMagnitude The base magnitude of this effect. - * @param baseDuration The base duration of this effect. + * @param instigator The entity that caused this effect to be applied or modified. + * @param entity The entity that the effect is currently on. + * @param baseMagnitude The base magnitude of this effect. + * @param baseDuration The base duration of this effect. */ public OnEffectModifyEvent(EntityRef instigator, EntityRef entity, float baseMagnitude, long baseDuration) { this.instigator = instigator; @@ -97,18 +116,18 @@ public OnEffectModifyEvent(EntityRef instigator, EntityRef entity, float baseMag } /** - * Create an instance of this event with the given base values, alteration effect, and ID (if needed). Use this one - * over the other method if you wish to use the updated effects system. + * Create an instance of this event with the given base values, alteration effect, and ID (if needed). Use this one over the other + * method if you wish to use the updated effects system. * - * @param instigator The entity that caused this effect to be applied or modified. - * @param entity The entity that the effect is currently on. - * @param baseMagnitude The base magnitude of this effect. - * @param baseDuration The base duration of this effect. - * @param alterationEffect The original alteration effect that created this effect. - * @param id The optional ID of this effect. Only used for effects that support sub-types (like DOT - * for example). - */ - public OnEffectModifyEvent(EntityRef instigator, EntityRef entity, float baseMagnitude, long baseDuration, AlterationEffect alterationEffect, String id) { + * @param instigator The entity that caused this effect to be applied or modified. + * @param entity The entity that the effect is currently on. + * @param baseMagnitude The base magnitude of this effect. + * @param baseDuration The base duration of this effect. + * @param alterationEffect The original alteration effect that created this effect. + * @param id The optional ID of this effect. Only used for effects that support sub-types (like DOT for example). + */ + public OnEffectModifyEvent(EntityRef instigator, EntityRef entity, float baseMagnitude, long baseDuration, + AlterationEffect alterationEffect, String id) { this.instigator = instigator; this.entity = entity; this.baseMagnitude = baseMagnitude; @@ -120,21 +139,25 @@ public OnEffectModifyEvent(EntityRef instigator, EntityRef entity, float baseMag /** * Get the entity who instigated this modify event. * - * @return A reference to the instigator entity. + * @return A reference to the instigator entity. */ - public EntityRef getInstigator() { return instigator; } + public EntityRef getInstigator() { + return instigator; + } /** * Get a reference to the entity being affected. * - * @return A reference to the affected entity. + * @return A reference to the affected entity. */ - public EntityRef getEntity() { return entity; } + public EntityRef getEntity() { + return entity; + } /** * Get a reference to the alteration effect that created the original effect. * - * @return A reference to the original alteration effect. + * @return A reference to the original alteration effect. */ public AlterationEffect getAlterationEffect() { return alterationEffect; @@ -143,17 +166,17 @@ public AlterationEffect getAlterationEffect() { /** * Get the ID of this effect. * - * @return The ID of the effect. + * @return The ID of the effect. */ public String getId() { return id; } /** - * Get the shortest duration of all modifiers collected in this list. If one or more had zero duration, zero will - * be returned. Otherwise, it'll be the shortest duration counted. + * Get the shortest duration of all modifiers collected in this list. If one or more had zero duration, zero will be returned. + * Otherwise, it'll be the shortest duration counted. * - * @return The shortest duration counted. + * @return The shortest duration counted. */ public long getShortestDuration() { if (hasZeroDuration) { @@ -166,7 +189,7 @@ public long getShortestDuration() { /** * Get a list of all the potion effect magnitude multipliers. * - * @return A TFloatList containing the magnitude modifiers. + * @return A TFloatList containing the magnitude modifiers. */ public TFloatList getMagnitudeMultipliers() { return magnitudeMultipliers; @@ -175,7 +198,7 @@ public TFloatList getMagnitudeMultipliers() { /** * Get a list of all the potion effect duration multipliers. * - * @return A TFloatList containing the duration modifiers. + * @return A TFloatList containing the duration modifiers. */ public TFloatList getDurationMultipliers() { return durationMultipliers; @@ -184,7 +207,7 @@ public TFloatList getDurationMultipliers() { /** * Get a list of all the potion effect magnitude (pre)modifiers. * - * @return A TFloatList containing the magnitude (pre)modifiers. + * @return A TFloatList containing the magnitude (pre)modifiers. */ public TFloatList getMagnitudeModifiers() { return magnitudeModifiers; @@ -193,18 +216,18 @@ public TFloatList getMagnitudeModifiers() { /** * Get a list of all the potion effect duration (pre)modifiers. * - * @return A TDoubleList containing the duration (pre)modifiers. + * @return A TDoubleList containing the duration (pre)modifiers. */ public TDoubleList getDurationModifiers() { return durationModifiers; } /** - * Get the effectID of the effect modifier with the shortest duration. If one or more had zero duration, the last - * effectID counted that had zero duration will be returned. Otherwise, the effectID associated with the modifier - * with the shortest duration will be returned. + * Get the effectID of the effect modifier with the shortest duration. If one or more had zero duration, the last effectID counted that + * had zero duration will be returned. Otherwise, the effectID associated with the modifier with the shortest duration will be + * returned. * - * @return The effectID associated to the modifier with the shortest counted duration. + * @return The effectID associated to the modifier with the shortest counted duration. */ public String getEffectIDWithShortestDuration() { if (hasZeroDuration) { @@ -217,7 +240,7 @@ public String getEffectIDWithShortestDuration() { /** * Get the effectID associated with the modifier with infinite duration. * - * @return The effectID of the modifier with infinite duration. + * @return The effectID of the modifier with infinite duration. */ public String getEffectIDWithInfiniteDuration() { return effectIDWithInfiniteDuration; @@ -226,7 +249,7 @@ public String getEffectIDWithInfiniteDuration() { /** * Get whether one or more of the modifiers collected has infinite duration. * - * @return The value of the hasInfDuration flag. + * @return The value of the hasInfDuration flag. */ public boolean getHasInfDuration() { return hasInfDuration; @@ -235,7 +258,7 @@ public boolean getHasInfDuration() { /** * Add a multiplier to the magnitude multipliers list. * - * @param amount The value of the multiplier to add to the list. + * @param amount The value of the multiplier to add to the list. */ public void multiplyMagnitude(float amount) { magnitudeMultipliers.add(amount); @@ -244,7 +267,7 @@ public void multiplyMagnitude(float amount) { /** * Add a multiplier to the duration multipliers list. * - * @param amount The value of the multiplier to add to the list. + * @param amount The value of the multiplier to add to the list. */ public void multiplyDuration(float amount) { durationMultipliers.add(amount); @@ -253,7 +276,7 @@ public void multiplyDuration(float amount) { /** * Add a (pre)modifier to the magnitude (pre)modifiers list. * - * @param amount The value of the modifier to add to the list. + * @param amount The value of the modifier to add to the list. */ public void addMagnitude(float amount) { magnitudeModifiers.add(amount); @@ -262,7 +285,7 @@ public void addMagnitude(float amount) { /** * Add a (pre)modifier to the duration (pre)modifiers list. * - * @param amount The value of the modifier to add to the list. + * @param amount The value of the modifier to add to the list. */ public void addDuration(double amount) { if (amount < shortestDuration) { @@ -278,7 +301,7 @@ public void addDuration(double amount) { /** * Add a (pre)modifier to the duration (pre)modifiers list. * - * @param amount The value of the modifier to add to the list. + * @param amount The value of the modifier to add to the list. */ public void addDuration(double amount, String effectID) { if (amount < shortestDuration) { @@ -299,7 +322,7 @@ public void addDuration(double amount, String effectID) { /** * Add a negative (pre)modifier to the magnitude (pre)modifiers list. * - * @param amount The value of the modifier to add to the list. + * @param amount The value of the modifier to add to the list. */ public void subtractMagnitude(float amount) { magnitudeModifiers.add(-amount); @@ -308,7 +331,7 @@ public void subtractMagnitude(float amount) { /** * Add a negative (pre)modifier to the duration (pre)modifiers list. * - * @param amount The value of the modifier to add to the list. + * @param amount The value of the modifier to add to the list. */ public void subtractDuration(long amount) { durationModifiers.add(-amount); @@ -317,7 +340,7 @@ public void subtractDuration(long amount) { /** * Apply all of the magnitude modifiers and multipliers to get the net magnitude result value. * - * @return The result of the magnitude modifier and multiplier calculations. + * @return The result of the magnitude modifier and multiplier calculations. */ public float getMagnitudeResultValue() { // For now, add all modifiers and multiply by all multipliers. @@ -347,7 +370,7 @@ public float getMagnitudeResultValue() { /** * Apply all of the duration modifiers and multipliers to get the net duration result value. * - * @return The result of the duration modifier and multiplier calculations. + * @return The result of the duration modifier and multiplier calculations. */ public long getDurationResultValue() { // For now, add all modifiers and multiply by all multipliers. Negative modifiers cap to zero, but negative diff --git a/src/main/java/org/terasology/alterationEffects/OnEffectRemoveEvent.java b/src/main/java/org/terasology/alterationEffects/OnEffectRemoveEvent.java index 1203e77..1fa91fe 100644 --- a/src/main/java/org/terasology/alterationEffects/OnEffectRemoveEvent.java +++ b/src/main/java/org/terasology/alterationEffects/OnEffectRemoveEvent.java @@ -1,18 +1,5 @@ -/* - * Copyright 2016 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.alterationEffects; import gnu.trove.iterator.TDoubleIterator; @@ -29,57 +16,85 @@ * a modifier for a particular effect. */ public class OnEffectRemoveEvent implements ConsumableEvent { - /** Flags whether this event been consumed or not. */ + /** + * Flags whether this event been consumed or not. + */ private boolean consumed; - /** Flags whether this effect has expired or not. */ + /** + * Flags whether this effect has expired or not. + */ private boolean expired = false; - /** The instigator entity that instigated this effect modification. */ + /** + * The instigator entity that instigated this effect modification. + */ private EntityRef instigator; - /** A reference to the entity being affected this by effect. */ + /** + * A reference to the entity being affected this by effect. + */ private EntityRef entity; - /** Reference to the original alteration effect that spawned this effect. */ + /** + * Reference to the original alteration effect that spawned this effect. + */ private AlterationEffect alterationEffect; - /** Used to distinguish different effects under the same parent type. Like DOT or Resist ones. */ + /** + * Used to distinguish different effects under the same parent type. Like DOT or Resist ones. + */ private String id = ""; - /** Used to identify individual effects. */ + /** + * Used to identify individual effects. + */ private String effectID = ""; - /** Base magnitude of this effect. */ + /** + * Base magnitude of this effect. + */ private float baseMagnitude = 0f; - /** Base duration of this effect. */ + /** + * Base duration of this effect. + */ private long baseDuration = 0; - /** The current shortest duration of all the effects */ + /** + * The current shortest duration of all the effects + */ private long shortestDuration = Long.MAX_VALUE; - /** A list of all the multipliers for this effect's magnitude. */ + /** + * A list of all the multipliers for this effect's magnitude. + */ private TFloatList magnitudeMultipliers = new TFloatArrayList(); - /** A list of all the multipliers for this effect's duration. */ + /** + * A list of all the multipliers for this effect's duration. + */ private TFloatList durationMultipliers = new TFloatArrayList(); - /** A list of all the modifiers for this effect's magnitude. */ + /** + * A list of all the modifiers for this effect's magnitude. + */ private TFloatList magnitudeModifiers = new TFloatArrayList(); - /** A list of all the modifiers for this effect's duration. */ + /** + * A list of all the modifiers for this effect's duration. + */ private TDoubleList durationModifiers = new TDoubleArrayList(); /** - * Create an instance of this event with the given base values, alteration effect, effectID (for differentiating - * individual effects), and ID (if needed). + * Create an instance of this event with the given base values, alteration effect, effectID (for differentiating individual effects), + * and ID (if needed). * - * @param instigator The entity that caused this effect to be removed. - * @param entity The entity that the effect was currently on. - * @param alterationEffect The original alteration effect that created this effect. - * @param effectID The effectID of the modifier that expired. - * @param id The ID of this effect. + * @param instigator The entity that caused this effect to be removed. + * @param entity The entity that the effect was currently on. + * @param alterationEffect The original alteration effect that created this effect. + * @param effectID The effectID of the modifier that expired. + * @param id The ID of this effect. */ public OnEffectRemoveEvent(EntityRef instigator, EntityRef entity, AlterationEffect alterationEffect, String effectID, String id) { this.instigator = instigator; @@ -90,16 +105,16 @@ public OnEffectRemoveEvent(EntityRef instigator, EntityRef entity, AlterationEff } /** - * Create an instance of this event with the given base values, alteration effect, effectID (for differentiating - * individual effects), ID (if needed), and starting expire flag value. The latter will indicate if this event was - * sent due to an effect expiring or just getting removed before its duration had concluded. + * Create an instance of this event with the given base values, alteration effect, effectID (for differentiating individual effects), ID + * (if needed), and starting expire flag value. The latter will indicate if this event was sent due to an effect expiring or just + * getting removed before its duration had concluded. * - * @param instigator The entity that caused this effect to be removed. - * @param entity The entity that the effect was currently on. - * @param alterationEffect The original alteration effect that created this effect. - * @param effectID The effectID of the modifier that expired. - * @param id The ID of this effect. - * @param expired Flag indicating whether this effect modifier had expired or not. + * @param instigator The entity that caused this effect to be removed. + * @param entity The entity that the effect was currently on. + * @param alterationEffect The original alteration effect that created this effect. + * @param effectID The effectID of the modifier that expired. + * @param id The ID of this effect. + * @param expired Flag indicating whether this effect modifier had expired or not. */ public OnEffectRemoveEvent(EntityRef instigator, EntityRef entity, AlterationEffect alterationEffect, String effectID, String id, boolean expired) { this.instigator = instigator; @@ -113,21 +128,25 @@ public OnEffectRemoveEvent(EntityRef instigator, EntityRef entity, AlterationEff /** * Get the entity who instigated this modify event. * - * @return A reference to the instigator entity. + * @return A reference to the instigator entity. */ - public EntityRef getInstigator() { return instigator; } + public EntityRef getInstigator() { + return instigator; + } /** * Get a reference to the entity being affected. * - * @return A reference to the affected entity. + * @return A reference to the affected entity. */ - public EntityRef getEntity() { return entity; } + public EntityRef getEntity() { + return entity; + } /** * Get a reference to the alteration effect that created the original effect. * - * @return A reference to the original alteration effect. + * @return A reference to the original alteration effect. */ public AlterationEffect getAlterationEffect() { return alterationEffect; @@ -136,7 +155,7 @@ public AlterationEffect getAlterationEffect() { /** * Get the effectID of this effect modifier. * - * @return The effectID of the modifier. + * @return The effectID of the modifier. */ public String getEffectId() { return effectID; @@ -145,7 +164,7 @@ public String getEffectId() { /** * Get the ID of this effect. * - * @return The ID of the effect. + * @return The ID of the effect. */ public String getId() { return id; @@ -154,7 +173,7 @@ public String getId() { /** * Get the shortest duration of all modifiers collected in this list. * - * @return The shortest duration counted. + * @return The shortest duration counted. */ public long getShortestDuration() { return shortestDuration; @@ -163,7 +182,7 @@ public long getShortestDuration() { /** * Get a list of all the potion effect magnitude multipliers. * - * @return A TFloatList containing the magnitude modifiers. + * @return A TFloatList containing the magnitude modifiers. */ public TFloatList getMagnitudeMultipliers() { return magnitudeMultipliers; @@ -172,7 +191,7 @@ public TFloatList getMagnitudeMultipliers() { /** * Get a list of all the potion effect duration multipliers. * - * @return A TFloatList containing the duration modifiers. + * @return A TFloatList containing the duration modifiers. */ public TFloatList getDurationMultipliers() { return durationMultipliers; @@ -181,7 +200,7 @@ public TFloatList getDurationMultipliers() { /** * Get a list of all the potion effect magnitude (pre)modifiers. * - * @return A TFloatList containing the magnitude (pre)modifiers. + * @return A TFloatList containing the magnitude (pre)modifiers. */ public TFloatList getMagnitudeModifiers() { return magnitudeModifiers; @@ -190,7 +209,7 @@ public TFloatList getMagnitudeModifiers() { /** * Get a list of all the potion effect duration (pre)modifiers. * - * @return A TDoubleList containing the duration (pre)modifiers. + * @return A TDoubleList containing the duration (pre)modifiers. */ public TDoubleList getDurationModifiers() { return durationModifiers; @@ -199,7 +218,7 @@ public TDoubleList getDurationModifiers() { /** * Add a multiplier to the magnitude multipliers list. * - * @param amount The value of the multiplier to add to the list. + * @param amount The value of the multiplier to add to the list. */ public void multiplyMagnitude(float amount) { magnitudeMultipliers.add(amount); @@ -208,7 +227,7 @@ public void multiplyMagnitude(float amount) { /** * Add a multiplier to the duration multipliers list. * - * @param amount The value of the multiplier to add to the list. + * @param amount The value of the multiplier to add to the list. */ public void multiplyDuration(float amount) { durationMultipliers.add(amount); @@ -217,7 +236,7 @@ public void multiplyDuration(float amount) { /** * Add a (pre)modifier to the magnitude (pre)modifiers list. * - * @param amount The value of the modifier to add to the list. + * @param amount The value of the modifier to add to the list. */ public void addMagnitude(float amount) { magnitudeModifiers.add(amount); @@ -226,7 +245,7 @@ public void addMagnitude(float amount) { /** * Add a (pre)modifier to the duration (pre)modifiers list. * - * @param amount The value of the modifier to add to the list. + * @param amount The value of the modifier to add to the list. */ public void addDuration(double amount) { if (amount < shortestDuration) { @@ -242,7 +261,7 @@ public void addDuration(double amount) { /** * Add a negative (pre)modifier to the magnitude (pre)modifiers list. * - * @param amount The value of the modifier to add to the list. + * @param amount The value of the modifier to add to the list. */ public void subtractMagnitude(float amount) { magnitudeModifiers.add(-amount); @@ -251,7 +270,7 @@ public void subtractMagnitude(float amount) { /** * Add a negative (pre)modifier to the duration (pre)modifiers list. * - * @param amount The value of the modifier to add to the list. + * @param amount The value of the modifier to add to the list. */ public void subtractDuration(long amount) { durationModifiers.add(-amount); @@ -260,7 +279,7 @@ public void subtractDuration(long amount) { /** * Apply all of the magnitude modifiers and multipliers to get the net magnitude result value. * - * @return The result of the magnitude modifier and multiplier calculations. + * @return The result of the magnitude modifier and multiplier calculations. */ public float getMagnitudeResultValue() { // For now, add all modifiers and multiply by all multipliers. Negative modifiers cap to zero, but negative @@ -292,7 +311,7 @@ public float getMagnitudeResultValue() { /** * Apply all of the duration modifiers and multipliers to get the net duration result value. * - * @return The result of the duration modifier and multiplier calculations. + * @return The result of the duration modifier and multiplier calculations. */ public long getDurationResultValue() { // For now, add all modifiers and multiply by all multipliers. Negative modifiers cap to zero, but negative @@ -334,7 +353,7 @@ public void consume() { /** * Get whether this effect has expired (time ran out) or not (was removed before time ran out). * - * @return The value of the expired flag. + * @return The value of the expired flag. */ public boolean isExpired() { return expired; diff --git a/src/main/java/org/terasology/alterationEffects/boost/BoostAuthoritySystem.java b/src/main/java/org/terasology/alterationEffects/boost/BoostAuthoritySystem.java index 76fc8fb..25131f2 100644 --- a/src/main/java/org/terasology/alterationEffects/boost/BoostAuthoritySystem.java +++ b/src/main/java/org/terasology/alterationEffects/boost/BoostAuthoritySystem.java @@ -1,30 +1,17 @@ -/* - * Copyright 2016 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.alterationEffects.boost; import org.terasology.engine.core.Time; import org.terasology.engine.entitySystem.entity.EntityManager; import org.terasology.engine.entitySystem.entity.EntityRef; import org.terasology.engine.entitySystem.entity.lifecycleEvents.BeforeDeactivateComponent; -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.module.health.components.HealthComponent; import org.terasology.engine.registry.In; +import org.terasology.gestalt.entitysystem.event.ReceiveEvent; +import org.terasology.module.health.components.HealthComponent; /** * This authority system manages all the health boost effects currently in-effect across all entities. @@ -39,16 +26,16 @@ public class BoostAuthoritySystem extends BaseComponentSystem { /** * This will remove the health boost from an entity just before its health boost component is removed. * - * @param event Event that indicates that the HealthBoostComponent will be deactivated and removed. - * @param entity Entity that has the health boost component. - * @param hBoost The health boost component. Used as delimiter/filter as well as for its sole variable. + * @param event Event that indicates that the HealthBoostComponent will be deactivated and removed. + * @param entity Entity that has the health boost component. + * @param hBoost The health boost component. Used as delimiter/filter as well as for its sole variable. */ @ReceiveEvent public void removeHealthBoost(BeforeDeactivateComponent event, EntityRef entity, HealthBoostComponent hBoost) { HealthComponent h = entity.getComponent(HealthComponent.class); // Reverse the max health boosting effect by dividing the old boost amount. - h.maxHealth = Math.round(h.maxHealth / (1f + 0.01f*hBoost.boostAmount)); + h.maxHealth = Math.round(h.maxHealth / (1f + 0.01f * hBoost.boostAmount)); // If the current health is greater than the new max health, set the current health value to be the max health. if (h.currentHealth > h.maxHealth) { diff --git a/src/main/java/org/terasology/alterationEffects/boost/HealthBoostAlterationEffect.java b/src/main/java/org/terasology/alterationEffects/boost/HealthBoostAlterationEffect.java index 65044fb..23acfa4 100644 --- a/src/main/java/org/terasology/alterationEffects/boost/HealthBoostAlterationEffect.java +++ b/src/main/java/org/terasology/alterationEffects/boost/HealthBoostAlterationEffect.java @@ -1,18 +1,5 @@ -/* - * Copyright 2016 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.alterationEffects.boost; import org.terasology.alterationEffects.AlterationEffect; @@ -35,10 +22,10 @@ public class HealthBoostAlterationEffect implements AlterationEffect { private final DelayManager delayManager; /** - * Constructor. Instantiate an instance of this alteration effect using the provided context. This context will be - * used to get the time and DelayManager. + * Constructor. Instantiate an instance of this alteration effect using the provided context. This context will be used to get the time + * and DelayManager. * - * @param context The context which this effect will be executed on. + * @param context The context which this effect will be executed on. */ public HealthBoostAlterationEffect(Context context) { this.time = context.get(Time.class); @@ -48,14 +35,14 @@ public HealthBoostAlterationEffect(Context context) { /** * Removes the effect of the given health boost from the entity. * - * @param entity The entity which has the health boost effect. - * @param hBoost The health boost component. + * @param entity The entity which has the health boost effect. + * @param hBoost The health boost component. */ private void removeBoost(EntityRef entity, HealthBoostComponent hBoost) { HealthComponent h = entity.getComponent(HealthComponent.class); // Reverse the max health boosting effect by dividing the old boost amount. - h.maxHealth = Math.round(h.maxHealth / (1f + 0.01f*hBoost.boostAmount)); + h.maxHealth = Math.round(h.maxHealth / (1f + 0.01f * hBoost.boostAmount)); // If the current health is greater than the new max health, set the current health value to be the max health. if (h.currentHealth > h.maxHealth) { @@ -64,13 +51,13 @@ private void removeBoost(EntityRef entity, HealthBoostComponent hBoost) { } /** - * This will apply the health boost effect on the given entity. This method will send out an event to the other - * applicable effect systems so that they can contribute with their own health boost effect related modifiers. + * This will apply the health boost effect on the given entity. This method will send out an event to the other applicable effect + * systems so that they can contribute with their own health boost effect related modifiers. * - * @param instigator The entity who applied the health boost effect. - * @param entity The entity that the health boost effect is being applied on. - * @param magnitude The magnitude of the health boost effect. - * @param duration The duration of the health boost effect. + * @param instigator The entity who applied the health boost effect. + * @param entity The entity that the health boost effect is being applied on. + * @param magnitude The magnitude of the health boost effect. + * @param duration The duration of the health boost effect. */ @Override public void applyEffect(EntityRef instigator, EntityRef entity, float magnitude, long duration) { @@ -127,16 +114,18 @@ public void applyEffect(EntityRef instigator, EntityRef entity, float magnitude, // add a delayed action to the DelayManager using the new system. if (modifiedDuration < Long.MAX_VALUE && modifiedDuration > 0 && duration != AlterationEffects.DURATION_INDEFINITE) { String effectID = effectModifyEvent.getEffectIDWithShortestDuration(); - delayManager.addDelayedAction(entity, AlterationEffects.EXPIRE_TRIGGER_PREFIX + AlterationEffects.MAX_HEALTH_BOOST + "|" + effectID, modifiedDuration); - } - // Otherwise, if the duration is greater than 0, there are no modifiers found, and the effect modify event was not consumed, - // add a delayed action to the DelayManager using the old system. - else if (duration > 0 && !modifiersFound && !effectModifyEvent.isConsumed()) { + delayManager.addDelayedAction(entity, + AlterationEffects.EXPIRE_TRIGGER_PREFIX + AlterationEffects.MAX_HEALTH_BOOST + "|" + effectID, modifiedDuration); + + } else if (duration > 0 && !modifiersFound && !effectModifyEvent.isConsumed()) { + // Otherwise, if the duration is greater than 0, there are no modifiers found, and the effect modify event was not consumed, + // add a delayed action to the DelayManager using the old system. + delayManager.addDelayedAction(entity, AlterationEffects.EXPIRE_TRIGGER_PREFIX + AlterationEffects.MAX_HEALTH_BOOST, duration); - } - // Otherwise, if there are either no modifiers found, or none of the modifiers collected in the event have infinite - // duration, remove the component associated with this health boost effect. - else if (!modifiersFound || !effectModifyEvent.getHasInfDuration()) { + } else if (!modifiersFound || !effectModifyEvent.getHasInfDuration()) { + // Otherwise, if there are either no modifiers found, or none of the modifiers collected in the event have infinite + // duration, remove the component associated with this health boost effect. + entity.removeComponent(HealthBoostComponent.class); } // If this point is reached and none of the above if-clauses were met, that means there was at least one modifier @@ -144,14 +133,14 @@ else if (!modifiersFound || !effectModifyEvent.getHasInfDuration()) { } /** - * This will apply the health boost effect on the given entity by calling the method - * {@link #applyEffect(EntityRef, EntityRef, float, long)}. + * This will apply the health boost effect on the given entity by calling the method {@link #applyEffect(EntityRef, EntityRef, float, + * long)}. * - * @param instigator The entity who applied the health boost effect. - * @param entity The entity that the health boost effect is being applied on. - * @param id Inapplicable to the health boost effect. - * @param magnitude The magnitude of the health boost effect. - * @param duration The duration of the health boost effect. + * @param instigator The entity who applied the health boost effect. + * @param entity The entity that the health boost effect is being applied on. + * @param id Inapplicable to the health boost effect. + * @param magnitude The magnitude of the health boost effect. + * @param duration The duration of the health boost effect. */ @Override public void applyEffect(EntityRef instigator, EntityRef entity, String id, float magnitude, long duration) { diff --git a/src/main/java/org/terasology/alterationEffects/breath/WaterBreathingAlterationEffect.java b/src/main/java/org/terasology/alterationEffects/breath/WaterBreathingAlterationEffect.java index 63107ba..8719037 100644 --- a/src/main/java/org/terasology/alterationEffects/breath/WaterBreathingAlterationEffect.java +++ b/src/main/java/org/terasology/alterationEffects/breath/WaterBreathingAlterationEffect.java @@ -1,4 +1,4 @@ -// Copyright 2020 The Terasology Foundation +// Copyright 2021 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 package org.terasology.alterationEffects.breath; diff --git a/src/main/java/org/terasology/alterationEffects/breath/WaterBreathingAuthoritySystem.java b/src/main/java/org/terasology/alterationEffects/breath/WaterBreathingAuthoritySystem.java index 8f83976..d8f27fb 100644 --- a/src/main/java/org/terasology/alterationEffects/breath/WaterBreathingAuthoritySystem.java +++ b/src/main/java/org/terasology/alterationEffects/breath/WaterBreathingAuthoritySystem.java @@ -3,18 +3,18 @@ package org.terasology.alterationEffects.breath; 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.module.health.events.BeforeDamagedEvent; import org.terasology.engine.world.block.BlockComponent; import org.terasology.engine.world.block.BlockUri; +import org.terasology.gestalt.entitysystem.event.ReceiveEvent; +import org.terasology.module.health.events.BeforeDamagedEvent; /** * This authority system manages all the water breathing effects currently in-effect across all entities. */ -@RegisterSystem(value = RegisterMode.AUTHORITY) +@RegisterSystem(RegisterMode.AUTHORITY) public class WaterBreathingAuthoritySystem extends BaseComponentSystem { /** * Cancel any potential oncoming water or drowning damage when the water breathing effect is currently in-effect. diff --git a/src/main/java/org/terasology/alterationEffects/buff/BuffDamageAlterationEffect.java b/src/main/java/org/terasology/alterationEffects/buff/BuffDamageAlterationEffect.java index cc46370..2641a15 100644 --- a/src/main/java/org/terasology/alterationEffects/buff/BuffDamageAlterationEffect.java +++ b/src/main/java/org/terasology/alterationEffects/buff/BuffDamageAlterationEffect.java @@ -1,4 +1,4 @@ -// Copyright 2020 The Terasology Foundation +// Copyright 2021 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 package org.terasology.alterationEffects.buff; diff --git a/src/main/java/org/terasology/alterationEffects/buff/BuffDamageAuthoritySystem.java b/src/main/java/org/terasology/alterationEffects/buff/BuffDamageAuthoritySystem.java index 9b67844..987da87 100644 --- a/src/main/java/org/terasology/alterationEffects/buff/BuffDamageAuthoritySystem.java +++ b/src/main/java/org/terasology/alterationEffects/buff/BuffDamageAuthoritySystem.java @@ -1,33 +1,18 @@ -/* - * Copyright 2016 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.alterationEffects.buff; import org.terasology.alterationEffects.AlterationEffects; import org.terasology.alterationEffects.OnEffectRemoveEvent; import org.terasology.engine.context.Context; -import org.terasology.engine.core.Time; -import org.terasology.engine.entitySystem.entity.EntityManager; 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.module.health.events.BeforeDamagedEvent; import org.terasology.engine.registry.In; +import org.terasology.gestalt.entitysystem.event.ReceiveEvent; +import org.terasology.module.health.events.BeforeDamagedEvent; import java.util.regex.Pattern; @@ -37,20 +22,16 @@ */ @RegisterSystem(value = RegisterMode.AUTHORITY) public class BuffDamageAuthoritySystem extends BaseComponentSystem { - @In - private Time time; - @In - private EntityManager entityManager; @In private Context context; /** - * When one of this entity's buff damage effects expire, remove it from the damage buff effects map and - * recalculate the total magnitude for this damage type. + * When one of this entity's buff damage effects expire, remove it from the damage buff effects map and recalculate the total magnitude + * for this damage type. * - * @param event Event that indicates that the delayed action has expired. - * @param entity Entity that has the buff damage component. - * @param component Stores information of all the entity's current damage buffs. + * @param event Event that indicates that the delayed action has expired. + * @param entity Entity that has the buff damage component. + * @param component Stores information of all the entity's current damage buffs. */ @ReceiveEvent public void expireBuffDamageEffect(DelayedActionTriggeredEvent event, EntityRef entity, BuffDamageComponent component) { @@ -100,7 +81,7 @@ public void expireBuffDamageEffect(DelayedActionTriggeredEvent event, EntityRef // If the size of the damage buffs map is zero and the buff damage component doesn't exist // anymore, remove it from the entity. - if (component.bdes.size() == 0 && component != null) { + if (component.bdes.size() == 0) { entity.removeComponent(BuffDamageComponent.class); } } @@ -108,12 +89,12 @@ public void expireBuffDamageEffect(DelayedActionTriggeredEvent event, EntityRef } /** - * Upon getting a damage event and the entity on the sending end has a damage buff, check to see if the incoming - * damage type matches the buff's type. If so, increase the damage by the buff's amount. + * Upon getting a damage event and the entity on the sending end has a damage buff, check to see if the incoming damage type matches the + * buff's type. If so, increase the damage by the buff's amount. * - * @param event Event with information of the outgoing damage. - * @param entity Entity that's dealing the damage. - * @param component Stores information of all the entity's current damage buffs. + * @param event Event with information of the outgoing damage. + * @param entity Entity that's dealing the damage. + * @param component Stores information of all the entity's current damage buffs. */ @ReceiveEvent public void buffDamageOfType(BeforeDamagedEvent event, EntityRef entity, BuffDamageComponent component) { diff --git a/src/main/java/org/terasology/alterationEffects/buff/BuffDamageComponent.java b/src/main/java/org/terasology/alterationEffects/buff/BuffDamageComponent.java index a1b0784..07fb191 100644 --- a/src/main/java/org/terasology/alterationEffects/buff/BuffDamageComponent.java +++ b/src/main/java/org/terasology/alterationEffects/buff/BuffDamageComponent.java @@ -11,12 +11,14 @@ * This component is used for keeping track of the various buff damage effects an entity can have currently in effect. */ public class BuffDamageComponent implements Component { - /** This map keeps track of the various damage buff effects currently in effect. */ + /** + * This map keeps track of the various damage buff effects currently in effect. + */ public Map bdes = new HashMap(); @Override public void copyFrom(BuffDamageComponent other) { bdes.clear(); - other.bdes.forEach((k, v)-> this.bdes.put(k, v.copy())); + other.bdes.forEach((k, v) -> this.bdes.put(k, v.copy())); } } diff --git a/src/main/java/org/terasology/alterationEffects/buff/BuffDamageEffect.java b/src/main/java/org/terasology/alterationEffects/buff/BuffDamageEffect.java index 917484b..c55eb98 100644 --- a/src/main/java/org/terasology/alterationEffects/buff/BuffDamageEffect.java +++ b/src/main/java/org/terasology/alterationEffects/buff/BuffDamageEffect.java @@ -9,10 +9,14 @@ */ @MappedContainer public class BuffDamageEffect { - /** The damage type that will be buffed. */ + /** + * The damage type that will be buffed. + */ public String damageType; - /** The amount that the damage of this type will be additively increased or buffed by. */ + /** + * The amount that the damage to this type will be additively increased or buffed by. + */ public int buffAmount; BuffDamageEffect copy() { diff --git a/src/main/java/org/terasology/alterationEffects/damageOverTime/CureAllDamageOverTimeAlterationEffect.java b/src/main/java/org/terasology/alterationEffects/damageOverTime/CureAllDamageOverTimeAlterationEffect.java index 31bf8ca..c23d055 100644 --- a/src/main/java/org/terasology/alterationEffects/damageOverTime/CureAllDamageOverTimeAlterationEffect.java +++ b/src/main/java/org/terasology/alterationEffects/damageOverTime/CureAllDamageOverTimeAlterationEffect.java @@ -1,18 +1,5 @@ -/* - * Copyright 2016 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.alterationEffects.damageOverTime; import org.terasology.alterationEffects.AlterationEffect; diff --git a/src/main/java/org/terasology/alterationEffects/damageOverTime/CureDamageOverTimeAlterationEffect.java b/src/main/java/org/terasology/alterationEffects/damageOverTime/CureDamageOverTimeAlterationEffect.java index aef9b8e..9e92051 100644 --- a/src/main/java/org/terasology/alterationEffects/damageOverTime/CureDamageOverTimeAlterationEffect.java +++ b/src/main/java/org/terasology/alterationEffects/damageOverTime/CureDamageOverTimeAlterationEffect.java @@ -1,18 +1,5 @@ -/* - * Copyright 2016 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.alterationEffects.damageOverTime; import org.terasology.alterationEffects.AlterationEffect; diff --git a/src/main/java/org/terasology/alterationEffects/damageOverTime/DamageOverTimeAlterationEffect.java b/src/main/java/org/terasology/alterationEffects/damageOverTime/DamageOverTimeAlterationEffect.java index 336ba16..73baa25 100644 --- a/src/main/java/org/terasology/alterationEffects/damageOverTime/DamageOverTimeAlterationEffect.java +++ b/src/main/java/org/terasology/alterationEffects/damageOverTime/DamageOverTimeAlterationEffect.java @@ -1,18 +1,5 @@ -/* - * Copyright 2016 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.alterationEffects.damageOverTime; import org.terasology.alterationEffects.AlterationEffect; @@ -36,10 +23,10 @@ public class DamageOverTimeAlterationEffect implements AlterationEffect { private final DelayManager delayManager; /** - * Constructor. Instantiate an instance of this alteration effect using the provided context. This context will be - * used to get the DelayManager and current time. + * Constructor. Instantiate an instance of this alteration effect using the provided context. This context will be used to get the + * DelayManager and current time. * - * @param context The context which this effect will be executed on. + * @param context The context which this effect will be executed on. */ public DamageOverTimeAlterationEffect(Context context) { this.time = context.get(Time.class); @@ -47,13 +34,13 @@ public DamageOverTimeAlterationEffect(Context context) { } /** - * This will apply the damage over time (DOT) effect on the given entity by calling the method - * {@link #applyEffect(EntityRef, EntityRef, String, float, long)} with the ID being set to "Default". + * This will apply the damage over time (DOT) effect on the given entity by calling the method {@link #applyEffect(EntityRef, EntityRef, + * String, float, long)} with the ID being set to "Default". * - * @param instigator The entity who applied the damage over time effect. - * @param entity The entity that the damage over time effect is being applied on. - * @param magnitude The magnitude of the damage over time effect. - * @param duration The duration of the damage over time effect. + * @param instigator The entity who applied the damage over time effect. + * @param entity The entity that the damage over time effect is being applied on. + * @param magnitude The magnitude of the damage over time effect. + * @param duration The duration of the damage over time effect. */ @Override public void applyEffect(EntityRef instigator, EntityRef entity, float magnitude, long duration) { @@ -61,16 +48,15 @@ public void applyEffect(EntityRef instigator, EntityRef entity, float magnitude, } /** - * This will apply the damage over time (DOT) effect on the given entity. This method will send out an event to the - * other applicable effect systems so that they can contribute with their own resist damage effect related - * modifiers. + * This will apply the damage over time (DOT) effect on the given entity. This method will send out an event to the other applicable + * effect systems so that they can contribute with their own resist damage effect related modifiers. * - * @param instigator The entity who applied the damage over time effect. - * @param entity The entity that the damage over time effect. is being applied on. - * @param id The ID of this damage over time effect. This is used for determining what damage type to - * use or inflict on the user. For example, fire, poison, etc. - * @param magnitude The magnitude of the damage over time effect. - * @param duration The duration of the damage over time effect. + * @param instigator The entity who applied the damage over time effect. + * @param entity The entity that the damage over time effect. is being applied on. + * @param id The ID of this damage over time effect. This is used for determining what damage type to use or inflict on the + * user. For example, fire, poison, etc. + * @param magnitude The magnitude of the damage over time effect. + * @param duration The duration of the damage over time effect. */ public void applyEffect(EntityRef instigator, EntityRef entity, String id, float magnitude, long duration) { // First, determine if the entity already has a DOT component attached. If so, just replace the damage amount @@ -146,16 +132,14 @@ public void applyEffect(EntityRef instigator, EntityRef entity, String id, float delayManager.addDelayedAction(entity, AlterationEffects.EXPIRE_TRIGGER_PREFIX + AlterationEffects.DAMAGE_OVER_TIME + ":" + id + "|" + effectID, modifiedDuration); - } - // Otherwise, if the duration is greater than 0, there are no modifiers found, and the effect modify event was not consumed, - // add a delayed action to the DelayManager using the old system. - else if (duration > 0 && !modifiersFound && !effectModifyEvent.isConsumed()) { + } else if (duration > 0 && !modifiersFound && !effectModifyEvent.isConsumed()) { + // Otherwise, if the duration is greater than 0, there are no modifiers found, and the effect modify event was not consumed, + // add a delayed action to the DelayManager using the old system. delayManager.addDelayedAction(entity, AlterationEffects.EXPIRE_TRIGGER_PREFIX + AlterationEffects.DAMAGE_OVER_TIME + ":" + id, duration); - } - // Otherwise, if there are either no modifiers found, or none of the modifiers collected in the event have infinite - // duration, remove the resist effect from the DOT component. - else if (!modifiersFound || !effectModifyEvent.getHasInfDuration()) { + } else if (!modifiersFound || !effectModifyEvent.getHasInfDuration()) { + // Otherwise, if there are either no modifiers found, or none of the modifiers collected in the event have infinite + // duration, remove the resist effect from the DOT component. dot.dots.remove(id, dotEffect); } // If this point is reached and none of the above if-clauses were met, that means there was at least one modifier diff --git a/src/main/java/org/terasology/alterationEffects/damageOverTime/DamageOverTimeAuthoritySystem.java b/src/main/java/org/terasology/alterationEffects/damageOverTime/DamageOverTimeAuthoritySystem.java index 257d62f..dbcfc03 100644 --- a/src/main/java/org/terasology/alterationEffects/damageOverTime/DamageOverTimeAuthoritySystem.java +++ b/src/main/java/org/terasology/alterationEffects/damageOverTime/DamageOverTimeAuthoritySystem.java @@ -1,18 +1,5 @@ -/* - * Copyright 2016 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.alterationEffects.damageOverTime; import org.terasology.alterationEffects.AlterationEffects; @@ -21,16 +8,16 @@ import org.terasology.engine.core.Time; import org.terasology.engine.entitySystem.entity.EntityManager; 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.entitySystem.systems.UpdateSubscriberSystem; import org.terasology.engine.logic.delay.DelayedActionTriggeredEvent; -import org.terasology.module.health.components.HealthComponent; -import org.terasology.module.health.events.DoDamageEvent; import org.terasology.engine.registry.In; import org.terasology.engine.utilities.Assets; +import org.terasology.gestalt.entitysystem.event.ReceiveEvent; +import org.terasology.module.health.components.HealthComponent; +import org.terasology.module.health.events.DoDamageEvent; import java.util.regex.Pattern; @@ -38,7 +25,7 @@ * This authority system manages all the damage over time (DOT) effects currently in-effect across all entities. By * that, it handles what course of action to take when one expires, and applies the DOT damage at regular intervals. */ -@RegisterSystem(value = RegisterMode.AUTHORITY) +@RegisterSystem(RegisterMode.AUTHORITY) public class DamageOverTimeAuthoritySystem extends BaseComponentSystem implements UpdateSubscriberSystem { /** Integer storing when to check each effect. */ private static final int CHECK_INTERVAL = 100; diff --git a/src/main/java/org/terasology/alterationEffects/damageOverTime/DamageOverTimeComponent.java b/src/main/java/org/terasology/alterationEffects/damageOverTime/DamageOverTimeComponent.java index 6cfd119..526810f 100644 --- a/src/main/java/org/terasology/alterationEffects/damageOverTime/DamageOverTimeComponent.java +++ b/src/main/java/org/terasology/alterationEffects/damageOverTime/DamageOverTimeComponent.java @@ -13,10 +13,14 @@ * in effect. */ public class DamageOverTimeComponent implements Component { - /** This map keeps track of the various DOT effects currently in effect. */ + /** + * This map keeps track of the various DOT effects currently in effect. + */ public Map dots = new HashMap(); - /** This map keeps track of all the effectIDs of all the current DOT effects being applied to an entity. */ + /** + * This map keeps track of all the effectIDs of all the current DOT effects being applied to an entity. + */ public Map> effectIDMap = new HashMap>(); @Override diff --git a/src/main/java/org/terasology/alterationEffects/damageOverTime/DamageOverTimeEffect.java b/src/main/java/org/terasology/alterationEffects/damageOverTime/DamageOverTimeEffect.java index 86578de..c79ecc7 100644 --- a/src/main/java/org/terasology/alterationEffects/damageOverTime/DamageOverTimeEffect.java +++ b/src/main/java/org/terasology/alterationEffects/damageOverTime/DamageOverTimeEffect.java @@ -9,13 +9,19 @@ */ @MappedContainer public class DamageOverTimeEffect { - /** The type of damage that will be inflicted. */ + /** + * The type of damage that will be inflicted. + */ public String damageType; - /** The amount of damage that will be inflicted upon on the entity per tick. */ + /** + * The amount of damage that will be inflicted upon on the entity per tick. + */ public int damageAmount; - /** The last time this effect dealt damage. */ + /** + * The last time this effect dealt damage. + */ public long lastDamageTime; public DamageOverTimeEffect copy() { diff --git a/src/main/java/org/terasology/alterationEffects/decover/DecoverAlterationEffect.java b/src/main/java/org/terasology/alterationEffects/decover/DecoverAlterationEffect.java index e5eb81a..293c2ec 100644 --- a/src/main/java/org/terasology/alterationEffects/decover/DecoverAlterationEffect.java +++ b/src/main/java/org/terasology/alterationEffects/decover/DecoverAlterationEffect.java @@ -1,4 +1,4 @@ -// Copyright 2020 The Terasology Foundation +// Copyright 2021 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 package org.terasology.alterationEffects.decover; diff --git a/src/main/java/org/terasology/alterationEffects/decover/DecoverAuthoritySystem.java b/src/main/java/org/terasology/alterationEffects/decover/DecoverAuthoritySystem.java index 59e1c7e..878e1cf 100644 --- a/src/main/java/org/terasology/alterationEffects/decover/DecoverAuthoritySystem.java +++ b/src/main/java/org/terasology/alterationEffects/decover/DecoverAuthoritySystem.java @@ -1,31 +1,18 @@ -/* - * Copyright 2016 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.alterationEffects.decover; 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.gestalt.entitysystem.event.ReceiveEvent; import org.terasology.module.health.events.BeforeRestoreEvent; /** * This authority system handles events for entities with the decover effect. */ -@RegisterSystem(value = RegisterMode.AUTHORITY) +@RegisterSystem(RegisterMode.AUTHORITY) public class DecoverAuthoritySystem extends BaseComponentSystem { /** * This prevents the entity from being healed. diff --git a/src/main/java/org/terasology/alterationEffects/regenerate/RegenerationAlterationEffect.java b/src/main/java/org/terasology/alterationEffects/regenerate/RegenerationAlterationEffect.java index f791467..ff422ff 100644 --- a/src/main/java/org/terasology/alterationEffects/regenerate/RegenerationAlterationEffect.java +++ b/src/main/java/org/terasology/alterationEffects/regenerate/RegenerationAlterationEffect.java @@ -1,4 +1,4 @@ -// Copyright 2020 The Terasology Foundation +// Copyright 2021 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 package org.terasology.alterationEffects.regenerate; diff --git a/src/main/java/org/terasology/alterationEffects/regenerate/RegenerationAlterationSystem.java b/src/main/java/org/terasology/alterationEffects/regenerate/RegenerationAlterationSystem.java index 8daf0d1..c422625 100644 --- a/src/main/java/org/terasology/alterationEffects/regenerate/RegenerationAlterationSystem.java +++ b/src/main/java/org/terasology/alterationEffects/regenerate/RegenerationAlterationSystem.java @@ -1,12 +1,11 @@ // Copyright 2021 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 - package org.terasology.alterationEffects.regenerate; 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.RegisterSystem; +import org.terasology.gestalt.entitysystem.event.ReceiveEvent; import org.terasology.module.health.events.BeforeRegenEvent; import static org.terasology.alterationEffects.regenerate.RegenerationAlterationEffect.REGEN_EFFECT_ID; diff --git a/src/main/java/org/terasology/alterationEffects/regenerate/RegenerationComponent.java b/src/main/java/org/terasology/alterationEffects/regenerate/RegenerationComponent.java index d513af9..685d23f 100644 --- a/src/main/java/org/terasology/alterationEffects/regenerate/RegenerationComponent.java +++ b/src/main/java/org/terasology/alterationEffects/regenerate/RegenerationComponent.java @@ -13,13 +13,16 @@ * This component is used for storing the health regeneration values an entity with the regeneration effect applied has. */ public class RegenerationComponent implements Component { - /** The amount of healing that will be applied to the entity per tick. */ + /** + * The amount of healing that will be applied to the entity per tick. + */ public int regenerationAmount; - /** The last time this entity regenerated health via the regen effect. */ + /** + * The last time this entity regenerated health via the regen effect. + */ public long lastRegenerationTime; - /** */ public Map activeRegenerations = new HashMap<>(); @Override diff --git a/src/main/java/org/terasology/alterationEffects/resist/ResistDamageAlterationEffect.java b/src/main/java/org/terasology/alterationEffects/resist/ResistDamageAlterationEffect.java index 35901e2..9d1797a 100644 --- a/src/main/java/org/terasology/alterationEffects/resist/ResistDamageAlterationEffect.java +++ b/src/main/java/org/terasology/alterationEffects/resist/ResistDamageAlterationEffect.java @@ -1,18 +1,5 @@ -/* - * Copyright 2016 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.alterationEffects.resist; import org.terasology.alterationEffects.AlterationEffect; @@ -32,23 +19,23 @@ public class ResistDamageAlterationEffect implements AlterationEffect { private final DelayManager delayManager; /** - * Constructor. Instantiate an instance of this alteration effect using the provided context. This context will be - * used to get the DelayManager. + * Constructor. Instantiate an instance of this alteration effect using the provided context. This context will be used to get the + * DelayManager. * - * @param context The context which this effect will be executed on. + * @param context The context which this effect will be executed on. */ public ResistDamageAlterationEffect(Context context) { this.delayManager = context.get(DelayManager.class); } /** - * This will apply the resist damage effect on the given entity by calling the method - * {@link #applyEffect(EntityRef, EntityRef, String, float, long)}. + * This will apply the resist damage effect on the given entity by calling the method {@link #applyEffect(EntityRef, EntityRef, String, + * float, long)}. * - * @param instigator The entity who applied the resist damage effect. - * @param entity The entity that the resist damage effect is being applied on. - * @param magnitude The magnitude of the resist damage effect. - * @param duration The duration of the resist damage effect. + * @param instigator The entity who applied the resist damage effect. + * @param entity The entity that the resist damage effect is being applied on. + * @param magnitude The magnitude of the resist damage effect. + * @param duration The duration of the resist damage effect. */ @Override public void applyEffect(EntityRef instigator, EntityRef entity, float magnitude, long duration) { @@ -56,15 +43,14 @@ public void applyEffect(EntityRef instigator, EntityRef entity, float magnitude, } /** - * This will apply the resist damage effect on the given entity. This method will send out an event to the other - * applicable effect systems so that they can contribute with their own resist damage effect related modifiers. + * This will apply the resist damage effect on the given entity. This method will send out an event to the other applicable effect + * systems so that they can contribute with their own resist damage effect related modifiers. * - * @param instigator The entity who applied the resist damage effect. - * @param entity The entity that the resist damage effect is being applied on. - * @param id The ID of this resist damage effect. This is used for determining what damage type to add - * this resistance to. - * @param magnitude The magnitude of the resist damage effect. - * @param duration The duration of the resist damage effect. + * @param instigator The entity who applied the resist damage effect. + * @param entity The entity that the resist damage effect is being applied on. + * @param id The ID of this resist damage effect. This is used for determining what damage type to add this resistance to. + * @param magnitude The magnitude of the resist damage effect. + * @param duration The duration of the resist damage effect. */ public void applyEffect(EntityRef instigator, EntityRef entity, String id, float magnitude, long duration) { // First, determine if the entity already has a resist damage component attached. If not, create a new one and @@ -124,16 +110,14 @@ public void applyEffect(EntityRef instigator, EntityRef entity, String id, float String effectID = effectModifyEvent.getEffectIDWithShortestDuration(); delayManager.addDelayedAction(entity, AlterationEffects.EXPIRE_TRIGGER_PREFIX + AlterationEffects.RESIST_DAMAGE + ":" + id + "|" + effectID, modifiedDuration); - } - // Otherwise, if the duration is greater than 0, there are no modifiers found, and the effect modify event was not consumed, - // add a delayed action to the DelayManager using the old system. - else if (duration > 0 && !modifiersFound && !effectModifyEvent.isConsumed()) { + } else if (duration > 0 && !modifiersFound && !effectModifyEvent.isConsumed()) { + // Otherwise, if the duration is greater than 0, there are no modifiers found, and the effect modify event was not consumed, + // add a delayed action to the DelayManager using the old system. delayManager.addDelayedAction(entity, AlterationEffects.EXPIRE_TRIGGER_PREFIX + AlterationEffects.RESIST_DAMAGE + ":" + id, duration); - } - // Otherwise, if there are either no modifiers found, or none of the modifiers collected in the event have infinite - // duration, remove the resist effect from the resist damage component. - else if (!modifiersFound || !effectModifyEvent.getHasInfDuration()) { + } else if (!modifiersFound || !effectModifyEvent.getHasInfDuration()) { + // Otherwise, if there are either no modifiers found, or none of the modifiers collected in the event have infinite + // duration, remove the resist effect from the resist damage component. resDamageComponent.rdes.remove(id, resEffect); } // If this point is reached and none of the above if-clauses were met, that means there was at least one modifier diff --git a/src/main/java/org/terasology/alterationEffects/resist/ResistDamageAuthoritySystem.java b/src/main/java/org/terasology/alterationEffects/resist/ResistDamageAuthoritySystem.java index 2ffb7a4..75e6e41 100644 --- a/src/main/java/org/terasology/alterationEffects/resist/ResistDamageAuthoritySystem.java +++ b/src/main/java/org/terasology/alterationEffects/resist/ResistDamageAuthoritySystem.java @@ -1,33 +1,18 @@ -/* - * Copyright 2016 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.alterationEffects.resist; import org.terasology.alterationEffects.AlterationEffects; import org.terasology.alterationEffects.OnEffectRemoveEvent; import org.terasology.engine.context.Context; -import org.terasology.engine.core.Time; -import org.terasology.engine.entitySystem.entity.EntityManager; 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.module.health.events.BeforeDamagedEvent; import org.terasology.engine.registry.In; +import org.terasology.gestalt.entitysystem.event.ReceiveEvent; +import org.terasology.module.health.events.BeforeDamagedEvent; import java.util.regex.Pattern; @@ -37,20 +22,16 @@ */ @RegisterSystem(value = RegisterMode.AUTHORITY) public class ResistDamageAuthoritySystem extends BaseComponentSystem { - @In - private Time time; - @In - private EntityManager entityManager; @In private Context context; /** - * When one of this entity's resist damage effects expire, remove it from the resist damage effects map and - * recalculate the total magnitude for this damage type. + * When one of this entity's resist damage effects expire, remove it from the resist damage effects map and recalculate the total + * magnitude for this damage type. * - * @param event Event that indicates that the delayed action has expired. - * @param entity Entity that has the resist damage component. - * @param component Stores information of all the entity's current damage resistances. + * @param event Event that indicates that the delayed action has expired. + * @param entity Entity that has the resist damage component. + * @param component Stores information of all the entity's current damage resistances. */ @ReceiveEvent public void expireResistDamageEffect(DelayedActionTriggeredEvent event, EntityRef entity, ResistDamageComponent component) { @@ -100,7 +81,7 @@ public void expireResistDamageEffect(DelayedActionTriggeredEvent event, EntityRe // If the size of the damage resistances map is zero and the resist damage component doesn't exist // anymore, remove it from the entity. - if (component.rdes.size() == 0 && component != null) { + if (component.rdes.size() == 0) { entity.removeComponent(ResistDamageComponent.class); } } @@ -108,12 +89,12 @@ public void expireResistDamageEffect(DelayedActionTriggeredEvent event, EntityRe } /** - * Upon getting a damage event and the entity on the receiving end has a damage resistance, check to see if the - * incoming damage type matches the resistance. If so, reduce the damage. + * Upon getting a damage event and the entity on the receiving end has a damage resistance, check to see if the incoming damage type + * matches the resistance. If so, reduce the damage. * - * @param event Event with information of the incoming damage. - * @param entity Entity that the damage is going to be dealt to. - * @param component Stores information of all the entity's current damage resistances. + * @param event Event with information of the incoming damage. + * @param entity Entity that the damage is going to be dealt to. + * @param component Stores information of all the entity's current damage resistances. */ @ReceiveEvent public void resistDamageOfType(BeforeDamagedEvent event, EntityRef entity, ResistDamageComponent component) { @@ -128,8 +109,7 @@ public void resistDamageOfType(BeforeDamagedEvent event, EntityRef entity, Resis // subtract the resistance from the damage. if (rdEffect.resistAmount >= event.getResultValue()) { event.multiply(0); - } - else { + } else { event.add(-rdEffect.resistAmount); } } diff --git a/src/main/java/org/terasology/alterationEffects/resist/ResistDamageEffect.java b/src/main/java/org/terasology/alterationEffects/resist/ResistDamageEffect.java index de3ad8a..2118e96 100644 --- a/src/main/java/org/terasology/alterationEffects/resist/ResistDamageEffect.java +++ b/src/main/java/org/terasology/alterationEffects/resist/ResistDamageEffect.java @@ -1,18 +1,5 @@ -/* - * Copyright 2016 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.alterationEffects.resist; import org.terasology.reflection.MappedContainer; diff --git a/src/main/java/org/terasology/alterationEffects/speed/GlueAlterationEffect.java b/src/main/java/org/terasology/alterationEffects/speed/GlueAlterationEffect.java index 17b58b3..0137712 100644 --- a/src/main/java/org/terasology/alterationEffects/speed/GlueAlterationEffect.java +++ b/src/main/java/org/terasology/alterationEffects/speed/GlueAlterationEffect.java @@ -1,4 +1,4 @@ -// Copyright 2020 The Terasology Foundation +// Copyright 2021 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 package org.terasology.alterationEffects.speed; diff --git a/src/main/java/org/terasology/alterationEffects/speed/ItemUseSpeedAlterationEffect.java b/src/main/java/org/terasology/alterationEffects/speed/ItemUseSpeedAlterationEffect.java index 8569720..2fca0b4 100644 --- a/src/main/java/org/terasology/alterationEffects/speed/ItemUseSpeedAlterationEffect.java +++ b/src/main/java/org/terasology/alterationEffects/speed/ItemUseSpeedAlterationEffect.java @@ -1,4 +1,4 @@ -// Copyright 2020 The Terasology Foundation +// Copyright 2021 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 package org.terasology.alterationEffects.speed; @@ -7,7 +7,6 @@ import org.terasology.alterationEffects.EffectContext; import org.terasology.alterationEffects.OnEffectModifyEvent; import org.terasology.engine.context.Context; -import org.terasology.engine.logic.delay.DelayManager; import java.util.Optional; @@ -17,11 +16,9 @@ */ public class ItemUseSpeedAlterationEffect extends ComponentBasedAlterationEffect { - private DelayManager delayManager; - /** - * Constructor. Instantiate an instance of this alteration effect using the provided context. This context will be - * used to get the DelayManager. + * Constructor. Instantiate an instance of this alteration effect using the provided context. This context will be used to get the + * DelayManager. * * @param context The context which this effect will be executed on. */ diff --git a/src/main/java/org/terasology/alterationEffects/speed/ItemUseSpeedComponent.java b/src/main/java/org/terasology/alterationEffects/speed/ItemUseSpeedComponent.java index 4a99ef5..c3d5f4d 100644 --- a/src/main/java/org/terasology/alterationEffects/speed/ItemUseSpeedComponent.java +++ b/src/main/java/org/terasology/alterationEffects/speed/ItemUseSpeedComponent.java @@ -1,6 +1,7 @@ // Copyright 2021 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 package org.terasology.alterationEffects.speed; + import org.terasology.gestalt.entitysystem.component.Component; /** diff --git a/src/main/java/org/terasology/alterationEffects/speed/JumpSpeedAlterationEffect.java b/src/main/java/org/terasology/alterationEffects/speed/JumpSpeedAlterationEffect.java index 2cd0254..fa7e0ff 100644 --- a/src/main/java/org/terasology/alterationEffects/speed/JumpSpeedAlterationEffect.java +++ b/src/main/java/org/terasology/alterationEffects/speed/JumpSpeedAlterationEffect.java @@ -1,4 +1,4 @@ -// Copyright 2020 The Terasology Foundation +// Copyright 2021 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 package org.terasology.alterationEffects.speed; @@ -17,8 +17,8 @@ public class JumpSpeedAlterationEffect extends ComponentBasedAlterationEffect { /** - * Constructor. Instantiate an instance of this alteration effect using the provided context. This context will be - * used to get the DelayManager. + * Constructor. Instantiate an instance of this alteration effect using the provided context. This context will be used to get the + * DelayManager. * * @param context The context which this effect will be executed on. */ diff --git a/src/main/java/org/terasology/alterationEffects/speed/JumpSpeedComponent.java b/src/main/java/org/terasology/alterationEffects/speed/JumpSpeedComponent.java index a322c3a..5666164 100644 --- a/src/main/java/org/terasology/alterationEffects/speed/JumpSpeedComponent.java +++ b/src/main/java/org/terasology/alterationEffects/speed/JumpSpeedComponent.java @@ -7,12 +7,13 @@ * This is the component added to entities with the jump speed effect. */ public class JumpSpeedComponent implements Component { - /** This will affect how much the base jump speed is added by. */ + /** + * This will affect how much the base jump speed is added by. + */ public float modifier; // TODO: Won't work until AlterationEffects has something else in addition to magnitude. /** - * This affects how much the base jump speed is multiplied by. 1 is normal speed, 0 is immobility, and 2 is double - * speed. + * This affects how much the base jump speed is multiplied by. 1 is normal speed, 0 is immobility, and 2 is double speed. */ public float multiplier; diff --git a/src/main/java/org/terasology/alterationEffects/speed/MultiJumpAlterationEffect.java b/src/main/java/org/terasology/alterationEffects/speed/MultiJumpAlterationEffect.java index 15a9619..0f62aa1 100644 --- a/src/main/java/org/terasology/alterationEffects/speed/MultiJumpAlterationEffect.java +++ b/src/main/java/org/terasology/alterationEffects/speed/MultiJumpAlterationEffect.java @@ -1,4 +1,4 @@ -// Copyright 2020 The Terasology Foundation +// Copyright 2021 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 package org.terasology.alterationEffects.speed; diff --git a/src/main/java/org/terasology/alterationEffects/speed/SpeedAlterationSystem.java b/src/main/java/org/terasology/alterationEffects/speed/SpeedAlterationSystem.java index 7b11191..16ae17b 100644 --- a/src/main/java/org/terasology/alterationEffects/speed/SpeedAlterationSystem.java +++ b/src/main/java/org/terasology/alterationEffects/speed/SpeedAlterationSystem.java @@ -1,22 +1,8 @@ -/* - * 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.alterationEffects.speed; 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.RegisterSystem; import org.terasology.engine.logic.characters.AffectItemUseCooldownTimeEvent; @@ -24,6 +10,7 @@ import org.terasology.engine.logic.characters.AffectMultiJumpEvent; import org.terasology.engine.logic.characters.GetMaxSpeedEvent; import org.terasology.engine.logic.characters.MovementMode; +import org.terasology.gestalt.entitysystem.event.ReceiveEvent; /** * This system manages the effects of the various speed or movement-related alteration effects on entities. @@ -31,25 +18,21 @@ @RegisterSystem public class SpeedAlterationSystem extends BaseComponentSystem { /** - * When an entity tries to move in any direction, modify the speed based on what effects are being applied to the - * entity. + * When an entity tries to move in any direction, modify the speed based on what effects are being applied to the entity. * - * @param event Stores information on what the max speed currently is and collects potential speed - * modifiers. - * @param entityRef The entity trying to move. + * @param event Stores information on what the max speed currently is and collects potential speed modifiers. + * @param entityRef The entity trying to move. */ @ReceiveEvent public void modifySpeed(GetMaxSpeedEvent event, EntityRef entityRef) { // If the entity's stunned, prevent it from moving. if (entityRef.hasComponent(StunComponent.class)) { event.multiply(0); - } - // If the entity is walking and they have a walk speed effect, boost their walking speed by the multiplier. - else if (event.getMovementMode() == MovementMode.WALKING && entityRef.hasComponent(WalkSpeedComponent.class)) { + } else if (event.getMovementMode() == MovementMode.WALKING && entityRef.hasComponent(WalkSpeedComponent.class)) { + // If the entity is walking and they have a walk speed effect, boost their walking speed by the multiplier. event.multiply(entityRef.getComponent(WalkSpeedComponent.class).multiplier); - } - // If the entity is swimming and they have a swim speed effect, boost their swimming speed by the multiplier. - else if (event.getMovementMode() == MovementMode.SWIMMING && entityRef.hasComponent(SwimSpeedComponent.class)) { + } else if (event.getMovementMode() == MovementMode.SWIMMING && entityRef.hasComponent(SwimSpeedComponent.class)) { + // If the entity is swimming and they have a swim speed effect, boost their swimming speed by the multiplier. event.multiply(entityRef.getComponent(SwimSpeedComponent.class).multiplier); } @@ -62,18 +45,17 @@ else if (event.getMovementMode() == MovementMode.SWIMMING && entityRef.hasCompon /** * When an entity tries to jump, modify the jump speed based on what effects are being applied to the entity. * - * @param event Stores information on the jump force and allows other systems to modify it. - * @param entityRef The entity trying to jump. + * @param event Stores information on the jump force and allows other systems to modify it. + * @param entityRef The entity trying to jump. */ @ReceiveEvent public void modifyJumpSpeed(AffectJumpForceEvent event, EntityRef entityRef) { // If the entity's stunned, prevent it from moving. if (entityRef.hasComponent(StunComponent.class)) { event.multiply(0); - } - // If the entity is beginning to jump and they have a jump speed effect, boost their jumping speed by the - // multiplier. - else if (entityRef.hasComponent(JumpSpeedComponent.class)) { + } else if (entityRef.hasComponent(JumpSpeedComponent.class)) { + // If the entity is beginning to jump and they have a jump speed effect, boost their jumping speed by the + // multiplier. event.multiply(entityRef.getComponent(JumpSpeedComponent.class).multiplier); } @@ -84,11 +66,11 @@ else if (entityRef.hasComponent(JumpSpeedComponent.class)) { } /** - * When an entity tries to jump, modify the max number jumps (before hitting the ground) based on what effects are - * being applied to the entity. + * When an entity tries to jump, modify the max number jumps (before hitting the ground) based on what effects are being applied to the + * entity. * - * @param event Stores information on the number of jumps and allows other systems to modify it. - * @param entityRef The entity trying to jump. + * @param event Stores information on the number of jumps and allows other systems to modify it. + * @param entityRef The entity trying to jump. */ @ReceiveEvent public void modifyMultiJump(AffectMultiJumpEvent event, EntityRef entityRef) { @@ -99,11 +81,10 @@ public void modifyMultiJump(AffectMultiJumpEvent event, EntityRef entityRef) { } /** - * When an entity tries to use an item, modify the cooldown time based on what effects are being applied to the - * entity. + * When an entity tries to use an item, modify the cooldown time based on what effects are being applied to the entity. * - * @param event Stores information on the item's cooldown and allows other systems to modify it. - * @param entityRef The entity trying to use an item. + * @param event Stores information on the item's cooldown and allows other systems to modify it. + * @param entityRef The entity trying to use an item. */ @ReceiveEvent public void modifyItemUseSpeed(AffectItemUseCooldownTimeEvent event, EntityRef entityRef) { diff --git a/src/main/java/org/terasology/alterationEffects/speed/StunAlterationEffect.java b/src/main/java/org/terasology/alterationEffects/speed/StunAlterationEffect.java index 38c099e..d8d272e 100644 --- a/src/main/java/org/terasology/alterationEffects/speed/StunAlterationEffect.java +++ b/src/main/java/org/terasology/alterationEffects/speed/StunAlterationEffect.java @@ -1,4 +1,4 @@ -// Copyright 2020 The Terasology Foundation +// Copyright 2021 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 package org.terasology.alterationEffects.speed; diff --git a/src/main/java/org/terasology/alterationEffects/speed/SwimSpeedAlterationEffect.java b/src/main/java/org/terasology/alterationEffects/speed/SwimSpeedAlterationEffect.java index 976e937..4023ec4 100644 --- a/src/main/java/org/terasology/alterationEffects/speed/SwimSpeedAlterationEffect.java +++ b/src/main/java/org/terasology/alterationEffects/speed/SwimSpeedAlterationEffect.java @@ -1,4 +1,4 @@ -// Copyright 2020 The Terasology Foundation +// Copyright 2021 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 package org.terasology.alterationEffects.speed; diff --git a/src/main/java/org/terasology/alterationEffects/speed/WalkSpeedAlterationEffect.java b/src/main/java/org/terasology/alterationEffects/speed/WalkSpeedAlterationEffect.java index 48c8605..50c5420 100644 --- a/src/main/java/org/terasology/alterationEffects/speed/WalkSpeedAlterationEffect.java +++ b/src/main/java/org/terasology/alterationEffects/speed/WalkSpeedAlterationEffect.java @@ -1,4 +1,4 @@ -// Copyright 2020 The Terasology Foundation +// Copyright 2021 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 package org.terasology.alterationEffects.speed;