コード例 #1
0
        public override bool CanShoot(MyShootActionEnum action, long shooter, out MyGunStatusEnum status)
        {
            bool retval = base.CanShoot(action, shooter, out status);

            // No need for cooldown for the first shot
            if (status == MyGunStatusEnum.Cooldown && action == MyShootActionEnum.PrimaryAction && m_firstShot == true)
            {
                status = MyGunStatusEnum.OK;
                retval = true;
            }

            return retval;
        }
コード例 #2
0
ファイル: MyWelder.cs プロジェクト: Chrus/SpaceEngineers
        public override bool CanShoot(MyShootActionEnum action, long shooter, out MyGunStatusEnum status)
        {
            if (action == MyShootActionEnum.SecondaryAction)
            {
				status = MyGunStatusEnum.OK;
                return true;
            }

            if (!base.CanShoot(action, shooter, out status))
            {
                return false;
            }


            status = MyGunStatusEnum.OK;
            var block = GetTargetBlock();
            if (block == null)
            {
                var info = FindProjectedBlock();
                if (info.raycastResult == BuildCheckResult.OK)
                {
                    return true;
                }

                status = MyGunStatusEnum.Failed;
                return false;
            }

            Debug.Assert(Owner is MyCharacter, "Only character can use welder!");
            if (Owner == null)
            {
                status = MyGunStatusEnum.Failed;
                return false;
            }

            if (MySession.Static.CreativeMode && (!block.IsFullIntegrity || block.HasDeformation))
            {
                return true;
            }

            if (block.IsFullIntegrity && block.HasDeformation)
            {
                return true;
            }

            {
                var info = FindProjectedBlock();
                if (info.raycastResult == BuildCheckResult.OK)
                {
                    return true;
                }
            }

            MyCharacter character = Owner as MyCharacter;
            System.Diagnostics.Debug.Assert(character.GetInventory() as MyInventory != null, "Null or unexpected inventory type returned!");
            if (!block.CanContinueBuild(character.GetInventory() as MyInventory))
            {
                status = MyGunStatusEnum.Failed;
                if (!block.IsFullIntegrity)
                    if (Owner != null && Owner == MySession.Static.LocalCharacter)
                        BeginFailReactionLocal(0, 0);
                return false;
            }

            return true;
        }
コード例 #3
0
        internal bool CanShoot(MyShootActionEnum action, out MyGunStatusEnum status, out IMyGunObject<MyDeviceBase> FailedGun)
        {
            FailedGun = null;
            if (m_currentGuns == null)
            {
                status = MyGunStatusEnum.NotSelected;
                return false;
            }

            bool result = false;
            status = MyGunStatusEnum.OK;

            // Report only one weapon status; Return true if any of the weapons can shoot
            foreach (var weapon in m_currentGuns)
            {
                MyGunStatusEnum weaponStatus;
                result |= weapon.CanShoot(action, m_shipController.ControllerInfo.Controller != null ? m_shipController.ControllerInfo.Controller.Player.Identity.IdentityId : m_shipController.OwnerId, out weaponStatus);
                // mw:TODO maybe autoswitch when gun has no ammo?
                //if (weaponStatus == MyGunStatusEnum.OutOfAmmo)
                //{
                //    if (weapon.GunBase.SwitchAmmoMagazineToFirstAvailable())
                //    {
                //        weaponStatus = MyGunStatusEnum.OK;
                //        result = true;
                //    }
                //}
                if (weaponStatus != MyGunStatusEnum.OK)
                {
                    FailedGun = weapon;
                    status = weaponStatus;
                }
            }

            return result;
        }
コード例 #4
0
 private void ShootFailedLocal(MyShootActionEnum action, MyGunStatusEnum status)
 {
 }
コード例 #5
0
        private void ShootFailedLocal(MyShootActionEnum action, MyGunStatusEnum status)
        {
            if (status == MyGunStatusEnum.OutOfAmmo)
            {
                ShowOutOfAmmoNotification();
            }

            m_currentWeapon.ShootFailReactionLocal(action, status);
        }
