From 3753c833cca265d1ebd6b062fc82c5f06685647f Mon Sep 17 00:00:00 2001 From: mrcookieunderscore13 Date: Sat, 8 May 2021 17:00:57 -0500 Subject: [PATCH 1/3] Add decay-time, recovery-time, and owned-decay-time attributes to control points. Signed-off-by: mrcookie --- .../tc/oc/pgm/controlpoint/ControlPoint.java | 39 ++++++++++++++++++- .../controlpoint/ControlPointDefinition.java | 33 ++++++++++++++++ .../pgm/controlpoint/ControlPointParser.java | 10 +++++ 3 files changed, 81 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/tc/oc/pgm/controlpoint/ControlPoint.java b/core/src/main/java/tc/oc/pgm/controlpoint/ControlPoint.java index f5683474ae..02ec5ac227 100644 --- a/core/src/main/java/tc/oc/pgm/controlpoint/ControlPoint.java +++ b/core/src/main/java/tc/oc/pgm/controlpoint/ControlPoint.java @@ -49,6 +49,11 @@ public class ControlPoint extends SimpleGoal protected final Vector centerPoint; + // time values to increment by for decay, recovery, and owned-decay + protected final float decayIncrement; + protected final float recoveryIncrement; + protected final float ownedDecayIncrement; + // This is set false after the first state change if definition.permanent == true protected boolean capturable = true; @@ -80,6 +85,24 @@ public ControlPoint(Match match, ControlPointDefinition definition) { this.playerTracker = new ControlPointPlayerTracker(match, this.getCaptureRegion()); this.blockDisplay = new ControlPointBlockDisplay(match, this); + + this.decayIncrement = + definition.getDecayTime().equals(Duration.ZERO) + ? 0 + : (float) definition.getTimeToCapture().toMillis() + / (float) definition.getDecayTime().toMillis(); + + this.recoveryIncrement = + definition.getRecoveryTime().equals(Duration.ZERO) + ? 0 + : (float) definition.getTimeToCapture().toMillis() + / (float) definition.getRecoveryTime().toMillis(); + + this.ownedDecayIncrement = + definition.getOwnedDecayTime().equals(Duration.ZERO) + ? 0 + : (float) definition.getTimeToCapture().toMillis() + / (float) definition.getOwnedDecayTime().toMillis(); } public void registerEvents() { @@ -413,7 +436,6 @@ private void dominate(Competitor dominantTeam, Duration dominantTime) { } ControlPointDefinition definition = this.getDefinition(); - if (this.controllingTeam != null && definition.hasNeutralState()) { // Point is owned and must go through the neutral state before another team can capture it if (dominantTeam == this.controllingTeam) { @@ -423,6 +445,16 @@ private void dominate(Competitor dominantTeam, Duration dominantTime) { } else if (!definition.isIncrementalCapture()) { // No team is dominant and point is not incremental, so reset the time this.capturingTime = Duration.ZERO; + } else if (TimeUtils.isLongerThan(definition.getOwnedDecayTime(), Duration.ZERO)) { + // Decay a team's capture + this.progressUncapture( + null, Duration.ofMillis((long) (ownedDecayIncrement * dominantTime.toMillis()))); + } else if (TimeUtils.isLongerThan(definition.getRecoveryTime(), Duration.ZERO) + && TimeUtils.isLongerThan(this.capturingTime, Duration.ZERO)) { + // recover a team's capture -- mutually exclusive with owned decay + this.regressCapture( + this.controllingTeam, + Duration.ofMillis((long) (recoveryIncrement * dominantTime.toMillis()))); } } else if (this.capturingTeam != null) { // Point is being captured by a specific team @@ -434,6 +466,11 @@ private void dominate(Competitor dominantTeam, Duration dominantTime) { // No team is dominant and point is not incremental, so reset time and clear capturing team this.capturingTime = Duration.ZERO; this.capturingTeam = null; + } else if (TimeUtils.isLongerThan(definition.getDecayTime(), Duration.ZERO) + && TimeUtils.isLongerThan(this.capturingTime, Duration.ZERO)) { + // No team is dominating, point is incremental, and there is a defined decay time + this.regressCapture( + null, Duration.ofMillis((long) (decayIncrement * dominantTime.toMillis()))); } } else if (dominantTeam != null && dominantTeam != this.controllingTeam diff --git a/core/src/main/java/tc/oc/pgm/controlpoint/ControlPointDefinition.java b/core/src/main/java/tc/oc/pgm/controlpoint/ControlPointDefinition.java index 11dbe3f614..d189cde237 100644 --- a/core/src/main/java/tc/oc/pgm/controlpoint/ControlPointDefinition.java +++ b/core/src/main/java/tc/oc/pgm/controlpoint/ControlPointDefinition.java @@ -38,6 +38,15 @@ public class ControlPointDefinition extends GoalDefinition { // Base time for the point to transition between states private final Duration timeToCapture; + // Time it takes for a point to decay while unowned. (Time is accurate when near 100% capture) + private final Duration decayTime; + + // Time it takes for a point to recover to captured state. (Accurate when almost uncaptured) + private final Duration recoveryTime; + + // Time it takes for a point to transition to neutral state. + private final Duration ownedDecayTime; + // Capture time multiplier for increasing or decreasing capture time based on the number of // players on the point private final float timeMultiplier; @@ -92,6 +101,9 @@ public ControlPointDefinition( Filter visualMaterials, BlockVector capturableDisplayBeacon, Duration timeToCapture, + Duration decayTime, + Duration recoveryTime, + Duration ownedDecayTime, float timeMultiplier, @Nullable TeamFactory initialOwner, CaptureCondition captureCondition, @@ -112,6 +124,9 @@ public ControlPointDefinition( this.visualMaterials = visualMaterials; this.capturableDisplayBeacon = capturableDisplayBeacon; this.timeToCapture = timeToCapture; + this.decayTime = decayTime; + this.recoveryTime = recoveryTime; + this.ownedDecayTime = ownedDecayTime; this.timeMultiplier = timeMultiplier; this.initialOwner = initialOwner; this.captureCondition = captureCondition; @@ -132,6 +147,12 @@ public String toString() { + this.getId() + " timeToCapture=" + this.getTimeToCapture() + + " decayTime=" + + this.getDecayTime() + + " recoveryTime=" + + this.getRecoveryTime() + + " ownedDecayTime=" + + this.getOwnedDecayTime() + " timeMultiplier=" + this.getTimeMultiplier() + " initialOwner=" @@ -192,6 +213,18 @@ public Duration getTimeToCapture() { return this.timeToCapture; } + public Duration getDecayTime() { + return this.decayTime; + } + + public Duration getRecoveryTime() { + return this.recoveryTime; + } + + public Duration getOwnedDecayTime() { + return this.ownedDecayTime; + } + public float getTimeMultiplier() { return this.timeMultiplier; } diff --git a/core/src/main/java/tc/oc/pgm/controlpoint/ControlPointParser.java b/core/src/main/java/tc/oc/pgm/controlpoint/ControlPointParser.java index dce99cc1bc..55fcbfcd47 100644 --- a/core/src/main/java/tc/oc/pgm/controlpoint/ControlPointParser.java +++ b/core/src/main/java/tc/oc/pgm/controlpoint/ControlPointParser.java @@ -77,6 +77,13 @@ public static ControlPointDefinition parseControlPoint( Duration timeToCapture = XMLUtils.parseDuration(elControlPoint.getAttribute("capture-time"), Duration.ofSeconds(30)); + Duration decayTime = + XMLUtils.parseDuration(elControlPoint.getAttribute("decay-time"), Duration.ZERO); + Duration recoveryTime = + XMLUtils.parseDuration(elControlPoint.getAttribute("recovery-time"), Duration.ZERO); + Duration ownedDecayTime = + XMLUtils.parseDuration(elControlPoint.getAttribute("owned-decay-time"), Duration.ZERO); + float timeMultiplier = XMLUtils.parseNumber( elControlPoint.getAttribute("time-multiplier"), Float.class, koth ? 0.1f : 0f); @@ -117,6 +124,9 @@ public static ControlPointDefinition parseControlPoint( visualMaterials, capturableDisplayBeacon == null ? null : capturableDisplayBeacon.toBlockVector(), timeToCapture, + decayTime, + recoveryTime, + ownedDecayTime, timeMultiplier, initialOwner, captureCondition, From fe3c0386585ffe8b2b6a61ff91f5f4e2e7a8c7dc Mon Sep 17 00:00:00 2001 From: mrcookieunderscore13 Date: Tue, 11 May 2021 13:32:19 -0500 Subject: [PATCH 2/3] Change decay and recovery to mimic the same functionality as in 1.9 PGM. Changed everything from units of time to rate. Signed-off-by: mrcookie --- .../tc/oc/pgm/controlpoint/ControlPoint.java | 160 ++++++++---------- .../controlpoint/ControlPointDefinition.java | 54 +++--- .../pgm/controlpoint/ControlPointParser.java | 41 +++-- 3 files changed, 124 insertions(+), 131 deletions(-) diff --git a/core/src/main/java/tc/oc/pgm/controlpoint/ControlPoint.java b/core/src/main/java/tc/oc/pgm/controlpoint/ControlPoint.java index 02ec5ac227..c272d67349 100644 --- a/core/src/main/java/tc/oc/pgm/controlpoint/ControlPoint.java +++ b/core/src/main/java/tc/oc/pgm/controlpoint/ControlPoint.java @@ -49,11 +49,6 @@ public class ControlPoint extends SimpleGoal protected final Vector centerPoint; - // time values to increment by for decay, recovery, and owned-decay - protected final float decayIncrement; - protected final float recoveryIncrement; - protected final float ownedDecayIncrement; - // This is set false after the first state change if definition.permanent == true protected boolean capturable = true; @@ -85,24 +80,6 @@ public ControlPoint(Match match, ControlPointDefinition definition) { this.playerTracker = new ControlPointPlayerTracker(match, this.getCaptureRegion()); this.blockDisplay = new ControlPointBlockDisplay(match, this); - - this.decayIncrement = - definition.getDecayTime().equals(Duration.ZERO) - ? 0 - : (float) definition.getTimeToCapture().toMillis() - / (float) definition.getDecayTime().toMillis(); - - this.recoveryIncrement = - definition.getRecoveryTime().equals(Duration.ZERO) - ? 0 - : (float) definition.getTimeToCapture().toMillis() - / (float) definition.getRecoveryTime().toMillis(); - - this.ownedDecayIncrement = - definition.getOwnedDecayTime().equals(Duration.ZERO) - ? 0 - : (float) definition.getTimeToCapture().toMillis() - / (float) definition.getOwnedDecayTime().toMillis(); } public void registerEvents() { @@ -426,9 +403,6 @@ private void dominateAndFireEvents(@Nullable Competitor dominantTeam, Duration d * *

