示例#1
0
        private void ResetAttackFSM(SmartEntity troopEntity)
        {
            StaRTS.Utils.Diagnostics.Logger logger = Service.Logger;
            StateComponent stateComp = troopEntity.StateComp;

            if (stateComp == null)
            {
                logger.Error("ResetAttackFSM StateComp is null");
                return;
            }
            stateComp.Reset();
            TroopComponent troopComp = troopEntity.TroopComp;

            if (troopComp == null)
            {
                logger.Error("ResetAttackFSM TroopComp is null");
                return;
            }
            if (troopComp.TroopType == null)
            {
                logger.Error("ResetAttackFSM TroopVO is null");
                return;
            }
            ShooterComponent shooterComp = troopEntity.ShooterComp;

            if (shooterComp == null)
            {
                logger.Error("ResetAttackFSM ShooterComp is null");
                return;
            }
            TroopRole troopRole = shooterComp.ShooterVO.TroopRole;

            if (troopRole == TroopRole.None)
            {
                troopRole = shooterComp.OriginalShooterVO.TroopRole;
            }
            HealthType healthType = (troopRole != TroopRole.Healer) ? HealthType.Damaging : HealthType.Healing;

            shooterComp.Reset();
            shooterComp.AttackFSM = new AttackFSM(Service.BattleController, troopEntity, troopEntity.StateComp, shooterComp, troopEntity.TransformComp, healthType);
        }
示例#2
0
        private void SpawnProjectile(uint id, object cookie)
        {
            SpecialAttack specialAttack = (SpecialAttack)cookie;

            StaRTS.Utils.Diagnostics.Logger logger = Service.Logger;
            if (specialAttack == null)
            {
                logger.Error("SpawnProjectile: specialAttack is null");
                this.SendSpecialAttackFired(null);
                return;
            }
            if (specialAttack.GetGunLocator() == null)
            {
                logger.Error("SpawnProjectile: specialAttack.GetGunLocator() is null " + specialAttack.VO.Uid);
                this.SendSpecialAttackFired(specialAttack.VO);
                return;
            }
            if (specialAttack.GetGunLocator().transform == null)
            {
                logger.Error("SpawnProjectile: specialAttack.GetGunLocator().transform is null " + specialAttack.VO.Uid);
                this.SendSpecialAttackFired(specialAttack.VO);
                return;
            }
            Vector3 position = specialAttack.GetGunLocator().transform.position;

            if (specialAttack.VO == null)
            {
                logger.Error("SpawnProjectile: specialAttack.VO is null");
                this.SendSpecialAttackFired(specialAttack.VO);
                return;
            }
            float num      = specialAttack.VO.NumberOfAttackers;
            int   quantity = (int)((float)specialAttack.VO.Damage / num);

            specialAttack.ApplySpecialAttackBuffs(ref quantity);
            HealthFragment       payload = new HealthFragment(null, HealthType.Damaging, quantity);
            ProjectileController projectileController = Service.ProjectileController;

            if (specialAttack.TargetShield != null && !specialAttack.VO.ProjectileType.PassThroughShield)
            {
                Entity shieldBorderEntity = specialAttack.TargetShield.ShieldBorderEntity;
                if (shieldBorderEntity == null)
                {
                    logger.Error("SpawnProjectile: shieldTarget is null");
                    this.SendSpecialAttackFired(specialAttack.VO);
                    return;
                }
                Vector3 targetWorldPos = specialAttack.TargetWorldPos;
                Vector3 targetWorldLoc = Vector3.zero;
                if (!Service.ShieldController.GetRayShieldIntersection(position, specialAttack.TargetWorldPos, specialAttack.TargetShield, out targetWorldLoc))
                {
                    targetWorldLoc = targetWorldPos;
                }
                Target target      = Target.CreateTargetWithWorldLocation((SmartEntity)shieldBorderEntity, targetWorldLoc);
                int    spawnBoardX = Units.WorldToBoardX((float)((int)position.x));
                int    spawnBoardZ = Units.WorldToBoardZ((float)((int)position.z));
                projectileController.SpawnProjectileForTarget(specialAttack.VO.HitDelay, spawnBoardX, spawnBoardZ, position, target, payload, specialAttack.TeamType, null, specialAttack.VO.ProjectileType, false, specialAttack.SpecialAttackBuffs, specialAttack.VO.Faction, null);
                this.AddProjectileInFlight(specialAttack.VO.ProjectileType);
            }
            else
            {
                Bullet bullet = projectileController.SpawnProjectileForTargetPosition(specialAttack.VO.HitDelay, position, specialAttack.TargetBoardX, specialAttack.TargetBoardZ, payload, specialAttack.TeamType, null, specialAttack.VO.ProjectileType, specialAttack.SpecialAttackBuffs, specialAttack.VO.Faction, specialAttack.VO.HasDropoff);
                if (specialAttack.VO.HasDropoff)
                {
                    bullet.Cookie = specialAttack;
                    ProjectileView projectileView = Service.ProjectileViewManager.SpawnProjectile(bullet);
                    Transform      transform      = projectileView.GetTransform();
                    this.AttachGameObject(transform, specialAttack.StarshipDetachableGameObject, false);
                    specialAttack.UpdateDetachableShadowAnimator(SpecialAttackDetachableObjectState.Falling);
                }
                this.AddProjectileInFlight(specialAttack.VO.ProjectileType);
            }
            this.SendSpecialAttackFired(specialAttack.VO);
        }