-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Human and NightElf Build #5
Open
MfromAzeroth
wants to merge
6
commits into
Retera:experimental
Choose a base branch
from
MfromAzeroth:main
base: experimental
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5903307
Added 'uhpr' to available values in CUnitData.java
MfromAzeroth 4b0848a
Added hit point regeneration data
MfromAzeroth 61c3ac4
Added regenerateHitPoints
MfromAzeroth b60e883
Merged with Retera's newest public version and added Wisp consumption on
MfromAzeroth 4ee537d
Implemented Human Build, Power Building and Repair Costs
MfromAzeroth 2a58c54
Bug fixes and details for night elf build
MfromAzeroth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
376 changes: 281 additions & 95 deletions
376
core/src/com/etheller/warsmash/viewer5/handlers/w3x/simulation/CUnit.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...theller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/CBehaviorHumanBuild.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.build; | ||
|
||
public class CBehaviorHumanBuild { | ||
} |
66 changes: 66 additions & 0 deletions
66
...ller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/CBehaviorNightElfBuild.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.build; | ||
|
||
import com.etheller.warsmash.util.WarsmashConstants; | ||
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CSimulation; | ||
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnit; | ||
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.CUnitType; | ||
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.CAbility; | ||
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.abilities.build.CAbilityBuildInProgress; | ||
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.CBehavior; | ||
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.pathing.CBuildingPathingType; | ||
import com.etheller.warsmash.viewer5.handlers.w3x.simulation.players.CPlayer; | ||
|
||
import java.awt.image.BufferedImage; | ||
import java.util.EnumSet; | ||
|
||
public class CBehaviorNightElfBuild extends CBehaviorOrcBuild{ | ||
public CBehaviorNightElfBuild(CUnit unit) { | ||
super(unit); | ||
} | ||
|
||
@Override | ||
protected CBehavior update(final CSimulation simulation, final boolean withinFacingWindow) { | ||
if (!this.unitCreated) { | ||
this.unitCreated = true; | ||
final CUnitType unitTypeToCreate = simulation.getUnitData().getUnitType(this.orderId); | ||
final BufferedImage buildingPathingPixelMap = unitTypeToCreate.getBuildingPathingPixelMap(); | ||
boolean buildLocationObstructed = false; | ||
if (buildingPathingPixelMap != null) { | ||
final EnumSet<CBuildingPathingType> preventedPathingTypes = unitTypeToCreate.getPreventedPathingTypes(); | ||
final EnumSet<CBuildingPathingType> requiredPathingTypes = unitTypeToCreate.getRequiredPathingTypes(); | ||
|
||
if (!simulation.getPathingGrid().checkPathingTexture(this.target.getX(), this.target.getY(), | ||
(int) simulation.getGameplayConstants().getBuildingAngle(), buildingPathingPixelMap, | ||
preventedPathingTypes, requiredPathingTypes, simulation.getWorldCollision(), this.unit)) { | ||
buildLocationObstructed = true; | ||
} | ||
} | ||
final int playerIndex = this.unit.getPlayerIndex(); | ||
if (!buildLocationObstructed) { | ||
final CUnit constructedStructure = simulation.createUnit(this.orderId, playerIndex, this.target.getX(), | ||
this.target.getY(), simulation.getGameplayConstants().getBuildingAngle()); | ||
constructedStructure.setConstructing(true); | ||
constructedStructure.setWorkerInside(this.unit); | ||
constructedStructure.setLife(simulation, | ||
constructedStructure.getMaximumLife() * WarsmashConstants.BUILDING_CONSTRUCT_START_LIFE); | ||
constructedStructure.setFoodUsed(unitTypeToCreate.getFoodUsed()); | ||
constructedStructure.add(simulation, | ||
new CAbilityBuildInProgress(simulation.getHandleIdAllocator().createId())); | ||
for (final CAbility ability : constructedStructure.getAbilities()) { | ||
ability.visit(AbilityDisableWhileUnderConstructionVisitor.INSTANCE); | ||
} | ||
this.unit.setHidden(true); | ||
this.unit.setPaused(true); | ||
this.unit.setInvulnerable(true); | ||
constructedStructure.setConstuctionProcessType(ConstructionFlag.CONSUME_WORKER); | ||
simulation.unitConstructedEvent(this.unit, constructedStructure); | ||
} | ||
else { | ||
final CPlayer player = simulation.getPlayer(playerIndex); | ||
refund(player, unitTypeToCreate); | ||
simulation.getCommandErrorListener(playerIndex).showCantPlaceError(); | ||
} | ||
} | ||
return this.unit.pollNextOrderBehavior(simulation); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...m/etheller/warsmash/viewer5/handlers/w3x/simulation/behaviors/build/ConstructionFlag.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.etheller.warsmash.viewer5.handlers.w3x.simulation.behaviors.build; | ||
|
||
public enum ConstructionFlag { | ||
NONE, CONSUME_WORKER, REQURIE_REPAIR; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if instead of setting the construction progress type in this large copy of the Orc Build code, we have the orc style build base class for the behavior call some function here, maybe called
applyConstructionProgressType(constructedStructure)
that is abstract and implemented by the subclass, so that Night Elf build will make this call to tell the unit to have CONSUME_WORKER flag, and orc build will do nothing. That way, a year from now when someone needs to change all of this other code for how orc build works in the "update" method, that person in the future won't have to change two copies of this?This comment is just a stylistic suggestion more than anything, in case someone has time to play with that whenever one of us handles the merge conflicts. (My "experimental" branch does not have Night Elf build yet at the time of writing, so thinking about this isn't wasted effort, although just getting your change as written into there would be great too.) Looks like what you have should still work fine, and there are plenty of non-ideal stylstic choices in my code with worse code duplication than this sitting around. So, just a suggestion here that occurred to me while reviewing.