⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 entity.java

📁 MegaMek is a networked Java clone of BattleTech, a turn-based sci-fi boardgame for 2+ players. Fight
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * MegaMek - * Copyright (C) 2000,2001,2002,2003,2004,2005 Ben Mazur (bmazur@sev.org) * *  This program is free software; you can redistribute it and/or modify it *  under the terms of the GNU General Public License as published by the Free *  Software Foundation; either version 2 of the License, or (at your option) *  any later version. * *  This program is distributed in the hope that it will be useful, but *  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *  for more details. */package megamek.common;import megamek.common.actions.ChargeAttackAction;import megamek.common.actions.DfaAttackAction;import megamek.common.actions.DisplacementAttackAction;import megamek.common.actions.PushAttackAction;import megamek.common.actions.WeaponAttackAction;import megamek.common.event.GameEntityChangeEvent;import megamek.common.preference.PreferenceManager;import megamek.common.util.StringUtil;import java.io.Serializable;import java.util.ArrayList;import java.util.Enumeration;import java.util.List;import java.util.Vector;import java.util.Iterator;/** * Entity is a master class for basically anything on the board except * terrain. */public abstract class Entity extends TurnOrdered    implements Serializable, Transporter, Targetable, RoundUpdated{    public static final int        NONE                = -1;    public static final int        LOC_NONE            = -1;    public static final int        LOC_DESTROYED       = -2;    public static final int        MAX_C3_NODES        = 12;    protected transient IGame    game;    protected int               id = Entity.NONE;    /** ID settable by external sources (such as mm.net) */    protected int               externalId = Entity.NONE;    protected float             weight;    protected boolean           omni = false;    protected String            chassis;    protected String            model;    protected String            fluff = null;    protected int               year;    protected int               techLevel;    protected Engine            engine;    protected boolean           mixedTech = false;    protected boolean           designValid = true;    protected String            displayName = null;    protected String            shortName = null;    public int                  duplicateMarker = 1;    protected transient Player  owner;    protected int               ownerId;    public Pilot                crew = new Pilot();    protected boolean           shutDown = false;    protected boolean           doomed = false;    protected boolean           destroyed = false;    private Coords              position = null;    protected int               facing = 0;    protected int               sec_facing = 0;    protected int               walkMP = 0;    protected int               jumpMP = 0;    protected int               targSys = MiscType.T_TARGSYS_STANDARD;    protected boolean           done = false;    protected boolean           prone = false;    protected boolean           hullDown = false;    protected boolean           findingClub = false;    protected boolean           armsFlipped = false;    protected boolean           unjammingRAC = false;    protected boolean           hasSpotlight = false;    protected boolean           illuminated = false;    protected boolean           spotlightIsActive = false;    protected boolean           usedSearchlight = false;    protected boolean           stuckInSwamp = false;    protected boolean           canUnstickByJumping = false;    protected int               taggedBy = -1;    protected boolean           layingMines = false;    protected boolean           _isEMId = false;        protected DisplacementAttackAction displacementAttack = null;    public int                  heat = 0;    public int                  heatBuildup = 0;    public int                  delta_distance = 0;    public int                  mpUsed = 0;    public int                  moved = IEntityMovementType.MOVE_NONE;    public boolean              gotPavementBonus = false;    public boolean              hitThisRoundByAntiTSM = false;    private int[]               exposure;    private int[]               armor;    private int[]               internal;    private int[]               orig_armor;    private int[]               orig_internal;    public int                  damageThisPhase;    public int                  engineHitsThisRound;    public boolean              rolledForEngineExplosion = false; //So that we don't roll twice in one round    public boolean              dodging;    public boolean              spotting;    private boolean             clearingMinefield = false;    protected int               killerId = Entity.NONE;    private int                 offBoardDistance = 0;    private int                 offBoardDirection = IOffBoardDirections.NONE;    private int                 retreatedDirection = IOffBoardDirections.NONE;    /**     * The object that tracks this unit's Inferno round hits.     */    public InfernoTracker       infernos = new InfernoTracker();    public ArtilleryTracker     aTracker= new ArtilleryTracker();    protected String            C3NetIdString = null;    protected int               C3Master = NONE;    protected int               C3CompanyMasterIndex = LOC_DESTROYED;    protected int               armorType = EquipmentType.T_ARMOR_UNKNOWN;    protected int               armorTechLevel = TechConstants.T_TECH_UNKNOWN;    protected int               structureType = EquipmentType.T_STRUCTURE_UNKNOWN;    protected ArrayList<Mounted>            equipmentList = new ArrayList<Mounted>();    protected ArrayList<Mounted>            weaponList = new ArrayList<Mounted>();    protected ArrayList<Mounted>            ammoList = new ArrayList<Mounted>();    protected ArrayList<Mounted>            miscList = new ArrayList<Mounted>();        protected Vector            pendingINarcPods = new Vector();    protected Vector            iNarcPods = new Vector();    protected Vector            failedEquipmentList = new Vector();    // which teams have NARCd us?  a long allows for 64 teams.    protected long              m_lNarcedBy = 0;    protected long              m_lPendingNarc = 0;    protected CriticalSlot[][]  crits; // [loc][slot]    protected int               movementMode  = IEntityMovementMode.NONE;    protected boolean           isHidden = false;    /**     * The components of this entity that can transport other entities.     */    private Vector<Transporter>   transports = new Vector<Transporter>();    /**      * The ids of the MechWarriors this entity has picked up     */    private Vector                pickedUpMechWarriors = new Vector();        /**     * The ID of the <code>Entity</code> that has loaded this unit.     */    private int                 conveyance = Entity.NONE;    /**     * Set to <code>true</code> if this unit was unloaded this turn.     */    private boolean             unloadedThisTurn = false;    /**     * The id of the <code>Entity</code> that is the current target of a     * swarm attack by this unit.     */    private int                 swarmTargetId = Entity.NONE;    /**     * The id of the <code>Entity</code> that is attacking this unit with     * a swarm attack.     */    private int                 swarmAttackerId = Entity.NONE;    /**     * Flag that indicates that the unit can still     * be salvaged (given enough time and parts).     */    private boolean             salvageable = true;    /**     * The removal condition is set when the entitiy is removed from the game.     */    private int removalCondition = IEntityRemovalConditions.REMOVE_UNKNOWN;    /**     * The round this unit will be deployed     */    private int deployRound = 0;    /**     * Marks an entity as having been deployed     */    private boolean deployed = false;    /**     * The unit number of this entity.  All entities which are     * members of the same low-level unit are expected to share     * the same unit number.  Future implementations may store     * multiple unit designations in the same unit number (e.g.     * battalion, company, platoon, and lance).     */    private char unitNumber     = (char) Entity.NONE;    /**      * Indicates whether this entity has been seen by the enemy     * during the course of this game.  Used in double-blind.     */    private boolean seenByEnemy = false;    /**      * Indicates whether this entity can currently be seen by     * the enemy.  Used in double-blind.     */    private boolean visibleToEnemy = false;    /** Whether this entity is captured or not. */    private boolean captured = false;    /**     * this is the elevation of the Entity--with respect to the surface of the hex it's in.     * In other words, this may need to *change* as it moves from hex to hex--without it going up or down.     * I.e.--level 0 hex, elevation 5--it moves to a level 2 hex, without going up or down.     * elevation is now 3.     */    protected int elevation = 0;        /**      * 2 vectors holding entity and weapon ids,     * to see who hit us this round with a swarm volley from what     * launcher     */        private Vector hitBySwarmsEntity = new Vector();    private Vector hitBySwarmsWeapon = new Vector();        //Whether this unit is canon;    private boolean canon;        private int assaultDropInProgress = 0;    private boolean climbMode = false; //save climb mode from turn to turn for convenience         protected int lastTarget = Entity.NONE;        /**     * Generates a new, blank, entity.     */    public Entity() {        this.armor = new int[locations()];        this.internal = new int[locations()];        this.orig_armor = new int[locations()];        this.orig_internal = new int[locations()];        this.crits = new CriticalSlot[locations()][];        this.exposure = new int[locations()];        for (int i = 0; i < locations(); i++) {            this.crits[i] = new CriticalSlot[getNumberOfCriticals(i)];        }        setC3NetId(this);    }    /**     * Restores the entity after serialization     */    public void restore() {        // restore all mounted equipments        for (Mounted mounted : equipmentList) {            mounted.restore();        }    }    public int getId() {        return id;    }    public void setId(int id) {        this.id = id;        displayName = null;        shortName = null;    }    public int getExternalId() {        return externalId;    }    public void setExternalId(int externalId) {        this.externalId = externalId;    }    public IGame getGame() { return game; }        public void setGame(IGame game) {        this.game = game;        this.restore();        // Make sure the owner is set.        if ( null == owner ) {            if ( Entity.NONE == ownerId ) {                throw new IllegalStateException                    ( "Entity doesn't know its owner's ID." );            }			Player player = game.getPlayer(ownerId);			if ( null == player ) {			    System.err.println			        ( "Entity can't find player #" + ownerId );			} else {			    setOwner( player );			}        }        // Also set game for each entity "loaded" in this entity.        Vector v = this.getLoadedUnits();        Enumeration iter = v.elements();        while (iter.hasMoreElements())        {           ((Entity)iter.nextElement()).setGame(game);        }    }    /**     * Returns the unit code for this entity.     */    public String getModel() {        return model;    }    public void setModel(String model) {        this.model = model;    }    /**     * Returns the chassis name for this entity.     */    public String getChassis() {        return chassis;    }    public void setChassis(String chassis) {        this.chassis = chassis;    }        /**     * Returns the fluff for this entity.     */    public String getFluff() {        return fluff;    }    public void setFluff(String fluff) {        this.fluff = fluff;    }        /**     * Returns the unit tech for this entity.     */    public int getTechLevel() {        return techLevel;    }    public void setTechLevel(int techLevel) {        this.techLevel = techLevel;    }    public boolean isClan() {        return ( techLevel == TechConstants.T_CLAN_LEVEL_2 ||                 techLevel == TechConstants.T_CLAN_LEVEL_3 );    }    public boolean isClanArmor() {        if (getArmorTechLevel() == TechConstants.T_TECH_UNKNOWN)            return isClan();		return ((getArmorTechLevel() == TechConstants.T_CLAN_LEVEL_2)		        || (getArmorTechLevel() == TechConstants.T_CLAN_LEVEL_3));    }    public boolean isMixedTech() {        return mixedTech;    }    public void setMixedTech(boolean mixedTech) {        this.mixedTech = mixedTech;    }    public boolean isDesignValid() {        return designValid;    }    public void setDesignValid(boolean designValid) {        this.designValid = designValid;    }    public int getYear() {        return year;    }    public void setYear(int year) {        this.year = year;    }    public float getWeight() {        return weight;    }    public int getWeightClass() {        return EntityWeightClass.getWeightClass((int)getWeight());

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -