Limb collisions can damage hull again, new UI for steering, sonar & reactor, fabricators can require more than one of each ingredient, timer for character imploding, AICharacter position syncing changes, watcher, commands can also be given to controlled character

This commit is contained in:
Regalis
2016-01-13 22:19:01 +02:00
parent 5513637fe5
commit eb20af622d
23 changed files with 400 additions and 204 deletions

View File

@@ -397,6 +397,13 @@
<Content Include="Content\Characters\TigerThresher\damagedtigerthresher.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Characters\Watcher\watcher.xml">
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Characters\Watcher\watcher.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\InfoTexts.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 KiB

View File

@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8" ?>
<Character name ="watcher" humanoid="false" health ="1000">
<ragdoll waveamplitude="0.0" swimspeed="0.5" walkspeed="0.3" flip="true" rotatetowardsmovement="false" headangle="-90">
<!-- head -->
<limb id = "0" width="350" height="320" type="Head" steerforce="1.0" flip="true" armorsector="0.0,360.0" armorvalue="100.0">
<sprite texture="Content/Characters/Watcher/watcher.png" sourcerect="0,0,369,348" depth="0.02" origin ="0.5,0.6"/>
</limb>
<limb id = "1" radius="50" height="120" flip="true">
<sprite texture="Content/Characters/Watcher/watcher.png" sourcerect="395,0,117,239" depth="0.025" origin="0.5,0.5"/>
</limb>
<limb id = "2" width="300" height="119" flip="true">
<sprite texture="Content/Characters/Watcher/watcher.png" sourcerect="0,370,302,142" depth="0.025" origin="0.5,0.5"/>
</limb>
<joint limb1="0" limb1anchor="60,130" limb2="1" limb2anchor="-30,100" lowerlimit="70" upperlimit="80"/>
<joint limb1="0" limb1anchor="72,110" limb2="2" limb2anchor="120,-20" lowerlimit="90" upperlimit="180"/>
</ragdoll>
<ai attackhumans="0.0" attackrooms="0.0" sight="1.0" hearing="0.0" attackwhenprovoked="true"/>
</Character>

View File

@@ -15,8 +15,11 @@
<sound file="fabricator.ogg" type="OnActive" range="1000.0" loop="true"/>
<fabricableitem name="Harpoon Gun" requireditems="Steel Bar" requiredtime="20"/>
<fabricableitem name="Plasma Cutter" requireditems="Steel Bar" requiredtime="20"/>
<fabricableitem name="Harpoon Gun" requireditems="Steel Bar, Polycarbonate Bar" requiredtime="20"/>
<fabricableitem name="Plasma Cutter" requireditems="Steel Bar, Polycarbonate Bar" requiredtime="20"/>
<fabricableitem name="Welding Tool" requireditems="Steel Bar, Polycarbonate Bar" requiredtime="20"/>
<fabricableitem name="Railgun Shell" requireditems="Steel Bar, Steel Bar, Polycarbonate Bar" requiredtime="20"/>
<fabricableitem name="And Component" requireditems="Steel Bar, FPGA Circuit" requiredtime="10"/>
<fabricableitem name="Or Component" requireditems="Steel Bar, FPGA Circuit" requiredtime="10"/>

View File

@@ -6,7 +6,7 @@
Tags="smallitem"
pickdistance="150"
canbepicked="true"
price="10">
price="50">
<Sprite texture ="materials.png" sourcerect="0,0,24,12" depth="0.55"/>
@@ -22,7 +22,7 @@
pickdistance="150"
spritecolor="0.2,0.35,0.06,1.0"
canbepicked="true"
price="50">
price="100">
<Sprite texture ="materials.png" sourcerect="0,0,24,12" depth="0.55"/>
@@ -46,6 +46,22 @@
<Holdable slots="Any,RightHand,LeftHand" handle1="0,0"/>
</Item>
<Item
name="Polycarbonate Bar"
category="Material"
Tags="smallitem"
pickdistance="150"
spritecolor="1.0,1.0,1.0,0.9"
canbepicked="true"
price="50">
<Sprite texture ="materials.png" sourcerect="0,0,24,12" depth="0.55"/>
<Body width="24" height="12"/>
<Holdable slots="Any,RightHand,LeftHand" handle1="0,0"/>
</Item>
<Item
name="Incendium Bar"
@@ -53,8 +69,7 @@
Tags="smallitem"
pickdistance="150"
spritecolor="0.5,0.0,0.0,1.0"
canbepicked="true"
price="50">
canbepicked="true">
<Sprite texture ="materials.png" sourcerect="0,0,24,12" depth="0.55"/>
@@ -69,8 +84,7 @@
Tags="smallitem"
pickdistance="150"
spritecolor="1.0,0.7,0.05,1.0"
canbepicked="true"
price="50">
canbepicked="true">
<Sprite texture ="materials.png" sourcerect="0,0,24,12" depth="0.55"/>