コード例 #6
0
        private void ShowShootNotification(MyGunStatusEnum status, IMyGunObject<MyDeviceBase> weapon)
        {
            if (!ControllerInfo.IsLocallyHumanControlled())
                return;

            switch (status)
            {
                case MyGunStatusEnum.NotSelected:
                    if (m_noWeaponNotification == null)
                    {
                        m_noWeaponNotification = new MyHudNotification(MySpaceTexts.NotificationNoWeaponSelected, 2000, font: MyFontEnum.Red);
                        MyHud.Notifications.Add(m_noWeaponNotification);
                    }

                    MyHud.Notifications.Add(m_noWeaponNotification);
                    break;
                case MyGunStatusEnum.OutOfAmmo:
                    if (m_outOfAmmoNotification == null)
                    {
                        m_outOfAmmoNotification = new MyHudNotification(MySpaceTexts.OutOfAmmo, 2000, font: MyFontEnum.Red);
                    }

                    if (weapon is MyCubeBlock)
                        m_outOfAmmoNotification.SetTextFormatArguments((weapon as MyCubeBlock).DisplayNameText);

                    MyHud.Notifications.Add(m_outOfAmmoNotification);
                    break;
                case MyGunStatusEnum.NotFunctional:
                case MyGunStatusEnum.OutOfPower:
                    if (m_weaponNotWorkingNotification == null)
                    {
                        m_weaponNotWorkingNotification = new MyHudNotification(MySpaceTexts.NotificationWeaponNotWorking, 2000, font: MyFontEnum.Red);
                    }

                    if (weapon is MyCubeBlock)
                        m_weaponNotWorkingNotification.SetTextFormatArguments((weapon as MyCubeBlock).DisplayNameText);

                    MyHud.Notifications.Add(m_weaponNotWorkingNotification);
                    break;
                default:
                    break;
            }
        }
コード例 #7
0
 public void ShootFailReactionLocal(MyShootActionEnum action, MyGunStatusEnum status)
 { }
コード例 #8
0
        public override bool CanShoot(MyShootActionEnum action, long shooter, out MyGunStatusEnum status)
        {
            status = MyGunStatusEnum.OK;
            if (action != MyShootActionEnum.PrimaryAction)
            {
                status = MyGunStatusEnum.Failed;
                return false;
            }

            if (!m_gunBase.HasAmmoMagazines)
            {
                status = MyGunStatusEnum.Failed;
                return false;
            }

            if ((MySandboxGame.TotalGamePlayTimeInMilliseconds - m_lastTimeShoot) < m_gunBase.ShootIntervalInMiliseconds / (CubeGrid.GridSizeEnum == MyCubeSize.Small ? 1 : 4))
            {
                status = MyGunStatusEnum.Cooldown;
                return false;
            }

            if (!HasPlayerAccess(shooter))
            {
                status = MyGunStatusEnum.AccessDenied;
                return false;
            }
            if (!PowerReceiver.IsPowered)
            {
                status = MyGunStatusEnum.OutOfPower;
                return false;
            }
            if (!IsFunctional)
            {
                status = MyGunStatusEnum.NotFunctional;
                return false;
            }
            if (!Enabled)
            {
                status = MyGunStatusEnum.Disabled;
                return false;
            }
            if (!MySession.Static.CreativeMode && !m_gunBase.HasEnoughAmmunition())
            {
                status = MyGunStatusEnum.OutOfAmmo;
                return false;
            }
            return true;
        }
コード例 #9
0
 public virtual void BeginFailReaction(MyShootActionEnum action, MyGunStatusEnum status)
 {
 }
コード例 #10
0
 public virtual bool CanShoot(out MyGunStatusEnum status)
 {
     status = MyGunStatusEnum.OK;
     return(true);
 }
コード例 #11
0
 public abstract bool CanShoot(MyShootActionEnum action, long shooter, out MyGunStatusEnum status);
コード例 #12
0
 public void ShootFailReactionLocal(MyShootActionEnum action, MyGunStatusEnum status)
 {
 }
