diff --git a/Subsurface/Content/Characters/Crawler/crawler.xml b/Subsurface/Content/Characters/Crawler/crawler.xml index f34cde953..7d2b58e22 100644 --- a/Subsurface/Content/Characters/Crawler/crawler.xml +++ b/Subsurface/Content/Characters/Crawler/crawler.xml @@ -14,7 +14,7 @@ flip="true"> - + @@ -28,7 +28,7 @@ - + @@ -36,7 +36,7 @@ - + @@ -44,7 +44,7 @@ - + @@ -52,7 +52,7 @@ - + diff --git a/Subsurface/Content/Characters/Human/human.xml b/Subsurface/Content/Characters/Human/human.xml index 5af2065ec..1494045b1 100644 --- a/Subsurface/Content/Characters/Human/human.xml +++ b/Subsurface/Content/Characters/Human/human.xml @@ -3,7 +3,7 @@ - - + - + - + - + @@ -46,7 +46,7 @@ - + @@ -74,7 +74,7 @@ - + @@ -87,6 +87,6 @@ + attackcooldown="3.0"/> diff --git a/Subsurface/Content/Items/Electricity/poweritems.xml b/Subsurface/Content/Items/Electricity/poweritems.xml index 69a93d797..7e4394ebb 100644 --- a/Subsurface/Content/Items/Electricity/poweritems.xml +++ b/Subsurface/Content/Items/Electricity/poweritems.xml @@ -14,7 +14,7 @@ - + @@ -41,7 +41,7 @@ - + diff --git a/Subsurface/Content/Items/Engine/engine.xml b/Subsurface/Content/Items/Engine/engine.xml index 3cbef74f4..c1daaaa47 100644 --- a/Subsurface/Content/Items/Engine/engine.xml +++ b/Subsurface/Content/Items/Engine/engine.xml @@ -9,7 +9,7 @@ - + @@ -28,7 +28,7 @@ - + diff --git a/Subsurface/Content/Items/Medical/medical.xml b/Subsurface/Content/Items/Medical/medical.xml index b5910f85d..852c38190 100644 --- a/Subsurface/Content/Items/Medical/medical.xml +++ b/Subsurface/Content/Items/Medical/medical.xml @@ -11,7 +11,7 @@ - + @@ -26,7 +26,7 @@ - + diff --git a/Subsurface/Content/Items/Pump/pump.xml b/Subsurface/Content/Items/Pump/pump.xml index 0a1ae3556..04a3b4d25 100644 --- a/Subsurface/Content/Items/Pump/pump.xml +++ b/Subsurface/Content/Items/Pump/pump.xml @@ -6,7 +6,7 @@ - + diff --git a/Subsurface/Content/Items/Reactor/reactor.xml b/Subsurface/Content/Items/Reactor/reactor.xml index 41d310058..74546b500 100644 --- a/Subsurface/Content/Items/Reactor/reactor.xml +++ b/Subsurface/Content/Items/Reactor/reactor.xml @@ -21,7 +21,7 @@ - + diff --git a/Subsurface/Source/Characters/AI/AIController.cs b/Subsurface/Source/Characters/AI/AIController.cs index 577f51a56..6694614d4 100644 --- a/Subsurface/Source/Characters/AI/AIController.cs +++ b/Subsurface/Source/Characters/AI/AIController.cs @@ -1,5 +1,6 @@ using Lidgren.Network; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; namespace Subsurface { @@ -21,7 +22,7 @@ namespace Subsurface set { Character.AnimController.TargetMovement = value; } } - public Vector2 Position + public Vector2 SimPosition { get { return Character.AnimController.Limbs[0].SimPosition; } } @@ -44,6 +45,11 @@ namespace Subsurface steeringManager = new SteeringManager(this); } + public virtual void DebugDraw(SpriteBatch spriteBatch) + { + + } + public virtual void OnAttacked(IDamageable attacker, float amount) { } public virtual void SelectTarget(AITarget target) { } diff --git a/Subsurface/Source/Characters/AI/EnemyAIController.cs b/Subsurface/Source/Characters/AI/EnemyAIController.cs index 6c1547203..ce17b51d2 100644 --- a/Subsurface/Source/Characters/AI/EnemyAIController.cs +++ b/Subsurface/Source/Characters/AI/EnemyAIController.cs @@ -6,6 +6,7 @@ using FarseerPhysics; using Lidgren.Network; using Microsoft.Xna.Framework; using FarseerPhysics.Dynamics; +using Microsoft.Xna.Framework.Graphics; namespace Subsurface { @@ -264,6 +265,9 @@ namespace Subsurface public override void OnAttacked(IDamageable attacker, float amount) { + updateTargetsTimer = Math.Min(updateTargetsTimer, 0.1f); + coolDownTimer *= 0.1f; + if (attacker==null || attacker.AiTarget==null) return; AITargetMemory targetMemory = FindTargetMemory(attacker.AiTarget); targetMemory.Priority += amount; @@ -319,7 +323,7 @@ namespace Subsurface Vector2.Normalize(attackPosition - limb.SimPosition)); } - steeringManager.SteeringSeek(attackPosition + (limb.SimPosition-Position), 5.0f); + steeringManager.SteeringSeek(attackPosition + (limb.SimPosition-SimPosition), 5.0f); break; default: @@ -329,6 +333,7 @@ namespace Subsurface if (attackTimer >= limb.attack.Duration) { + wallAttackPos = Vector2.Zero; attackTimer = 0.0f; if (Vector2.Distance(limb.SimPosition, attackPosition)<5.0) coolDownTimer = attackCoolDown; @@ -477,6 +482,32 @@ namespace Subsurface } } + public override void DebugDraw(SpriteBatch spriteBatch) + { + if (Character.IsDead) return; + + Vector2 pos = Character.Position; + pos.Y = -pos.Y; + + if (selectedAiTarget!=null) + { + GUI.DrawLine(spriteBatch, pos, ConvertUnits.ToDisplayUnits(new Vector2(selectedAiTarget.Position.X, -selectedAiTarget.Position.Y)), Color.Red); + + if (wallAttackPos!=Vector2.Zero) + { + GUI.DrawRectangle(spriteBatch, ConvertUnits.ToDisplayUnits(new Vector2(wallAttackPos.X, -wallAttackPos.Y)) - new Vector2(10.0f, 10.0f), new Vector2(20.0f, 20.0f), Color.Red, false); + } + + spriteBatch.DrawString(GUI.Font, targetValue.ToString(), pos - Vector2.UnitY*20.0f, Color.Red); + + } + + spriteBatch.DrawString(GUI.Font, targetValue.ToString(), pos - Vector2.UnitY * 80.0f, Color.Red); + + spriteBatch.DrawString(GUI.Font, "updatetargets: "+updateTargetsTimer, pos - Vector2.UnitY * 100.0f, Color.Red); + spriteBatch.DrawString(GUI.Font, "cooldown: " + coolDownTimer, pos - Vector2.UnitY * 120.0f, Color.Red); + } + public override void FillNetworkData(NetOutgoingMessage message) { message.Write((byte)state); diff --git a/Subsurface/Source/Characters/AI/ISteerable.cs b/Subsurface/Source/Characters/AI/ISteerable.cs index fbea7c827..3a4ec5379 100644 --- a/Subsurface/Source/Characters/AI/ISteerable.cs +++ b/Subsurface/Source/Characters/AI/ISteerable.cs @@ -16,7 +16,7 @@ namespace Subsurface get; } - Vector2 Position + Vector2 SimPosition { get; } diff --git a/Subsurface/Source/Characters/AI/SteeringManager.cs b/Subsurface/Source/Characters/AI/SteeringManager.cs index f63e29f44..7ac461f44 100644 --- a/Subsurface/Source/Characters/AI/SteeringManager.cs +++ b/Subsurface/Source/Characters/AI/SteeringManager.cs @@ -63,7 +63,7 @@ namespace Subsurface private Vector2 DoSteeringSeek(Vector2 target, float speed = 1.0f) { - Vector2 targetVel = target - host.Position; + Vector2 targetVel = target - host.SimPosition; if (targetVel.LengthSquared() < 0.00001f) return Vector2.Zero; @@ -111,12 +111,12 @@ namespace Subsurface float maxDistance = 2.0f; - Vector2 ahead = host.Position + Vector2.Normalize(host.Steering)*maxDistance; + Vector2 ahead = host.SimPosition + Vector2.Normalize(host.Steering)*maxDistance; if (rayCastTimer <= 0.0f) { rayCastTimer = RayCastInterval; - Body closestBody = Submarine.CheckVisibility(host.Position, ahead); + Body closestBody = Submarine.CheckVisibility(host.SimPosition, ahead); if (closestBody == null) { avoidSteering = Vector2.Zero; diff --git a/Subsurface/Source/Characters/AI/SteeringPath.cs b/Subsurface/Source/Characters/AI/SteeringPath.cs index d88ba2106..125fff3e9 100644 --- a/Subsurface/Source/Characters/AI/SteeringPath.cs +++ b/Subsurface/Source/Characters/AI/SteeringPath.cs @@ -5,32 +5,55 @@ namespace Subsurface { class SteeringPath { - private Queue nodes; - - WayPoint currentNode; + private List nodes; + + int currentIndex; public SteeringPath() { - nodes = new Queue(); + nodes = new List(); } public void AddNode(WayPoint node) { if (node == null) return; - nodes.Enqueue(node); + nodes.Add(node); } public WayPoint CurrentNode { - get { return currentNode; } + get + { + if (currentIndex < 0 || currentIndex > nodes.Count - 1) return null; + return nodes[currentIndex]; + } } - public WayPoint GetNode(Vector2 pos, float minDistance = 0.1f) + public List Nodes { - if (nodes.Count == 0) return null; - if (currentNode == null || Vector2.Distance(pos, currentNode.SimPosition) < minDistance) currentNode = nodes.Dequeue(); + get { return nodes; } + } - return currentNode; + public WayPoint NextNode + { + get + { + if (currentIndex+1 < 0 || currentIndex+1 > nodes.Count - 1) return null; + return nodes[currentIndex+1]; + } + } + + public void SkipToNextNode() + { + currentIndex++; + } + + public WayPoint CheckProgress(Vector2 pos, float minSimDistance = 0.1f) + { + if (nodes.Count == 0 || currentIndex>nodes.Count-1) return null; + if (Vector2.Distance(pos, nodes[currentIndex].SimPosition) < minSimDistance) currentIndex++; + + return CurrentNode; } public void ClearPath() diff --git a/Subsurface/Source/Characters/AICharacter.cs b/Subsurface/Source/Characters/AICharacter.cs index 1b6297fc5..90b78a7c7 100644 --- a/Subsurface/Source/Characters/AICharacter.cs +++ b/Subsurface/Source/Characters/AICharacter.cs @@ -59,6 +59,13 @@ namespace Subsurface aiController.Update(deltaTime); } + public override void DrawFront(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch) + { + base.DrawFront(spriteBatch); + + if (GameMain.DebugDraw) aiController.DebugDraw(spriteBatch); + } + public override AttackResult AddDamage(IDamageable attacker, Vector2 position, Attack attack, float deltaTime, bool playSound = false) { AttackResult result = base.AddDamage(attacker, position, attack, deltaTime, playSound); @@ -113,7 +120,7 @@ namespace Subsurface LargeUpdateTimer = Math.Max(0, LargeUpdateTimer - 1); } } - + public override void ReadNetworkData(NetworkEventType type, NetIncomingMessage message) { if (type == NetworkEventType.KillCharacter) diff --git a/Subsurface/Source/Characters/BackgroundSprite/BackgroundSprite.cs b/Subsurface/Source/Characters/BackgroundSprite/BackgroundSprite.cs index a00c2f2c0..9a80cc56e 100644 --- a/Subsurface/Source/Characters/BackgroundSprite/BackgroundSprite.cs +++ b/Subsurface/Source/Characters/BackgroundSprite/BackgroundSprite.cs @@ -37,7 +37,7 @@ namespace Subsurface get { return drawPosition; } } - public Vector2 Position + public Vector2 SimPosition { get { return position; } } @@ -179,7 +179,7 @@ namespace Subsurface foreach (BackgroundSprite member in Members) { - midPoint += member.Position; + midPoint += member.SimPosition; } midPoint /= Members.Count; diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index 4fd273ae8..332f0ce47 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -72,7 +72,7 @@ namespace Subsurface protected bool isDead; - bool isHumanoid; + public readonly bool IsHumanoid; //the name of the species (e.q. human) public readonly string SpeciesName; @@ -200,7 +200,7 @@ namespace Subsurface get { return bleeding; } set { - if (MathUtils.IsValid(value)) return; + if (!MathUtils.IsValid(value)) return; bleeding = Math.Max(value, 0.0f); } } @@ -344,9 +344,9 @@ namespace Subsurface SpeciesName = ToolBox.GetAttributeString(doc.Root, "name", "Unknown"); - isHumanoid = ToolBox.GetAttributeBool(doc.Root, "humanoid", false); + IsHumanoid = ToolBox.GetAttributeBool(doc.Root, "humanoid", false); - if (isHumanoid) + if (IsHumanoid) { AnimController = new HumanoidAnimController(this, doc.Root.Element("ragdoll")); AnimController.TargetDir = Direction.Right; @@ -660,7 +660,7 @@ namespace Subsurface if (closestCharacter != null) { if (closestCharacter != selectedCharacter) selectedCharacter = null; - if (!closestCharacter.isHumanoid) closestCharacter = null; + if (!closestCharacter.IsHumanoid) closestCharacter = null; } closestItem = FindClosestItem(mouseSimPos); @@ -706,7 +706,7 @@ namespace Subsurface { selectedCharacter = null; } - else if (closestCharacter != null && closestCharacter.isDead && closestCharacter.isHumanoid) + else if (closestCharacter != null && closestCharacter.isDead && closestCharacter.IsHumanoid) { selectedCharacter = closestCharacter; } @@ -758,7 +758,7 @@ namespace Subsurface ControlLocalPlayer(deltaTime, cam); } - Control(deltaTime, cam); + if (!(this is AICharacter)) Control(deltaTime, cam); UpdateSightRange(); aiTarget.SoundRange = 0.0f; @@ -820,7 +820,7 @@ namespace Subsurface CharacterHUD.Draw(spriteBatch, this, cam); } - public void DrawFront(SpriteBatch spriteBatch) + public virtual void DrawFront(SpriteBatch spriteBatch) { Vector2 pos = ConvertUnits.ToDisplayUnits(AnimController.Limbs[0].SimPosition); pos.Y = -pos.Y; diff --git a/Subsurface/Source/Characters/HumanoidAnimController.cs b/Subsurface/Source/Characters/HumanoidAnimController.cs index 1cbd69add..fcb959d86 100644 --- a/Subsurface/Source/Characters/HumanoidAnimController.cs +++ b/Subsurface/Source/Characters/HumanoidAnimController.cs @@ -30,14 +30,9 @@ namespace Subsurface public override void UpdateAnim(float deltaTime) { - if (character.IsDead) return; - - Vector2 colliderPos = GetLimb(LimbType.Torso).SimPosition; + if (character.IsDead) return; - if (!MathUtils.IsValid(RefLimb.body.SimPosition)) - { - int a = 1; - } + Vector2 colliderPos = GetLimb(LimbType.Torso).SimPosition; //if (inWater) stairs = null; @@ -57,7 +52,7 @@ namespace Subsurface case Physics.CollisionStairs: if (inWater && TargetMovement.Y < 0.5f) return -1; Structure structure = fixture.Body.UserData as Structure; - if (stairs == null && structure!=null) + if (stairs == null && structure != null) { if (LowestLimb.SimPosition.Y < structure.SimPosition.Y) { @@ -70,7 +65,7 @@ namespace Subsurface } break; case Physics.CollisionPlatform: - Structure platform = fixture.Body.UserData as Structure; + Structure platform = fixture.Body.UserData as Structure; if (IgnorePlatforms || LowestLimb.Position.Y < platform.Rect.Y) return -1; break; case Physics.CollisionWall: @@ -118,12 +113,12 @@ namespace Subsurface if (closestFraction == 1) //raycast didn't hit anything { floorY = (currentHull == null) ? -1000.0f : ConvertUnits.ToSimUnits(currentHull.Rect.Y - currentHull.Rect.Height); - } + } else { floorY = rayStart.Y + (rayEnd.Y - rayStart.Y) * closestFraction; } - + IgnorePlatforms = (TargetMovement.Y < 0.0f); @@ -175,18 +170,20 @@ namespace Subsurface aiming = false; } - + void UpdateStanding() { Vector2 handPos; + //if you're allergic to magic numbers, stop reading now + Limb leftFoot = GetLimb(LimbType.LeftFoot); Limb rightFoot = GetLimb(LimbType.RightFoot); Limb head = GetLimb(LimbType.Head); Limb torso = GetLimb(LimbType.Torso); - Limb waist = GetLimb(LimbType.Waist); + Limb waist = GetLimb(LimbType.Waist); Limb leftHand = GetLimb(LimbType.LeftHand); Limb rightHand = GetLimb(LimbType.RightHand); @@ -198,31 +195,31 @@ namespace Subsurface float walkCycleSpeed = head.LinearVelocity.X * walkAnimSpeed; if (stairs != null) { - TargetMovement = new Vector2(MathHelper.Clamp(TargetMovement.X, -2.0f, 2.0f), TargetMovement.Y) ; + TargetMovement = new Vector2(MathHelper.Clamp(TargetMovement.X, -1.5f, 1.5f), TargetMovement.Y); - if ((TargetMovement.X>0.0f && stairs.StairDirection == Direction.Right) || + if ((TargetMovement.X > 0.0f && stairs.StairDirection == Direction.Right) || TargetMovement.X < 0.0f && stairs.StairDirection == Direction.Left) { - TargetMovement *= 1.35f; + TargetMovement *= 1.7f; + walkCycleSpeed *= 1.7f; } - else + else { - TargetMovement /= 1.2f; - } - - walkCycleSpeed *= 1.5f; + TargetMovement /= 1.0f; + walkCycleSpeed *= 1.5f; + } } Vector2 colliderPos = new Vector2(torso.SimPosition.X, floorY); float walkPosX = (float)Math.Cos(walkPos); float walkPosY = (float)Math.Sin(walkPos); - float runningModifier = (float)Math.Max(Math.Abs(movement.X) / 1.5f, 1.0); + float runningModifier = (float)Math.Max(Math.Abs(TargetMovement.X) / 1.5f, 1.0); Vector2 stepSize = new Vector2( this.stepSize.X * walkPosX * runningModifier, this.stepSize.Y * walkPosY * runningModifier * runningModifier); - + float footMid = waist.SimPosition.X;// (leftFoot.SimPosition.X + rightFoot.SimPosition.X) / 2.0f; int limbsInWater = 0; @@ -231,184 +228,169 @@ namespace Subsurface if (limb.inWater) limbsInWater++; } - TargetMovement *= (1.0f - 0.5f*((float)limbsInWater/(float)Limbs.Count())); + TargetMovement *= (1.0f - 0.5f * ((float)limbsInWater / (float)Limbs.Count())); movement = MathUtils.SmoothStep(movement, TargetMovement, movementLerp); movement.Y = 0.0f; - - - //place the anchors of the head and the torso to make the ragdoll stand - if (onGround && LowestLimb != null && (LowestLimb.SimPosition.Y-floorY < 0.5f || stairs != null) && head !=null) + for (int i = 0; i < 2; i++) { - getUpSpeed = getUpSpeed * (head.SimPosition.Y - colliderPos.Y);//, 0.25f); + Limb leg = GetLimb((i == 0) ? LimbType.LeftThigh : LimbType.RightThigh);// : leftLeg; - if (stairs != null) - { - if (LowestLimb.SimPosition.Y < stairs.SimPosition.Y) IgnorePlatforms = true; - - torso.pullJoint.Enabled = true; - torso.pullJoint.WorldAnchorB = new Vector2( - MathHelper.SmoothStep(torso.SimPosition.X, footMid + movement.X * 0.35f, getUpSpeed * 0.8f), - MathHelper.SmoothStep(torso.SimPosition.Y, colliderPos.Y + TorsoPosition - Math.Abs(walkPosX * 0.05f), getUpSpeed * 3.0f)); + if (leg.SimPosition.Y < torso.SimPosition.Y) continue; - - head.pullJoint.Enabled = true; - head.pullJoint.WorldAnchorB = new Vector2( - MathHelper.SmoothStep(head.SimPosition.X, footMid + movement.X * 0.4f, getUpSpeed * 0.8f), - MathHelper.SmoothStep(head.SimPosition.Y, colliderPos.Y + HeadPosition - Math.Abs(walkPosX * 0.05f), getUpSpeed * 3.0f)); - } - else - { - torso.pullJoint.Enabled = true; - torso.pullJoint.WorldAnchorB = - MathUtils.SmoothStep(torso.SimPosition, - new Vector2(footMid + movement.X * 0.3f, colliderPos.Y + TorsoPosition), getUpSpeed); - - head.pullJoint.Enabled = true; - head.pullJoint.WorldAnchorB = - MathUtils.SmoothStep(head.SimPosition, - new Vector2(footMid + movement.X * (0.2f + runningModifier / 10.0f), colliderPos.Y + HeadPosition), getUpSpeed); - - waist.pullJoint.Enabled = true; - waist.pullJoint.WorldAnchorB = waist.SimPosition + movement*0.1f; - //MathUtils.SmoothStep(waist.SimPosition, - //new Vector2(footMid + movement.X * 0.4f, colliderPos.Y + HeadPosition), getUpSpeed); - } - - - //moving horizontally - if (TargetMovement.X != 0.0f) - { - //progress the walking animation - walkPos -= (walkCycleSpeed / runningModifier)*0.8f; - - MoveLimb(leftFoot, - colliderPos + new Vector2( - stepSize.X, - (stepSize.Y > 0.0f) ? stepSize.Y : -0.15f), - 15.0f, true); - - MoveLimb(rightFoot, - colliderPos + new Vector2( - -stepSize.X, - (-stepSize.Y > 0.0f) ? -stepSize.Y : -0.15f), - 15.0f, true); - - leftFoot.body.SmoothRotate(leftLeg.body.Rotation + MathHelper.PiOver2 * Dir * 1.6f, 20.0f * runningModifier); - rightFoot.body.SmoothRotate(rightLeg.body.Rotation + MathHelper.PiOver2 * Dir * 1.6f, 20.0f * runningModifier); - - if (runningModifier>1.0f) - { - if (walkPosY > 0.0f) - { - GetLimb(LimbType.LeftThigh).body.ApplyTorque(-walkPosY * Dir * Math.Abs(movement.X) * thighTorque); - } - else - { - GetLimb(LimbType.RightThigh).body.ApplyTorque(walkPosY * Dir * Math.Abs(movement.X) * thighTorque); - } - } - - if (legTorque>0.0f) - { - if (Math.Sign(walkPosX) != Math.Sign(movement.X)) - { - GetLimb(LimbType.LeftLeg).body.ApplyTorque(-walkPosY * Dir * Math.Abs(movement.X) * legTorque / runningModifier); - } - else - { - GetLimb(LimbType.RightLeg).body.ApplyTorque(walkPosY * Dir * Math.Abs(movement.X) * legTorque / runningModifier); - } - } - - //calculate the positions of hands - handPos = torso.SimPosition; - handPos.X = -walkPosX * 0.2f;// *runningModifier; - - float lowerY = -0.6f + runningModifier/3.5f; - - handPos.Y = lowerY + (float)(Math.Abs(Math.Sin(walkPos - Math.PI * 1.5f) * 0.05)) / runningModifier; - - Vector2 posAdditon = new Vector2(movement.X*0.07f, 0.0f); - if (stairs!=null) - { - if ((stairs.StairDirection == Direction.Right && movement.X < 0.0f) || - (stairs.StairDirection == Direction.Left && movement.X > 0.0f)) - { - posAdditon.Y -= 0.1f; - } - else - { - posAdditon.Y += 0.1f; - } - } - - if (!rightHand.Disabled) - { - rightHand.body.ApplyTorque(walkPosY * runningModifier * Dir); - MoveLimb(rightHand, torso.SimPosition + posAdditon + - new Vector2( - -handPos.X, - (Math.Sign(walkPosX) == Math.Sign(Dir)) ? handPos.Y : lowerY), - 15.0f, true); - } - - if (!leftHand.Disabled) - { - leftHand.body.ApplyTorque(-walkPosY * runningModifier * Dir); - MoveLimb(leftHand, torso.SimPosition + posAdditon + - new Vector2( - handPos.X, - (Math.Sign(walkPosX) == Math.Sign(-Dir)) ? handPos.Y : lowerY), - 15.0f, true); - } - - } - else - { - float movementFactor = (movement.X / 4.0f) * movement.X * Math.Sign(movement.X); - - Vector2 footPos = new Vector2( - colliderPos.X + movementFactor - Dir * 0.05f, - colliderPos.Y - 0.2f - Math.Abs(movementFactor)); - - MoveLimb(leftFoot, footPos, 2.5f); - MoveLimb(rightFoot, footPos, 2.5f); - - leftFoot.body.SmoothRotate(Dir * MathHelper.PiOver2, 5.0f); - rightFoot.body.SmoothRotate(Dir * MathHelper.PiOver2, 5.0f); - - if (!rightHand.Disabled) - { - // MoveLimb(rightHand, handPos, 0.05f, true); - //rightHand.body.ApplyLinearImpulse((handPos - rightHand.Position)); - rightHand.body.SmoothRotate(0.0f, 5.0f); - - var rightArm = GetLimb(LimbType.RightArm); - rightArm.body.SmoothRotate(0.0f, 20.0f); - } - - if (!leftHand.Disabled) - { - //MoveLimb(leftHand, handPos, 0.05f, true); - //leftHand.body.ApplyLinearImpulse((handPos - leftHand.Position)); - leftHand.body.SmoothRotate(0.0f, 5.0f); - - var leftArm = GetLimb(LimbType.LeftArm); - leftArm.body.SmoothRotate(0.0f, 20.0f); - } - } + leg.body.ApplyTorque(-Dir * leg.Mass * 10.0f); } - //for (int i = 0; i < 2; i++) - //{ - // Limb leg = (i == 0) ? rightLeg : leftLeg; + //place the anchors of the head and the torso to make the ragdoll stand - // if (leg.SimPosition.Y < waist.SimPosition.Y) continue; + if (LowestLimb == null) return; + + if (!onGround || (LowestLimb.SimPosition.Y - floorY > 0.5f && stairs == null)) return; + + getUpSpeed = getUpSpeed * (head.SimPosition.Y - colliderPos.Y); + + if (stairs != null) + { + if (LowestLimb.SimPosition.Y < stairs.SimPosition.Y) IgnorePlatforms = true; + + torso.pullJoint.Enabled = true; + torso.pullJoint.WorldAnchorB = new Vector2( + MathHelper.SmoothStep(torso.SimPosition.X, footMid + movement.X * 0.35f, getUpSpeed * 0.8f), + MathHelper.SmoothStep(torso.SimPosition.Y, colliderPos.Y + TorsoPosition - Math.Abs(walkPosX * 0.05f), getUpSpeed * 2.0f)); + + + head.pullJoint.Enabled = true; + head.pullJoint.WorldAnchorB = new Vector2( + MathHelper.SmoothStep(head.SimPosition.X, footMid + movement.X * 0.4f, getUpSpeed * 0.8f), + MathHelper.SmoothStep(head.SimPosition.Y, colliderPos.Y + HeadPosition - Math.Abs(walkPosX * 0.05f), getUpSpeed * 2.0f)); + + waist.pullJoint.Enabled = true; + waist.pullJoint.WorldAnchorB = waist.SimPosition;// +movement * 0.3f; + } + else + { + torso.pullJoint.Enabled = true; + torso.pullJoint.WorldAnchorB = + MathUtils.SmoothStep(torso.SimPosition, + new Vector2(footMid + movement.X * 0.3f, colliderPos.Y + TorsoPosition), getUpSpeed); + + + head.pullJoint.Enabled = true; + head.pullJoint.WorldAnchorB = + MathUtils.SmoothStep(head.SimPosition, + new Vector2(footMid + movement.X * 0.3f, colliderPos.Y + HeadPosition), getUpSpeed*1.2f); + + waist.pullJoint.Enabled = true; + waist.pullJoint.WorldAnchorB = waist.SimPosition + movement * 0.1f; + //MathUtils.SmoothStep(waist.SimPosition, + //new Vector2(footMid + movement.X * 0.4f, colliderPos.Y + HeadPosition), getUpSpeed); + } + + + //moving horizontally + if (TargetMovement.X != 0.0f) + { + //progress the walking animation + walkPos -= (walkCycleSpeed / runningModifier) * 0.8f; + + MoveLimb(leftFoot, + colliderPos + new Vector2( + stepSize.X, + (stepSize.Y > 0.0f) ? stepSize.Y : -0.15f), + 15.0f, true); + + MoveLimb(rightFoot, + colliderPos + new Vector2( + -stepSize.X, + (-stepSize.Y > 0.0f) ? -stepSize.Y : -0.15f), + 15.0f, true); + + leftFoot.body.SmoothRotate(leftLeg.body.Rotation + MathHelper.PiOver2 * Dir * 1.6f, 20.0f * runningModifier); + rightFoot.body.SmoothRotate(rightLeg.body.Rotation + MathHelper.PiOver2 * Dir * 1.6f, 20.0f * runningModifier); + + if (runningModifier > 1.0f) + { + if (walkPosY > 0.0f) + { + GetLimb(LimbType.LeftThigh).body.ApplyTorque(-walkPosY * Dir * Math.Abs(movement.X) * thighTorque); + } + else + { + GetLimb(LimbType.RightThigh).body.ApplyTorque(walkPosY * Dir * Math.Abs(movement.X) * thighTorque); + } + } + + if (legTorque > 0.0f) + { + if (Math.Sign(walkPosX) != Math.Sign(movement.X)) + { + GetLimb(LimbType.LeftLeg).body.ApplyTorque(-walkPosY * Dir * Math.Abs(movement.X) * legTorque / runningModifier); + } + else + { + GetLimb(LimbType.RightLeg).body.ApplyTorque(walkPosY * Dir * Math.Abs(movement.X) * legTorque / runningModifier); + } + } + + //calculate the positions of hands + handPos = torso.SimPosition; + handPos.X = -walkPosX * 0.4f; + + float lowerY = -1.0f + (runningModifier - 1.0f) * 0.8f; + + handPos.Y = lowerY + (float)(Math.Abs(Math.Sin(walkPos - Math.PI * 1.5f) * 0.15 * runningModifier)); + + Vector2 posAddition = new Vector2(-movement.X * 0.015f * runningModifier, 0.0f); + + if (!rightHand.Disabled) + { + HandIK(rightHand, torso.SimPosition + posAddition + + new Vector2( + -handPos.X, + (Math.Sign(walkPosX) == Math.Sign(Dir)) ? handPos.Y : lowerY), 0.7f*runningModifier); + } + + if (!leftHand.Disabled) + { + HandIK(leftHand, torso.SimPosition + posAddition + + new Vector2( + handPos.X, + (Math.Sign(walkPosX) == Math.Sign(-Dir)) ? handPos.Y : lowerY), 0.7f * runningModifier); + } + + } + else + { + float movementFactor = (movement.X / 4.0f) * movement.X * Math.Sign(movement.X); + + Vector2 footPos = new Vector2( + colliderPos.X, + colliderPos.Y - 0.2f); + + MoveLimb(leftFoot, footPos, 2.5f); + MoveLimb(rightFoot, footPos, 2.5f); + + leftFoot.body.SmoothRotate(Dir * MathHelper.PiOver2, 5.0f); + rightFoot.body.SmoothRotate(Dir * MathHelper.PiOver2, 5.0f); + + if (!rightHand.Disabled) + { + rightHand.body.SmoothRotate(0.0f, 5.0f); + + var rightArm = GetLimb(LimbType.RightArm); + rightArm.body.SmoothRotate(0.0f, 20.0f); + } + + if (!leftHand.Disabled) + { + leftHand.body.SmoothRotate(0.0f, 5.0f); + + var leftArm = GetLimb(LimbType.LeftArm); + leftArm.body.SmoothRotate(0.0f, 20.0f); + } + } - // //leg.body.ApplyTorque(Dir * leg.Mass * 50.0f); - //} } @@ -416,23 +398,23 @@ namespace Subsurface { movement = MathUtils.SmoothStep(movement, TargetMovement, movementLerp); - if (inWater && movement.LengthSquared()>0.00001f) + if (inWater && movement.LengthSquared() > 0.00001f) { movement = Vector2.Normalize(movement); } - + RefLimb.pullJoint.Enabled = true; RefLimb.pullJoint.WorldAnchorB = - RefLimb.SimPosition + movement*0.15f; + RefLimb.SimPosition + movement * 0.15f; RefLimb.body.SmoothRotate(0.0f); foreach (Limb l in Limbs) { - if (l==RefLimb) continue; + if (l == RefLimb) continue; l.body.SetTransform(RefLimb.SimPosition, RefLimb.Rotation); } - //new Vector2(movement.X, floorY + HeadPosition), 0.5f); + //new Vector2(movement.X, floorY + HeadPosition), 0.5f); } void UpdateSwimming() @@ -447,20 +429,20 @@ namespace Subsurface if (currentHull != null && (currentHull.Rect.Y - currentHull.Surface > 50.0f) && !head.inWater) { - surfaceLimiter = (ConvertUnits.ToDisplayUnits(head.SimPosition.Y)-surfaceY); + surfaceLimiter = (ConvertUnits.ToDisplayUnits(head.SimPosition.Y) - surfaceY); surfaceLimiter = Math.Max(1.0f, surfaceLimiter); if (surfaceLimiter > 20.0f) return; } - Limb torso = GetLimb(LimbType.Torso); - Limb leftHand = GetLimb(LimbType.LeftHand); - Limb rightHand = GetLimb(LimbType.RightHand); + Limb torso = GetLimb(LimbType.Torso); + Limb leftHand = GetLimb(LimbType.LeftHand); + Limb rightHand = GetLimb(LimbType.RightHand); + + Limb leftFoot = GetLimb(LimbType.LeftFoot); + Limb rightFoot = GetLimb(LimbType.RightFoot); + Limb leftLeg = GetLimb(LimbType.LeftLeg); + Limb rightLeg = GetLimb(LimbType.RightLeg); - Limb leftFoot = GetLimb(LimbType.LeftFoot); - Limb rightFoot = GetLimb(LimbType.RightFoot); - Limb leftLeg = GetLimb(LimbType.LeftLeg); - Limb rightLeg = GetLimb(LimbType.RightLeg); - float rotation = MathHelper.WrapAngle(torso.Rotation); rotation = MathHelper.ToDegrees(rotation); if (rotation < 0.0f) rotation += 360; @@ -475,12 +457,12 @@ namespace Subsurface float targetSpeed = TargetMovement.Length(); if (targetSpeed > 0.0f) TargetMovement /= targetSpeed; - + if (targetSpeed > 0.1f) { if (!aiming) { - torso.body.SmoothRotate(MathUtils.VectorToAngle(TargetMovement)-MathHelper.PiOver2); + torso.body.SmoothRotate(MathUtils.VectorToAngle(TargetMovement) - MathHelper.PiOver2); } } else @@ -526,7 +508,7 @@ namespace Subsurface movement.Y -= 0.05f; head.body.ApplyForce((new Vector2(movement.X, - movement.Y / surfaceLimiter + 0.2f) - head.body.LinearVelocity * 0.2f) * + movement.Y / surfaceLimiter + 0.2f) - head.body.LinearVelocity * 0.2f) * 30.0f * head.body.Mass); torso.body.ApplyForce((new Vector2(movement.X, @@ -546,7 +528,7 @@ namespace Subsurface transformedFootPos, Matrix.CreateRotationZ(torso.body.Rotation)); - if (Math.Abs(MathUtils.GetShortestAngle(torso.Rotation, rightThigh.Rotation))<0.3f) + if (Math.Abs(MathUtils.GetShortestAngle(torso.Rotation, rightThigh.Rotation)) < 0.3f) { MoveLimb(rightFoot, footPos - transformedFootPos, 1.0f); } @@ -554,14 +536,14 @@ namespace Subsurface { MoveLimb(leftFoot, footPos + transformedFootPos, 1.0f); } - + handPos = (torso.SimPosition + head.SimPosition) / 2.0f; //if (!rightHand.Disabled) rightHand.body.ApplyTorque(leftHand.body.Mass * Dir); //if (!leftHand.Disabled) leftHand.body.ApplyTorque(leftHand.body.Mass * Dir); - + //at the surface, not moving sideways -> hands just float around - if (!headInWater && TargetMovement.X == 0.0f && TargetMovement.Y>0) + if (!headInWater && TargetMovement.X == 0.0f && TargetMovement.Y > 0) { handPos.X = handPos.X + Dir * 0.6f; @@ -612,12 +594,12 @@ namespace Subsurface //MoveLimb(leftHand, handPos + leftHandPos,1.5f); HandIK(leftHand, handPos + leftHandPos, 0.5f); - } + } } void UpdateClimbing() { - if (character.SelectedConstruction == null || character.SelectedConstruction.GetComponent()==null) + if (character.SelectedConstruction == null || character.SelectedConstruction.GetComponent() == null) { Anim = Animation.None; return; @@ -630,15 +612,15 @@ namespace Subsurface Vector2 footPos, handPos; - Limb leftFoot = GetLimb(LimbType.LeftFoot); - Limb rightFoot = GetLimb(LimbType.RightFoot); - Limb head = GetLimb(LimbType.Head); - Limb torso = GetLimb(LimbType.Torso); + Limb leftFoot = GetLimb(LimbType.LeftFoot); + Limb rightFoot = GetLimb(LimbType.RightFoot); + Limb head = GetLimb(LimbType.Head); + Limb torso = GetLimb(LimbType.Torso); - Limb waist = GetLimb(LimbType.Waist); + Limb waist = GetLimb(LimbType.Waist); - Limb leftHand = GetLimb(LimbType.LeftHand); - Limb rightHand = GetLimb(LimbType.RightHand); + Limb leftHand = GetLimb(LimbType.LeftHand); + Limb rightHand = GetLimb(LimbType.RightHand); Vector2 ladderSimPos = ConvertUnits.ToSimUnits( character.SelectedConstruction.Rect.X + character.SelectedConstruction.Rect.Width / 2.0f, @@ -668,7 +650,7 @@ namespace Subsurface rightHand.body.ApplyTorque(Dir * 2.0f); footPos = new Vector2( - handPos.X - Dir*0.05f, + handPos.X - Dir * 0.05f, head.SimPosition.Y - stepHeight * 2.7f - ladderSimPos.Y - 0.7f); //if (movement.Y < 0) footPos.Y += 0.05f; @@ -712,7 +694,7 @@ namespace Subsurface // - reached the top or bottom of the ladder if (Math.Abs(torso.LinearVelocity.Y) > 5.0f || TargetMovement.X != 0.0f || - (TargetMovement.Y < 0.0f && ConvertUnits.ToSimUnits(trigger.Height) + handPos.Y < HeadPosition*1.5f) || + (TargetMovement.Y < 0.0f && ConvertUnits.ToSimUnits(trigger.Height) + handPos.Y < HeadPosition * 1.5f) || (TargetMovement.Y > 0.0f && handPos.Y > 0.3f)) { Anim = Animation.None; @@ -721,7 +703,7 @@ namespace Subsurface } } - + //float punchTimer; //bool punching; @@ -777,12 +759,12 @@ namespace Subsurface transformedHandlePos[0] = Vector2.Transform(handlePos[0], itemTransfrom); transformedHandlePos[1] = Vector2.Transform(handlePos[1], itemTransfrom); - Limb head = GetLimb(LimbType.Head); - Limb torso = GetLimb(LimbType.Torso); - Limb leftHand = GetLimb(LimbType.LeftHand); - Limb rightHand = GetLimb(LimbType.RightHand); + Limb head = GetLimb(LimbType.Head); + Limb torso = GetLimb(LimbType.Torso); + Limb leftHand = GetLimb(LimbType.LeftHand); + Limb rightHand = GetLimb(LimbType.RightHand); - Vector2 itemPos = aim ? aimPos : holdPos; + Vector2 itemPos = aim ? aimPos : holdPos; float itemAngle; if (stunTimer <= 0.0f && aim && itemPos != Vector2.Zero) @@ -810,7 +792,7 @@ namespace Subsurface { itemAngle = (torso.body.Rotation + holdAngle * Dir); } - + Vector2 shoulderPos = limbJoints[2].WorldAnchorA; Vector2 transformedHoldPos = shoulderPos; @@ -847,7 +829,7 @@ namespace Subsurface } Vector2 bodyVelocity = torso.body.LinearVelocity / 60.0f; - + item.body.ResetDynamics(); item.body.SetTransform(MathUtils.SmoothStep(item.body.SimPosition, transformedHoldPos + bodyVelocity, 0.5f), itemAngle); @@ -859,7 +841,7 @@ namespace Subsurface Limb hand = (i == 0) ? rightHand : leftHand; HandIK(hand, transformedHoldPos + transformedHandlePos[i]); - } + } } private void HandIK(Limb hand, Vector2 pos, float force = 1.0f) @@ -883,20 +865,22 @@ namespace Subsurface float armAngle = MathUtils.SolveTriangleSSS(a, b, c); float handAngle = MathUtils.SolveTriangleSSS(b, a, c); - arm.body.SmoothRotate((ang2 - armAngle * Dir), 20.0f*force); - hand.body.SmoothRotate((ang2 + handAngle * Dir), 100.0f*force); + arm.body.SmoothRotate((ang2 - armAngle * Dir), 20.0f * force); + hand.body.SmoothRotate((ang2 + handAngle * Dir), 100.0f * force); } public override void Flip() { base.Flip(); + walkPos = -walkPos; + Limb torso = GetLimb(LimbType.Torso); Vector2 difference; Matrix torsoTransform = Matrix.CreateRotationZ(torso.Rotation); - + for (int i = 0; i < character.SelectedItems.Length; i++) { if (character.SelectedItems[i] != null) @@ -926,7 +910,7 @@ namespace Subsurface l.body.SetTransform(torso.SimPosition + Vector2.Transform(difference, -torsoTransform), -l.body.Rotation); break; default: - if (!inWater) l.body.SetTransform(l.body.SimPosition, + if (!inWater) l.body.SetTransform(l.body.SimPosition, MathUtils.WrapAnglePi(l.body.Rotation * (l.DoesFlip ? -1.0f : 1.0f))); break; } diff --git a/Subsurface/Source/Characters/Jobs/JobPrefab.cs b/Subsurface/Source/Characters/Jobs/JobPrefab.cs index af0919b85..004bdb8d3 100644 --- a/Subsurface/Source/Characters/Jobs/JobPrefab.cs +++ b/Subsurface/Source/Characters/Jobs/JobPrefab.cs @@ -103,7 +103,9 @@ namespace Subsurface { int width = 500, height = 400; - GUIFrame frame = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), GUI.Style); + GUIFrame backFrame = new GUIFrame(Rectangle.Empty, Color.Black*0.5f); + + GUIFrame frame = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), GUI.Style, backFrame); frame.Padding = new Vector4(30.0f, 30.0f, 30.0f, 30.0f); new GUITextBlock(new Rectangle(0,0,100,20), name, GUI.Style, Alignment.TopLeft, Alignment.TopLeft, frame, false, GUI.LargeFont); @@ -142,7 +144,7 @@ namespace Subsurface - return frame; + return backFrame; } public static void LoadAll(List filePaths) diff --git a/Subsurface/Source/Characters/Limb.cs b/Subsurface/Source/Characters/Limb.cs index f74c5b15d..be0580bb6 100644 --- a/Subsurface/Source/Characters/Limb.cs +++ b/Subsurface/Source/Characters/Limb.cs @@ -193,7 +193,7 @@ namespace Subsurface body.CollidesWith = Physics.CollisionAll & ~Physics.CollisionCharacter & ~Physics.CollisionMisc; } - impactTolerance = ToolBox.GetAttributeFloat(element, "impacttolerance", 10.0f); + impactTolerance = ToolBox.GetAttributeFloat(element, "impacttolerance", character.IsHumanoid ? 15.0f : 50.0f); body.UserData = this; diff --git a/Subsurface/Source/DebugConsole.cs b/Subsurface/Source/DebugConsole.cs index 8cff35e83..796d37b65 100644 --- a/Subsurface/Source/DebugConsole.cs +++ b/Subsurface/Source/DebugConsole.cs @@ -212,6 +212,13 @@ namespace Subsurface case "editchar": GameMain.EditCharacterScreen.Select(); break; + case "heal": + if (Character.Controlled!=null) + { + Character.Controlled.Health = Character.Controlled.MaxHealth; + Character.Controlled.Bleeding = 0.0f; + } + break; case "freecamera": case "freecam": Character.Controlled = null; diff --git a/Subsurface/Source/GameSession/GameSession.cs b/Subsurface/Source/GameSession/GameSession.cs index 641f711a7..7e9df144b 100644 --- a/Subsurface/Source/GameSession/GameSession.cs +++ b/Subsurface/Source/GameSession/GameSession.cs @@ -111,6 +111,12 @@ namespace Subsurface this.level = level; + if (submarine==null) + { + DebugConsole.ThrowError("Couldn't start game session, submarine not selected"); + return; + } + if (reloadSub || Submarine.Loaded != submarine) submarine.Load(); if (level != null) diff --git a/Subsurface/Source/Items/Components/ItemComponent.cs b/Subsurface/Source/Items/Components/ItemComponent.cs index 2d4da696e..5b75efbb1 100644 --- a/Subsurface/Source/Items/Components/ItemComponent.cs +++ b/Subsurface/Source/Items/Components/ItemComponent.cs @@ -207,11 +207,16 @@ namespace Subsurface.Items.Components statusEffects.Add(StatusEffect.Load(subElement)); break; case "guiframe": + string rectStr = ToolBox.GetAttributeString(subElement, "rect", "0.0,0.0,0.5,0.5"); + + string[] components = rectStr.Split(','); + if (components.Length < 4) continue; + Vector4 rect = ToolBox.GetAttributeVector4(subElement, "rect", Vector4.One); - rect.X *= GameMain.GraphicsWidth; - rect.Y *= GameMain.GraphicsHeight; - rect.Z *= GameMain.GraphicsWidth; - rect.W *= GameMain.GraphicsHeight; + if (components[0].Contains(".")) rect.X *= GameMain.GraphicsWidth; + if (components[1].Contains(".")) rect.Y *= GameMain.GraphicsHeight; + if (components[2].Contains(".")) rect.Z *= GameMain.GraphicsWidth; + if (components[3].Contains(".")) rect.W *= GameMain.GraphicsHeight; Vector4 color = ToolBox.GetAttributeVector4(subElement, "color", Vector4.One); @@ -228,7 +233,7 @@ namespace Subsurface.Items.Components guiFrame = new GUIFrame( new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Z, (int)rect.W), - new Color(color.X, color.Y, color.Z, color.W), alignment, GUI.Style); + new Color(color.X, color.Y, color.Z) * color.W, alignment, GUI.Style); //guiFrame.Alpha = color.W; break; diff --git a/Subsurface/Source/Items/Components/Machines/Radar.cs b/Subsurface/Source/Items/Components/Machines/Radar.cs index b542a6f9b..25cecb794 100644 --- a/Subsurface/Source/Items/Components/Machines/Radar.cs +++ b/Subsurface/Source/Items/Components/Machines/Radar.cs @@ -172,6 +172,31 @@ namespace Subsurface.Items.Components quest.RadarPosition, displayScale, center, (rect.Width * 0.55f)); } } + + if (!GameMain.DebugDraw) return; + + var steering = item.GetComponent(); + if (steering == null || steering.SteeringPath == null) return; + + Vector2 prevPos = Vector2.Zero; + + foreach (WayPoint wp in steering.SteeringPath.Nodes) + { + Vector2 pos = (wp.Position - Submarine.Loaded.Position) * displayScale; + if (pos.Length() > radius) continue; + + pos.Y = -pos.Y; + pos += center; + + GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos.X -3 / 2, (int)pos.Y - 3, 6, 6), (steering.SteeringPath.CurrentNode==wp) ? Color.LightGreen : Color.Green, false); + + if (prevPos!=Vector2.Zero) + { + GUI.DrawLine(spriteBatch, pos, prevPos, Color.Green); + } + + prevPos = pos; + } } private void DrawMarker(SpriteBatch spriteBatch, string label, Vector2 position, float scale, Vector2 center, float radius) diff --git a/Subsurface/Source/Items/Components/Machines/Steering.cs b/Subsurface/Source/Items/Components/Machines/Steering.cs index c028307ee..c73ad1387 100644 --- a/Subsurface/Source/Items/Components/Machines/Steering.cs +++ b/Subsurface/Source/Items/Components/Machines/Steering.cs @@ -12,6 +12,8 @@ namespace Subsurface.Items.Components { class Steering : Powered { + private const float AutopilotRayCastInterval = 5.0f; + private Vector2 currVelocity; private Vector2 targetVelocity; @@ -24,6 +26,8 @@ namespace Subsurface.Items.Components private float networkUpdateTimer; private bool valueChanged; + private float autopilotRayCastTimer; + bool AutoPilot { get { return autoPilot; } @@ -37,7 +41,7 @@ namespace Subsurface.Items.Components { if (pathFinder==null) pathFinder = new PathFinder(WayPoint.WayPointList, false); steeringPath = pathFinder.FindPath( - ConvertUnits.ToSimUnits(Level.Loaded.Position), + ConvertUnits.ToSimUnits(Submarine.Loaded.Position), ConvertUnits.ToSimUnits(Level.Loaded.EndPosition)); } } @@ -59,6 +63,11 @@ namespace Subsurface.Items.Components get { return targetVelocity; } } + public SteeringPath SteeringPath + { + get { return steeringPath; } + } + public Steering(Item item, XElement element) : base(item, element) { @@ -81,21 +90,7 @@ namespace Subsurface.Items.Components // ConvertUnits.ToSimUnits(Level.Loaded.EndPosition)); //} - steeringPath.GetNode(Vector2.Zero, 20.0f); - - if (steeringPath.CurrentNode!=null) - { - float prediction = 10.0f; - - Vector2 futurePosition = Submarine.Loaded.Speed * prediction; - - Vector2 targetSpeed = (steeringPath.CurrentNode.Position - futurePosition); - - //float dist = targetSpeed.Length(); - targetSpeed = Vector2.Normalize(targetSpeed); - - TargetVelocity = targetSpeed*100.0f; - } + UpdateAutoPilot(deltaTime); } else if (valueChanged) { @@ -160,6 +155,51 @@ namespace Subsurface.Items.Components } } + private void UpdateAutoPilot(float deltaTime) + { + autopilotRayCastTimer -= deltaTime; + + steeringPath.CheckProgress(ConvertUnits.ToSimUnits(Submarine.Loaded.Position), 10.0f); + + if (autopilotRayCastTimer<=0.0f && steeringPath.NextNode != null) + { + Vector2 diff = steeringPath.NextNode.Position - Submarine.Loaded.Position; + + bool nextVisible = true; + for (int x = -1; x < 2; x += 2) + { + for (int y = -1; y < 2; y += 2) + { + Vector2 cornerPos = + new Vector2(Submarine.Borders.Width * x, Submarine.Borders.Height * y) / 2.0f; + + cornerPos = ConvertUnits.ToSimUnits(cornerPos*1.2f); + + if (Submarine.PickBody(cornerPos, cornerPos + diff, null, Physics.CollisionLevel) == null) continue; + + nextVisible = false; + x = 2; + y = 2; + } + } + + if (nextVisible) steeringPath.SkipToNextNode(); + + autopilotRayCastTimer = AutopilotRayCastInterval; + } + + if (steeringPath.CurrentNode != null) + { + float prediction = 5.0f; + + Vector2 futurePosition = Submarine.Loaded.Speed * prediction; + Vector2 targetSpeed = ((steeringPath.CurrentNode.Position - Submarine.Loaded.Position) - futurePosition); + + targetSpeed = Vector2.Normalize(targetSpeed); + TargetVelocity = targetSpeed * 100.0f; + } + } + public override void ReceiveSignal(string signal, Connection connection, Item sender, float power=0.0f) { if (connection.Name == "velocity_in") diff --git a/Subsurface/Source/Items/Components/Power/PowerContainer.cs b/Subsurface/Source/Items/Components/Power/PowerContainer.cs index 73e8303a0..1e1fb6d4e 100644 --- a/Subsurface/Source/Items/Components/Power/PowerContainer.cs +++ b/Subsurface/Source/Items/Components/Power/PowerContainer.cs @@ -184,24 +184,24 @@ namespace Subsurface.Items.Components public override void DrawHUD(SpriteBatch spriteBatch, Character character) { - int width = 300, height = 200; - int x = GameMain.GraphicsWidth / 2 - width / 2; - int y = GameMain.GraphicsHeight / 2 - height / 2; + GuiFrame.Draw(spriteBatch); - GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black, true); + int x = GuiFrame.Rect.X; + int y = GuiFrame.Rect.Y; + //GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black, true); spriteBatch.DrawString(GUI.Font, "Charge: " + (int)charge + "/" + (int)capacity + " (" + (int)((charge / capacity) * 100.0f) + " %)", new Vector2(x + 30, y + 30), Color.White); - spriteBatch.DrawString(GUI.Font, "Recharge rate: " + (rechargeSpeed / maxRechargeSpeed), new Vector2(x + 30, y + 100), Color.White); - if (GUI.DrawButton(spriteBatch, new Rectangle(x + 50, y + 150, 40, 40), "+")) + spriteBatch.DrawString(GUI.Font, "Recharge rate: " + (int)((rechargeSpeed / maxRechargeSpeed)*100.0f)+" %", new Vector2(x + 30, y + 100), Color.White); + if (GUI.DrawButton(spriteBatch, new Rectangle(x + 200, y + 90, 40, 40), "+")) { rechargeSpeed = Math.Min(rechargeSpeed + maxRechargeSpeed*0.1f, maxRechargeSpeed); item.NewComponentEvent(this, true); } - if (GUI.DrawButton(spriteBatch, new Rectangle(x + 250, y + 150, 40, 40), "-")) + if (GUI.DrawButton(spriteBatch, new Rectangle(x + 250, y + 90, 40, 40), "-")) { rechargeSpeed = Math.Max(rechargeSpeed - maxRechargeSpeed * 0.1f, 0.0f); item.NewComponentEvent(this, true); diff --git a/Subsurface/Source/Items/Components/Power/PowerTransfer.cs b/Subsurface/Source/Items/Components/Power/PowerTransfer.cs index 529e466c5..1661d73b5 100644 --- a/Subsurface/Source/Items/Components/Power/PowerTransfer.cs +++ b/Subsurface/Source/Items/Components/Power/PowerTransfer.cs @@ -146,8 +146,6 @@ namespace Subsurface.Items.Components GuiFrame.Draw(spriteBatch); - GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black, true); - spriteBatch.DrawString(GUI.Font, "Power: " + (int)(-currPowerConsumption), new Vector2(x + 30, y + 30), Color.White); spriteBatch.DrawString(GUI.Font, "Load: " + (int)powerLoad, new Vector2(x + 30, y + 100), Color.White); } diff --git a/Subsurface/Source/Items/Components/Projectile.cs b/Subsurface/Source/Items/Components/Projectile.cs index eb1864165..80197fed8 100644 --- a/Subsurface/Source/Items/Components/Projectile.cs +++ b/Subsurface/Source/Items/Components/Projectile.cs @@ -142,7 +142,7 @@ namespace Subsurface.Items.Components Limb limb; Structure structure; if ((limb = (f2.Body.UserData as Limb)) != null) - { + { attackResult = attack.DoDamage(null, limb.character, item.SimPosition, 1.0f); } else if ((structure = (f2.Body.UserData as Structure)) != null) diff --git a/Subsurface/Source/Map/Levels/Level.cs b/Subsurface/Source/Map/Levels/Level.cs index 9445e49c0..e175708ca 100644 --- a/Subsurface/Source/Map/Levels/Level.cs +++ b/Subsurface/Source/Map/Levels/Level.cs @@ -818,17 +818,18 @@ int currentTargetIndex = 1; public void Draw(SpriteBatch spriteBatch) { - Vector2 pos = endPosition; - pos.X += Position.X; + Vector2 pos = endPosition; pos.Y = -pos.Y - Position.Y; if (GameMain.GameScreen.Cam.WorldView.Y < -pos.Y-512) return; - float x = GameMain.GameScreen.Cam.WorldView.X-512.0f; + pos.X = GameMain.GameScreen.Cam.WorldView.X-512.0f; + //pos.X += Position.X % 512; + int width = (int)(Math.Ceiling(GameMain.GameScreen.Cam.WorldView.Width/512.0f + 2.0f)*512.0f); spriteBatch.Draw(shaftTexture, - new Rectangle((int)(MathUtils.Round(x, 512.0f)), (int)pos.Y, width, 512), + new Rectangle((int)(MathUtils.Round(pos.X, 512.0f) + Position.X % 512) , (int)pos.Y, width, 512), new Rectangle(0, 0, width, 256), Color.White, 0.0f, Vector2.Zero, diff --git a/Subsurface/Source/Map/Submarine.cs b/Subsurface/Source/Map/Submarine.cs index 90344ebef..54ee2a618 100644 --- a/Subsurface/Source/Map/Submarine.cs +++ b/Subsurface/Source/Map/Submarine.cs @@ -241,7 +241,7 @@ namespace Subsurface } } - public static Body PickBody(Vector2 rayStart, Vector2 rayEnd, List ignoredBodies = null) + public static Body PickBody(Vector2 rayStart, Vector2 rayEnd, List ignoredBodies = null, Category? collisionCategory = null) { @@ -251,7 +251,9 @@ namespace Subsurface { if (fixture == null || fixture.CollisionCategories == Category.None || - fixture.CollisionCategories == Physics.CollisionMisc) return -1; + fixture.CollisionCategories == Physics.CollisionMisc) return -1; + + if (collisionCategory != null && !fixture.CollisionCategories.HasFlag((Category)collisionCategory)) return -1; if (ignoredBodies != null && ignoredBodies.Contains(fixture.Body)) return -1; diff --git a/Subsurface/Source/Networking/GameClient.cs b/Subsurface/Source/Networking/GameClient.cs index 299c145ee..dd3ecae38 100644 --- a/Subsurface/Source/Networking/GameClient.cs +++ b/Subsurface/Source/Networking/GameClient.cs @@ -388,7 +388,10 @@ namespace Subsurface.Networking string mapName = inc.ReadString(); string mapHash = inc.ReadString(); - GameMain.NetLobbyScreen.TrySelectMap(mapName, mapHash); + if (!GameMain.NetLobbyScreen.TrySelectMap(mapName, mapHash)) + { + yield return CoroutineStatus.Success; + } yield return CoroutineStatus.Running; @@ -397,7 +400,8 @@ namespace Subsurface.Networking TimeSpan duration = new TimeSpan(0, (int)durationMinutes, 0); Rand.SetSyncedSeed(seed); //int gameModeIndex = inc.ReadInt32(); - GameMain.GameSession = new GameSession(Submarine.Loaded, "", GameMain.NetLobbyScreen.SelectedMode); + + GameMain.GameSession = new GameSession(GameMain.NetLobbyScreen.SelectedMap, "", GameMain.NetLobbyScreen.SelectedMode); yield return CoroutineStatus.Running; diff --git a/Subsurface/Source/Screens/GameScreen.cs b/Subsurface/Source/Screens/GameScreen.cs index 58f5cdfd2..90a781394 100644 --- a/Subsurface/Source/Screens/GameScreen.cs +++ b/Subsurface/Source/Screens/GameScreen.cs @@ -265,7 +265,17 @@ namespace Subsurface } Hull.renderer.Render(graphics, cam, renderTargetAir, Cam.ShaderTransform); - + + spriteBatch.Begin(SpriteSortMode.BackToFront, + BlendState.AlphaBlend, SamplerState.LinearWrap, + null, null, null, + cam.Transform); + + Submarine.DrawFront(spriteBatch); + + spriteBatch.End(); + + if (GameMain.GameSession != null && GameMain.GameSession.Level != null) { GameMain.GameSession.Level.Render(graphics, cam); @@ -289,8 +299,6 @@ namespace Subsurface null, null, null, cam.Transform); - Submarine.DrawFront(spriteBatch); - foreach (Character c in Character.CharacterList) c.DrawFront(spriteBatch); if (GameMain.GameSession != null && GameMain.GameSession.Level != null) diff --git a/Subsurface/Source/Screens/MainMenuScreen.cs b/Subsurface/Source/Screens/MainMenuScreen.cs index 4665bb1eb..6529e55db 100644 --- a/Subsurface/Source/Screens/MainMenuScreen.cs +++ b/Subsurface/Source/Screens/MainMenuScreen.cs @@ -34,12 +34,11 @@ namespace Subsurface - buttonsTab = new GUIFrame(new Rectangle(50, 200, 200, 500), Color.Transparent, Alignment.Left); + buttonsTab = new GUIFrame(new Rectangle(50, 0, 200, 360), Color.Transparent, Alignment.Left | Alignment.CenterY); //menuTabs[(int)Tabs.Main].Padding = GUI.style.smallPadding; Rectangle panelRect = new Rectangle( - GameMain.GraphicsWidth / 2 - 250, - buttonsTab.Rect.Y, + 290, buttonsTab.Rect.Y, 500, 360); GUIButton button = new GUIButton(new Rectangle(0, 0, 0, 30), "Tutorial", Alignment.CenterX, GUI.Style, buttonsTab); diff --git a/Subsurface/Source/Screens/NetLobbyScreen.cs b/Subsurface/Source/Screens/NetLobbyScreen.cs index e115819cb..dbec38b8d 100644 --- a/Subsurface/Source/Screens/NetLobbyScreen.cs +++ b/Subsurface/Source/Screens/NetLobbyScreen.cs @@ -102,7 +102,7 @@ namespace Subsurface public string DurationText() { - return "Game duration: " + GameDuration + " min"; + return "Duration: " + GameDuration.Minutes + " min"; } public NetLobbyScreen() @@ -138,6 +138,7 @@ namespace Subsurface new Rectangle((int)(panelRect.Width * 0.7f + 20), 0, (int)(panelRect.Width * 0.3f - 20), (int)(panelRect.Height * 0.6f)), GUI.Style, menu); + playerFrame.Padding = new Vector4(20.0f, 20.0f, 20.0f, 20.0f); //player list ------------------------------------------------------------------ @@ -153,7 +154,7 @@ namespace Subsurface int columnWidth = infoFrame.Rect.Width / 5 - 30; int columnX = 0; - new GUITextBlock(new Rectangle(columnX, 120, columnWidth, 30), "Selected submarine:", GUI.Style, infoFrame); + new GUITextBlock(new Rectangle(columnX, 120, columnWidth, 30), "Submarine:", GUI.Style, infoFrame); subList = new GUIListBox(new Rectangle(columnX, 150, columnWidth, infoFrame.Rect.Height - 150 - 80), Color.White, GUI.Style, infoFrame); subList.OnSelected = SelectMap; @@ -180,7 +181,7 @@ namespace Subsurface //gamemode ------------------------------------------------------------------ - new GUITextBlock(new Rectangle(columnX, 120, 0, 30), "Selected game mode: ", GUI.Style, infoFrame); + new GUITextBlock(new Rectangle(columnX, 120, 0, 30), "Game mode: ", GUI.Style, infoFrame); modeList = new GUIListBox(new Rectangle(columnX, 150, columnWidth, infoFrame.Rect.Height - 150 - 80), GUI.Style, infoFrame); @@ -204,7 +205,8 @@ namespace Subsurface var modeDescription = new GUITextBlock( new Rectangle(columnX, 150, (int)(columnWidth * 1.5f), infoFrame.Rect.Height - 150 - 80), - "", Color.Black*0.3f, Color.White, Alignment.TopLeft, Alignment.TopLeft, GUI.Style, infoFrame, true); + "", GUI.Style, Alignment.TopLeft, Alignment.TopLeft, infoFrame, true, GameMain.GraphicsWidth>1024 ? GUI.Font : GUI.SmallFont); + modeDescription.Color = Color.Black * 0.3f; modeList.UserData = modeDescription; @@ -213,7 +215,7 @@ namespace Subsurface //duration ------------------------------------------------------------------ GUITextBlock durationText = new GUITextBlock(new Rectangle(columnX, 120, columnWidth, 20), - "Game duration: ", GUI.Style, Alignment.Left, Alignment.TopLeft, infoFrame); + "Duration: ", GUI.Style, Alignment.Left, Alignment.TopLeft, infoFrame); durationText.TextGetter = DurationText; durationBar = new GUIScrollBar(new Rectangle(columnX, 150, columnWidth, 20), @@ -272,7 +274,7 @@ namespace Subsurface if (IsServer && GameMain.Server != null) { - GUIButton startButton = new GUIButton(new Rectangle(0, 0, 200, 30), "Start", Alignment.BottomRight, GUI.Style, infoFrame); + GUIButton startButton = new GUIButton(new Rectangle(0, 0, 100, 30), "Start", Alignment.BottomRight, GUI.Style, infoFrame); startButton.OnClicked = GameMain.Server.StartGameClicked; startButton.UserData = "startButton"; @@ -285,7 +287,7 @@ namespace Subsurface if (playerFrame.children.Find(c => c.UserData as string == "playyourself") == null) { - var playYourself = new GUITickBox(new Rectangle(-30, -30, 20, 20), "Play yourself", Alignment.TopLeft, playerFrame); + var playYourself = new GUITickBox(new Rectangle(-10, -10, 20, 20), "Play yourself", Alignment.TopLeft, playerFrame); playYourself.Selected = GameMain.Server.CharacterInfo != null; playYourself.OnSelected = TogglePlayYourself; playYourself.UserData = "playyourself"; @@ -307,34 +309,34 @@ namespace Subsurface if (IsServer && GameMain.Server != null) { - var playYourself = new GUITickBox(new Rectangle(-30, -30, 20, 20), "Play yourself", Alignment.TopLeft, playerFrame); + var playYourself = new GUITickBox(new Rectangle(-10, -10, 20, 20), "Play yourself", Alignment.TopLeft, playerFrame); playYourself.Selected = GameMain.Server.CharacterInfo != null; playYourself.OnSelected = TogglePlayYourself; playYourself.UserData = "playyourself"; } - new GUITextBlock(new Rectangle(60, 0, 200, 30), "Name: ", GUI.Style, playerFrame); + new GUITextBlock(new Rectangle(60, 30, 200, 30), "Name: ", GUI.Style, playerFrame); - GUITextBox playerName = new GUITextBox(new Rectangle(60, 30, 0, 20), + GUITextBox playerName = new GUITextBox(new Rectangle(60, 55, 0, 20), Alignment.TopLeft, GUI.Style, playerFrame); playerName.Text = characterInfo.Name; playerName.OnEnter += ChangeCharacterName; - new GUITextBlock(new Rectangle(0, 70, 200, 30), "Gender: ", GUI.Style, playerFrame); + new GUITextBlock(new Rectangle(0, 100, 200, 30), "Gender: ", GUI.Style, playerFrame); - GUIButton maleButton = new GUIButton(new Rectangle(0, 100, 70, 20), "Male", + GUIButton maleButton = new GUIButton(new Rectangle(70, 100, 60, 20), "Male", Alignment.TopLeft, GUI.Style, playerFrame); maleButton.UserData = Gender.Male; maleButton.OnClicked += SwitchGender; - GUIButton femaleButton = new GUIButton(new Rectangle(90, 100, 70, 20), "Female", + GUIButton femaleButton = new GUIButton(new Rectangle(140, 100, 60, 20), "Female", Alignment.TopLeft, GUI.Style, playerFrame); femaleButton.UserData = Gender.Female; femaleButton.OnClicked += SwitchGender; new GUITextBlock(new Rectangle(0, 150, 200, 30), "Job preferences:", GUI.Style, playerFrame); - jobList = new GUIListBox(new Rectangle(0, 180, 250, 0), GUI.Style, playerFrame); + jobList = new GUIListBox(new Rectangle(0, 180, 0, 0), GUI.Style, playerFrame); jobList.Enabled = false; @@ -393,12 +395,12 @@ namespace Subsurface { if (GameMain.Server != null) GameMain.Server.UpdateNetLobby(obj); - Submarine sub = (Submarine)obj; + //Submarine sub = (Submarine)obj; //submarine already loaded - if (Submarine.Loaded != null && sub.FilePath == Submarine.Loaded.FilePath) return true; + //if (Submarine.Loaded != null && sub.FilePath == Submarine.Loaded.FilePath) return true; - sub.Load(); + //sub.Load(); return true; } @@ -538,7 +540,7 @@ namespace Subsurface GUIComponent existing = playerFrame.FindChild("playerhead"); if (existing != null) playerFrame.RemoveChild(existing); - GUIImage image = new GUIImage(new Rectangle(0, 0, 30, 30), characterInfo.HeadSprite, Alignment.TopLeft, playerFrame); + GUIImage image = new GUIImage(new Rectangle(0, 40, 30, 30), characterInfo.HeadSprite, Alignment.TopLeft, playerFrame); image.UserData = "playerhead"; } @@ -609,7 +611,7 @@ namespace Subsurface if (jobPrefab == null) return false; jobInfoFrame = jobPrefab.CreateInfoFrame(); - GUIButton closeButton = new GUIButton(new Rectangle(0,0,100,20), "Close", Alignment.BottomRight, GUI.Style, jobInfoFrame); + GUIButton closeButton = new GUIButton(new Rectangle(0,0,100,20), "Close", Alignment.BottomRight, GUI.Style, jobInfoFrame.children[0]); closeButton.OnClicked = CloseJobInfo; return true; } @@ -663,17 +665,17 @@ namespace Subsurface Submarine map = Submarine.SavedSubmarines.Find(m => m.Name == mapName); if (map == null) { - DebugConsole.ThrowError("The map ''" + mapName + "'' has been selected by the server."); - DebugConsole.ThrowError("Matching map not found in your map folder."); + new GUIMessageBox("Submarine not found!","The submarine ''" + mapName + "'' has been selected by the server. Matching file not found in your map folder."); return false; } else { if (map.MD5Hash.Hash != md5Hash) { - DebugConsole.ThrowError("Your version of the map file ''" + map.Name + "'' doesn't match the server's version!"); - DebugConsole.ThrowError("Your file: " + map.Name + "(MD5 hash : " + map.MD5Hash.Hash + ")"); - DebugConsole.ThrowError("Server's file: " + mapName + "(MD5 hash : " + md5Hash + ")"); + new GUIMessageBox("Submarine not found!", + "Your version of the map file ''" + map.Name + "'' doesn't match the server's version!" + +"\nYour file: " + map.Name + "(MD5 hash : " + map.MD5Hash.Hash + ")" + +"\nServer's file: " + mapName + "(MD5 hash : " + md5Hash + ")"); return false; } else diff --git a/Subsurface/Source/Sounds/OggStream.cs b/Subsurface/Source/Sounds/OggStream.cs index 8050ecc4e..ae4be34ae 100644 --- a/Subsurface/Source/Sounds/OggStream.cs +++ b/Subsurface/Source/Sounds/OggStream.cs @@ -69,7 +69,7 @@ namespace Subsurface.Sounds internal readonly int alSourceId; internal readonly int[] alBufferIds; - readonly int alFilterId; + //readonly int alFilterId; readonly Stream underlyingStream; internal VorbisReader Reader { get; private set; } @@ -99,15 +99,15 @@ namespace Subsurface.Sounds if (ALHelper.Efx.IsInitialized) { - alFilterId = ALHelper.Efx.GenFilter(); - ALHelper.Efx.Filter(alFilterId, EfxFilteri.FilterType, (int)EfxFilterType.Lowpass); - ALHelper.Efx.Filter(alFilterId, EfxFilterf.LowpassGain, 1); - LowPassHFGain = 1; + //alFilterId = ALHelper.Efx.GenFilter(); + //ALHelper.Efx.Filter(alFilterId, EfxFilteri.FilterType, (int)EfxFilterType.Lowpass); + //ALHelper.Efx.Filter(alFilterId, EfxFilterf.LowpassGain, 1); + //ALHelper.Efx.BindFilterToSource(alSourceId, alFilterId); + //LowPassHFGain = 1; } underlyingStream = stream; - Volume = 1; IsLooped = true; } @@ -154,7 +154,7 @@ namespace Subsurface.Sounds } } - public void Play() + public void Play(float volume) { var state = AL.GetSourceState(alSourceId); @@ -172,6 +172,8 @@ namespace Subsurface.Sounds // LogHandler("{", logX++, logY); //#endif AL.SourcePlay(alSourceId); + this.Volume = volume; + try { ALHelper.Check(); @@ -229,20 +231,20 @@ namespace Subsurface.Sounds } } - float lowPassHfGain; - public float LowPassHFGain - { - get { return lowPassHfGain; } - set - { - if (ALHelper.Efx.IsInitialized) - { - ALHelper.Efx.Filter(alFilterId, EfxFilterf.LowpassGainHF, lowPassHfGain = value); - ALHelper.Efx.BindFilterToSource(alSourceId, alFilterId); - ALHelper.Check(); - } - } - } + //float lowPassHfGain; + //public float LowPassHFGain + //{ + // get { return lowPassHfGain; } + // set + // { + // if (ALHelper.Efx.IsInitialized) + // { + // ALHelper.Efx.Filter(alFilterId, EfxFilterf.LowpassGainHF, lowPassHfGain = value); + // ALHelper.Efx.BindFilterToSource(alSourceId, alFilterId); + // ALHelper.Check(); + // } + // } + //} float volume; public float Volume @@ -288,8 +290,8 @@ namespace Subsurface.Sounds AL.DeleteSource(alSourceId); AL.DeleteBuffers(alBufferIds); - if (ALHelper.Efx.IsInitialized) - ALHelper.Efx.DeleteFilter(alFilterId); + //if (ALHelper.Efx.IsInitialized) + // ALHelper.Efx.DeleteFilter(alFilterId); ALHelper.Check(); #if TRACE diff --git a/Subsurface/Source/Sounds/SoundManager.cs b/Subsurface/Source/Sounds/SoundManager.cs index 06cf5f7ff..62c89c6ae 100644 --- a/Subsurface/Source/Sounds/SoundManager.cs +++ b/Subsurface/Source/Sounds/SoundManager.cs @@ -324,9 +324,7 @@ namespace Subsurface.Sounds oggStreamer.AddStream(oggStream); - oggStream.Volume = volume; - - oggStream.Play(); + oggStream.Play(volume); return oggStream; } diff --git a/Subsurface/Subsurface.csproj.user b/Subsurface/Subsurface.csproj.user index c2dd67340..d8060d791 100644 --- a/Subsurface/Subsurface.csproj.user +++ b/Subsurface/Subsurface.csproj.user @@ -9,7 +9,7 @@ en-US false - ShowAllFiles + ProjectFiles diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index 1a110377f..3097c7716 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