View File

@@ -68,6 +68,12 @@
pickdistance="200"
price="100">
<Deconstruct time="10">
<Item name="Steel Bar"/>
<Item name="Steel Bar"/>
<Item name="Polycarbonate Bar"/>
</Deconstruct>
<Sprite texture="weapons.png" sourcerect="0,58,88,20" depth ="0.5"/>
<Body width="87" height="18"/>

View File

@@ -29,8 +29,9 @@
price="500"
tags="weapon">
<Deconstruct time="10">
<Deconstruct time="10">
<Item name="Steel Bar"/>
<Item name="Polycarbonate Bar"/>
</Deconstruct>
<Sprite texture="weapons.png" sourcerect="0,25,98,25" depth="0.5"/>

View File

@@ -159,18 +159,11 @@ namespace Barotrauma
characterButton.UserData = character;
characterButton.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
if (character == Character.Controlled)
{
characterButton.CanBeSelected = false;
characterButton.Color = Color.LightGray * 0.3f;
}
else
{
characterButton.Color = Color.Black * 0.5f;
characterButton.HoverColor = Color.LightGray * 0.5f;
characterButton.SelectedColor = Color.Gold * 0.5f;
characterButton.OutlineColor = Color.LightGray * 0.8f;
}
characterButton.Color = Character.Controlled == character ? Color.Gold * 0.3f : Color.Black * 0.5f;
characterButton.HoverColor = Color.LightGray * 0.5f;
characterButton.SelectedColor = Color.Gold * 0.5f;
characterButton.OutlineColor = Color.LightGray * 0.8f;
string name = character.Info.Name;
if (character.Info.Job != null) name += '\n' + "(" + character.Info.Job.Name + ")";

View File

@@ -16,6 +16,8 @@ namespace Barotrauma
private const float UpdateTargetsInterval = 5.0f;
private const float RaycastInterval = 1.0f;
private bool attackWhenProvoked;
//the preference to attack a specific type of target (-1.0 - 1.0)
//0.0 = doesn't attack targets of the type
@@ -84,6 +86,8 @@ namespace Barotrauma
sight = ToolBox.GetAttributeFloat(aiElement, "sight", 0.0f);
hearing = ToolBox.GetAttributeFloat(aiElement, "hearing", 0.0f);
attackWhenProvoked = ToolBox.GetAttributeBool(aiElement, "attackwhenprovoked", false);
steeringManager = new SteeringManager(this);
state = AiState.None;
@@ -286,6 +290,12 @@ namespace Barotrauma
updateTargetsTimer = Math.Min(updateTargetsTimer, 0.1f);
coolDownTimer *= 0.1f;
if (amount > 1.0f && attackWhenProvoked)
{
attackHumans = 100.0f;
attackRooms = 100.0f;
}
if (attacker==null || attacker.AiTarget==null) return;
AITargetMemory targetMemory = FindTargetMemory(attacker.AiTarget);
targetMemory.Priority += amount;
@@ -508,11 +518,13 @@ namespace Barotrauma
message.Write(wallAttack);
if (wallAttack)
{
message.WriteRangedSingle(MathHelper.Clamp(wallAttackPos.X, -50.0f, 50.0f), -50.0f, 50.0f, 10);
message.WriteRangedSingle(MathHelper.Clamp(wallAttackPos.Y, -50.0f, 50.0f), -50.0f, 50.0f, 10);
}
//if (wallAttack)
//{
// Vector2 relativeWallAttackPos = wallAttackPos - Submarine.Loaded.SimPosition;
// message.WriteRangedSingle(MathHelper.Clamp(relativeWallAttackPos.X, -50.0f, 50.0f), -50.0f, 50.0f, 10);
// message.WriteRangedSingle(MathHelper.Clamp(relativeWallAttackPos.Y, -50.0f, 50.0f), -50.0f, 50.0f, 10);
//}
//message.Write(Velocity.X);
//message.Write(Velocity.Y);
@@ -542,14 +554,16 @@ namespace Barotrauma
newState = (AiState)(message.ReadByte());
bool wallAttack = message.ReadBoolean();
//bool wallAttack = message.ReadBoolean();
if (wallAttack)
{
newWallAttackPos = new Vector2(
message.ReadRangedSingle(-50.0f, 50.0f, 10),
message.ReadRangedSingle(-50.0f, 50.0f, 10));
}
//if (wallAttack)
//{
// newWallAttackPos = new Vector2(
// message.ReadRangedSingle(-50.0f, 50.0f, 10),
// message.ReadRangedSingle(-50.0f, 50.0f, 10));
// newWallAttackPos += Submarine.Loaded.SimPosition;
//}
//newVelocity = new Vector2(message.ReadFloat(), message.ReadFloat());
@@ -565,7 +579,7 @@ namespace Barotrauma
catch { return; }
wallAttackPos = newWallAttackPos;
//wallAttackPos = newWallAttackPos;
steeringManager.WanderAngle = wanderAngle;
//this.updateTargetsTimer = updateTargetsTimer;

