public StaticWeaponProfile(IMyRemoteControl remoteControl, IMyTerminalBlock block) : base(remoteControl, block) { _staticWeaponBlock = block as IMyUserControllableGun; IsStatic = true; if (_staticWeaponBlock != null) { _gunBase = (IMyGunObject <MyGunBase>)_staticWeaponBlock; } else { _weaponValid = false; } if (!_weaponValid) { return; } if (_remoteControl.WorldMatrix.Forward == _staticWeaponBlock.WorldMatrix.Forward) { _isForwardFacingWeapon = true; } GetWeaponDefinition(_staticWeaponBlock); }
void Shoot(IMyUserControllableGun gun, bool b) { if (b) { gun.ApplyAction("Shoot_On"); } else { gun.ApplyAction("Shoot_Off"); } }
public RegularWeapon(IMyTerminalBlock block, IMyRemoteControl remoteControl, IBehavior behavior) : base(block, remoteControl, behavior) { if (!_isValid) { return; } GetWeaponDefinition(_block); if (_weaponDefinition == null) { Logger.MsgDebug(_block.CustomName + " Weapon Definition Not Found", DebugTypeEnum.WeaponSetup); _isValid = false; return; } foreach (var ammoData in _weaponDefinition.WeaponAmmoDatas) { if (ammoData == null) { continue; } if (ammoData.RateOfFire > 0) { _rateOfFire = ammoData.RateOfFire; } } if (_block as IMyLargeTurretBase != null) { _isTurret = true; _turret = _block as IMyLargeTurretBase; _gunBase = _turret as IMyGunObject <MyGunBase>; } else if (_block as IMyUserControllableGun != null) { _isStatic = true; _staticGun = _block as IMyUserControllableGun; _gunBase = _staticGun as IMyGunObject <MyGunBase>; } else { Logger.MsgDebug(_block.CustomName + " Is Neither Gun Or Turret?", DebugTypeEnum.WeaponSetup); _isValid = false; return; } //Get Rate of Fire //Determine If Barrage Capable }
public TargetingBase(IMyEntity entity, IMyCubeBlock controllingBlock) { if (entity == null) { throw new ArgumentNullException("entity"); } if (controllingBlock == null) { throw new ArgumentNullException("controllingBlock"); } MyEntity = entity; CubeBlock = (IMyUserControllableGun)controllingBlock; myTarget = NoTarget.Instance; CurrentTarget = myTarget; Options = new TargetingOptions(); entity.OnClose += Entity_OnClose; //Log.DebugLog("entity: " + MyEntity.getBestName() + ", block: " + CubeBlock.getBestName(), "TargetingBase()"); }
public Missile( List <IMyGyro> gyros, List <IMyThrust> thrusters, IMyShipMergeBlock mergeBlock = null, IMyUserControllableGun gun = null, List <IMyWarhead> warheads = null, IMyTimerBlock customP = null, IMySensorBlock sensor = null) { // Initialize _gyros = gyros; _thrusters = thrusters; _mergeBlock = mergeBlock; _gun = gun; _warheads = warheads; _customP = customP; _sensor = sensor; // Check if the missile is valid if (_gyros == null) { Error |= MissileError.MissingGyros; } if (_thrusters == null) { Error |= MissileError.MissingThrust; } if (_mergeBlock == null && gun == null && _warheads == null) { Error |= MissileError.MissingDetach; } if (Error != MissileError.None) { Error ^= MissileError.None; return; } }
void SetRange(IMyUserControllableGun gun, float range) { gun.SetValueFloat("Range", range); }
float GetRange(IMyUserControllableGun gun) { return(gun.GetValueFloat("Range")); }
private static bool IsAGun(IMyUserControllableGun gun) { return(gun is IMySmallGatlingGun || gun is IMyLargeGatlingTurret || gun is IMyLargeInteriorTurret); }
private static bool IsAGun(IMyUserControllableGun gun) { return gun is IMySmallGatlingGun || gun is IMyLargeGatlingTurret || gun is IMyLargeInteriorTurret; }
public void SequenceWeapons() { //GetBlocks(); EchoBuilder.Clear(); if (_weapons.Count == 0) { Echo("----------------------------------\n ERROR: No weapons in group '" + ThisGroup.Name + "' were found."); return; } if (_weapons[0].CubeGrid.GridSizeEnum == MyCubeSize.Large) { _defaultRateOfFire = 2; } else { _defaultRateOfFire = 1; } //Checks for divide by zero if (_delay == 0) { _delay = 1; //stops divide by zero _desiredRPM = 3600.0 / _delay; } //Sets default rate of fire if (!_manualOverride) { var delayUnrounded = 60.0 / (double)_weapons.Count / (double)_defaultRateOfFire; //set _delay between weapons _delay = (int)Math.Ceiling(delayUnrounded); _desiredRPM = 3600.0 / _delay; } //Checks if guns are being fired if (!_isShooting) { foreach (IMyUserControllableGun thisWeapon in _weapons) //need to track if bool has been reset { if (thisWeapon.IsShooting && thisWeapon.Enabled) { _isShooting = true; break; } } } //===SEQUENCER HANDLING=== if (_timeCount >= _delay) { if (!_limitReached) { ////===RESETTING ALL WEAPON STATES=== foreach (var thisWeapon in _weapons) { thisWeapon.Enabled = false; } //===ACTIVATING SPECIFIED WEAPON=== if (_weaponCount >= _weapons.Count) { _weaponCount = 0; //incase something gets broken } weaponToFire = _weapons[_weaponCount]; weaponToFire.Enabled = true; _limitReached = true; } else { if (weaponToFire.Enabled == false) { weaponToFire.Enabled = true; } } if (_isShooting) { if (_weaponCount + 1 < _weapons.Count) { _weaponCount++; //counts once per _delay } else { _weaponCount = 0; } _timeCount = 0; //start count over _isShooting = false; weaponToFire.Enabled = false; _limitReached = false; if (_burstCount > 1 && _shouldBurst) { _burstCount--; } else if (_shouldBurst) { _shouldBurst = false; _executeToggle = false; _burstCount = 0; //has to be bigger than 0 } } if (_executeToggle) { weaponToFire.ApplyAction("ShootOnce"); //there is no interface method for this :( _messageToggle = ">>Toggle Fire Enabled<<"; } else { _messageToggle = "<<Toggle Fire Disabled>>"; } } else { _timeCount++; //continues to count until _delay is hit } if (_manualOverride) { _messageOverride = ">>Defaults Overriden<<"; } else { _messageOverride = "<<Defaults Applied>>"; } //Debug string output = $"----------------------------------\nInfo for '{ThisGroup.Name}' \n{_messageToggle}\n{_messageOverride}\nNo. Weapons: {_weapons.Count}\nRate of Fire: {_desiredRPM} -> {3600.0 / (double)_delay:N1} RPM\nDelay: {_delay} ticks\nCurrent Time: {_timeCount}\nWeapon Count: {_weaponCount}\nIsShooting: {_isShooting}\nBurst Count: {_burstCount}"; Echo(output); }