public GuidedMissileLauncher(WeaponTargeting weapon) { m_weaponTarget = weapon; m_relayPart = RelayClient.GetOrCreateRelayPart(m_weaponTarget.CubeBlock); this._initialTarget = NoTarget.Instance; MyWeaponBlockDefinition defn = (MyWeaponBlockDefinition)CubeBlock.GetCubeBlockDefinition(); Vector3[] points = new Vector3[3]; Vector3 forwardAdjust = Vector3.Forward * WeaponDescription.GetFor(CubeBlock).MissileSpawnForward; points[0] = CubeBlock.LocalAABB.Min + forwardAdjust; points[1] = CubeBlock.LocalAABB.Max + forwardAdjust; points[2] = CubeBlock.LocalAABB.Min + Vector3.Up * defn.Size.Y * CubeBlock.CubeGrid.GridSize + forwardAdjust; MissileSpawnBox = BoundingBox.CreateFromPoints(points); if (m_weaponTarget.myTurret != null) { Log.TraceLog("original box: " + MissileSpawnBox); MissileSpawnBox.Inflate(CubeBlock.CubeGrid.GridSize * 2f); } Log.TraceLog("MissileSpawnBox: " + MissileSpawnBox); myInventory = ((MyEntity)CubeBlock).GetInventoryBase(0); Registrar.Add(weapon.CubeBlock, this); m_weaponTarget.GuidedLauncher = true; m_gameCooldownTime = TimeSpan.FromSeconds(60d / MyDefinitionManager.Static.GetWeaponDefinition(defn.WeaponDefinitionId).WeaponAmmoDatas[(int)MyAmmoType.Missile].RateOfFire); Log.TraceLog("m_gameCooldownTime: " + m_gameCooldownTime); CubeBlock.AppendingCustomInfo += CubeBlock_AppendingCustomInfo; }
public Turret(IMyCubeBlock block) : base(block) { // definition limits MyLargeTurretBaseDefinition definition = CubeBlock.GetCubeBlockDefinition() as MyLargeTurretBaseDefinition; if (definition == null) { throw new NullReferenceException("definition"); } minElevation = Math.Max(MathHelper.ToRadians(definition.MinElevationDegrees), -0.6f); maxElevation = MathHelper.ToRadians(definition.MaxElevationDegrees); minAzimuth = MathHelper.ToRadians(definition.MinAzimuthDegrees); maxAzimuth = MathHelper.ToRadians(definition.MaxAzimuthDegrees); Can360 = Math.Abs(definition.MaxAzimuthDegrees - definition.MinAzimuthDegrees) >= 360; // speeds are in rads per ms (from S.E. source) speedElevation = definition.ElevationSpeed * 100f / 6f; speedAzimuth = definition.RotationSpeed * 100f / 6f; setElevation = myTurret.Elevation; setAzimuth = myTurret.Azimuth; // subparts for turrets form a chain var subparts = ((MyCubeBlock)CubeBlock).Subparts; while (subparts.Count != 0) { m_barrel = subparts.FirstPair().Value; subparts = m_barrel.Subparts; } //Log.DebugLog("definition limits = " + definition.MinElevationDegrees + ", " + definition.MaxElevationDegrees + ", " + definition.MinAzimuthDegrees + ", " + definition.MaxAzimuthDegrees, "Turret()"); //Log.DebugLog("radian limits = " + minElevation + ", " + maxElevation + ", " + minAzimuth + ", " + maxAzimuth, "Turret()"); }