View File

@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FarseerPhysics;
namespace Barotrauma
{
@@ -108,7 +109,9 @@ namespace Barotrauma
message.Write(AnimController.TargetDir == Direction.Right);
message.WriteRangedSingle(MathHelper.Clamp(AnimController.TargetMovement.X, -1.0f, 1.0f), -1.0f, 1.0f, 8);
message.WriteRangedSingle(MathHelper.Clamp(AnimController.TargetMovement.X, -1.0f, 1.0f), -1.0f, 1.0f, 8);
message.Write(Submarine != null);
message.Write(AnimController.RefLimb.SimPosition.X);
message.Write(AnimController.RefLimb.SimPosition.Y);
@@ -177,6 +180,8 @@ namespace Barotrauma
if (sendingTime <= LastNetworkUpdate) return;
bool inSub = false;
Vector2 pos = Vector2.Zero, vel = Vector2.Zero;
try
@@ -185,6 +190,8 @@ namespace Barotrauma
targetMovement.X = message.ReadRangedSingle(-1.0f, 1.0f, 8);
targetMovement.Y = message.ReadRangedSingle(-1.0f, 1.0f, 8);
inSub = message.ReadBoolean();
pos.X = message.ReadFloat();
pos.Y = message.ReadFloat();
@@ -199,9 +206,19 @@ namespace Barotrauma
AnimController.TargetDir = (targetDir) ? Direction.Right : Direction.Left;
AnimController.TargetMovement = targetMovement;
AnimController.RefLimb.body.TargetPosition = pos;
AnimController.RefLimb.body.TargetVelocity = vel;
AnimController.TargetMovement = AnimController.EstimateCurrPosition(pos, (float)(NetTime.Now) - sendingTime);
if (inSub)
{
Hull newHull = Hull.FindHull(ConvertUnits.ToDisplayUnits(pos), AnimController.CurrentHull, false);
if (newHull != null)
{
AnimController.CurrentHull = newHull;
Submarine = newHull.Submarine;
}
}
LastNetworkUpdate = sendingTime;
return;

View File

@@ -88,11 +88,11 @@ namespace Barotrauma
if (flip)
{
//targetDir = (movement.X > 0.0f) ? Direction.Right : Direction.Left;
if (movement.X > 0.1f && movement.X > Math.Abs(movement.Y)*0.5f)
if (targetMovement.X > 0.1f && targetMovement.X > Math.Abs(targetMovement.Y) * 0.5f)
{
TargetDir = Direction.Right;
}
else if (movement.X < -0.1f && movement.X < -Math.Abs(movement.Y)*0.5f)
else if (targetMovement.X < -0.1f && targetMovement.X < -Math.Abs(targetMovement.Y) * 0.5f)
{
TargetDir = Direction.Left;
}
@@ -191,7 +191,7 @@ namespace Barotrauma
for (int i = 0; i < Limbs.Count(); i++)
{
if (steerForce!=Vector2.Zero)
if (steerForce != Vector2.Zero)
Limbs[i].body.ApplyForce(steerForce * Limbs[i].SteerForce * Limbs[i].Mass);
if (Limbs[i].type != LimbType.Torso) continue;
@@ -369,7 +369,7 @@ namespace Barotrauma
}
}
}
void UpdateDying(float deltaTime)
{
Limb head = GetLimb(LimbType.Head);
@@ -403,20 +403,29 @@ namespace Barotrauma
}
}
public override Vector2 EstimateCurrPosition(Vector2 prevPosition, float timePassed)
{
timePassed = MathHelper.Clamp(timePassed, 0.0f, 1.0f);
Vector2 currPosition = prevPosition + targetMovement * timePassed;
return currPosition;
}
private void Mirror()
{
float leftX = Limbs[0].SimPosition.X, rightX = Limbs[0].SimPosition.X;
for (int i = 1; i < Limbs.Count(); i++ )
{
if (Limbs[i].SimPosition.X < leftX)
{
leftX = Limbs[i].SimPosition.X;
}
else if (Limbs[i].SimPosition.X > rightX)
{
rightX = Limbs[i].SimPosition.X;
}
}
//float leftX = Limbs[0].SimPosition.X, rightX = Limbs[0].SimPosition.X;
//for (int i = 1; i < Limbs.Count(); i++ )
//{
// if (Limbs[i].SimPosition.X < leftX)
// {
// leftX = Limbs[i].SimPosition.X;
// }
// else if (Limbs[i].SimPosition.X > rightX)
// {
// rightX = Limbs[i].SimPosition.X;
// }
//}
float midX = GetCenterOfMass().X;
@@ -424,7 +433,7 @@ namespace Barotrauma
{
Vector2 newPos = new Vector2(midX - (l.SimPosition.X - midX), l.SimPosition.Y);
if (Submarine.CheckVisibility(l.SimPosition, newPos)!=null)
if (Submarine.CheckVisibility(l.SimPosition, newPos) != null)
{
Vector2 diff = newPos - l.SimPosition;

View File

@@ -38,7 +38,7 @@ namespace Barotrauma
//the movement speed of the ragdoll
public Vector2 movement;
//the target speed towards which movement is interpolated
private Vector2 targetMovement;
protected Vector2 targetMovement;
//a movement vector that overrides targetmovement if trying to steer
//a Character to the position sent by server in multiplayer mode
@@ -782,15 +782,24 @@ namespace Barotrauma
{
if (inWater)
{
//foreach (Limb limb in Limbs)
//{
// //if (limb.body.TargetPosition == Vector2.Zero) continue;
// limb.body.SetTransform(limb.SimPosition + Vector2.Normalize(diff) * 0.1f, limb.Rotation);
//}
correctionMovement =
Vector2.Lerp(targetMovement, Vector2.Normalize(diff) * MathHelper.Clamp(dist * 8.0f, 0.1f, 8.0f), 0.2f);
if (character is AICharacter)
{
correctionMovement =
Vector2.Lerp(targetMovement, Vector2.Normalize(diff) * MathHelper.Clamp(dist * 8.0f, 0.1f, 8.0f), 0.5f);
}
else
{
foreach (Limb limb in Limbs)
{
//if (limb.body.TargetPosition == Vector2.Zero) continue;
limb.body.SetTransform(limb.SimPosition + Vector2.Normalize(diff) * 0.1f, limb.Rotation);
}
}
}
else
{
@@ -809,7 +818,7 @@ namespace Barotrauma
SetPosition(refLimb.body.TargetPosition);
if (character is AICharacter) SetRotation(refLimb.body.TargetRotation);
//if (character is AICharacter) SetRotation(refLimb.body.TargetRotation);
//foreach (Limb limb in Limbs)
//{

View File

@@ -32,10 +32,23 @@ namespace Barotrauma
set { controlled = value; }
}
private bool enabled;
public bool Enabled
{
get;
set;
get
{
return enabled;
}
set
{
enabled = value;
foreach (Limb limb in AnimController.Limbs)
{
limb.body.Enabled = enabled;
}
}
}
public readonly bool IsNetworkPlayer;
@@ -239,6 +252,13 @@ namespace Barotrauma
}
}
public float PressureTimer
{
get;
private set;
}
public float SpeedMultiplier
{
get;
@@ -652,6 +672,9 @@ namespace Barotrauma
private Item FindClosestItem(Vector2 mouseSimPos)
{
Limb torso = AnimController.GetLimb(LimbType.Torso);
if (torso == null) return null;
Vector2 pos = (torso.body.TargetPosition != Vector2.Zero) ? torso.body.TargetPosition : torso.SimPosition;
return Item.FindPickable(pos, selectedConstruction == null ? mouseSimPos : selectedConstruction.SimPosition, AnimController.CurrentHull, selectedItems);
@@ -885,8 +908,19 @@ namespace Barotrauma
if (!protectedFromPressure &&
(AnimController.CurrentHull == null || AnimController.CurrentHull.LethalPressure >= 100.0f))
{
Implode();
return;
PressureTimer += ((AnimController.CurrentHull == null) ?
100.0f : AnimController.CurrentHull.LethalPressure) * deltaTime;
if (PressureTimer >= 100.0f)
{
Implode();
return;
}
}
else
{
PressureTimer = 0.0f;
}
}
@@ -1503,10 +1537,12 @@ namespace Barotrauma
else
{
cursorPosition = Position + new Vector2(1000.0f, 0.0f) * dir;
AnimController.TargetDir = dir < 0 ? Direction.Left : Direction.Right;
}
AnimController.RefLimb.body.TargetPosition =
AnimController.EstimateCurrPosition(pos, (float)(NetTime.Now + message.SenderConnection.RemoteTimeOffset) - sendingTime);
AnimController.EstimateCurrPosition(pos, (float)(NetTime.Now) - sendingTime);
LastNetworkUpdate = sendingTime;

View File

@@ -14,8 +14,6 @@ namespace Barotrauma
private static GUIProgressBar drowningBar, healthBar;
private static float pressureTimer;
public static void TakeDamage()
{
healthBar.Flash();
@@ -29,9 +27,6 @@ namespace Barotrauma
if (character.Oxygen < 10.0f) drowningBar.Flash();
}
if (healthBar != null) healthBar.Update(deltaTime);
pressureTimer += ((character.AnimController.CurrentHull == null) ?
100.0f : character.AnimController.CurrentHull.LethalPressure)*deltaTime;
}
public static void Draw(SpriteBatch spriteBatch, Character character, Camera cam)
@@ -134,7 +129,7 @@ namespace Barotrauma
if (pressureFactor>0.0f)
{
float indicatorAlpha = ((float)Math.Sin(pressureTimer * 0.1f) + 1.0f) * 0.5f;
float indicatorAlpha = ((float)Math.Sin(character.PressureTimer * 0.1f) + 1.0f) * 0.5f;
indicatorAlpha = MathHelper.Clamp(indicatorAlpha, 0.1f, pressureFactor/100.0f);

View File

@@ -12,7 +12,7 @@ namespace Barotrauma.Items.Components
{
public readonly ItemPrefab TargetItem;
public readonly List<ItemPrefab> RequiredItems;
public readonly List<Tuple<ItemPrefab, int>> RequiredItems;
public readonly float RequiredTime;
@@ -29,14 +29,27 @@ namespace Barotrauma.Items.Components
return;
}
RequiredItems = new List<ItemPrefab>();
RequiredItems = new List<Tuple<ItemPrefab, int>>();
string[] requiredItemNames = ToolBox.GetAttributeString(element, "requireditems", "").Split(',');
foreach (string requiredItemName in requiredItemNames)
{
ItemPrefab requiredItem = ItemPrefab.list.Find(ip => ip.Name.ToLower() == requiredItemName.Trim().ToLower()) as ItemPrefab;
if (requiredItem == null) continue;
RequiredItems.Add(requiredItem);
var existing = RequiredItems.Find(r => r.Item1 == requiredItem);
if (existing == null)
{
RequiredItems.Add(new Tuple<ItemPrefab, int>(requiredItem, 1));
}
else
{
RequiredItems.Remove(existing);
RequiredItems.Add(new Tuple<ItemPrefab, int>(requiredItem, existing.Item2+1));
}
}
RequiredTime = ToolBox.GetAttributeFloat(element, "requiredtime", 1.0f);
@@ -123,9 +136,9 @@ namespace Barotrauma.Items.Components
selectedItemFrame, true);
string text = "Required items:\n";
foreach (ItemPrefab ip in targetItem.RequiredItems)
foreach (Tuple<ItemPrefab,int> ip in targetItem.RequiredItems)
{
text += " - " + ip.Name + "\n";
text += " - " + ip.Item1.Name + " x"+ip.Item2+"\n";
}
text += "Required time: " + targetItem.RequiredTime + " s";
@@ -234,9 +247,9 @@ namespace Barotrauma.Items.Components
return;
}
foreach (ItemPrefab ip in fabricatedItem.RequiredItems)
foreach (Tuple<ItemPrefab,int> ip in fabricatedItem.RequiredItems)
{
var requiredItem = containers[0].Inventory.Items.FirstOrDefault(it => it != null && it.Prefab == ip);
var requiredItem = containers[0].Inventory.Items.FirstOrDefault(it => it != null && it.Prefab == ip.Item1);
containers[0].Inventory.RemoveItem(requiredItem);
}
@@ -253,9 +266,9 @@ namespace Barotrauma.Items.Components
activateButton.Enabled = true;
ItemContainer container = item.GetComponent<ItemContainer>();
foreach (ItemPrefab ip in targetItem.RequiredItems)
foreach (Tuple<ItemPrefab,int> ip in targetItem.RequiredItems)
{
if (Array.Find(container.Inventory.Items, it => it != null && it.Prefab == ip) != null) continue;
if (Array.FindAll(container.Inventory.Items, it => it != null && it.Prefab == ip.Item1).Count() < ip.Item2) continue;
activateButton.Enabled = false;
break;
}

View File

@@ -45,7 +45,15 @@ namespace Barotrauma.Items.Components
}
}
//renderTarget = new RenderTarget2D(Game1.CurrGraphicsDevice, GuiFrame.Rect.Width, GuiFrame.Rect.Height);
var tickBox = new GUITickBox(new Rectangle(0,0,20,20), "Sonar", Alignment.TopLeft, GuiFrame);
tickBox.OnSelected = (GUITickBox box) =>
{
IsActive = box.Selected;
item.NewComponentEvent(this, true, false);
return true;
};
}
public override void Update(float deltaTime, Camera cam)
@@ -86,16 +94,12 @@ namespace Barotrauma.Items.Components
{
int x = GuiFrame.Rect.X;
int y = GuiFrame.Rect.Y;
GuiFrame.Update(1.0f / 60.0f);
GuiFrame.Draw(spriteBatch);
if (voltage < minVoltage) return;
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 0, y + 0, 150, 30), "Activate Sonar"))
{
IsActive = !IsActive;
item.NewComponentEvent(this, true, false);
}
int radius = GuiFrame.Rect.Height / 2 - 30;
DrawRadar(spriteBatch, new Rectangle((int)GuiFrame.Center.X - radius, (int)GuiFrame.Center.Y - radius, radius * 2, radius * 2));