If there is no neutral state, then the point is always either being captured by a specific * team, or not being captured at all. - * - *

If incremental capturing is disabled, then capturingTimeMillis is reset to zero whenever it - * stops increasing. */ private void dominate(Competitor dominantTeam, Duration dominantTime) { if (!this.capturable || !TimeUtils.isLongerThan(dominantTime, Duration.ZERO)) { @@ -439,38 +413,29 @@ private void dominate(Competitor dominantTeam, Duration dominantTime) { if (this.controllingTeam != null && definition.hasNeutralState()) { // Point is owned and must go through the neutral state before another team can capture it if (dominantTeam == this.controllingTeam) { - this.regressCapture(dominantTeam, dominantTime); + // owner is recovering the point + recover(dominantTeam, dominantTime); } else if (dominantTeam != null) { - this.progressUncapture(dominantTeam, dominantTime); - } else if (!definition.isIncrementalCapture()) { - // No team is dominant and point is not incremental, so reset the time - this.capturingTime = Duration.ZERO; - } else if (TimeUtils.isLongerThan(definition.getOwnedDecayTime(), Duration.ZERO)) { - // Decay a team's capture - this.progressUncapture( - null, Duration.ofMillis((long) (ownedDecayIncrement * dominantTime.toMillis()))); - } else if (TimeUtils.isLongerThan(definition.getRecoveryTime(), Duration.ZERO) - && TimeUtils.isLongerThan(this.capturingTime, Duration.ZERO)) { - // recover a team's capture -- mutually exclusive with owned decay - this.regressCapture( - this.controllingTeam, - Duration.ofMillis((long) (recoveryIncrement * dominantTime.toMillis()))); + // non-owner is uncapturing the point + uncapture(dominantTeam, dominantTime); + } else if (definition.getOwnedDecayRate() > 0.0) { + // nobody on point so decay to neutral state + ownedDecay(dominantTime); + } else { + // nobody on point, so "decay" to fully captured + decay(dominantTime); } } else if (this.capturingTeam != null) { // Point is being captured by a specific team if (dominantTeam == this.capturingTeam) { - this.progressCapture(dominantTeam, dominantTime); + // capturing team is making progress + capture(dominantTime); } else if (dominantTeam != null) { - this.regressCapture(dominantTeam, dominantTime); - } else if (!definition.isIncrementalCapture()) { - // No team is dominant and point is not incremental, so reset time and clear capturing team - this.capturingTime = Duration.ZERO; - this.capturingTeam = null; - } else if (TimeUtils.isLongerThan(definition.getDecayTime(), Duration.ZERO) - && TimeUtils.isLongerThan(this.capturingTime, Duration.ZERO)) { - // No team is dominating, point is incremental, and there is a defined decay time - this.regressCapture( - null, Duration.ofMillis((long) (decayIncrement * dominantTime.toMillis()))); + // non-capturing team is dominate, so regress capturing team's progress + recover(dominantTeam, dominantTime); + } else { + // No team is dominating so decay + decay(dominantTime); } } else if (dominantTeam != null && dominantTeam != this.controllingTeam @@ -482,24 +447,30 @@ private void dominate(Competitor dominantTeam, Duration dominantTime) { } } - /** Progress toward the neutral state */ - private void progressUncapture(Competitor dominantTeam, Duration dominantTime) { - this.capturingTime = this.capturingTime.plus(dominantTime); - - if (!TimeUtils.isShorterThan(this.capturingTime, this.definition.getTimeToCapture())) { - // If uncapture is complete, recurse with the dominant team's remaining time - dominantTime = this.capturingTime.minus(this.definition.getTimeToCapture()); + private @Nullable Duration addCaptureTime(final Duration duration) { + this.capturingTime = this.capturingTime.plus(duration); + if (!TimeUtils.isLongerThan(definition.getTimeToCapture(), this.capturingTime)) { + final Duration remainder = this.capturingTime.minus(definition.getTimeToCapture()); this.capturingTime = Duration.ZERO; - this.controllingTeam = null; - this.dominate(dominantTeam, dominantTime); + return remainder; } + return null; } - /** Progress toward a new controller */ - private void progressCapture(Competitor dominantTeam, Duration dominantTime) { - this.capturingTime = this.capturingTime.plus(dominantTime); - if (!TimeUtils.isShorterThan(this.capturingTime, this.definition.getTimeToCapture())) { - this.capturingTime = Duration.ZERO; + private @Nullable Duration subtractCaptureTime(final Duration duration) { + if (TimeUtils.isLongerThan(this.capturingTime, duration)) { + this.capturingTime = this.capturingTime.minus(duration); + return null; + } else { + final Duration remainder = duration.minus(this.capturingTime); + this.capturingTime = duration.ZERO; + return remainder; + } + } + // Progress to a new owner + private void capture(Duration dominantTime) { + dominantTime = addCaptureTime(dominantTime); + if (dominantTime != null) { // Point is captured this.controllingTeam = this.capturingTeam; this.capturingTeam = null; if (this.getDefinition().isPermanent()) { @@ -508,31 +479,48 @@ private void progressCapture(Competitor dominantTeam, Duration dominantTime) { } } } - - /** Regress toward the current state */ - private void regressCapture(Competitor dominantTeam, Duration dominantTime) { - boolean crossZero = false; - if (definition.isIncrementalCapture()) { - // For incremental points, decrease the capture time - if (TimeUtils.isLongerThan(this.capturingTime, dominantTime)) { - this.capturingTime = this.capturingTime.minus(dominantTime); - } else { - dominantTime = dominantTime.minus(this.capturingTime); - this.capturingTime = Duration.ZERO; - crossZero = true; - } - } else { - // For non-incremental points, reset capture time to zero - this.capturingTime = Duration.ZERO; - crossZero = true; + // Progress towards the neutral state + private void uncapture(Competitor dominantTeam, Duration dominantTime) { + dominantTime = addCaptureTime(dominantTime); + if (dominantTime != null) { + this.controllingTeam = null; + this.dominate(dominantTeam, dominantTime); } - - if (crossZero) { + } + // Point being pulled back to current state (There is a lead on the point) + private void recover(Competitor dominantTeam, Duration dominantTime) { + dominantTime = + subtractCaptureTime( + Duration.ofMillis((long) (definition.getRecoveryRate() * dominantTime.toMillis()))); + if (dominantTeam != null) { this.capturingTeam = null; if (dominantTeam != this.controllingTeam) { // If the dominant team is not the controller, recurse with the remaining time - this.dominate(dominantTeam, dominantTime); + this.dominate( + dominantTeam, + Duration.ofMillis( + (long) ((1.0 / definition.getRecoveryRate()) * dominantTime.toMillis()))); } } } + // Point is being decayed back to its current state (No lead on point) + private void decay(Duration dominantTime) { + dominantTime = + subtractCaptureTime( + Duration.ofMillis((long) (definition.getDecayRate() * dominantTime.toMillis()))); + if (dominantTime != null) { + this.capturingTeam = null; + } + } + + // Point is being decayed back to neutral (No lead on point) + private void ownedDecay(Duration dominantTime) { + dominantTime = + addCaptureTime( + Duration.ofMillis((long) (definition.getOwnedDecayRate() * dominantTime.toMillis()))); + if (dominantTime != null) { + this.controllingTeam = null; + this.capturingTeam = null; + } + } } diff --git a/core/src/main/java/tc/oc/pgm/controlpoint/ControlPointDefinition.java b/core/src/main/java/tc/oc/pgm/controlpoint/ControlPointDefinition.java index d189cde237..6ff968884d 100644 --- a/core/src/main/java/tc/oc/pgm/controlpoint/ControlPointDefinition.java +++ b/core/src/main/java/tc/oc/pgm/controlpoint/ControlPointDefinition.java @@ -39,13 +39,13 @@ public class ControlPointDefinition extends GoalDefinition { private final Duration timeToCapture; // Time it takes for a point to decay while unowned. (Time is accurate when near 100% capture) - private final Duration decayTime; + private final double decayRate; // Time it takes for a point to recover to captured state. (Accurate when almost uncaptured) - private final Duration recoveryTime; + private final double recoveryRate; // Time it takes for a point to transition to neutral state. - private final Duration ownedDecayTime; + private final double ownedDecayRate; // Capture time multiplier for increasing or decreasing capture time based on the number of // players on the point @@ -63,10 +63,6 @@ public enum CaptureCondition { private final CaptureCondition captureCondition; - // true: progress is retained if capturing is interrupted - // false: progress resets to zero if capturing is interrupted - private final boolean incrementalCapture; - // true: point must transition through unowned state to change owners // false: point transitions directly from one owner to the next // NOTE: points always start in an unowned state, regardless of this value @@ -101,13 +97,12 @@ public ControlPointDefinition( Filter visualMaterials, BlockVector capturableDisplayBeacon, Duration timeToCapture, - Duration decayTime, - Duration recoveryTime, - Duration ownedDecayTime, + double decayRate, + double recoveryRate, + double ownedDecayRate, float timeMultiplier, @Nullable TeamFactory initialOwner, CaptureCondition captureCondition, - boolean incrementalCapture, boolean neutralState, boolean permanent, float pointsPerSecond, @@ -124,13 +119,12 @@ public ControlPointDefinition( this.visualMaterials = visualMaterials; this.capturableDisplayBeacon = capturableDisplayBeacon; this.timeToCapture = timeToCapture; - this.decayTime = decayTime; - this.recoveryTime = recoveryTime; - this.ownedDecayTime = ownedDecayTime; + this.decayRate = decayRate; + this.recoveryRate = recoveryRate; + this.ownedDecayRate = ownedDecayRate; this.timeMultiplier = timeMultiplier; this.initialOwner = initialOwner; this.captureCondition = captureCondition; - this.incrementalCapture = incrementalCapture; this.neutralState = neutralState; this.permanent = permanent; this.pointsPerSecond = pointsPerSecond; @@ -147,20 +141,18 @@ public String toString() { + this.getId() + " timeToCapture=" + this.getTimeToCapture() - + " decayTime=" - + this.getDecayTime() - + " recoveryTime=" - + this.getRecoveryTime() - + " ownedDecayTime=" - + this.getOwnedDecayTime() + + " decayRate=" + + this.getDecayRate() + + " recoveryRate=" + + this.getRecoveryRate() + + " ownedDecayRate=" + + this.getOwnedDecayRate() + " timeMultiplier=" + this.getTimeMultiplier() + " initialOwner=" + this.getInitialOwner() + " captureCondition=" + this.getCaptureCondition() - + " incrementalCapture=" - + this.isIncrementalCapture() + " neutralState=" + this.hasNeutralState() + " permanent=" @@ -213,16 +205,16 @@ public Duration getTimeToCapture() { return this.timeToCapture; } - public Duration getDecayTime() { - return this.decayTime; + public double getDecayRate() { + return this.decayRate; } - public Duration getRecoveryTime() { - return this.recoveryTime; + public double getRecoveryRate() { + return this.recoveryRate; } - public Duration getOwnedDecayTime() { - return this.ownedDecayTime; + public double getOwnedDecayRate() { + return this.ownedDecayRate; } public float getTimeMultiplier() { @@ -238,10 +230,6 @@ public CaptureCondition getCaptureCondition() { return this.captureCondition; } - public boolean isIncrementalCapture() { - return this.incrementalCapture; - } - public boolean hasNeutralState() { return this.neutralState; } diff --git a/core/src/main/java/tc/oc/pgm/controlpoint/ControlPointParser.java b/core/src/main/java/tc/oc/pgm/controlpoint/ControlPointParser.java index 55fcbfcd47..289e5d87cb 100644 --- a/core/src/main/java/tc/oc/pgm/controlpoint/ControlPointParser.java +++ b/core/src/main/java/tc/oc/pgm/controlpoint/ControlPointParser.java @@ -77,18 +77,36 @@ public static ControlPointDefinition parseControlPoint( Duration timeToCapture = XMLUtils.parseDuration(elControlPoint.getAttribute("capture-time"), Duration.ofSeconds(30)); - Duration decayTime = - XMLUtils.parseDuration(elControlPoint.getAttribute("decay-time"), Duration.ZERO); - Duration recoveryTime = - XMLUtils.parseDuration(elControlPoint.getAttribute("recovery-time"), Duration.ZERO); - Duration ownedDecayTime = - XMLUtils.parseDuration(elControlPoint.getAttribute("owned-decay-time"), Duration.ZERO); + final double decayRate, recoveryRate, ownedDecayRate; + final Node attrIncremental = Node.fromAttr(elControlPoint, "incremental"); + final Node attrDecay = Node.fromAttr(elControlPoint, "decay-rate"); + final Node attrRecovery = Node.fromAttr(elControlPoint, "recovery-rate"); + final Node attrOwnedDecay = Node.fromAttr(elControlPoint, "owned-decay-rate"); + if (attrIncremental == null) { + recoveryRate = + XMLUtils.parseNumber(attrRecovery, Double.class, koth ? 1D : Double.POSITIVE_INFINITY); + decayRate = + XMLUtils.parseNumber(attrDecay, Double.class, koth ? 0.0 : Double.POSITIVE_INFINITY); + ownedDecayRate = XMLUtils.parseNumber(attrOwnedDecay, Double.class, 0.0); + } else { + if (attrDecay != null) + throw new InvalidXMLException("Cannot combine this attribute with incremental", attrDecay); + if (attrRecovery != null) + throw new InvalidXMLException( + "Cannot combine this attribute with incremental", attrRecovery); + if (attrOwnedDecay != null) + throw new InvalidXMLException( + "Cannot combine this attribute with incremental", attrOwnedDecay); + + final boolean incremental = XMLUtils.parseBoolean(attrIncremental, koth); + recoveryRate = incremental ? 1.0 : Double.POSITIVE_INFINITY; + ownedDecayRate = 0.0; + decayRate = incremental ? 0.0 : Double.POSITIVE_INFINITY; + } float timeMultiplier = XMLUtils.parseNumber( elControlPoint.getAttribute("time-multiplier"), Float.class, koth ? 0.1f : 0f); - boolean incrementalCapture = - XMLUtils.parseBoolean(elControlPoint.getAttribute("incremental"), koth); boolean neutralState = XMLUtils.parseBoolean(elControlPoint.getAttribute("neutral-state"), koth); boolean permanent = XMLUtils.parseBoolean(elControlPoint.getAttribute("permanent"), false); @@ -124,13 +142,12 @@ public static ControlPointDefinition parseControlPoint( visualMaterials, capturableDisplayBeacon == null ? null : capturableDisplayBeacon.toBlockVector(), timeToCapture, - decayTime, - recoveryTime, - ownedDecayTime, + decayRate, + recoveryRate, + ownedDecayRate, timeMultiplier, initialOwner, captureCondition, - incrementalCapture, neutralState, permanent, pointsPerSecond, From 5e46f60bb554be5e34a350165e7a7334c27b40da Mon Sep 17 00:00:00 2001 From: mrcookieunderscore13 Date: Thu, 13 May 2021 19:31:21 -0500 Subject: [PATCH 3/3] Cleanups Signed-off-by: mrcookie --- .../tc/oc/pgm/controlpoint/ControlPoint.java | 2 +- .../oc/pgm/controlpoint/ControlPointParser.java | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/tc/oc/pgm/controlpoint/ControlPoint.java b/core/src/main/java/tc/oc/pgm/controlpoint/ControlPoint.java index c272d67349..2ca5d7cb63 100644 --- a/core/src/main/java/tc/oc/pgm/controlpoint/ControlPoint.java +++ b/core/src/main/java/tc/oc/pgm/controlpoint/ControlPoint.java @@ -418,7 +418,7 @@ private void dominate(Competitor dominantTeam, Duration dominantTime) { } else if (dominantTeam != null) { // non-owner is uncapturing the point uncapture(dominantTeam, dominantTime); - } else if (definition.getOwnedDecayRate() > 0.0) { + } else if (definition.getOwnedDecayRate() > 0) { // nobody on point so decay to neutral state ownedDecay(dominantTime); } else { diff --git a/core/src/main/java/tc/oc/pgm/controlpoint/ControlPointParser.java b/core/src/main/java/tc/oc/pgm/controlpoint/ControlPointParser.java index 289e5d87cb..cd9d023c5b 100644 --- a/core/src/main/java/tc/oc/pgm/controlpoint/ControlPointParser.java +++ b/core/src/main/java/tc/oc/pgm/controlpoint/ControlPointParser.java @@ -89,19 +89,15 @@ public static ControlPointDefinition parseControlPoint( XMLUtils.parseNumber(attrDecay, Double.class, koth ? 0.0 : Double.POSITIVE_INFINITY); ownedDecayRate = XMLUtils.parseNumber(attrOwnedDecay, Double.class, 0.0); } else { - if (attrDecay != null) - throw new InvalidXMLException("Cannot combine this attribute with incremental", attrDecay); - if (attrRecovery != null) + if (attrDecay != null || attrRecovery != null || attrOwnedDecay != null) throw new InvalidXMLException( - "Cannot combine this attribute with incremental", attrRecovery); - if (attrOwnedDecay != null) - throw new InvalidXMLException( - "Cannot combine this attribute with incremental", attrOwnedDecay); + "Cannot combine this attribute with incremental", + attrDecay != null ? attrDecay : attrRecovery != null ? attrRecovery : attrOwnedDecay); final boolean incremental = XMLUtils.parseBoolean(attrIncremental, koth); recoveryRate = incremental ? 1.0 : Double.POSITIVE_INFINITY; - ownedDecayRate = 0.0; decayRate = incremental ? 0.0 : Double.POSITIVE_INFINITY; + ownedDecayRate = 0.0; } float timeMultiplier = @@ -109,6 +105,10 @@ public static ControlPointDefinition parseControlPoint( elControlPoint.getAttribute("time-multiplier"), Float.class, koth ? 0.1f : 0f); boolean neutralState = XMLUtils.parseBoolean(elControlPoint.getAttribute("neutral-state"), koth); + + if (neutralState == false && ownedDecayRate > 0) { + throw new InvalidXMLException("This attribute requires a neutral state.", attrOwnedDecay); + } boolean permanent = XMLUtils.parseBoolean(elControlPoint.getAttribute("permanent"), false); float pointsPerSecond = XMLUtils.parseNumber(elControlPoint.getAttribute("points"), Float.class, 1f);