Skip to content

Commit 70f4938

Browse files
author
Bytekeeper
committed
Added copy constructor to Agent.java.
1 parent 3610db2 commit 70f4938

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

src/main/java/org/bk/ass/Agent.java

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,65 @@ public Agent(String name) {
8787
this.name = name;
8888
}
8989

90+
/**
91+
* Copy constructor. References to other agents are cleared:
92+
* <ul>
93+
* <li>attackTarget</li>
94+
* <li>restoreTarget</li>
95+
* <li>interceptors</li>
96+
* </ul>
97+
*/
98+
public Agent(Agent other) {
99+
this.name = other.name;
100+
this.attackTargetPriority = other.attackTargetPriority;
101+
this.armorShifted = other.armorShifted;
102+
this.shieldUpgrades = other.shieldUpgrades;
103+
this.userObject = other.userObject;
104+
this.elevationLevel = other.elevationLevel;
105+
this.x = other.x;
106+
this.y = other.y;
107+
this.speedSquared = other.speedSquared;
108+
this.speed = other.speed;
109+
this.vx = other.vx;
110+
this.vy = other.vy;
111+
this.healthShifted = other.healthShifted;
112+
this.maxHealthShifted = other.maxHealthShifted;
113+
this.healedThisFrame = other.healedThisFrame;
114+
this.hpConstructionRate = other.hpConstructionRate;
115+
this.shieldsShifted = other.shieldsShifted;
116+
this.maxShieldsShifted = other.maxShieldsShifted;
117+
this.energyShifted = other.energyShifted;
118+
this.maxEnergyShifted = other.maxEnergyShifted;
119+
this.cooldown = other.cooldown;
120+
this.maxCooldown = other.maxCooldown;
121+
this.stopFrames = other.stopFrames;
122+
this.remainingStimFrames = other.remainingStimFrames;
123+
this.canStim = other.canStim;
124+
this.plagueDamagePerFrameShifted = other.plagueDamagePerFrameShifted;
125+
this.regeneratesHealth = other.regeneratesHealth;
126+
this.isSuicider = other.isSuicider;
127+
this.isHealer = other.isHealer;
128+
this.isFlyer = other.isFlyer;
129+
this.isOrganic = other.isOrganic;
130+
this.isMechanic = other.isMechanic;
131+
this.isKiter = other.isKiter;
132+
this.isRepairer = other.isRepairer;
133+
this.protectedByDarkSwarm = other.protectedByDarkSwarm;
134+
this.burrowed = other.burrowed;
135+
this.burrowedAttacker = other.burrowedAttacker;
136+
this.detected = other.detected;
137+
this.isStasised = other.isStasised;
138+
this.isLockeddown = other.isLockeddown;
139+
this.size = other.size;
140+
this.isMelee = other.isMelee;
141+
this.airWeapon = other.airWeapon;
142+
this.groundWeapon = other.groundWeapon;
143+
this.onDeathHandler = other.onDeathHandler;
144+
this.attackTarget = null;
145+
this.restoreTarget = null;
146+
this.interceptors = Collections.emptyList();
147+
}
148+
90149
public Agent setUserObject(Object userObject) {
91150
this.userObject = userObject;
92151
return this;

0 commit comments

Comments
 (0)