View File

@@ -154,6 +154,63 @@ namespace Barotrauma.Items.Components
powerPerTemp = 1.0f;
IsActive = true;
var button = new GUIButton(new Rectangle(410, 70, 40,40), "+", GUI.Style, GuiFrame);
button.OnPressed = () =>
{
unsentChanges = true;
ShutDownTemp += 100.0f;
return true;
};
button = new GUIButton(new Rectangle(460, 70, 40, 40), "-", GUI.Style, GuiFrame);
button.OnPressed = () =>
{
unsentChanges = true;
ShutDownTemp -= 100.0f;
return true;
};
button = new GUIButton(new Rectangle(410, 170, 100, 40), "TURN ON", GUI.Style, GuiFrame);
button.OnClicked = ToggleAutoTemp;
button = new GUIButton(new Rectangle(210, 290, 40, 40), "+", GUI.Style, GuiFrame);
button.OnPressed = () =>
{
unsentChanges = true;
FissionRate += 1.0f;
return true;
};
button = new GUIButton(new Rectangle(210, 340, 40, 40), "-", GUI.Style, GuiFrame);
button.OnPressed = () =>
{
unsentChanges = true;
FissionRate -= 1.0f;
return true;
};
button = new GUIButton(new Rectangle(500, 290, 40, 40), "+", GUI.Style, GuiFrame);
button.OnPressed = () =>
{
unsentChanges = true;
CoolingRate += 1.0f;
return true;
};
button = new GUIButton(new Rectangle(500, 340, 40, 40), "-", GUI.Style, GuiFrame);
button.OnPressed = () =>
{
unsentChanges = true;
CoolingRate -= 1.0f;
return true;
};
}
public override void Update(float deltaTime, Camera cam)
@@ -231,7 +288,7 @@ namespace Barotrauma.Items.Components
}
//fission rate can't be lowered below a certain amount if the core is too hot
FissionRate = Math.Max(fissionRate, heat / 200.0f);
//FissionRate = Math.Max(fissionRate, heat / 200.0f);
//the power generated by the reactor is equal to the temperature
currPowerConsumption = -temperature*powerPerTemp;
@@ -372,6 +429,7 @@ namespace Barotrauma.Items.Components
int x = GuiFrame.Rect.X;
int y = GuiFrame.Rect.Y;
GuiFrame.Update(1.0f / 60.0f);
GuiFrame.Draw(spriteBatch);
float xOffset = (graphTimer / (float)updateGraphInterval);
@@ -390,61 +448,32 @@ namespace Barotrauma.Items.Components
new Rectangle(x + 30, y + 30, 400, 250), 10000.0f, xOffset, Color.Yellow);
spriteBatch.DrawString(GUI.Font, "Shutdown Temperature: " + shutDownTemp, new Vector2(x + 450, y + 80), Color.White);
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 450, y + 110, 40, 40), "+", true))
{
unsentChanges = true;
ShutDownTemp += 100.0f;
}
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 500, y + 110, 40, 40), "-", true))
{
unsentChanges = true;
ShutDownTemp -= 100.0f;
}
spriteBatch.DrawString(GUI.Font, "Automatic Temperature Control: " + ((autoTemp) ? "ON" : "OFF"), new Vector2(x + 450, y + 180), Color.White);
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 450, y + 210, 100, 40), ((autoTemp) ? "TURN OFF" : "TURN ON")))
{
unsentChanges = true;
autoTemp = !autoTemp;
}
y += 300;
spriteBatch.DrawString(GUI.Font, "Fission rate: " + (int)fissionRate + " %", new Vector2(x + 30, y), Color.White);
DrawGraph(fissionRateGraph, spriteBatch,
new Rectangle(x + 30, y + 30, 200, 100), 100.0f, xOffset, Color.Orange);
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 250, y + 30, 40, 40), "+", true))
{
unsentChanges = true;
FissionRate += 1.0f;
}
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 250, y + 80, 40, 40), "-", true))
{
unsentChanges = true;
FissionRate -= 1.0f;
}
spriteBatch.DrawString(GUI.Font, "Cooling rate: " + (int)coolingRate + " %", new Vector2(x + 320, y), Color.White);
DrawGraph(coolingRateGraph, spriteBatch,
new Rectangle(x + 320, y + 30, 200, 100), 100.0f, xOffset, Color.LightBlue);
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 540, y + 30, 40, 40), "+", true))
{
unsentChanges = true;
CoolingRate += 1.0f;
}
if (GUI.DrawButton(spriteBatch, new Rectangle(x + 540, y + 80, 40, 40), "-", true))
{
unsentChanges = true;
CoolingRate -= 1.0f;
}
//y = y - 260;
}
private bool ToggleAutoTemp(GUIButton button, object userdata)
{
unsentChanges = true;
autoTemp = !autoTemp;
button.Text = autoTemp ? "TURN OFF" : "TURN ON";
return true;
}
static void UpdateGraph<T>(IList<T> graph, T newValue)