コード例 #13
0
        public override bool CanShoot(MyShootActionEnum action, long shooter, out MyGunStatusEnum status)
        {
            if (!base.CanShoot(action, shooter, out status))
            {
                return(false);
            }

            if (action == MyShootActionEnum.SecondaryAction)
            {
                return(true);
            }


            status = MyGunStatusEnum.OK;
            var block = GetTargetBlock();

            if (block == null)
            {
                var info = FindProjectedBlock();
                if (info.raycastResult == MyProjector.BuildCheckResult.OK)
                {
                    return(true);
                }

                status = MyGunStatusEnum.Failed;
                return(false);
            }

            Debug.Assert(Owner is MyCharacter, "Only character can use welder!");
            if (Owner == null)
            {
                status = MyGunStatusEnum.Failed;
                return(false);
            }

            if (MySession.Static.CreativeMode && (!block.IsFullIntegrity || block.HasDeformation))
            {
                return(true);
            }

            if (block.IsFullIntegrity && block.HasDeformation)
            {
                return(true);
            }

            {
                var info = FindProjectedBlock();
                if (info.raycastResult == MyProjector.BuildCheckResult.OK)
                {
                    return(true);
                }
            }

            MyCharacter character = Owner as MyCharacter;

            if (!block.CanContinueBuild(character.GetInventory()))
            {
                status = MyGunStatusEnum.Failed;
                return(false);
            }

            return(true);
        }
コード例 #14
0
 private void ShootBeginFailed(MyShootActionEnum action, MyGunStatusEnum status)
 {
 }
コード例 #15
0
ファイル: MyWelder.cs プロジェクト: Chrus/SpaceEngineers
        public override void BeginFailReaction(MyShootActionEnum action, MyGunStatusEnum status)
        {
            base.BeginFailReaction(action, status);

            m_soundEmitter.PlaySingleSound(weldSoundIdle, true, true);

            FillStockpile();
        }
コード例 #16
0
ファイル: MyWelder.cs プロジェクト: Chrus/SpaceEngineers
        public override void BeginFailReactionLocal(MyShootActionEnum action, MyGunStatusEnum status)
        {
            var block = GetTargetBlock();

            if (block != m_failedBlock)
            {
                UnmarkMissingComponent();
                MyHud.Notifications.Remove(m_missingComponentNotification);
            }

            m_failedBlock = block;

            if (block == null)
                return;

            if (block.IsFullIntegrity)
                return;

            int missingGroupIndex, missingGroupAmount;
            block.ComponentStack.GetMissingInfo(out missingGroupIndex, out missingGroupAmount);

            var missingGroup = block.ComponentStack.GetGroupInfo(missingGroupIndex);
            MarkMissingComponent(missingGroupIndex);
            m_missingComponentNotification.SetTextFormatArguments(
                string.Format("{0} ({1}x)", missingGroup.Component.DisplayNameText, missingGroupAmount),
                block.BlockDefinition.DisplayNameText.ToString());
            MyHud.Notifications.Add(m_missingComponentNotification);
            if ((m_playedFailSound && m_failedBlockSound != block) || m_playedFailSound == false)
            {
                MyGuiAudio.PlaySound(MyGuiSounds.HudUnable);
                m_playedFailSound = true;
                m_failedBlockSound = block;
            }
        }
