Пример #1
0
    public void destroySelf(bool doDelete = true)
    {
        Debug.LogWarning("Destroyself called");


        if (type == Type.AIRCRAFT)
        {
            GameManager.getGM().getTeamAircraftList(team).Remove(this);
        }


        if (showInWorldList)
        {
            removeFromDatalink(); // if not present in world's list, is likely too simple to involve datalink
            CombatFlow.combatUnits.Remove(this);
        }


        if (ownerLane != null)
        {
            ownerLane.unitDeath(this);
        }

        if (isLocalPlayer)
        {
            //Debug.LogWarning("localplayer: " + gameObject.name + " destroyed. Calling showSpawnMenu");
            GameManager.getGM().showSpawnMenu();

            PlayerInput_Aircraft input = GetComponent <PlayerInput_Aircraft>();
            input.hardpointController.destroyWeapons();
        }

        if (camManager != null)
        {
            // remove this camera from perspectiveManager's list
            //  Is this a crusty way of doing this? Might be perspectiveManager's responsibility instead?
            camManager.cameras.Remove(unitCam);
        }

        //Weapon weaponRef = GetComponent<Weapon>();
        //if(weaponRef != null)
        //{
        //    Destroy(weaponRef.effectsObj);
        //}

        if (myHudIconRef != null)
        {
            Destroy(myHudIconRef.gameObject);
        }

        //Destroy(gameObject);

        if (doDelete)
        {
            Weapon myWeapon = GetComponent <Weapon>();

            bool missileFound = false;
            if (networkDeath && myWeapon != null && (localOwned || isLocalPlayer))
            {
                myWeapon.destroyWeapon();
            }
            else
            {
                Destroy(gameObject);
            }
        }
    }