View File

@@ -72,6 +72,16 @@ namespace Barotrauma.Items.Components
: base(item, element)
{
IsActive = true;
var tickBox = new GUITickBox(new Rectangle(0,25,20,20), "Autopilot", Alignment.TopLeft, GuiFrame);
tickBox.OnSelected = (GUITickBox box) =>
{
AutoPilot = box.Selected;
item.NewComponentEvent(this, true, true);
return true;
};
}
public override void Update(float deltaTime, Camera cam)
@@ -116,18 +126,12 @@ namespace Barotrauma.Items.Components
int x = GuiFrame.Rect.X;
int y = GuiFrame.Rect.Y;
GuiFrame.Update(1.0f / 60.0f);
GuiFrame.Draw(spriteBatch);
Rectangle velRect = new Rectangle(x + 20, y + 20, width - 40, height - 40);
//GUI.DrawRectangle(spriteBatch, velRect, Color.White, false);
if (GUI.DrawButton(spriteBatch, new Rectangle(x + width - 150, y + height - 30, 150, 30), "Autopilot"))
{
AutoPilot = !AutoPilot;
item.NewComponentEvent(this, true, true);
}
GUI.DrawLine(spriteBatch,
new Vector2(velRect.Center.X,velRect.Center.Y),
new Vector2(velRect.Center.X + currVelocity.X, velRect.Center.Y - currVelocity.Y),

View File

@@ -187,7 +187,7 @@ namespace Barotrauma
{
for (int i = 0; i < linkedTo.Count; i++)
{
if (linkedTo[i].Rect.Y - linkedTo[i].Rect.Height / 2.0f > WorldRect.Y)
if (linkedTo[i].Rect.Y - linkedTo[i].Rect.Height / 2.0f > rect.Y-rect.Height/2.0f)
{
GUI.DrawRectangle(sb, new Rectangle(WorldRect.X, -WorldRect.Y - 10, rect.Width, 10), Color.Green * 0.3f, true);
}

View File

@@ -343,85 +343,97 @@ namespace Barotrauma
if (cell == null)
{
Limb limb = f2.Body.UserData as Limb;
if (limb!=null)
if (limb != null)
{
if (limb.character.Submarine != null) return false;
bool collision = HandleLimbCollision(contact, limb);
Vector2 normal2;
FixedArray2<Vector2> points;
contact.GetWorldManifold(out normal2, out points);
Vector2 targetPos = ConvertUnits.ToDisplayUnits(points[0] + limb.LinearVelocity * ((float)Physics.step));
Hull newHull = Hull.FindHull(targetPos, null);
if (newHull == null) return true;
var gaps = newHull.FindGaps();
bool gapFound = false;
foreach (Gap gap in gaps)
if (collision)
{
if (gap.isHorizontal)
{
if (targetPos.Y < gap.WorldRect.Y && targetPos.Y > gap.WorldRect.Y - gap.WorldRect.Height)
{
gapFound = true;
break;
}
}
else
{
if (targetPos.X > gap.WorldRect.X && targetPos.X < gap.WorldRect.Right)
{
gapFound = true;
break;
}
}
Vector2 normal = Vector2.Normalize(body.Position - limb.SimPosition);
//if (Submarine.RectContains(gap.WorldRect, targetPos))
//{
// gapFound = true;
// break;
//}
normal *= limb.Mass/100.0f;
ApplyImpact(normal, contact);
}
//var pickedBody = Submarine.PickBody(
// points[0] - limb.LinearVelocity * ((float)Physics.step) - ConvertUnits.ToSimUnits(submarine.Position) - submarine.Velocity * ((float)Physics.step),
// points[0] - ConvertUnits.ToSimUnits(submarine.Position), null, Physics.CollisionWall);
if (!gapFound)
{
return true;
}
var ragdoll = limb.character.AnimController;
ragdoll.FindHull();
return false;
return collision;
}
return true;
}
Vector2 normal;
FarseerPhysics.Common.FixedArray2<Vector2> worldPoints;
contact.GetWorldManifold(out normal, out worldPoints);
Vector2 lastContactPoint = worldPoints[0];
normal = Vector2.Normalize(ConvertUnits.ToDisplayUnits(body.Position) - cell.Center);
float impact = Vector2.Dot(Velocity, -normal);
var collisionNormal = Vector2.Normalize(ConvertUnits.ToDisplayUnits(body.Position) - cell.Center);
ApplyImpact(collisionNormal, contact);
//Vector2 u = Vector2.Dot(Velocity, -normal) * normal;
//Vector2 w = (Velocity + u);
//speed = ConvertUnits.ToDisplayUnits(w * (1.0f - Friction) + u * Restitution);
if (impact < 3.0f) return true;
return true;
}
private bool HandleLimbCollision(Contact contact, Limb limb)
{
if (limb.character.Submarine != null) return false;
Vector2 normal2;
FixedArray2<Vector2> points;
contact.GetWorldManifold(out normal2, out points);
Vector2 targetPos = ConvertUnits.ToDisplayUnits(points[0] + limb.LinearVelocity * ((float)Physics.step));
Hull newHull = Hull.FindHull(targetPos, null);
if (newHull == null) return true;
var gaps = newHull.FindGaps();
bool gapFound = false;
foreach (Gap gap in gaps)
{
if (gap.isHorizontal)
{
if (targetPos.Y < gap.WorldRect.Y && targetPos.Y > gap.WorldRect.Y - gap.WorldRect.Height)
{
gapFound = true;
break;
}
}
else
{
if (targetPos.X > gap.WorldRect.X && targetPos.X < gap.WorldRect.Right)
{
gapFound = true;
break;
}
}
}
if (!gapFound) return true;
var ragdoll = limb.character.AnimController;
ragdoll.FindHull();
return false;
}
private void ApplyImpact(Vector2 normal,Contact contact)
{
Vector2 tempNormal;
FarseerPhysics.Common.FixedArray2<Vector2> worldPoints;
contact.GetWorldManifold(out tempNormal, out worldPoints);
Vector2 lastContactPoint = worldPoints[0];
float impact = Vector2.Dot(Velocity, -normal);
if (impact < 3.0f) return;
SoundPlayer.PlayDamageSound(DamageSoundType.StructureBlunt, impact * 10.0f, ConvertUnits.ToDisplayUnits(lastContactPoint));
GameMain.GameScreen.Cam.Shake = impact * 2.0f;
@@ -446,7 +458,6 @@ namespace Barotrauma
Explosion.RangedStructureDamage(ConvertUnits.ToDisplayUnits(lastContactPoint), impact * 50.0f, impact * DamageMultiplier);
return true;
}
}

View File

@@ -73,6 +73,8 @@ namespace Barotrauma
yield return CoroutineStatus.Running;
}
GUI.ScreenOverlayColor = Color.TransparentBlack;
Running = false;
yield return CoroutineStatus.Success;

View File

@@ -501,7 +501,7 @@ namespace Barotrauma.Networking
break;
case (byte)PacketTypes.UpdateNetLobby:
if (gameStarted) continue;
//if (gameStarted) continue;
GameMain.NetLobbyScreen.ReadData(inc);
break;
case (byte)PacketTypes.Traitor:

Binary file not shown.