public DimensionalPrison(Vector2 Position) { this.p1 = Position + new Vector2(0f, -400f); this.p2 = Position + new Vector2(-400f, 400f); this.p3 = Position + new Vector2(400f, 400f); this.s1 = ResourceManager.CreateShipAtPoint(this.PlatformName, EmpireManager.GetEmpireByName("Unknown"), this.p1); this.s2 = ResourceManager.CreateShipAtPoint(this.PlatformName, EmpireManager.GetEmpireByName("Unknown"), this.p2); this.s3 = ResourceManager.CreateShipAtPoint(this.PlatformName, EmpireManager.GetEmpireByName("Unknown"), this.p3); this.Position = Position; Rectangle r = new Rectangle((int)Position.X - 200, (int)Position.Y - 200, 400, 400); this.Prison = new BackgroundItem(); this.Prison.LoadContent(Anomaly.screen.ScreenManager, Anomaly.screen.view, Anomaly.screen.projection); this.Prison.UpperLeft = new Vector3((float)r.X, (float)r.Y, 0f); this.Prison.LowerLeft = this.Prison.UpperLeft + new Vector3(0f, (float)r.Height, 0f); this.Prison.UpperRight = this.Prison.UpperLeft + new Vector3((float)r.Width, 0f, 0f); this.Prison.LowerRight = this.Prison.UpperLeft + new Vector3((float)r.Width, (float)r.Height, 0f); this.Prison.Texture = ResourceManager.TextureDict["Textures/star_neutron"]; this.Prison.FillVertices(); this.b1 = new Beam(this.p1, Position, 50, this.s1) { weapon = ResourceManager.WeaponsDict["AncientRepulsor"] }; this.b1.LoadContent(Anomaly.screen.ScreenManager, Anomaly.screen.view, Anomaly.screen.projection); this.s1.Beams.Add(this.b1); this.b1.infinite = true; this.b1.range = 2500f; this.b1.thickness = 75; this.b1.PowerCost = 0f; this.b1.damageAmount = 0f; this.b2 = new Beam(this.p2, Position, 50, this.s2) { weapon = ResourceManager.WeaponsDict["AncientRepulsor"] }; this.b2.LoadContent(Anomaly.screen.ScreenManager, Anomaly.screen.view, Anomaly.screen.projection); this.b2.infinite = true; this.s2.Beams.Add(this.b2); this.b2.range = 2500f; this.b2.thickness = 75; this.b2.PowerCost = 0f; this.b2.damageAmount = 0f; this.b3 = new Beam(this.p3, Position, 50, this.s3) { weapon = ResourceManager.WeaponsDict["AncientRepulsor"] }; this.b3.LoadContent(Anomaly.screen.ScreenManager, Anomaly.screen.view, Anomaly.screen.projection); this.b3.infinite = true; this.s3.Beams.Add(this.b3); this.b3.range = 2500f; this.b3.thickness = 75; this.b3.PowerCost = 0f; this.b3.damageAmount = 0f; }
protected virtual void CreateMouseBeam(Vector2 destination) { Beam beam = new Beam(this.moduleAttachedTo.Center, destination, this.BeamThickness, this.moduleAttachedTo.GetParent()) { moduleAttachedTo = this.moduleAttachedTo, range = this.Range, followMouse = true, thickness = this.BeamThickness, Duration = (float)this.BeamDuration > 0 ? this.BeamDuration : 2f, PowerCost = (float)this.BeamPowerCostPerSecond, damageAmount = this.DamageAmount, weapon = this }; beam.LoadContent(Weapon.universeScreen.ScreenManager, Weapon.universeScreen.view, Weapon.universeScreen.projection); if (beam == null || !beam.Active) { beam.Die(null, true); return; } this.moduleAttachedTo.GetParent().Beams.Add(beam); this.ToggleSoundOn = false; if ((this.owner.GetSystem() != null && this.owner.GetSystem().isVisible || this.owner.isInDeepSpace) && Weapon.universeScreen.viewState <= UniverseScreen.UnivScreenState.SystemView) { //Added by McShooterz: Use sounds from new sound dictionary if (ResourceManager.SoundEffectDict.ContainsKey(this.fireCueName)) { AudioManager.PlaySoundEffect(ResourceManager.SoundEffectDict[fireCueName], Weapon.audioListener, this.owner.emitter, 0.5f); } else { if (!string.IsNullOrEmpty(this.fireCueName)) { this.fireCue = AudioManager.GetCue(this.fireCueName); if (!this.owner.isPlayerShip()) { this.fireCue.Apply3D(Weapon.audioListener, this.owner.emitter); } this.fireCue.Play(); } } if (!string.IsNullOrEmpty(this.ToggleSoundName) && !this.ToggleSoundOn) { this.ToggleSoundOn = true; this.ToggleCue = AudioManager.GetCue(this.ToggleSoundName); this.ToggleCue.Apply3D(Weapon.audioListener, this.owner.emitter); this.ToggleCue.Play(); } } }
protected virtual void CreateDroneBeam(Vector2 destination, GameplayObject target, DroneAI source) { if (source == null) return; Beam beam = new Beam(source.Owner.Center, target.Center, this.BeamThickness, source.Owner, target); beam.moduleAttachedTo = this.moduleAttachedTo; beam.PowerCost = (float)this.BeamPowerCostPerSecond; beam.range = this.Range; beam.thickness = this.BeamThickness; beam.Duration = (float)this.BeamDuration > 0 ? this.BeamDuration : 2f; beam.damageAmount = this.DamageAmount; beam.weapon = this; if(!beam.LoadContent(Weapon.universeScreen.ScreenManager, Weapon.universeScreen.view, Weapon.universeScreen.projection)) { beam.Die(null, true); return; } source.Beams.Add(beam); this.ToggleSoundOn = false; if (Weapon.universeScreen.viewState <= UniverseScreen.UnivScreenState.SystemView) { //Added by McShooterz: Use sounds from new sound dictionary if (ResourceManager.SoundEffectDict.ContainsKey(this.fireCueName)) { AudioManager.PlaySoundEffect(ResourceManager.SoundEffectDict[fireCueName], Weapon.audioListener, source.Owner.emitter, 0.5f); } else { if (!string.IsNullOrEmpty(this.fireCueName)) { this.fireCue = AudioManager.GetCue(this.fireCueName); this.fireCue.Apply3D(Weapon.audioListener, source.Owner.emitter); this.fireCue.Play(); } } if (!string.IsNullOrEmpty(this.ToggleSoundName)) { this.ToggleSoundOn = true; this.ToggleCue = AudioManager.GetCue(this.ToggleSoundName); this.ToggleCue.Apply3D(Weapon.audioListener, source.Owner.emitter); this.ToggleCue.Play(); } } }
protected virtual void CreateTargetedBeam(GameplayObject target) { Beam beam; //if (this.owner.Beams.pendingRemovals.TryPop(out beam)) //{ // //beam = new Beam(this.moduleAttachedTo.Center, this.BeamThickness, this.moduleAttachedTo.GetParent(), target); // beam.BeamRecreate(this.moduleAttachedTo.Center, this.BeamThickness, this.moduleAttachedTo.GetParent(), target); // beam.moduleAttachedTo = this.moduleAttachedTo; // beam.PowerCost = (float)this.BeamPowerCostPerSecond; // beam.range = this.Range; // beam.thickness = this.BeamThickness; // beam.Duration = (float)this.BeamDuration > 0 ? this.BeamDuration : 2f; // beam.damageAmount = this.DamageAmount; // beam.weapon = this; //} //else { beam = new Beam(this.moduleAttachedTo.Center, this.BeamThickness, this.moduleAttachedTo.GetParent(), target) { moduleAttachedTo = this.moduleAttachedTo, PowerCost = (float)this.BeamPowerCostPerSecond, range = this.Range, thickness = this.BeamThickness, Duration = (float)this.BeamDuration > 0 ? this.BeamDuration : 2f, damageAmount = this.DamageAmount, weapon = this, Destination=target.Center }; } //damage increase by level if (this.owner.Level > 0) { beam.damageAmount += beam.damageAmount * (float)this.owner.Level * 0.05f; } //Hull bonus damage increase if (GlobalStats.ActiveModInfo != null && GlobalStats.ActiveModInfo.useHullBonuses) { HullBonus mod; if (ResourceManager.HullBonuses.TryGetValue(this.owner.shipData.Hull, out mod)) beam.damageAmount += beam.damageAmount * mod.DamageBonus; } this.ModifyProjectile(beam); if ( !beam.LoadContent(Weapon.universeScreen.ScreenManager, Weapon.universeScreen.view, Weapon.universeScreen.projection)) { beam.Die(null, true); return; } this.moduleAttachedTo.GetParent().Beams.Add(beam); this.ToggleSoundOn = false; if (Weapon.universeScreen.viewState <= UniverseScreen.UnivScreenState.SystemView && this.moduleAttachedTo.GetParent().InFrustum) { //Added by McShooterz: Use sounds from new sound dictionary SoundEffect beamsound = null; if (ResourceManager.SoundEffectDict.TryGetValue(this.fireCueName,out beamsound)) { AudioManager.PlaySoundEffect(beamsound, Weapon.audioListener, this.owner.emitter, 0.5f); } else { if (!string.IsNullOrEmpty(this.fireCueName)) { this.fireCue = AudioManager.GetCue(this.fireCueName); if (!this.owner.isPlayerShip()) { this.fireCue.Apply3D(Weapon.audioListener, this.owner.emitter); } this.fireCue.Play(); } } if (!string.IsNullOrEmpty(this.ToggleSoundName)) { this.ToggleSoundOn = true; this.ToggleCue = AudioManager.GetCue(this.ToggleSoundName); this.ToggleCue.Apply3D(Weapon.audioListener, this.owner.emitter); this.ToggleCue.Play(); } } }
private void CollideBeam(Beam beam) { this.collisionResults.Clear(); beam.CollidedThisFrame = false; Vector2 vector2_1 = Vector2.Normalize(beam.Destination - beam.Source); float num1 = Vector2.Distance(beam.Destination, beam.Source); if ((double)num1 > (double)beam.range + 10.0) return; List<Vector2> list1 = new List<Vector2>(); beam.ActualHitDestination = beam.Destination; for (int index = 0; (double)(index * 75) < (double)num1; ++index) list1.Add(beam.Source + vector2_1 * (float)index * 75f); Ship ship1 = (Ship)null; Vector2 vector2_2 = Vector2.Zero; GameplayObject gameplayObject1 = (GameplayObject)null; //How repair beams repair modules if (beam.GetTarget() != null) { if (beam.GetTarget() is Ship) { Ship ship2 = beam.GetTarget() as Ship; ship2.MoveModulesTimer = 2f; Vector2 vector2_3 = beam.GetTarget().Center; beam.ActualHitDestination = beam.GetTarget().Center; if ((double)beam.damageAmount >= 0.0) { //beam.owner.Beams.QueuePendingRemoval(beam); return; } using (LinkedList<ModuleSlot>.Enumerator enumerator = ship2.ModuleSlotList.GetEnumerator()) { while (enumerator.MoveNext()) { ModuleSlot current = enumerator.Current; if ((double)current.module.Health < (double)current.module.HealthMax) { ShipModule module = current.module; double num2 = (double)module.Health - (double)beam.damageAmount; module.Health = (float)num2; if ((double)current.module.Health < (double)current.module.HealthMax) break; current.module.Health = current.module.HealthMax; break; } } return; } } else if (beam.GetTarget() is ShipModule) { gameplayObject1 = (GameplayObject)(beam.GetTarget() as ShipModule).GetParent(); } else if (beam.GetTarget() is Asteroid) gameplayObject1 = beam.GetTarget(); else System.Diagnostics.Debug.WriteLine("beam null"); } else if (beam.Owner != null) gameplayObject1 = (GameplayObject)beam.owner; HashSet<GameplayObject> nearby = new HashSet<GameplayObject>(this.GetNearby(gameplayObject1)); HashSet<GameplayObject> AlliedShips = new HashSet<GameplayObject>(); foreach (Vector2 vector2_3 in list1) { foreach (GameplayObject gameplayObject2 in nearby) { if (gameplayObject2 is Ship) { if ((gameplayObject2 as Ship).loyalty == beam.owner.loyalty) AlliedShips.Add(gameplayObject2); else if (gameplayObject2 != beam.owner || beam.weapon.HitsFriendlies) { ++GlobalStats.BeamTests; if ((double)Vector2.Distance(gameplayObject2.Center, vector2_3) < (double)gameplayObject2.Radius) { ship1 = gameplayObject2 as Ship; ship1.MoveModulesTimer = 2f; vector2_2 = vector2_3; break; } } } } foreach (GameplayObject gameplayObject2 in AlliedShips) nearby.Remove(gameplayObject2); AlliedShips.Clear(); if (ship1 != null) break; } if (ship1 != null) { list1.Clear(); for (int index = 0; (double)(index * 8) < (double)ship1.Radius; ++index) list1.Add(vector2_2 + vector2_1 * (float)index * 8f); bool flag = false; if (beam.hitLast != null && beam.hitLast.Active) { List<ShipModule> list3 = new List<ShipModule>(); list3.Add(beam.hitLast); foreach (ShipModule shipModule in beam.hitLast.LinkedModulesList) list3.Add(shipModule); int num2 = -48; while (num2 < 48) { int num3 = -48; while (num3 < 48) { ModuleSlot test; if (beam.hitLast.GetParent().GetMD().TryGetValue(beam.hitLast.XMLPosition + new Vector2((float)num2, (float)num3), out test)) list3.Add(test.module); //if (beam.hitLast.GetParent().GetMD().ContainsKey(beam.hitLast.XMLPosition + new Vector2((float)num2, (float)num3))) //list3.Add(beam.hitLast.GetParent().GetMD()[beam.hitLast.XMLPosition + new Vector2((float)num2, (float)num3)].module); num3 += 16; } num2 += 16; } foreach (ShipModule shipModule in list3) { if (shipModule != null && shipModule.isExternal) { float num3 = 100000f; foreach (Vector2 vector2_3 in list1) { ++GlobalStats.BeamTests; float num4 = Vector2.Distance(vector2_3, shipModule.Center); if ((double)num4 <= (beam.IgnoresShields ? 16.0 : (double)shipModule.Radius + 8.0)) { ++GlobalStats.BeamTests; this.collisionResults.Add(new SpatialManager.CollisionResult() { Distance = (beam.IgnoresShields ? 16f : shipModule.Radius + 8f), Normal = Vector2.Normalize(Vector2.Zero), GameplayObject = (GameplayObject)shipModule }); beam.ActualHitDestination = vector2_3; flag = true; beam.hitLast = shipModule; break; } else if ((double)num4 <= (double)num3) num3 = num4; else break; } if (flag) break; } } if (!flag) beam.hitLast = (ShipModule)null; list3.Clear(); } if (!flag) { foreach (Vector2 vector2_3 in list1) { if (!beam.IgnoresShields) #region Hits a shield { for (int index = 0; index < ship1.GetShields().Count; ++index) { ++GlobalStats.BeamTests; ShipModule shipModule = ship1.GetShields()[index]; if (shipModule != null && (shipModule.Active || (double)beam.damageAmount <= 0.0)) { if ((double)shipModule.shield_power <= 0.0) beam.hitLast = (ShipModule)null; else if ((double)Vector2.Distance(vector2_3, shipModule.Center) <= (double)shipModule.Radius + 4.0) { ++GlobalStats.BeamTests; this.collisionResults.Add(new SpatialManager.CollisionResult() { Distance = shipModule.Radius + 8f, Normal = Vector2.Normalize(Vector2.Zero), GameplayObject = (GameplayObject)shipModule }); beam.ActualHitDestination = vector2_3; flag = true; beam.hitLast = shipModule; break; } } } } #endregion if (!flag) { for (int index = 0; index < ship1.ExternalSlots.Count; ++index) { ++GlobalStats.BeamTests; ModuleSlot moduleSlot = ship1.ExternalSlots.ElementAt(index); if (moduleSlot != null && (moduleSlot.module.Active || (double)beam.damageAmount <= 0.0) && (double)Vector2.Distance(vector2_3, moduleSlot.module.Center) <= (beam.IgnoresShields ? 12.0 : (double)moduleSlot.module.Radius + 4.0)) { ++GlobalStats.BeamTests; this.collisionResults.Add(new SpatialManager.CollisionResult() { Distance = (beam.IgnoresShields ? 12f : moduleSlot.module.Radius + 8f), Normal = Vector2.Normalize(Vector2.Zero), GameplayObject = (GameplayObject)moduleSlot.module }); beam.ActualHitDestination = vector2_3; flag = true; beam.hitLast = moduleSlot.module; break; } } if (flag) break; } else break; } } } if (this.collisionResults.Count <= 0) return; this.collisionResults.Sort(new Comparison<SpatialManager.CollisionResult>(SpatialManager.CollisionResult.Compare)); foreach (SpatialManager.CollisionResult collisionResult in this.collisionResults) { if (beam.Touch(collisionResult.GameplayObject)) beam.CollidedThisFrame = collisionResult.GameplayObject.CollidedThisFrame = true; } }