コード例 #17
0
ファイル: MyWelder.cs プロジェクト: martejj/SpaceEngineers
        public override bool CanShoot(MyShootActionEnum action, long shooter, out MyGunStatusEnum status)
        {
            if (!base.CanShoot(action, shooter, out status))
            {
                return false;
            }

            if (action == MyShootActionEnum.SecondaryAction)
            {
                return true;
            }


            status = MyGunStatusEnum.OK;
            var block = GetTargetBlock();
            if (block == null)
            {
                var info = FindProjectedBlock();
                if (info.raycastResult == MyProjector.BuildCheckResult.OK)
                {
                    return true;
                }

                status = MyGunStatusEnum.Failed;
                return false;
            }

            Debug.Assert(Owner is MyCharacter, "Only character can use welder!");
            if (Owner == null)
            {
                status = MyGunStatusEnum.Failed;
                return false;
            }

            if (MySession.Static.CreativeMode && (!block.IsFullIntegrity || block.HasDeformation))
            {
                return true;
            }

            if (block.IsFullIntegrity && block.HasDeformation)
            {
                return true;
            }

            {
                var info = FindProjectedBlock();
                if (info.raycastResult == MyProjector.BuildCheckResult.OK)
                {
                    return true;
                }
            }

            MyCharacter character = Owner as MyCharacter;
            if (!block.CanContinueBuild(character.GetInventory()))
            {
                status = MyGunStatusEnum.Failed;
                return false;
            }

            return true;
        }
コード例 #18
0
 public void BeginFailReaction(MyShootActionEnum action, MyGunStatusEnum status)
 {
     if (status == MyGunStatusEnum.OutOfAmmo && !MySession.Static.CreativeMode)
         m_gunBase.StartNoAmmoSound(m_soundEmitter);
 }
コード例 #19
0
        private void ShootFailedLocal(MyShootActionEnum action, MyGunStatusEnum status)
        {

        }
コード例 #20
0
        private void ShootBeginFailed(MyShootActionEnum action, MyGunStatusEnum status)
        {

        }
コード例 #21
0
 public abstract bool CanShoot(MyShootActionEnum action, long shooter, out MyGunStatusEnum status);
コード例 #22
0
 private void ShootBeginFailed(MyShootActionEnum action, MyGunStatusEnum status, IMyGunObject<MyDeviceBase> failedGun)
 {
     failedGun.BeginFailReaction(action, status);
 }
コード例 #23
0
 public virtual bool CanShoot(out MyGunStatusEnum status)
 {
     status = MyGunStatusEnum.OK;
     return true;
 }
コード例 #24
0
        private void ShootBeginFailed(MyShootActionEnum action, MyGunStatusEnum status)
        {
            m_currentWeapon.BeginFailReaction(action, status);

            if (MySession.Static.ControlledEntity == this)
            {
                m_currentWeapon.BeginFailReactionLocal(action, status);
            }
        }
コード例 #25
0
        public override bool CanShoot(MyShootActionEnum action, long shooter, out MyGunStatusEnum status)
        {
            //if (action == MyShootActionEnum.SecondaryAction)
            //{
            //    status = MyGunStatusEnum.OK;
            //    return true;
            //}

            if (!base.CanShoot(action, shooter, out status))
            {
                return(false);
            }


            status = MyGunStatusEnum.OK;
            var block = GetTargetBlock();

            if (block == null)
            {
                var info = FindProjectedBlock();
                if (info.raycastResult == BuildCheckResult.OK)
                {
                    return(true);
                }

                status = MyGunStatusEnum.Failed;
                return(false);
            }

            Debug.Assert(Owner is MyCharacter, "Only character can use welder!");
            if (Owner == null)
            {
                status = MyGunStatusEnum.Failed;
                return(false);
            }

            if (MySession.Static.CreativeMode && (!block.IsFullIntegrity || block.HasDeformation))
            {
                return(true);
            }

            if (block.IsFullIntegrity && block.HasDeformation)
            {
                return(true);
            }

            {
                var info = FindProjectedBlock();
                if (info.raycastResult == BuildCheckResult.OK)
                {
                    return(true);
                }
            }

            MyCharacter character = Owner as MyCharacter;

            System.Diagnostics.Debug.Assert(character.GetInventory() as MyInventory != null, "Null or unexpected inventory type returned!");
            if (!block.CanContinueBuild(character.GetInventory() as MyInventory))
            {
                status = MyGunStatusEnum.Failed;
                if (!block.IsFullIntegrity)
                {
                    if (Owner != null && Owner == MySession.Static.LocalCharacter)
                    {
                        BeginFailReactionLocal(0, 0);
                    }
                }
                return(false);
            }

            return(true);
        }