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; }
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; }
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; }
private void ShootFailedLocal(MyShootActionEnum action, MyGunStatusEnum status) { }
private void ShootFailedLocal(MyShootActionEnum action, MyGunStatusEnum status) { if (status == MyGunStatusEnum.OutOfAmmo) { ShowOutOfAmmoNotification(); } m_currentWeapon.ShootFailReactionLocal(action, status); }
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; } }
public void ShootFailReactionLocal(MyShootActionEnum action, MyGunStatusEnum status) { }
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; }
public virtual void BeginFailReaction(MyShootActionEnum action, MyGunStatusEnum status) { }
public virtual bool CanShoot(out MyGunStatusEnum status) { status = MyGunStatusEnum.OK; return(true); }
public abstract bool CanShoot(MyShootActionEnum action, long shooter, out MyGunStatusEnum status);
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); }
private void ShootBeginFailed(MyShootActionEnum action, MyGunStatusEnum status) { }
public override void BeginFailReaction(MyShootActionEnum action, MyGunStatusEnum status) { base.BeginFailReaction(action, status); m_soundEmitter.PlaySingleSound(weldSoundIdle, true, true); FillStockpile(); }
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; } }
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; }
public void BeginFailReaction(MyShootActionEnum action, MyGunStatusEnum status) { if (status == MyGunStatusEnum.OutOfAmmo && !MySession.Static.CreativeMode) m_gunBase.StartNoAmmoSound(m_soundEmitter); }
private void ShootBeginFailed(MyShootActionEnum action, MyGunStatusEnum status, IMyGunObject<MyDeviceBase> failedGun) { failedGun.BeginFailReaction(action, status); }
public virtual bool CanShoot(out MyGunStatusEnum status) { status = MyGunStatusEnum.OK; return true; }
private void ShootBeginFailed(MyShootActionEnum action, MyGunStatusEnum status) { m_currentWeapon.BeginFailReaction(action, status); if (MySession.Static.ControlledEntity == this) { m_currentWeapon.BeginFailReactionLocal(action, status); } }
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); }