Package megamek.common.force
Class Force
java.lang.Object
megamek.common.force.Force
- All Implemented Interfaces:
Serializable
A representation of a force or part of a force. Very similar to MHQ's Force. A Force in MM belongs to a player. It
can hold units of the owner's team.
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionForce(String name, int id, Camouflage camouflage) Creates a force with name n and id nId.Force(String name, int id, Camouflage camouflage, Force parent) Creates a sub force.Force(String name, int id, Camouflage camouflage, Player owner) Creates a top-level (no parent) force -
Method Summary
Modifier and TypeMethodDescriptionprotected Forceclone()booleancontainsEntity(int id) Returns true if the provided entity is among the force's direct members.booleanDeprecated, for removal: This API element is subject to removal in a future version.booleancontainsSubForce(Force force) Returns true if the provided force is among this force's direct subForces.static ForcecreateSubforce(String name, Force fParent) Creates a force object that is not integrated into any forces.static ForcecreateToplevelForce(String name, Player owner) Creates a force object that is not integrated into any forces.intintentityIndex(ForceAssignable unit) Returns the index of the provided unit in the list of direct members of this force.getCamouflageOrElse(Game game, Camouflage camouflage) intReturns the number of direct children of this force, i.e.intgetEntityId(int index) Returns the id of the entity at the provided index from the list of direct members of this force (not subForces).intgetId()getName()intReturns the player ID of the owner of this force.intReturns the Force ID of this force's parent force; -1 if top-level.intgetSubForceId(int index) Returns the id of the force at the provided index from the list of subForces of this force.booleanisEmpty()Returns true if the force contains neither units nor subForces.booleanvoidsetCamouflage(Camouflage camouflage) voidintintsubForceIndex(Force force) Returns the index of the provided force in the list of direct subForces of this force.toString()
-
Field Details
-
NO_FORCE
public static final int NO_FORCE- See Also:
-
-
Constructor Details
-
Force
Creates a top-level (no parent) force -
Force
Creates a sub force. -
Force
Creates a force with name n and id nId. Without either a parent or owner this force is a stub and should not be added to a Forces object. Used to parse the forceString, e.g. when loading a MUL.
-
-
Method Details
-
createSubforce
Creates a force object that is not integrated into any forces. Used to send a new force to the server. In other cases, use Forces.add. -
createToplevelForce
Creates a force object that is not integrated into any forces. Used to send a new force to the server. In other cases, use Forces.add. -
getName
-
setName
-
getId
public int getId() -
getCamouflage
-
getCamouflageOrElse
-
setCamouflage
-
getOwnerId
public int getOwnerId()Returns the player ID of the owner of this force. -
getParentId
public int getParentId()Returns the Force ID of this force's parent force; -1 if top-level. -
getParent
-
isTopLevel
public boolean isTopLevel() -
subForceCount
public int subForceCount() -
entityCount
public int entityCount() -
getChildCount
public int getChildCount()Returns the number of direct children of this force, i.e. the number of direct members + the number of direct subForces. -
isEmpty
public boolean isEmpty()Returns true if the force contains neither units nor subForces. -
getEntityId
public int getEntityId(int index) Returns the id of the entity at the provided index from the list of direct members of this force (not subForces). Indices outside 0 ... entityCount() - 1 will result in an exception. -
getSubForceId
public int getSubForceId(int index) Returns the id of the force at the provided index from the list of subForces of this force. Indices outside 0 ... subForceCount() - 1 will result in an exception. -
containsEntity
Deprecated, for removal: This API element is subject to removal in a future version.Returns true if the provided unit is among the force's direct members. Does NOT check if the unit is part of any sub force. -
containsEntity
public boolean containsEntity(int id) Returns true if the provided entity is among the force's direct members. Does NOT check if the entity is part of any sub force. -
entityIndex
Returns the index of the provided unit in the list of direct members of this force. Returns -1 if the unit is no direct member of this force. -
containsSubForce
Returns true if the provided force is among this force's direct subForces. -
subForceIndex
Returns the index of the provided force in the list of direct subForces of this force. Returns -1 if the force is no direct sub force of this force. -
getEntities
-
getSubForces
-
clone
-
toString
-