public override Vector <ApplyDamageResult> applyDamage(int tick, Vector <ApplyDamageResult> result = null)
        {
            if (result == null)
            {
                result = new Vector <ApplyDamageResult>();
            }
            var target = engine.context.actors.getActorByObjectId(_targetObjectId) as BattleUnit;

            if (target == null)
            {
                return(result);
            }

            target.receiveDamage(_damage);

            var damageResult = new ApplyDamageResult();

            damageResult.units          = (int)target.hp;
            damageResult.ownerId        = target.ownerId;
            damageResult.targetId       = _targetObjectId;
            damageResult.damageObjectId = objectId;
            damageResult.x = transform.x;
            damageResult.y = transform.y;
            damageResult.z = transform.z;

            result.push(damageResult);

            return(result);
        }
        public override Vector <ApplyDamageResult> applyDamage(int tick, Vector <ApplyDamageResult> result = null)
        {
            if (result == null)
            {
                result = new Vector <ApplyDamageResult>();
            }

            var unit = engine.context.actors.getActorByObjectId(_unitObjectId) as BattleUnit;

            if (unit == null)
            {
                return(result);
            }

            var building = engine.context.actors.getActorByObjectId(_buildingObjectId) as BattleBuilding;

            if (building.ownerId == unit.ownerId)
            {
                attachUnits(building, unit);
                return(result);
            }

            var damageResult = new ApplyDamageResult();

            var buildingDamage = building.powerDamage;
            var unitDamage     = unit.powerDamage;

            building.receiveDamage(unitDamage);
            unit.receiveDamage(buildingDamage);

            if (unit.units.count > building.units.count)
            {
                building.changeOwner(unit.ownerId);
                building.units.change(unit.units.count);

                var evt = engine.output.enqueueByFactory <BuildingChangeOwnerEvent>(tick);
                evt.objectId = building.objectId;
                evt.ownerId  = unit.ownerId;
                evt.units    = unit.units.count;
            }

            damageResult.x              = building.transform.x;
            damageResult.y              = building.transform.y;
            damageResult.z              = building.transform.z;
            damageResult.ownerId        = building.ownerId;
            damageResult.targetId       = building.objectId;
            damageResult.damageObjectId = objectId;
            damageResult.units          = building.units.count;

            result.push(damageResult);

            return(result);
        }