- CrewCommander key can be changed
- Improved logic for teleporting character in/out the sub - changed Turret.AIOperate to use the new coordinate system - neutralballastlevel option in steering - crewmanager UI works properly with different numbers of crew members - fixed obstructvision "twitching" when moving in/out the sub - resetting steering velocity when AI is waiting - GetItem AIObjective ignores items outside the sub - crew has the "dismissed" order by default -
This commit is contained in:
Binary file not shown.
@@ -15,6 +15,8 @@ namespace Barotrauma
|
||||
GUIFrame frame;
|
||||
//GUIListBox characterList;
|
||||
|
||||
private int characterFrameBottom;
|
||||
|
||||
public GUIFrame Frame
|
||||
{
|
||||
get { return IsOpen ? frame : null; }
|
||||
@@ -29,7 +31,6 @@ namespace Barotrauma
|
||||
public CrewCommander(CrewManager crewManager)
|
||||
{
|
||||
this.crewManager = crewManager;
|
||||
|
||||
}
|
||||
|
||||
public void ToggleGUIFrame()
|
||||
@@ -47,20 +48,19 @@ namespace Barotrauma
|
||||
{
|
||||
frame = new GUIFrame(Rectangle.Empty, Color.Black * 0.6f);
|
||||
frame.Padding = new Vector4(200.0f, 100.0f, 200.0f, 100.0f);
|
||||
|
||||
|
||||
//UpdateCharacters();
|
||||
|
||||
int buttonWidth = 130;
|
||||
int spacing = 20;
|
||||
|
||||
int y = 250;
|
||||
int y = 50;
|
||||
|
||||
for (int n = 0; n<2; n++)
|
||||
{
|
||||
|
||||
{
|
||||
List<Order> orders = (n==0) ?
|
||||
Order.PrefabList.FindAll(o => o.ItemComponentType == null) :
|
||||
Order.PrefabList.FindAll(o=> o.ItemComponentType!=null);
|
||||
Order.PrefabList.FindAll(o=> o.ItemComponentType != null);
|
||||
|
||||
int startX = (int)-(buttonWidth * orders.Count + spacing * (orders.Count - 1)) / 2;
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Barotrauma
|
||||
|
||||
public void UpdateCharacters()
|
||||
{
|
||||
if (frame == null) CreateGUIFrame();
|
||||
CreateGUIFrame();
|
||||
|
||||
List<GUIComponent> prevCharacterFrames = new List<GUIComponent>();
|
||||
foreach (GUIComponent child in frame.children)
|
||||
@@ -134,18 +134,19 @@ namespace Barotrauma
|
||||
|
||||
List<Character> aliveCharacters = crewManager.characters.FindAll(c => !c.IsDead);
|
||||
|
||||
characterFrameBottom = 0;
|
||||
|
||||
int charactersPerRow = 4;
|
||||
|
||||
int spacing = 5;
|
||||
|
||||
|
||||
int rows = (int)Math.Ceiling((double)aliveCharacters.Count / charactersPerRow);
|
||||
|
||||
int i = 0;
|
||||
foreach (Character character in aliveCharacters)
|
||||
{
|
||||
int rowCharacterCount = Math.Min(charactersPerRow, aliveCharacters.Count);
|
||||
if (aliveCharacters.Count - i < charactersPerRow-1) rowCharacterCount = aliveCharacters.Count % charactersPerRow;
|
||||
//if (i >= aliveCharacters.Count - charactersPerRow && aliveCharacters.Count % charactersPerRow > 0) rowCharacterCount = aliveCharacters.Count % charactersPerRow;
|
||||
|
||||
// rowCharacterCount = Math.Min(rowCharacterCount, aliveCharacters.Count - i);
|
||||
int startX = (int)-(150 * rowCharacterCount + spacing * (rowCharacterCount - 1)) / 2;
|
||||
@@ -159,12 +160,13 @@ namespace Barotrauma
|
||||
characterButton.UserData = character;
|
||||
characterButton.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
||||
|
||||
characterButton.Color = Character.Controlled == character ? Color.Gold * 0.3f : Color.Black * 0.5f;
|
||||
characterButton.Color = Character.Controlled == character ? Color.Gold * 0.2f : Color.Black * 0.5f;
|
||||
characterButton.HoverColor = Color.LightGray * 0.5f;
|
||||
characterButton.SelectedColor = Color.Gold * 0.5f;
|
||||
characterButton.SelectedColor = Color.Gold * 0.6f;
|
||||
characterButton.OutlineColor = Color.LightGray * 0.8f;
|
||||
|
||||
|
||||
characterFrameBottom = Math.Max(characterFrameBottom, characterButton.Rect.Bottom);
|
||||
|
||||
string name = character.Info.Name;
|
||||
if (character.Info.Job != null) name += '\n' + "(" + character.Info.Job.Name + ")";
|
||||
|
||||
@@ -187,6 +189,16 @@ namespace Barotrauma
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
foreach (GUIComponent child in frame.children)
|
||||
{
|
||||
if (!(child.UserData is Order)) continue;
|
||||
|
||||
Rectangle rect = child.Rect;
|
||||
rect.Y += characterFrameBottom;
|
||||
|
||||
child.Rect = rect;
|
||||
}
|
||||
}
|
||||
|
||||
private bool SetOrder(GUIButton button, object userData)
|
||||
@@ -225,12 +237,22 @@ namespace Barotrauma
|
||||
var existingOrder = characterFrame.children.Find(c => c.UserData as Order != null);
|
||||
if (existingOrder != null) characterFrame.RemoveChild(existingOrder);
|
||||
|
||||
var orderFrame = new GUIFrame(new Rectangle(0, characterFrame.Rect.Height, 0, 30 + order.Options.Length * 15), null, characterFrame);
|
||||
orderFrame.OutlineColor = Color.LightGray * 0.8f;
|
||||
var orderFrame = new GUIFrame(new Rectangle(-5, characterFrame.Rect.Height, characterFrame.Rect.Width, 30 + order.Options.Length * 15), null, characterFrame);
|
||||
orderFrame.OutlineColor = Color.LightGray * 0.5f;
|
||||
orderFrame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
||||
orderFrame.UserData = order;
|
||||
|
||||
var img = new GUIImage(new Rectangle(0, 0, 20, 20), order.SymbolSprite, Alignment.TopLeft, orderFrame);
|
||||
img.Scale = 20.0f / img.SourceRect.Width;
|
||||
img.Color = order.Color;
|
||||
img.CanBeFocused = false;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 20), order.DoingText, GUI.Style, Alignment.TopLeft, Alignment.TopCenter, orderFrame);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var optionList = new GUIListBox(new Rectangle(0, 20, 0, 80), Color.Transparent, null, orderFrame);
|
||||
optionList.UserData = order;
|
||||
|
||||
|
||||
@@ -289,7 +289,7 @@ namespace Barotrauma
|
||||
updateTargetsTimer = Math.Min(updateTargetsTimer, 0.1f);
|
||||
coolDownTimer *= 0.1f;
|
||||
|
||||
if (amount > 1.0f && attackWhenProvoked)
|
||||
if (amount > 0.1f && attackWhenProvoked)
|
||||
{
|
||||
attackHumans = 100.0f;
|
||||
attackRooms = 100.0f;
|
||||
|
||||
@@ -38,6 +38,14 @@ namespace Barotrauma
|
||||
objectiveManager.AddObjective(new AIObjectiveIdle(c));
|
||||
|
||||
updateObjectiveTimer = Rand.Range(0.0f, UpdateObjectiveInterval);
|
||||
|
||||
if (GameMain.GameSession!=null && GameMain.GameSession.CrewManager!=null)
|
||||
{
|
||||
CurrentOrder = Order.PrefabList.Find(o => o.Name.ToLower() == "dismissed");
|
||||
objectiveManager.SetOrder(CurrentOrder, "");
|
||||
GameMain.GameSession.CrewManager.SetCharacterOrder(Character, CurrentOrder);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void Update(float deltaTime)
|
||||
@@ -87,6 +95,8 @@ namespace Barotrauma
|
||||
if (Character.IsKeyDown(InputType.Aim))
|
||||
{
|
||||
Character.AnimController.TargetDir = Character.CursorPosition.X > Character.Position.X ? Direction.Right : Direction.Left;
|
||||
if (Character.SelectedConstruction != null) Character.SelectedConstruction.SecondaryUse(deltaTime, Character);
|
||||
|
||||
}
|
||||
else if (Math.Abs(Character.AnimController.TargetMovement.X) > 0.1f && !Character.AnimController.InWater)
|
||||
{
|
||||
@@ -110,6 +120,8 @@ namespace Barotrauma
|
||||
CurrentOrderOption = option;
|
||||
CurrentOrder = order;
|
||||
objectiveManager.SetOrder(order, option);
|
||||
|
||||
GameMain.GameSession.CrewManager.SetCharacterOrder(Character, order);
|
||||
}
|
||||
|
||||
public override void SelectTarget(AITarget target)
|
||||
|
||||
@@ -101,6 +101,9 @@ namespace Barotrauma
|
||||
{
|
||||
currSearchIndex++;
|
||||
|
||||
//don't try to get items from outside the sub
|
||||
if (Item.ItemList[currSearchIndex].CurrentHull == null) continue;
|
||||
|
||||
if (!Item.ItemList[currSearchIndex].HasTag(itemName) && Item.ItemList[currSearchIndex].Name != itemName) continue;
|
||||
if (IgnoreContainedItems && Item.ItemList[currSearchIndex].Container != null) continue;
|
||||
if (Item.ItemList[currSearchIndex].Inventory is CharacterInventory) continue;
|
||||
|
||||
@@ -59,7 +59,12 @@ namespace Barotrauma
|
||||
|
||||
protected override void Act(float deltaTime)
|
||||
{
|
||||
if (target == character) return;
|
||||
if (target == character)
|
||||
{
|
||||
character.AIController.SteeringManager.Reset();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
waitUntilPathUnreachable -= deltaTime;
|
||||
|
||||
@@ -116,7 +121,7 @@ namespace Barotrauma
|
||||
|
||||
completed = completed || Vector2.Distance(target != null ? target.SimPosition : targetPos, character.SimPosition) < allowedDistance;
|
||||
|
||||
if (completed) character.AIController.SteeringManager.SteeringManual(0.0f, -character.AIController.Steering);
|
||||
if (completed) character.AIController.SteeringManager.Reset();
|
||||
|
||||
return completed;
|
||||
}
|
||||
|
||||
@@ -70,6 +70,8 @@ namespace Barotrauma
|
||||
|
||||
public void SetOrder(Order order, string option)
|
||||
{
|
||||
if (order == null) return;
|
||||
|
||||
currentObjective = null;
|
||||
|
||||
switch (order.Name.ToLower())
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Barotrauma
|
||||
{
|
||||
class AIObjectiveOperateItem : AIObjective
|
||||
{
|
||||
private ItemComponent component;
|
||||
private ItemComponent component, controller;
|
||||
|
||||
private Entity operateTarget;
|
||||
|
||||
@@ -33,14 +33,14 @@ namespace Barotrauma
|
||||
public AIObjectiveOperateItem(ItemComponent item, Character character, string option, Entity operateTarget = null, bool useController = false)
|
||||
:base (character, option)
|
||||
{
|
||||
component = item;
|
||||
this.component = item;
|
||||
|
||||
this.operateTarget = operateTarget;
|
||||
|
||||
if (useController)
|
||||
{
|
||||
var controllers = item.Item.GetConnectedComponents<Controller>();
|
||||
if (controllers.Any()) component = controllers[0];
|
||||
if (controllers.Any()) controller = controllers[0];
|
||||
}
|
||||
|
||||
|
||||
@@ -49,21 +49,23 @@ namespace Barotrauma
|
||||
|
||||
protected override void Act(float deltaTime)
|
||||
{
|
||||
if (component.CanBeSelected)
|
||||
ItemComponent target = controller == null ? component : controller;
|
||||
|
||||
if (target.CanBeSelected)
|
||||
{
|
||||
if (Vector2.Distance(character.Position, component.Item.Position) < component.Item.PickDistance
|
||||
|| component.Item.IsInsideTrigger(character.WorldPosition))
|
||||
if (Vector2.Distance(character.Position, target.Item.Position) < target.Item.PickDistance
|
||||
|| target.Item.IsInsideTrigger(character.WorldPosition))
|
||||
{
|
||||
if (character.SelectedConstruction != component.Item && component.CanBeSelected)
|
||||
if (character.SelectedConstruction != target.Item && target.CanBeSelected)
|
||||
{
|
||||
component.Item.Pick(character, false, true);
|
||||
target.Item.Pick(character, false, true);
|
||||
}
|
||||
|
||||
if (component.AIOperate(deltaTime, character, this)) isCompleted = true;
|
||||
return;
|
||||
}
|
||||
|
||||
AddSubObjective(new AIObjectiveGoTo(component.Item, character));
|
||||
AddSubObjective(new AIObjectiveGoTo(target.Item, character));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -55,6 +55,11 @@ namespace Barotrauma
|
||||
steering += velocity;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
steering = Vector2.Zero;
|
||||
}
|
||||
|
||||
public virtual void Update(float speed = 1.0f)
|
||||
{
|
||||
float steeringSpeed = steering.Length();
|
||||
|
||||
@@ -553,10 +553,12 @@ namespace Barotrauma
|
||||
if (newHull == null && currentHull.Submarine != null)
|
||||
{
|
||||
SetPosition(refLimb.SimPosition + ConvertUnits.ToSimUnits(currentHull.Submarine.Position));
|
||||
character.CursorPosition += currentHull.Submarine.Position;
|
||||
}
|
||||
else if (currentHull == null && newHull != null && newHull.Submarine != null)
|
||||
{
|
||||
SetPosition(refLimb.SimPosition - ConvertUnits.ToSimUnits(newHull.Submarine.Position));
|
||||
character.CursorPosition -= newHull.Submarine.Position;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,8 +71,8 @@ namespace Barotrauma
|
||||
|
||||
this.sourceRect = sourceRect;
|
||||
|
||||
if (parent != null)
|
||||
parent.AddChild(this);
|
||||
if (parent != null) parent.AddChild(this);
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch)
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Barotrauma
|
||||
private int money;
|
||||
|
||||
private GUIFrame guiFrame;
|
||||
private GUIListBox listBox;
|
||||
private GUIListBox listBox, orderListBox;
|
||||
|
||||
private bool crewFrameOpen;
|
||||
private GUIButton crewButton;
|
||||
@@ -37,11 +37,15 @@ namespace Barotrauma
|
||||
|
||||
guiFrame = new GUIFrame(new Rectangle(0, 50, 150, 450), Color.Transparent);
|
||||
|
||||
listBox = new GUIListBox(new Rectangle(0, 30, 150, 0), Color.Transparent, null, guiFrame);
|
||||
listBox = new GUIListBox(new Rectangle(45, 30, 150, 0), Color.Transparent, null, guiFrame);
|
||||
listBox.ScrollBarEnabled = false;
|
||||
listBox.OnSelected = SelectCharacter;
|
||||
|
||||
crewButton = new GUIButton(new Rectangle(0, 00, 100, 20), "Crew", GUI.Style, guiFrame);
|
||||
orderListBox = new GUIListBox(new Rectangle(5, 30, 30, 0), Color.Transparent, null, guiFrame);
|
||||
orderListBox.ScrollBarEnabled = false;
|
||||
orderListBox.OnSelected = SelectCharacterOrder;
|
||||
|
||||
crewButton = new GUIButton(new Rectangle(5, 0, 100, 20), "Crew", GUI.Style, guiFrame);
|
||||
crewButton.OnClicked = ToggleCrewFrame;
|
||||
|
||||
commander = new CrewCommander(this);
|
||||
@@ -78,6 +82,31 @@ namespace Barotrauma
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetCharacterOrder(Character character, Order order)
|
||||
{
|
||||
if (order == null) return;
|
||||
|
||||
var characterFrame = listBox.FindChild(character);
|
||||
|
||||
if (characterFrame == null) return;
|
||||
|
||||
int characterIndex = listBox.children.IndexOf(characterFrame);
|
||||
|
||||
orderListBox.children[characterIndex].ClearChildren();
|
||||
|
||||
var img = new GUIImage(new Rectangle(0, 0, 30, 30), order.SymbolSprite, Alignment.Center, orderListBox.children[characterIndex]);
|
||||
img.Scale = 30.0f / img.SourceRect.Width;
|
||||
img.Color = order.Color;
|
||||
img.ToolTip ="Order: "+ order.Name;
|
||||
}
|
||||
|
||||
public bool SelectCharacterOrder(GUIComponent component, object selection)
|
||||
{
|
||||
GameMain.GameSession.CrewManager.commander.ToggleGUIFrame();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void AddCharacter(Character character)
|
||||
{
|
||||
characters.Add(character);
|
||||
@@ -94,11 +123,16 @@ namespace Barotrauma
|
||||
|
||||
character.Info.CreateCharacterFrame(listBox, character.Info.Name.Replace(' ', '\n'), character);
|
||||
|
||||
//GUIFrame frame = new GUIFrame(new Rectangle(0, 0, 0, 40), Color.Transparent, null, listBox);
|
||||
//frame.UserData = character;
|
||||
GUIFrame frame = new GUIFrame(new Rectangle(0, 0, 40, 40), Color.Transparent, null, orderListBox);
|
||||
frame.UserData = character;
|
||||
//frame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
||||
//frame.HoverColor = Color.LightGray * 0.5f;
|
||||
//frame.SelectedColor = Color.Gold * 0.5f;
|
||||
frame.HoverColor = Color.LightGray * 0.5f;
|
||||
frame.SelectedColor = Color.Gold * 0.5f;
|
||||
|
||||
var ai = character.AIController as HumanAIController;
|
||||
SetCharacterOrder(character, ai.CurrentOrder);
|
||||
|
||||
|
||||
|
||||
//string name = character.Info.Name.Replace(' ', '\n');
|
||||
|
||||
@@ -118,8 +152,17 @@ namespace Barotrauma
|
||||
{
|
||||
guiFrame.Update(deltaTime);
|
||||
|
||||
if (PlayerInput.KeyHit(Microsoft.Xna.Framework.Input.Keys.C))
|
||||
|
||||
if (GameMain.Config.KeyBind(InputType.CrewOrders).IsHit())
|
||||
{
|
||||
//deselect construction unless it's the ladders the character is climbing
|
||||
if (!commander.IsOpen && Character.Controlled != null &&
|
||||
Character.Controlled.SelectedConstruction != null &&
|
||||
Character.Controlled.SelectedConstruction.GetComponent<Items.Components.Ladder>() == null)
|
||||
{
|
||||
Character.Controlled.SelectedConstruction = null;
|
||||
}
|
||||
|
||||
//only allow opening the command UI if there are AICharacters in the crew
|
||||
if (commander.IsOpen || characters.Any(c => c is AICharacter)) commander.ToggleGUIFrame();
|
||||
}
|
||||
@@ -143,7 +186,6 @@ namespace Barotrauma
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
public void CreateCrewFrame(List<Character> crew)
|
||||
{
|
||||
int width = 600, height = 400;
|
||||
|
||||
@@ -57,10 +57,7 @@ namespace Barotrauma
|
||||
if (GameMain.GameSession != null && GameMain.GameSession.Map != null)
|
||||
{
|
||||
if (GameMain.GameSession.Map.CurrentLocation!=null)
|
||||
text = text.Replace("[location1]", GameMain.GameSession.Map.CurrentLocation.Name);
|
||||
|
||||
if (GameMain.GameSession.Map.SelectedLocation!= null)
|
||||
text = text.Replace("[location2]", GameMain.GameSession.Map.SelectedLocation.Name);
|
||||
text = text.Replace("[location]", GameMain.GameSession.Map.CurrentLocation.Name);
|
||||
}
|
||||
|
||||
return text;
|
||||
|
||||
@@ -136,7 +136,11 @@ namespace Barotrauma
|
||||
keyMapping[(int)InputType.Left] = new KeyOrMouse(Keys.A);
|
||||
keyMapping[(int)InputType.Right] = new KeyOrMouse(Keys.D);
|
||||
keyMapping[(int)InputType.Run] = new KeyOrMouse(Keys.LeftShift);
|
||||
keyMapping[(int)InputType.Chat] = new KeyOrMouse(Keys.Tab);
|
||||
|
||||
|
||||
keyMapping[(int)InputType.Chat] = new KeyOrMouse(Keys.Tab);
|
||||
keyMapping[(int)InputType.CrewOrders] = new KeyOrMouse(Keys.C);
|
||||
|
||||
keyMapping[(int)InputType.Select] = new KeyOrMouse(Keys.E);
|
||||
|
||||
keyMapping[(int)InputType.Use] = new KeyOrMouse(0);
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Barotrauma.Items.Components
|
||||
if (powerConsumption == 0.0f) voltage = 1.0f;
|
||||
|
||||
Force = MathHelper.Lerp(force, (voltage < minVoltage) ? 0.0f : targetForce, 0.1f);
|
||||
if (Force > 1.0f)
|
||||
if (Math.Abs(Force) > 1.0f)
|
||||
{
|
||||
Vector2 currForce = new Vector2((force / 100.0f) * maxForce * (voltage / minVoltage), 0.0f);
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
var mission = GameMain.GameSession.Mission;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(mission.RadarLabel))
|
||||
if (!string.IsNullOrWhiteSpace(mission.RadarLabel) && mission.RadarPosition != Vector2.Zero)
|
||||
{
|
||||
DrawMarker(spriteBatch,
|
||||
mission.RadarLabel,
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace Barotrauma.Items.Components
|
||||
private bool valueChanged;
|
||||
|
||||
private float autopilotRayCastTimer;
|
||||
|
||||
private float neutralBallastLevel;
|
||||
|
||||
bool AutoPilot
|
||||
{
|
||||
@@ -47,6 +49,17 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Editable, HasDefaultValue(0.5f, true)]
|
||||
public float NeutralBallastLevel
|
||||
{
|
||||
get { return neutralBallastLevel; }
|
||||
set
|
||||
{
|
||||
neutralBallastLevel = MathHelper.Clamp(value, 0.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
private Vector2 TargetVelocity
|
||||
{
|
||||
get { return targetVelocity;}
|
||||
@@ -115,7 +128,11 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
item.SendSignal(targetVelocity.X.ToString(CultureInfo.InvariantCulture), "velocity_x_out");
|
||||
|
||||
item.SendSignal((-targetVelocity.Y).ToString(CultureInfo.InvariantCulture), "velocity_y_out");
|
||||
float targetLevel = -targetVelocity.Y;
|
||||
|
||||
targetLevel += (neutralBallastLevel - 0.5f) * 100.0f;
|
||||
|
||||
item.SendSignal(targetLevel.ToString(CultureInfo.InvariantCulture), "velocity_y_out");
|
||||
}
|
||||
|
||||
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
|
||||
|
||||
@@ -174,6 +174,8 @@ namespace Barotrauma.Items.Components
|
||||
projectile.SetTransform(ConvertUnits.ToSimUnits(new Vector2(item.WorldRect.X + barrelPos.X, item.WorldRect.Y - barrelPos.Y)), -rotation);
|
||||
|
||||
projectiles[0].Use(deltaTime);
|
||||
projectiles[0].User = character;
|
||||
|
||||
if (projectile.Container != null) projectile.Container.RemoveContained(projectile);
|
||||
|
||||
return true;
|
||||
@@ -236,7 +238,7 @@ namespace Barotrauma.Items.Components
|
||||
//ignore humans and characters that are inside the sub
|
||||
if (enemy.IsDead || enemy.SpeciesName == "human" || enemy.AnimController.CurrentHull != null) continue;
|
||||
|
||||
float dist = Vector2.Distance(enemy.Position, item.Position);
|
||||
float dist = Vector2.Distance(enemy.WorldPosition, item.WorldPosition);
|
||||
if (dist < closestDist)
|
||||
{
|
||||
closestEnemy = enemy;
|
||||
@@ -246,18 +248,29 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (closestEnemy == null) return false;
|
||||
|
||||
character.CursorPosition = closestEnemy.Position;
|
||||
SecondaryUse(deltaTime, character);
|
||||
character.CursorPosition = closestEnemy.WorldPosition;
|
||||
if (item.Submarine!=null) character.CursorPosition -= item.Submarine.Position;
|
||||
character.SetInput(InputType.Aim, false, true);
|
||||
//Vector2 receive
|
||||
|
||||
float enemyAngle = MathUtils.VectorToAngle(closestEnemy.Position-item.Position);
|
||||
float turretAngle = -(rotation - MathHelper.TwoPi);
|
||||
//Vector2 centerPos = new Vector2(item.WorldRect.X + barrelPos.X, item.WorldRect.Y - barrelPos.Y);
|
||||
|
||||
if (Math.Abs(enemyAngle - turretAngle) > 0.01f) return false;
|
||||
//Vector2 offset = receivedPos - centerPos;
|
||||
//offset.Y = -offset.Y;
|
||||
|
||||
var pickedBody = Submarine.PickBody(item.SimPosition, closestEnemy.SimPosition, null);
|
||||
//targetRotation = MathUtils.WrapAngleTwoPi(MathUtils.VectorToAngle(offset));
|
||||
|
||||
float enemyAngle = MathUtils.VectorToAngle(closestEnemy.WorldPosition-item.WorldPosition);
|
||||
float turretAngle = -rotation;
|
||||
|
||||
|
||||
|
||||
if (Math.Abs(MathUtils.GetShortestAngle(enemyAngle, turretAngle)) > 0.01f) return false;
|
||||
|
||||
var pickedBody = Submarine.PickBody(ConvertUnits.ToSimUnits(item.WorldPosition), closestEnemy.SimPosition, null);
|
||||
if (pickedBody != null && pickedBody.UserData as Limb == null) return false;
|
||||
|
||||
Use(deltaTime, character);
|
||||
if (objective.Option.ToLower()=="fire at will") Use(deltaTime, character);
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
@@ -72,6 +72,8 @@ namespace Barotrauma
|
||||
|
||||
public List<MapEntity> GetEntities(Vector2 position)
|
||||
{
|
||||
if (!MathUtils.IsValid(position)) new List<MapEntity>();
|
||||
|
||||
if (Submarine.Loaded != null) position -= Submarine.HiddenSubPosition;
|
||||
|
||||
if (position.X < limits.X || position.Y > limits.Y ||
|
||||
@@ -81,7 +83,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
Point indices = GetIndices(position);
|
||||
|
||||
|
||||
return entities[indices.X, indices.Y];
|
||||
}
|
||||
|
||||
|
||||
@@ -553,15 +553,8 @@ namespace Barotrauma
|
||||
foreach (Gap gap in Gap.GapList)
|
||||
{
|
||||
if (gap.Open < 0.01f) continue;
|
||||
if (gap.linkedTo.Count == 0) continue;
|
||||
|
||||
var gapHull = gap.linkedTo[0] as Hull;
|
||||
if (gapHull == this) gaps.Add(gap);
|
||||
|
||||
if (gap.linkedTo.Count < 2) continue;
|
||||
|
||||
gapHull = gap.linkedTo[1] as Hull;
|
||||
if (gapHull == this) gaps.Add(gap);
|
||||
if (gap.linkedTo.Contains(this)) gaps.Add(gap);
|
||||
}
|
||||
|
||||
return gaps;
|
||||
|
||||
@@ -212,26 +212,28 @@ namespace Barotrauma
|
||||
{
|
||||
if (targetPosition != null && targetPosition != Position)
|
||||
{
|
||||
//Vector2 targetSimPos = ConvertUnits.ToSimUnits((Vector2)targetPosition);
|
||||
|
||||
float dist = Vector2.Distance((Vector2)targetPosition, Position);
|
||||
if (dist > 1000.0f)
|
||||
{
|
||||
Vector2 moveAmount = ConvertUnits.ToSimUnits((Vector2)targetPosition) - body.Position;
|
||||
Vector2 displayerMoveAmount = ConvertUnits.ToDisplayUnits(moveAmount);
|
||||
|
||||
body.SetTransform(body.Position + moveAmount, 0.0f);
|
||||
if (Character.Controlled != null) Character.Controlled.CursorPosition += displayerMoveAmount;
|
||||
|
||||
GameMain.GameScreen.Cam.Position += ConvertUnits.ToDisplayUnits(moveAmount);
|
||||
GameMain.GameScreen.Cam.Position += displayerMoveAmount;
|
||||
targetPosition = null;
|
||||
}
|
||||
else if (dist > 50.0f)
|
||||
{
|
||||
Vector2 moveAmount = Vector2.Normalize((Vector2)targetPosition - Position);
|
||||
moveAmount *= ConvertUnits.ToSimUnits(Math.Min(dist, 100.0f));
|
||||
Vector2 displayerMoveAmount = ConvertUnits.ToDisplayUnits(moveAmount);
|
||||
|
||||
body.SetTransform(body.Position + moveAmount * deltaTime, 0.0f);
|
||||
|
||||
GameMain.GameScreen.Cam.Position += ConvertUnits.ToDisplayUnits(moveAmount * deltaTime);
|
||||
GameMain.GameScreen.Cam.Position += displayerMoveAmount * deltaTime;
|
||||
if (Character.Controlled != null) Character.Controlled.CursorPosition += displayerMoveAmount;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -351,7 +353,7 @@ namespace Barotrauma
|
||||
{
|
||||
Vector2 normal = Vector2.Normalize(body.Position - limb.SimPosition);
|
||||
|
||||
normal *= limb.Mass/100.0f;
|
||||
normal *= Math.Min(limb.Mass,100)/100.0f;
|
||||
|
||||
ApplyImpact(normal, contact);
|
||||
}
|
||||
@@ -382,20 +384,34 @@ namespace Barotrauma
|
||||
FixedArray2<Vector2> points;
|
||||
contact.GetWorldManifold(out normal2, out points);
|
||||
|
||||
Vector2 targetPos = ConvertUnits.ToDisplayUnits(points[0] + limb.LinearVelocity * ((float)Physics.step));
|
||||
Vector2 normalizedVel = limb.character.AnimController.RefLimb.LinearVelocity == Vector2.Zero ?
|
||||
Vector2.Zero : Vector2.Normalize(limb.character.AnimController.RefLimb.LinearVelocity);
|
||||
|
||||
Vector2 targetPos = ConvertUnits.ToDisplayUnits(points[0] + normalizedVel);
|
||||
|
||||
Hull newHull = Hull.FindHull(targetPos, null);
|
||||
|
||||
if (newHull == null) return true;
|
||||
if (newHull == null)
|
||||
{
|
||||
targetPos = ConvertUnits.ToDisplayUnits(points[0] - normalizedVel);
|
||||
|
||||
newHull = Hull.FindHull(targetPos, null);
|
||||
|
||||
if (newHull == null) return true;
|
||||
}
|
||||
|
||||
var gaps = newHull.FindGaps();
|
||||
|
||||
targetPos = limb.character.WorldPosition;
|
||||
|
||||
bool gapFound = false;
|
||||
foreach (Gap gap in gaps)
|
||||
foreach (Gap gap in Gap.GapList)
|
||||
{
|
||||
if (gap.Open == 0.0f || gap.IsRoomToRoom) continue;
|
||||
if (gap.isHorizontal)
|
||||
{
|
||||
if (targetPos.Y < gap.WorldRect.Y && targetPos.Y > gap.WorldRect.Y - gap.WorldRect.Height)
|
||||
if (targetPos.Y < gap.WorldRect.Y && targetPos.Y > gap.WorldRect.Y - gap.WorldRect.Height &&
|
||||
Math.Abs(gap.WorldRect.Center.X-targetPos.X)<200.0f)
|
||||
{
|
||||
gapFound = true;
|
||||
break;
|
||||
@@ -403,7 +419,8 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
if (targetPos.X > gap.WorldRect.X && targetPos.X < gap.WorldRect.Right)
|
||||
if (targetPos.X > gap.WorldRect.X && targetPos.X < gap.WorldRect.Right &&
|
||||
Math.Abs(gap.WorldRect.Y - gap.WorldRect.Height/2 - targetPos.Y) < 200.0f)
|
||||
{
|
||||
gapFound = true;
|
||||
break;
|
||||
|
||||
@@ -10,7 +10,8 @@ namespace Barotrauma
|
||||
Use,
|
||||
Aim,
|
||||
Up, Down, Left, Right,
|
||||
Run, Chat
|
||||
Run,
|
||||
Chat, CrewOrders
|
||||
}
|
||||
|
||||
public class KeyOrMouse
|
||||
|
||||
@@ -219,7 +219,7 @@ namespace Barotrauma
|
||||
if (musicClips == null) return;
|
||||
|
||||
Task criticalTask = null;
|
||||
if (GameMain.GameSession!=null)
|
||||
if (GameMain.GameSession!=null && GameMain.GameSession.TaskManager != null)
|
||||
{
|
||||
foreach (Task task in GameMain.GameSession.TaskManager.Tasks)
|
||||
{
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user