(55f425031) Tutorial outpost visual pass

This commit is contained in:
Joonas Rikkonen
2019-04-29 21:06:26 +03:00
parent 4023fab047
commit 788c51143b
10 changed files with 56 additions and 101 deletions
@@ -47,7 +47,6 @@ namespace Barotrauma
controlled = value; controlled = value;
if (controlled != null) controlled.Enabled = true; if (controlled != null) controlled.Enabled = true;
CharacterHealth.OpenHealthWindow = null; CharacterHealth.OpenHealthWindow = null;
} }
} }
@@ -85,7 +85,8 @@ namespace Barotrauma
{ {
if (character.Inventory != null) if (character.Inventory != null)
{ {
if (!character.LockHands && character.Stun < 0.1f) if (!character.LockHands && character.Stun < 0.1f &&
(character.SelectedConstruction == null || character.SelectedConstruction.GetComponent<Controller>() == null))
{ {
character.Inventory.Update(deltaTime, cam); character.Inventory.Update(deltaTime, cam);
} }
@@ -320,6 +321,7 @@ namespace Barotrauma
} }
if (character.Inventory != null && !character.LockHands) if (character.Inventory != null && !character.LockHands)
{ {
character.Inventory.Locked = (character.SelectedConstruction != null && character.SelectedConstruction.GetComponent<Controller>() != null);
character.Inventory.DrawOwn(spriteBatch); character.Inventory.DrawOwn(spriteBatch);
character.Inventory.CurrentLayout = CharacterHealth.OpenHealthWindow == null && character.SelectedCharacter == null ? character.Inventory.CurrentLayout = CharacterHealth.OpenHealthWindow == null && character.SelectedCharacter == null ?
CharacterInventory.Layout.Default : CharacterInventory.Layout.Default :
@@ -793,7 +793,7 @@ namespace Barotrauma
base.Draw(spriteBatch); base.Draw(spriteBatch);
if (hideButton != null && hideButton.Visible) if (hideButton != null && hideButton.Visible && !Locked)
{ {
hideButton.DrawManually(spriteBatch, alsoChildren: true); hideButton.DrawManually(spriteBatch, alsoChildren: true);
} }
@@ -835,6 +835,7 @@ namespace Barotrauma
color = Color.White; color = Color.White;
highlightedQuickUseSlot = slots[i]; highlightedQuickUseSlot = slots[i];
} }
if (Locked) { color *= 0.3f; }
var quickUseIndicator = Items[i].AllowedSlots.Any(a => a == InvSlotType.Any) ? var quickUseIndicator = Items[i].AllowedSlots.Any(a => a == InvSlotType.Any) ?
EquipIndicator : DropIndicator; EquipIndicator : DropIndicator;
@@ -820,8 +820,9 @@ namespace Barotrauma
else else
{ {
Sprite slotSprite = slot.SlotSprite ?? slotSpriteSmall; Sprite slotSprite = slot.SlotSprite ?? slotSpriteSmall;
Color slotColor = slot.IsHighlighted ? Color.White : Color.White * 0.8f;
spriteBatch.Draw(slotSprite.Texture, rect, slotSprite.SourceRect, slot.IsHighlighted ? Color.White : Color.White * 0.8f); if (inventory != null && inventory.Locked) { slotColor = Color.Gray * 0.5f; }
spriteBatch.Draw(slotSprite.Texture, rect, slotSprite.SourceRect, slotColor);
if (item != null && drawItem) if (item != null && drawItem)
{ {
@@ -873,14 +874,17 @@ namespace Barotrauma
} }
indicatorSprite.Draw(spriteBatch, containedIndicatorArea.Center.ToVector2(), indicatorSprite.Draw(spriteBatch, containedIndicatorArea.Center.ToVector2(),
Color.DarkGray * 0.9f, (inventory != null && inventory.Locked) ? Color.DarkGray * 0.5f : Color.DarkGray * 0.9f,
origin: indicatorSprite.size / 2, origin: indicatorSprite.size / 2,
rotate: 0.0f, rotate: 0.0f,
scale: indicatorScale); scale: indicatorScale);
Color indicatorColor = ToolBox.GradientLerp(containedState, Color.Red, Color.Orange, Color.Green);
if (inventory != null && inventory.Locked) { indicatorColor *= 0.5f; }
spriteBatch.Draw(indicatorSprite.Texture, containedIndicatorArea.Center.ToVector2(), spriteBatch.Draw(indicatorSprite.Texture, containedIndicatorArea.Center.ToVector2(),
sourceRectangle: new Rectangle(indicatorSprite.SourceRect.Location, new Point((int)(indicatorSprite.SourceRect.Width * containedState), indicatorSprite.SourceRect.Height)), sourceRectangle: new Rectangle(indicatorSprite.SourceRect.Location, new Point((int)(indicatorSprite.SourceRect.Width * containedState), indicatorSprite.SourceRect.Height)),
color: ToolBox.GradientLerp(containedState, Color.Red, Color.Orange, Color.Green), color: indicatorColor,
rotation: 0.0f, rotation: 0.0f,
origin: indicatorSprite.size / 2, origin: indicatorSprite.size / 2,
scale: indicatorScale, scale: indicatorScale,
@@ -920,6 +924,7 @@ namespace Barotrauma
} }
Color spriteColor = sprite == item.Sprite ? item.GetSpriteColor() : item.GetInventoryIconColor(); Color spriteColor = sprite == item.Sprite ? item.GetSpriteColor() : item.GetInventoryIconColor();
if (inventory != null && inventory.Locked) { spriteColor *= 0.5f; }
if (CharacterHealth.OpenHealthWindow != null && !item.UseInHealthInterface) if (CharacterHealth.OpenHealthWindow != null && !item.UseInHealthInterface)
{ {
spriteColor = Color.Lerp(spriteColor, Color.TransparentBlack, 0.5f); spriteColor = Color.Lerp(spriteColor, Color.TransparentBlack, 0.5f);
@@ -931,7 +936,10 @@ namespace Barotrauma
sprite.Draw(spriteBatch, itemPos, spriteColor, rotation, scale); sprite.Draw(spriteBatch, itemPos, spriteColor, rotation, scale);
} }
if (inventory != null && Character.Controlled?.Inventory == inventory && slot.QuickUseKey != Keys.None) if (inventory != null &&
!inventory.Locked &&
Character.Controlled?.Inventory == inventory &&
slot.QuickUseKey != Keys.None)
{ {
GUI.DrawString(spriteBatch, rect.Location.ToVector2(), GUI.DrawString(spriteBatch, rect.Location.ToVector2(),
slot.QuickUseKey.ToString().Substring(1, 1), slot.QuickUseKey.ToString().Substring(1, 1),
@@ -1,6 +1,9 @@
using Barotrauma.Extensions; using Barotrauma.Extensions;
using Barotrauma.Lights; using Barotrauma.Lights;
using Barotrauma.Networking; using Barotrauma.Networking;
using FarseerPhysics;
using FarseerPhysics.Dynamics;
using FarseerPhysics.Dynamics.Contacts;
using Lidgren.Network; using Lidgren.Network;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
@@ -165,6 +168,20 @@ namespace Barotrauma
{ {
Vector2 pos = ConvertUnits.ToDisplayUnits(f2.Body.Position); Vector2 pos = ConvertUnits.ToDisplayUnits(f2.Body.Position);
int section = FindSectionIndex(pos);
if (section > -1)
{
Vector2 normal = contact.Manifold.LocalNormal;
float impact = Vector2.Dot(f2.Body.LinearVelocity, -normal) * f2.Body.Mass * 0.1f;
if (impact > 10.0f)
{
SoundPlayer.PlayDamageSound("StructureBlunt", impact, SectionPosition(section, true), tags: Tags);
}
}
}
}
public override bool IsVisible(Rectangle worldView) public override bool IsVisible(Rectangle worldView)
{ {
Rectangle worldRect = WorldRect; Rectangle worldRect = WorldRect;
@@ -238,7 +238,7 @@ namespace Barotrauma
} }
float ambienceVolume = 0.8f; float ambienceVolume = 0.8f;
if (Character.Controlled != null) if (Character.Controlled != null && !Character.Controlled.Removed)
{ {
AnimController animController = Character.Controlled.AnimController; AnimController animController = Character.Controlled.AnimController;
if (animController.HeadInWater) if (animController.HeadInWater)
@@ -493,7 +493,7 @@ namespace Barotrauma
} }
else else
{ {
if (!IsLatchedOnSub) if (!IsProperlyLatchedOnSub)
{ {
UpdateWallTarget(); UpdateWallTarget();
} }
@@ -552,7 +552,7 @@ namespace Barotrauma
{ {
WallSection section = wallTarget.Structure.GetSection(wallTarget.SectionIndex); WallSection section = wallTarget.Structure.GetSection(wallTarget.SectionIndex);
Vector2 targetPos = wallTarget.Structure.SectionPosition(wallTarget.SectionIndex, true); Vector2 targetPos = wallTarget.Structure.SectionPosition(wallTarget.SectionIndex, true);
if (section?.gap != null && SteerThroughGap(wallTarget.Structure, section, targetPos, deltaTime)) if (section?.gap != null && section.gap.IsRoomToRoom && SteerThroughGap(wallTarget.Structure, section, targetPos, deltaTime))
{ {
return; return;
} }
@@ -791,6 +791,7 @@ namespace Barotrauma
{ {
UpdateLimbAttack(deltaTime, AttackingLimb, attackSimPos, distance); UpdateLimbAttack(deltaTime, AttackingLimb, attackSimPos, distance);
} }
return false;
} }
private bool SteerThroughGap(Structure wall, WallSection section, Vector2 targetWorldPos, float deltaTime) private bool SteerThroughGap(Structure wall, WallSection section, Vector2 targetWorldPos, float deltaTime)
@@ -1049,38 +1050,19 @@ namespace Barotrauma
private bool IsProperlyLatchedOnSub => LatchOntoAI != null && LatchOntoAI.IsAttachedToSub && SelectedAiTarget?.Entity == wallTarget?.Structure; private bool IsProperlyLatchedOnSub => LatchOntoAI != null && LatchOntoAI.IsAttachedToSub && SelectedAiTarget?.Entity == wallTarget?.Structure;
private bool IsProperlyLatchedOnSub => LatchOntoAI != null && LatchOntoAI.IsAttachedToSub && SelectedAiTarget?.Entity == wallTarget?.Structure;
//goes through all the AItargets, evaluates how preferable it is to attack the target, //goes through all the AItargets, evaluates how preferable it is to attack the target,
//whether the Character can see/hear the target and chooses the most preferable target within //whether the Character can see/hear the target and chooses the most preferable target within
//sight/hearing range //sight/hearing range
public AITarget UpdateTargets(Character character, out TargetingPriority priority) public AITarget UpdateTargets(Character character, out TargetingPriority priority)
{ {
if (IsLatchedOnSub) if (IsProperlyLatchedOnSub)
{ {
var wall = SelectedAiTarget.Entity as Structure; // If attached to a valid target, just keep the target.
// The target is not a wall or it's not the same as we are attached to -> release // Priority not used in this case.
bool releaseTarget = wall == null || !wall.Bodies.Contains(LatchOntoAI.AttachJoints[0].BodyB); priority = null;
if (!releaseTarget) return SelectedAiTarget;
{
for (int i = 0; i < wall.Sections.Length; i++)
{
if (CanPassThroughHole(wall, i))
{
releaseTarget = true;
}
}
}
if (releaseTarget)
{
SelectedAiTarget = null;
LatchOntoAI.DeattachFromBody();
}
else if (SelectedAiTarget.Entity == wallTarget?.Structure)
{
// If attached to a valid target, just keep the target.
// Priority not used in this case.
priority = null;
return SelectedAiTarget;
}
} }
AITarget newTarget = null; AITarget newTarget = null;
priority = null; priority = null;
@@ -1163,7 +1145,7 @@ namespace Barotrauma
else if (target.Entity != null) else if (target.Entity != null)
{ {
//skip the target if it's a room and the character is already inside a sub //skip the target if it's a room and the character is already inside a sub
if (character.CurrentHull != null && target.Entity is Hull) { continue; } if (character.CurrentHull != null && target.Entity is Hull) continue;
Door door = null; Door door = null;
if (target.Entity is Item item) if (target.Entity is Item item)
@@ -1192,13 +1174,6 @@ namespace Barotrauma
// Ignore structures that doesn't have a body (not walls) // Ignore structures that doesn't have a body (not walls)
continue; continue;
} }
if (s.IsPlatform)
{
continue;
}
float wallMaxHealth = 400; // Anything more than this is ignored -> 200 = 1
// Prefer weaker targets.
valueModifier = MathHelper.Lerp(2, 0, MathHelper.Clamp(s.Health / wallMaxHealth, 0, 1));
// Ignore walls when inside. // Ignore walls when inside.
valueModifier = character.CurrentHull == null ? 1 : 0; valueModifier = character.CurrentHull == null ? 1 : 0;
if (aggressiveBoarding) if (aggressiveBoarding)
@@ -2551,24 +2551,14 @@ namespace Barotrauma
if (info != null) { info.Remove(); } if (info != null) { info.Remove(); }
#if CLIENT
GameMain.GameSession?.CrewManager?.RemoveCharacter(this);
#endif
#if CLIENT
GameMain.GameSession?.CrewManager?.RemoveCharacter(this);
#endif
#if CLIENT
GameMain.GameSession?.CrewManager?.RemoveCharacter(this);
#endif
#if CLIENT #if CLIENT
GameMain.GameSession?.CrewManager?.RemoveCharacter(this); GameMain.GameSession?.CrewManager?.RemoveCharacter(this);
#endif #endif
CharacterList.Remove(this); CharacterList.Remove(this);
if (Controlled == this) { Controlled = null; }
if (Inventory != null) if (Inventory != null)
{ {
foreach (Item item in Inventory.Items) foreach (Item item in Inventory.Items)
@@ -34,33 +34,14 @@ namespace Barotrauma
{ {
Level.Loaded.TryGetInterestingPosition(true, Level.PositionType.MainPath, Level.Loaded.Size.X * 0.3f, out Vector2 spawnPos); Level.Loaded.TryGetInterestingPosition(true, Level.PositionType.MainPath, Level.Loaded.Size.X * 0.3f, out Vector2 spawnPos);
//bool isClient = GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient; bool isClient = GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient;
//for (int i = 0; i < monsterCount; i++)
//{
// monsters.Add(Character.Create(monsterFile, spawnPos, ToolBox.RandomSeed(8), null, isClient, true, false));
//}
//monsters.ForEach(m => m.Enabled = false);
//SwarmBehavior.CreateSwarm(monsters.Cast<AICharacter>());
//sonarPositions.Add(spawnPos);
float offsetAmount = 500;
for (int i = 0; i < monsterCount; i++) for (int i = 0; i < monsterCount; i++)
{ {
CoroutineManager.InvokeAfter(() => monsters.Add(Character.Create(monsterFile, spawnPos, ToolBox.RandomSeed(8), null, isClient, true, false));
{
bool isClient = GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient;
var monster = Character.Create(monsterFile, spawnPos + Rand.Vector(offsetAmount, Rand.RandSync.Server), i.ToString(), null, isClient, true, true);
monster.Enabled = false;
monsters.Add(monster);
if (monsters.Count == monsterCount)
{
//this will do nothing if the monsters have no swarm behavior defined,
//otherwise it'll make the spawned characters act as a swarm
SwarmBehavior.CreateSwarm(monsters.Cast<AICharacter>());
sonarPositions.Add(spawnPos);
}
}, Rand.Range(0f, monsterCount / 2, Rand.RandSync.Server));
} }
monsters.ForEach(m => m.Enabled = false);
SwarmBehavior.CreateSwarm(monsters.Cast<AICharacter>());
sonarPositions.Add(spawnPos);
} }
public override void Update(float deltaTime) public override void Update(float deltaTime)
@@ -636,24 +636,6 @@ namespace Barotrauma
if (character.DisableImpactDamageTimer > 0.0f || ((Limb)f2.Body.UserData).Mass < 100.0f) return true; if (character.DisableImpactDamageTimer > 0.0f || ((Limb)f2.Body.UserData).Mass < 100.0f) return true;
} }
if (!Prefab.Platform && Prefab.StairDirection == Direction.None)
{
Vector2 pos = ConvertUnits.ToDisplayUnits(f2.Body.Position);
int section = FindSectionIndex(pos);
if (section > -1)
{
Vector2 normal = contact.Manifold.LocalNormal;
float impact = Vector2.Dot(f2.Body.LinearVelocity, -normal) * f2.Body.Mass * 0.1f;
if (impact < 10.0f) return true;
#if CLIENT
SoundPlayer.PlayDamageSound("StructureBlunt", impact, SectionPosition(section, true), tags: Tags);
#endif
AddDamage(section, impact);
}
}
OnImpactProjSpecific(f1, f2, contact); OnImpactProjSpecific(f1, f2, contact);
return true; return true;