Endworm & moloch immune to bleeding, showing right sub name in save file info, disable charactermode before saving, option to end round when the end of the level is reached, maintain position option in steering
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<Character name ="endworm" humanoid="false" health="10000.0">
|
<Character name ="endworm" humanoid="false" health="10000.0" doesbleed="false">
|
||||||
|
|
||||||
<sound file="Content/Characters/Endworm/endwormidle.ogg" state="None" range="8000" />
|
<sound file="Content/Characters/Endworm/endwormidle.ogg" state="None" range="8000" />
|
||||||
<sound file="Content/Characters/Endworm/endwormattack1.ogg" state="Attack" range="8000" />
|
<sound file="Content/Characters/Endworm/endwormattack1.ogg" state="Attack" range="8000" />
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<Character name ="moloch" humanoid="false" health ="1000">
|
<Character name="moloch" humanoid="false" health="1000" doesbleed="false">
|
||||||
|
|
||||||
<sound file="Content/Characters/Moloch/attack1.ogg" state="Attack" range="3000"/>
|
<sound file="Content/Characters/Moloch/attack1.ogg" state="Attack" range="3000"/>
|
||||||
<sound file="Content/Characters/Moloch/attack2.ogg" state="Attack" range="3000"/>
|
<sound file="Content/Characters/Moloch/attack2.ogg" state="Attack" range="3000"/>
|
||||||
|
|||||||
@@ -8,6 +8,11 @@
|
|||||||
|
|
||||||
<Sprite texture ="button.png" depth="0.8"/>
|
<Sprite texture ="button.png" depth="0.8"/>
|
||||||
|
|
||||||
|
<Deconstruct time="10">
|
||||||
|
<Item name="Polycarbonate Bar"/>
|
||||||
|
<Item name="FPGA Circuit"/>
|
||||||
|
</Deconstruct>
|
||||||
|
|
||||||
<Body width="32" height="32"/>
|
<Body width="32" height="32"/>
|
||||||
|
|
||||||
<Controller userpos="0" direction ="None" canbepicked = "true" msg="Open [E]">
|
<Controller userpos="0" direction ="None" canbepicked = "true" msg="Open [E]">
|
||||||
|
|||||||
@@ -7,6 +7,10 @@
|
|||||||
pickdistance="150"
|
pickdistance="150"
|
||||||
price="50">
|
price="50">
|
||||||
|
|
||||||
|
<Deconstruct time="10">
|
||||||
|
<Item name="Steel Bar"/>
|
||||||
|
</Deconstruct>
|
||||||
|
|
||||||
<Sprite texture ="oxygentank.png" depth="0.5"/>
|
<Sprite texture ="oxygentank.png" depth="0.5"/>
|
||||||
|
|
||||||
<Body radius="6" height="22" density="5"/>
|
<Body radius="6" height="22" density="5"/>
|
||||||
@@ -26,6 +30,10 @@
|
|||||||
price="50"
|
price="50"
|
||||||
description="Small enough to carry around in case of need, but won't protect you from the water pressure in the event of a full-blown hull breach.">
|
description="Small enough to carry around in case of need, but won't protect you from the water pressure in the event of a full-blown hull breach.">
|
||||||
|
|
||||||
|
<Deconstruct time="10">
|
||||||
|
<Item name="Polycarbonate Bar"/>
|
||||||
|
</Deconstruct>
|
||||||
|
|
||||||
<Sprite texture ="DivingMask.png" depth="0.5"/>
|
<Sprite texture ="DivingMask.png" depth="0.5"/>
|
||||||
|
|
||||||
<Body radius="18" density="5"/>
|
<Body radius="18" density="5"/>
|
||||||
@@ -101,6 +109,12 @@
|
|||||||
price="50"
|
price="50"
|
||||||
description="A battery-powered underwater propulsion device.">
|
description="A battery-powered underwater propulsion device.">
|
||||||
|
|
||||||
|
<Deconstruct time="20">
|
||||||
|
<Item name="Steel Bar"/>
|
||||||
|
<Item name="Copper Bar"/>
|
||||||
|
<Item name="Polycarbonate Bar"/>
|
||||||
|
</Deconstruct>
|
||||||
|
|
||||||
<Sprite texture ="DivingSuit.png" depth="0.5" sourcerect="22,98,59,32" origin="0.6,0.66"/>
|
<Sprite texture ="DivingSuit.png" depth="0.5" sourcerect="22,98,59,32" origin="0.6,0.66"/>
|
||||||
|
|
||||||
<Body width="55" height="30" density="5"/>
|
<Body width="55" height="30" density="5"/>
|
||||||
|
|||||||
@@ -10,6 +10,11 @@
|
|||||||
|
|
||||||
<Sprite texture ="tools.png" sourcerect="0,17,41,17" depth="0.5"/>
|
<Sprite texture ="tools.png" sourcerect="0,17,41,17" depth="0.5"/>
|
||||||
|
|
||||||
|
<Deconstruct time="10">
|
||||||
|
<Item name="Polycarbonate Bar"/>
|
||||||
|
<Item name="Steel Bar"/>
|
||||||
|
</Deconstruct>
|
||||||
|
|
||||||
<!-- physics body -->
|
<!-- physics body -->
|
||||||
<Body width="41" height="17" density="5"/>
|
<Body width="41" height="17" density="5"/>
|
||||||
|
|
||||||
@@ -56,6 +61,11 @@
|
|||||||
price="100"
|
price="100"
|
||||||
description="Cuts through various materials using a jet of ionized oxygen.">
|
description="Cuts through various materials using a jet of ionized oxygen.">
|
||||||
|
|
||||||
|
<Deconstruct time="10">
|
||||||
|
<Item name="Polycarbonate Bar"/>
|
||||||
|
<Item name="Steel Bar"/>
|
||||||
|
</Deconstruct>
|
||||||
|
|
||||||
<Sprite texture ="tools.png" sourcerect="0,0,41,16" depth="0.5"/>
|
<Sprite texture ="tools.png" sourcerect="0,0,41,16" depth="0.5"/>
|
||||||
|
|
||||||
<Body width="41" height="16" density="5"/>
|
<Body width="41" height="16" density="5"/>
|
||||||
@@ -94,6 +104,10 @@
|
|||||||
pickdistance="150"
|
pickdistance="150"
|
||||||
price="50">
|
price="50">
|
||||||
|
|
||||||
|
<Deconstruct time="10">
|
||||||
|
<Item name="Steel Bar"/>
|
||||||
|
</Deconstruct>
|
||||||
|
|
||||||
<Sprite texture ="fueltank.png" depth="0.5"/>
|
<Sprite texture ="fueltank.png" depth="0.5"/>
|
||||||
|
|
||||||
<Body radius="6" height="22" density="5"/>
|
<Body radius="6" height="22" density="5"/>
|
||||||
@@ -113,6 +127,11 @@
|
|||||||
price="100"
|
price="100"
|
||||||
description="A handheld carbon dioxide extinguisher.">
|
description="A handheld carbon dioxide extinguisher.">
|
||||||
|
|
||||||
|
<Deconstruct time="10">
|
||||||
|
<Item name="Polycarbonate Bar"/>
|
||||||
|
<Item name="Steel Bar"/>
|
||||||
|
</Deconstruct>
|
||||||
|
|
||||||
<Sprite texture ="extinguisher.png" depth="0.5" sourcerect="0,0,34,64" origin="0.4,0.5"/>
|
<Sprite texture ="extinguisher.png" depth="0.5" sourcerect="0,0,34,64" origin="0.4,0.5"/>
|
||||||
|
|
||||||
<Body radius="10" height="45" density="5"/>
|
<Body radius="10" height="45" density="5"/>
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ namespace Barotrauma
|
|||||||
//the collision is ignored if the lowest limb is under the platform
|
//the collision is ignored if the lowest limb is under the platform
|
||||||
if (lowestLimb==null || lowestLimb.Position.Y < structure.Rect.Y) return false;
|
if (lowestLimb==null || lowestLimb.Position.Y < structure.Rect.Y) return false;
|
||||||
}
|
}
|
||||||
else if (structure.StairDirection!=Direction.None && lowestLimb != null)
|
else if (structure.StairDirection != Direction.None && lowestLimb != null)
|
||||||
{
|
{
|
||||||
float stairPosY = structure.StairDirection == Direction.Right ?
|
float stairPosY = structure.StairDirection == Direction.Right ?
|
||||||
lowestLimb.Position.X - structure.Rect.X : structure.Rect.Width - (lowestLimb.Position.X - structure.Rect.X);
|
lowestLimb.Position.X - structure.Rect.X : structure.Rect.Width - (lowestLimb.Position.X - structure.Rect.X);
|
||||||
|
|||||||
@@ -253,6 +253,12 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool DoesBleed
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public float PressureTimer
|
public float PressureTimer
|
||||||
{
|
{
|
||||||
@@ -402,6 +408,8 @@ namespace Barotrauma
|
|||||||
maxHealth = ToolBox.GetAttributeFloat(doc.Root, "health", 100.0f);
|
maxHealth = ToolBox.GetAttributeFloat(doc.Root, "health", 100.0f);
|
||||||
health = maxHealth;
|
health = maxHealth;
|
||||||
|
|
||||||
|
DoesBleed = ToolBox.GetAttributeBool(doc.Root, "doesbleed", true);
|
||||||
|
|
||||||
needsAir = ToolBox.GetAttributeBool(doc.Root, "needsair", false);
|
needsAir = ToolBox.GetAttributeBool(doc.Root, "needsair", false);
|
||||||
drowningTime = ToolBox.GetAttributeFloat(doc.Root, "drowningtime", 10.0f);
|
drowningTime = ToolBox.GetAttributeFloat(doc.Root, "drowningtime", 10.0f);
|
||||||
|
|
||||||
@@ -958,7 +966,7 @@ namespace Barotrauma
|
|||||||
PressureProtection -= deltaTime*100.0f;
|
PressureProtection -= deltaTime*100.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
Health -= bleeding;
|
Health -= bleeding*deltaTime;
|
||||||
if (health <= 0.0f) Kill(CauseOfDeath.Bloodloss, false);
|
if (health <= 0.0f) Kill(CauseOfDeath.Bloodloss, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1093,8 +1101,10 @@ namespace Barotrauma
|
|||||||
|
|
||||||
//health -= attackResult.Damage;
|
//health -= attackResult.Damage;
|
||||||
//if (health <= 0.0f && damageType == DamageType.Burn) Kill(CauseOfDeath.Burn);
|
//if (health <= 0.0f && damageType == DamageType.Burn) Kill(CauseOfDeath.Burn);
|
||||||
|
if (DoesBleed)
|
||||||
Bleeding += attackResult.Bleeding;
|
{
|
||||||
|
Bleeding += attackResult.Bleeding;
|
||||||
|
}
|
||||||
|
|
||||||
return attackResult;
|
return attackResult;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -359,6 +359,11 @@ namespace Barotrauma
|
|||||||
case "save":
|
case "save":
|
||||||
if (commands.Length < 2) break;
|
if (commands.Length < 2) break;
|
||||||
|
|
||||||
|
if (GameMain.EditMapScreen.CharacterMode)
|
||||||
|
{
|
||||||
|
GameMain.EditMapScreen.ToggleCharacterMode();
|
||||||
|
}
|
||||||
|
|
||||||
string fileName = string.Join(" ", commands.Skip(1));
|
string fileName = string.Join(" ", commands.Skip(1));
|
||||||
if (fileName.Contains("../"))
|
if (fileName.Contains("../"))
|
||||||
{
|
{
|
||||||
@@ -369,7 +374,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (WayPoint.WayPointList.Find(wp => !wp.MoveWithLevel && wp.SpawnType == SpawnType.Path)==null)
|
if (WayPoint.WayPointList.Find(wp => !wp.MoveWithLevel && wp.SpawnType == SpawnType.Path)==null)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("No waypoints found in the submarine. Did you forget to generate the waypoints?");
|
DebugConsole.ThrowError("No waypoints found in the submarine. AI controlled crew members won't be able to navigate without waypoints.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WayPoint.WayPointList.Find(wp => wp.SpawnType == SpawnType.Cargo) == null)
|
if (WayPoint.WayPointList.Find(wp => wp.SpawnType == SpawnType.Cargo) == null)
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
private static string configFile = "Content/randomevents.xml";
|
private static string configFile = "Content/randomevents.xml";
|
||||||
|
|
||||||
const int MaxPreviousEvents = 6;
|
//const int MaxPreviousEvents = 6;
|
||||||
const float PreviouslyUsedWeight = 10.0f;
|
//const float PreviouslyUsedWeight = 10.0f;
|
||||||
|
|
||||||
static List<int> previousEvents = new List<int>();
|
//static List<int> previousEvents = new List<int>();
|
||||||
|
|
||||||
protected string name;
|
protected string name;
|
||||||
protected string description;
|
protected string description;
|
||||||
@@ -109,16 +109,16 @@ namespace Barotrauma
|
|||||||
eventProbability[i] = ToolBox.GetAttributeInt(element, "commonness", 1);
|
eventProbability[i] = ToolBox.GetAttributeInt(element, "commonness", 1);
|
||||||
|
|
||||||
//if the event has been previously selected, it's less likely to be selected now
|
//if the event has been previously selected, it's less likely to be selected now
|
||||||
int previousEventIndex = previousEvents.FindIndex(x => x == i);
|
//int previousEventIndex = previousEvents.FindIndex(x => x == i);
|
||||||
if (previousEventIndex >= 0)
|
//if (previousEventIndex >= 0)
|
||||||
{
|
//{
|
||||||
//how many shifts ago was the event last selected
|
// //how many shifts ago was the event last selected
|
||||||
int eventDist = eventCount - previousEventIndex;
|
// int eventDist = eventCount - previousEventIndex;
|
||||||
|
|
||||||
float weighting = (1.0f / eventDist) * PreviouslyUsedWeight;
|
// float weighting = (1.0f / eventDist) * PreviouslyUsedWeight;
|
||||||
|
|
||||||
eventProbability[i] *= weighting;
|
// eventProbability[i] *= weighting;
|
||||||
}
|
//}
|
||||||
|
|
||||||
probabilitySum += eventProbability[i];
|
probabilitySum += eventProbability[i];
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ namespace Barotrauma
|
|||||||
ConstructorInfo constructor = t.GetConstructor(new[] { typeof(XElement) });
|
ConstructorInfo constructor = t.GetConstructor(new[] { typeof(XElement) });
|
||||||
object instance = constructor.Invoke(new object[] { element });
|
object instance = constructor.Invoke(new object[] { element });
|
||||||
|
|
||||||
previousEvents.Add(i);
|
//previousEvents.Add(i);
|
||||||
|
|
||||||
return (ScriptedEvent)instance;
|
return (ScriptedEvent)instance;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,15 +78,14 @@ namespace Barotrauma
|
|||||||
this.submarine = submarine;
|
this.submarine = submarine;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameSession(Submarine selectedSub, string saveFile, string filePath)
|
public GameSession(Submarine selectedSub, string saveFile, XDocument doc)
|
||||||
: this(selectedSub, saveFile)
|
: this(selectedSub, saveFile)
|
||||||
{
|
{
|
||||||
GameMain.GameSession = this;
|
GameMain.GameSession = this;
|
||||||
|
|
||||||
CrewManager = new CrewManager();
|
CrewManager = new CrewManager();
|
||||||
|
|
||||||
XDocument doc = ToolBox.TryLoadXml(filePath);
|
selectedSub.Name = ToolBox.GetAttributeString(doc.Root, "submarine", selectedSub.Name);
|
||||||
if (doc == null) return;
|
|
||||||
|
|
||||||
foreach (XElement subElement in doc.Root.Elements())
|
foreach (XElement subElement in doc.Root.Elements())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,8 +17,12 @@ namespace Barotrauma.Items.Components
|
|||||||
private Vector2 currVelocity;
|
private Vector2 currVelocity;
|
||||||
private Vector2 targetVelocity;
|
private Vector2 targetVelocity;
|
||||||
|
|
||||||
|
private GUITickBox maintainPosTickBox;
|
||||||
|
|
||||||
private bool autoPilot;
|
private bool autoPilot;
|
||||||
|
|
||||||
|
private Vector2? posToMaintain;
|
||||||
|
|
||||||
private SteeringPath steeringPath;
|
private SteeringPath steeringPath;
|
||||||
|
|
||||||
private PathFinder pathFinder;
|
private PathFinder pathFinder;
|
||||||
@@ -39,6 +43,9 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
autoPilot = value;
|
autoPilot = value;
|
||||||
|
|
||||||
|
maintainPosTickBox.Enabled = autoPilot;
|
||||||
|
|
||||||
|
|
||||||
if (autoPilot)
|
if (autoPilot)
|
||||||
{
|
{
|
||||||
if (pathFinder==null) pathFinder = new PathFinder(WayPoint.WayPointList, false);
|
if (pathFinder==null) pathFinder = new PathFinder(WayPoint.WayPointList, false);
|
||||||
@@ -46,6 +53,11 @@ namespace Barotrauma.Items.Components
|
|||||||
ConvertUnits.ToSimUnits(item.WorldPosition),
|
ConvertUnits.ToSimUnits(item.WorldPosition),
|
||||||
ConvertUnits.ToSimUnits(Level.Loaded.EndPosition));
|
ConvertUnits.ToSimUnits(Level.Loaded.EndPosition));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
maintainPosTickBox.Selected = false;
|
||||||
|
posToMaintain = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +99,6 @@ namespace Barotrauma.Items.Components
|
|||||||
IsActive = true;
|
IsActive = true;
|
||||||
|
|
||||||
var tickBox = new GUITickBox(new Rectangle(0,25,20,20), "Autopilot", Alignment.TopLeft, GuiFrame);
|
var tickBox = new GUITickBox(new Rectangle(0,25,20,20), "Autopilot", Alignment.TopLeft, GuiFrame);
|
||||||
|
|
||||||
tickBox.OnSelected = (GUITickBox box) =>
|
tickBox.OnSelected = (GUITickBox box) =>
|
||||||
{
|
{
|
||||||
AutoPilot = box.Selected;
|
AutoPilot = box.Selected;
|
||||||
@@ -95,6 +106,10 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
maintainPosTickBox = new GUITickBox(new Rectangle(0, 50, 20, 20), "Maintain position", Alignment.TopLeft, GuiFrame);
|
||||||
|
maintainPosTickBox.Enabled = false;
|
||||||
|
maintainPosTickBox.OnSelected = ToggleMaintainPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(float deltaTime, Camera cam)
|
public override void Update(float deltaTime, Camera cam)
|
||||||
@@ -179,47 +194,95 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
private void UpdateAutoPilot(float deltaTime)
|
private void UpdateAutoPilot(float deltaTime)
|
||||||
{
|
{
|
||||||
autopilotRayCastTimer -= deltaTime;
|
if (posToMaintain==null)
|
||||||
|
|
||||||
steeringPath.CheckProgress(ConvertUnits.ToSimUnits(item.WorldPosition), 10.0f);
|
|
||||||
|
|
||||||
if (autopilotRayCastTimer<=0.0f && steeringPath.NextNode != null)
|
|
||||||
{
|
{
|
||||||
Vector2 diff = ConvertUnits.ToSimUnits(steeringPath.NextNode.Position - item.WorldPosition);
|
|
||||||
|
|
||||||
bool nextVisible = true;
|
autopilotRayCastTimer -= deltaTime;
|
||||||
for (int x = -1; x < 2; x += 2)
|
|
||||||
|
steeringPath.CheckProgress(ConvertUnits.ToSimUnits(item.WorldPosition), 10.0f);
|
||||||
|
|
||||||
|
if (autopilotRayCastTimer<=0.0f && steeringPath.NextNode != null)
|
||||||
{
|
{
|
||||||
for (int y = -1; y < 2; y += 2)
|
Vector2 diff = Vector2.Normalize(ConvertUnits.ToSimUnits(steeringPath.NextNode.Position - Submarine.Loaded.WorldPosition));
|
||||||
|
|
||||||
|
bool nextVisible = true;
|
||||||
|
for (int x = -1; x < 2; x += 2)
|
||||||
{
|
{
|
||||||
Vector2 cornerPos =
|
for (int y = -1; y < 2; y += 2)
|
||||||
new Vector2(Submarine.Borders.Width * x, Submarine.Borders.Height * y) / 2.0f;
|
{
|
||||||
|
Vector2 cornerPos =
|
||||||
|
new Vector2(Submarine.Borders.Width * x, Submarine.Borders.Height * y) / 2.0f;
|
||||||
|
|
||||||
cornerPos = ConvertUnits.ToSimUnits(cornerPos * 1.2f + Submarine.Loaded.Position);
|
cornerPos = ConvertUnits.ToSimUnits(cornerPos * 1.2f + Submarine.Loaded.WorldPosition);
|
||||||
|
|
||||||
if (Submarine.PickBody(cornerPos, cornerPos + diff, null, Physics.CollisionLevel) == null) continue;
|
float dist = Vector2.Distance(cornerPos, steeringPath.NextNode.SimPosition);
|
||||||
|
|
||||||
nextVisible = false;
|
if (Submarine.PickBody(cornerPos, cornerPos + diff*dist, null, Physics.CollisionLevel) == null) continue;
|
||||||
x = 2;
|
|
||||||
y = 2;
|
nextVisible = false;
|
||||||
|
x = 2;
|
||||||
|
y = 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nextVisible) steeringPath.SkipToNextNode();
|
||||||
|
|
||||||
|
autopilotRayCastTimer = AutopilotRayCastInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextVisible) steeringPath.SkipToNextNode();
|
if (steeringPath.CurrentNode != null)
|
||||||
|
{
|
||||||
autopilotRayCastTimer = AutopilotRayCastInterval;
|
SteerTowardsPosition(steeringPath.CurrentNode.WorldPosition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SteerTowardsPosition((Vector2)posToMaintain);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (steeringPath.CurrentNode != null)
|
}
|
||||||
|
|
||||||
|
private void SteerTowardsPosition(Vector2 worldPosition)
|
||||||
|
{
|
||||||
|
float prediction = 10.0f;
|
||||||
|
|
||||||
|
Vector2 futurePosition = ConvertUnits.ToDisplayUnits(item.Submarine.Velocity) * prediction;
|
||||||
|
Vector2 targetSpeed = ((worldPosition - item.WorldPosition) - futurePosition);
|
||||||
|
|
||||||
|
if (targetSpeed.Length()>500.0f)
|
||||||
{
|
{
|
||||||
float prediction = 5.0f;
|
|
||||||
|
|
||||||
Vector2 futurePosition = ConvertUnits.ToDisplayUnits(item.Submarine.Velocity) * prediction;
|
|
||||||
Vector2 targetSpeed = ((steeringPath.CurrentNode.WorldPosition - item.WorldPosition) - futurePosition);
|
|
||||||
|
|
||||||
targetSpeed = Vector2.Normalize(targetSpeed);
|
targetSpeed = Vector2.Normalize(targetSpeed);
|
||||||
TargetVelocity = targetSpeed * 100.0f;
|
TargetVelocity = targetSpeed * 100.0f;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
targetVelocity = targetSpeed/5.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool ToggleMaintainPosition(GUITickBox tickBox)
|
||||||
|
{
|
||||||
|
item.NewComponentEvent(this, true, true);
|
||||||
|
|
||||||
|
if (tickBox.Selected)
|
||||||
|
{
|
||||||
|
if (Submarine.Loaded == null)
|
||||||
|
{
|
||||||
|
posToMaintain = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
posToMaintain = item.WorldPosition;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
posToMaintain = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power=0.0f)
|
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power=0.0f)
|
||||||
@@ -236,6 +299,15 @@ namespace Barotrauma.Items.Components
|
|||||||
message.Write(targetVelocity.Y);
|
message.Write(targetVelocity.Y);
|
||||||
|
|
||||||
message.Write(autoPilot);
|
message.Write(autoPilot);
|
||||||
|
if (autoPilot)
|
||||||
|
{
|
||||||
|
message.Write(posToMaintain != null);
|
||||||
|
if (posToMaintain != null)
|
||||||
|
{
|
||||||
|
message.Write(((Vector2)posToMaintain).X);
|
||||||
|
message.Write(((Vector2)posToMaintain).Y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -245,10 +317,22 @@ namespace Barotrauma.Items.Components
|
|||||||
Vector2 newTargetVelocity = Vector2.Zero;
|
Vector2 newTargetVelocity = Vector2.Zero;
|
||||||
bool newAutoPilot = false;
|
bool newAutoPilot = false;
|
||||||
|
|
||||||
|
Vector2? newPosToMaintain = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
newTargetVelocity = new Vector2(message.ReadFloat(), message.ReadFloat());
|
newTargetVelocity = new Vector2(message.ReadFloat(), message.ReadFloat());
|
||||||
newAutoPilot = message.ReadBoolean();
|
newAutoPilot = message.ReadBoolean();
|
||||||
|
if (newAutoPilot)
|
||||||
|
{
|
||||||
|
bool maintainPos = message.ReadBoolean();
|
||||||
|
if (maintainPos)
|
||||||
|
{
|
||||||
|
newPosToMaintain = new Vector2(
|
||||||
|
message.ReadFloat(),
|
||||||
|
message.ReadFloat());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
catch
|
catch
|
||||||
@@ -258,6 +342,9 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
TargetVelocity = newTargetVelocity;
|
TargetVelocity = newTargetVelocity;
|
||||||
AutoPilot = newAutoPilot;
|
AutoPilot = newAutoPilot;
|
||||||
|
|
||||||
|
maintainPosTickBox.Selected = newPosToMaintain != null;
|
||||||
|
posToMaintain = newPosToMaintain;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace Barotrauma
|
|||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get { return name; }
|
get { return name; }
|
||||||
//set { name = value; }
|
set { name = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector2 LastPickedPosition
|
public static Vector2 LastPickedPosition
|
||||||
|
|||||||
@@ -468,7 +468,7 @@ namespace Barotrauma
|
|||||||
Vector2 limbForce = direction * impact * 0.5f;
|
Vector2 limbForce = direction * impact * 0.5f;
|
||||||
|
|
||||||
float length = limbForce.Length();
|
float length = limbForce.Length();
|
||||||
if (length > 10.0f) limbForce = (limbForce / length) * 10.0f;
|
if (length > 5.0f) limbForce = (limbForce / length) * 5.0f;
|
||||||
|
|
||||||
foreach (Character c in Character.CharacterList)
|
foreach (Character c in Character.CharacterList)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -181,14 +181,16 @@ namespace Barotrauma.Networking
|
|||||||
if (DateTime.Now > timeOut)
|
if (DateTime.Now > timeOut)
|
||||||
{
|
{
|
||||||
restRequestHandle.Abort();
|
restRequestHandle.Abort();
|
||||||
DebugConsole.ThrowError("Couldn't connect to master server (request timed out)");
|
DebugConsole.NewMessage("Couldn't connect to master server (request timed out)", Color.Red);
|
||||||
registeredToMaster = false;
|
break;
|
||||||
|
//registeredToMaster = false;
|
||||||
}
|
}
|
||||||
System.Diagnostics.Debug.WriteLine("took "+sw.ElapsedMilliseconds+" ms");
|
|
||||||
|
|
||||||
yield return CoroutineStatus.Running;
|
yield return CoroutineStatus.Running;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.Diagnostics.Debug.WriteLine("took "+sw.ElapsedMilliseconds+" ms");
|
||||||
|
|
||||||
yield return CoroutineStatus.Success;
|
yield return CoroutineStatus.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,15 +200,13 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
if (response.ErrorException != null)
|
if (response.ErrorException != null)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Error while registering to master server", response.ErrorException);
|
DebugConsole.NewMessage("Error while registering to master server (" + response.ErrorException + ")", Color.Red);
|
||||||
registeredToMaster = false;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.StatusCode != System.Net.HttpStatusCode.OK)
|
if (response.StatusCode != System.Net.HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
DebugConsole.NewMessage("Error while reporting to master server (" + response.StatusCode + ": " + response.StatusDescription + ")", Color.Red);
|
DebugConsole.NewMessage("Error while reporting to master server (" + response.StatusCode + ": " + response.StatusDescription + ")", Color.Red);
|
||||||
//registeredToMaster = false;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,10 +224,14 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
inGameHUD.Update((float)Physics.step);
|
inGameHUD.Update((float)Physics.step);
|
||||||
|
|
||||||
//if all characters dead
|
bool isCrewDead =
|
||||||
if (AutoRestart &&
|
|
||||||
ConnectedClients.Find(c => c.Character != null && !c.Character.IsDead)==null &&
|
ConnectedClients.Find(c => c.Character != null && !c.Character.IsDead)==null &&
|
||||||
(myCharacter == null || myCharacter.IsDead))
|
(myCharacter == null || myCharacter.IsDead);
|
||||||
|
|
||||||
|
//restart if all characters are dead or submarine is at the end of the level
|
||||||
|
if ((AutoRestart && isCrewDead)
|
||||||
|
||
|
||||||
|
(endRoundAtLevelEnd && Submarine.Loaded!=null && Submarine.Loaded.AtEndPosition))
|
||||||
{
|
{
|
||||||
EndButtonHit(null, null);
|
EndButtonHit(null, null);
|
||||||
UpdateNetLobby(null,null);
|
UpdateNetLobby(null,null);
|
||||||
@@ -284,7 +288,7 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
if (gameStarted)
|
if (gameStarted)
|
||||||
{
|
{
|
||||||
if (myCharacter != null) new NetworkEvent(NetworkEventType.EntityUpdate, myCharacter.ID, false);
|
if (myCharacter != null && !myCharacter.IsDead) new NetworkEvent(NetworkEventType.EntityUpdate, myCharacter.ID, false);
|
||||||
|
|
||||||
foreach (Character c in Character.CharacterList)
|
foreach (Character c in Character.CharacterList)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
public bool ShowNetStats;
|
public bool ShowNetStats;
|
||||||
|
|
||||||
private TimeSpan refreshMasterInterval = new TimeSpan(0, 0, 40);
|
private TimeSpan refreshMasterInterval = new TimeSpan(0, 0, 30);
|
||||||
private TimeSpan sparseUpdateInterval = new TimeSpan(0, 0, 0, 3);
|
private TimeSpan sparseUpdateInterval = new TimeSpan(0, 0, 0, 3);
|
||||||
|
|
||||||
private SelectionMode subSelectionMode, modeSelectionMode;
|
private SelectionMode subSelectionMode, modeSelectionMode;
|
||||||
@@ -41,6 +41,8 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
private bool allowSpectating = true;
|
private bool allowSpectating = true;
|
||||||
|
|
||||||
|
private bool endRoundAtLevelEnd = true;
|
||||||
|
|
||||||
public bool AutoRestart
|
public bool AutoRestart
|
||||||
{
|
{
|
||||||
get { return (ConnectedClients.Count == 0) ? false : autoRestart; }
|
get { return (ConnectedClients.Count == 0) ? false : autoRestart; }
|
||||||
@@ -85,16 +87,22 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
private void CreateSettingsFrame()
|
private void CreateSettingsFrame()
|
||||||
{
|
{
|
||||||
settingsFrame = new GUIFrame(new Rectangle(0,0,GameMain.GraphicsWidth,GameMain.GraphicsHeight), Color.Black*0.5f);
|
settingsFrame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.5f);
|
||||||
|
|
||||||
GUIFrame innerFrame = new GUIFrame(new Rectangle(0,0,400,400), null, Alignment.Center, GUI.Style, settingsFrame);
|
GUIFrame innerFrame = new GUIFrame(new Rectangle(0, 0, 400, 400), null, Alignment.Center, GUI.Style, settingsFrame);
|
||||||
|
|
||||||
var randomizeLevelBox = new GUITickBox(new Rectangle(0, 0, 20, 20), "Randomize level seed", Alignment.Left, innerFrame);
|
new GUITextBlock(new Rectangle(0, -15, 0, 20), "Server settings", GUI.Style, innerFrame, GUI.LargeFont);
|
||||||
|
|
||||||
|
var randomizeLevelBox = new GUITickBox(new Rectangle(0, 30, 20, 20), "Randomize level seed", Alignment.Left, innerFrame);
|
||||||
randomizeLevelBox.Selected = randomizeSeed;
|
randomizeLevelBox.Selected = randomizeSeed;
|
||||||
randomizeLevelBox.OnSelected = ToggleRandomizeSeed;
|
randomizeLevelBox.OnSelected = ToggleRandomizeSeed;
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(0, 35, 100, 20), "Submarine selection:", GUI.Style, innerFrame);
|
var endBox = new GUITickBox(new Rectangle(0, 60, 20, 20), "End round when destination reached", Alignment.Left, innerFrame);
|
||||||
var selectionFrame = new GUIFrame(new Rectangle(0, 60, 300, 20), null, innerFrame);
|
endBox.Selected = endRoundAtLevelEnd;
|
||||||
|
endBox.OnSelected = (GUITickBox) => { endRoundAtLevelEnd = GUITickBox.Selected; return true; };
|
||||||
|
|
||||||
|
new GUITextBlock(new Rectangle(0, 95, 100, 20), "Submarine selection:", GUI.Style, innerFrame);
|
||||||
|
var selectionFrame = new GUIFrame(new Rectangle(0, 120, 300, 20), null, innerFrame);
|
||||||
for (int i = 0; i<3; i++)
|
for (int i = 0; i<3; i++)
|
||||||
{
|
{
|
||||||
var selectionTick = new GUITickBox(new Rectangle(i * 100, 0, 20, 20), ((SelectionMode)i).ToString(), Alignment.Left, selectionFrame);
|
var selectionTick = new GUITickBox(new Rectangle(i * 100, 0, 20, 20), ((SelectionMode)i).ToString(), Alignment.Left, selectionFrame);
|
||||||
@@ -103,8 +111,8 @@ namespace Barotrauma.Networking
|
|||||||
selectionTick.UserData = (SelectionMode)i;
|
selectionTick.UserData = (SelectionMode)i;
|
||||||
}
|
}
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(0, 85, 100, 20), "Mode selection:", GUI.Style, innerFrame);
|
new GUITextBlock(new Rectangle(0, 145, 100, 20), "Mode selection:", GUI.Style, innerFrame);
|
||||||
selectionFrame = new GUIFrame(new Rectangle(0, 110, 300, 20), null, innerFrame);
|
selectionFrame = new GUIFrame(new Rectangle(0, 170, 300, 20), null, innerFrame);
|
||||||
for (int i = 0; i<3; i++)
|
for (int i = 0; i<3; i++)
|
||||||
{
|
{
|
||||||
var selectionTick = new GUITickBox(new Rectangle(i*100, 0, 20, 20), ((SelectionMode)i).ToString(), Alignment.Left, selectionFrame);
|
var selectionTick = new GUITickBox(new Rectangle(i*100, 0, 20, 20), ((SelectionMode)i).ToString(), Alignment.Left, selectionFrame);
|
||||||
@@ -113,7 +121,7 @@ namespace Barotrauma.Networking
|
|||||||
selectionTick.UserData = (SelectionMode)i;
|
selectionTick.UserData = (SelectionMode)i;
|
||||||
}
|
}
|
||||||
|
|
||||||
var allowSpecBox = new GUITickBox(new Rectangle(0, 150, 20, 20), "Allow spectating", Alignment.Left, innerFrame);
|
var allowSpecBox = new GUITickBox(new Rectangle(0, 210, 20, 20), "Allow spectating", Alignment.Left, innerFrame);
|
||||||
allowSpecBox.Selected = true;
|
allowSpecBox.Selected = true;
|
||||||
allowSpecBox.OnSelected = ToggleAllowSpectating;
|
allowSpecBox.OnSelected = ToggleAllowSpectating;
|
||||||
|
|
||||||
|
|||||||
@@ -293,6 +293,12 @@ namespace Barotrauma
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void ToggleCharacterMode()
|
||||||
|
{
|
||||||
|
ToggleCharacterMode(null,null);
|
||||||
|
}
|
||||||
|
|
||||||
private bool ToggleCharacterMode(GUIButton button, object obj)
|
private bool ToggleCharacterMode(GUIButton button, object obj)
|
||||||
{
|
{
|
||||||
selectedTab = -1;
|
selectedTab = -1;
|
||||||
@@ -397,28 +403,30 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (characterMode)
|
if (characterMode)
|
||||||
{
|
{
|
||||||
if (Entity.FindEntityByID(dummyCharacter.ID)!=dummyCharacter)
|
if (dummyCharacter == null || Entity.FindEntityByID(dummyCharacter.ID)!=dummyCharacter)
|
||||||
{
|
{
|
||||||
ToggleCharacterMode(null, null);
|
ToggleCharacterMode(null, null);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
foreach (MapEntity me in MapEntity.mapEntityList)
|
|
||||||
{
|
{
|
||||||
me.IsHighlighted = false;
|
foreach (MapEntity me in MapEntity.mapEntityList)
|
||||||
}
|
|
||||||
|
|
||||||
if (dummyCharacter.SelectedConstruction==null)
|
|
||||||
{
|
|
||||||
Vector2 mouseSimPos = FarseerPhysics.ConvertUnits.ToSimUnits(dummyCharacter.CursorPosition);
|
|
||||||
foreach (Limb limb in dummyCharacter.AnimController.Limbs)
|
|
||||||
{
|
{
|
||||||
limb.body.SetTransform(mouseSimPos, 0.0f);
|
me.IsHighlighted = false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
dummyCharacter.ControlLocalPlayer((float)deltaTime, cam, false);
|
if (dummyCharacter.SelectedConstruction==null)
|
||||||
dummyCharacter.Control((float)deltaTime, cam);
|
{
|
||||||
cam.TargetPos = Vector2.Zero;
|
Vector2 mouseSimPos = FarseerPhysics.ConvertUnits.ToSimUnits(dummyCharacter.CursorPosition);
|
||||||
|
foreach (Limb limb in dummyCharacter.AnimController.Limbs)
|
||||||
|
{
|
||||||
|
limb.body.SetTransform(mouseSimPos, 0.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dummyCharacter.ControlLocalPlayer((float)deltaTime, cam, false);
|
||||||
|
dummyCharacter.Control((float)deltaTime, cam);
|
||||||
|
cam.TargetPos = Vector2.Zero;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -480,9 +480,9 @@ namespace Barotrauma
|
|||||||
Directory.CreateDirectory(SaveUtil.TempPath);
|
Directory.CreateDirectory(SaveUtil.TempPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
File.Copy(selectedSub.FilePath, Path.Combine(SaveUtil.TempPath, "map.sub"), true);
|
File.Copy(selectedSub.FilePath, Path.Combine(SaveUtil.TempPath, selectedSub.Name+".sub"), true);
|
||||||
|
|
||||||
selectedSub = new Submarine(Path.Combine(SaveUtil.TempPath, "map.sub"), "");
|
selectedSub = new Submarine(Path.Combine(SaveUtil.TempPath, selectedSub.Name + ".sub"), "");
|
||||||
|
|
||||||
GameMain.GameSession = new GameSession(selectedSub, saveNameBox.Text, GameModePreset.list.Find(gm => gm.Name == "Single Player"));
|
GameMain.GameSession = new GameSession(selectedSub, saveNameBox.Text, GameModePreset.list.Find(gm => gm.Name == "Single Player"));
|
||||||
(GameMain.GameSession.gameMode as SinglePlayerMode).GenerateMap(seedBox.Text);
|
(GameMain.GameSession.gameMode as SinglePlayerMode).GenerateMap(seedBox.Text);
|
||||||
@@ -515,7 +515,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Loading map ''"+saveFile+"'' failed", e);
|
DebugConsole.ThrowError("Loading save ''"+saveFile+"'' failed", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,30 +25,16 @@ namespace Barotrauma
|
|||||||
|
|
||||||
string tempPath = Path.Combine(SaveFolder, "temp");
|
string tempPath = Path.Combine(SaveFolder, "temp");
|
||||||
|
|
||||||
//if (Directory.Exists(tempPath))
|
|
||||||
//{
|
|
||||||
// Directory.Delete(tempPath, true);
|
|
||||||
//}
|
|
||||||
|
|
||||||
if (!Directory.Exists(tempPath))
|
if (!Directory.Exists(tempPath))
|
||||||
{
|
{
|
||||||
// DecompressToDirectory(fileName, tempPath, null);
|
|
||||||
//}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
Directory.CreateDirectory(tempPath);
|
Directory.CreateDirectory(tempPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
//Directory.CreateDirectory(Path.GetDirectoryName(filePath) + "\\temp");
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (Submarine.Loaded!=null)
|
if (Submarine.Loaded != null)
|
||||||
{
|
{
|
||||||
Submarine.Loaded.SaveAs(Path.Combine(tempPath, "map.sub"));
|
Submarine.Loaded.SaveAs(Path.Combine(tempPath, Submarine.Loaded.Name+".sub"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -83,8 +69,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
DecompressToDirectory(filePath, TempPath, null);
|
DecompressToDirectory(filePath, TempPath, null);
|
||||||
|
|
||||||
Submarine selectedMap = new Submarine(Path.Combine(TempPath, "map.sub"), "");// Submarine.Load();
|
XDocument doc = ToolBox.TryLoadXml(Path.Combine(TempPath, "gamesession.xml"));
|
||||||
GameMain.GameSession = new GameSession(selectedMap, fileName, Path.Combine(TempPath, "gamesession.xml"));
|
|
||||||
|
string subPath = Path.Combine(TempPath, ToolBox.GetAttributeString(doc.Root, "submarine", ""));
|
||||||
|
Submarine selectedMap = new Submarine(subPath, "");// Submarine.Load();
|
||||||
|
GameMain.GameSession = new GameSession(selectedMap, fileName, doc);
|
||||||
|
|
||||||
//Directory.Delete(tempPath, true);
|
//Directory.Delete(tempPath, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ namespace Barotrauma
|
|||||||
string relativePath = GetRelativePath(file, currentDir);
|
string relativePath = GetRelativePath(file, currentDir);
|
||||||
|
|
||||||
string dirRoot = relativePath.Split(Path.DirectorySeparatorChar).First();
|
string dirRoot = relativePath.Split(Path.DirectorySeparatorChar).First();
|
||||||
if (dirRoot == "Data") continue;
|
if (dirRoot != "Content" && dirRoot != "") continue;
|
||||||
|
|
||||||
if (filesToKeep.Contains(relativePath)) continue;
|
if (filesToKeep.Contains(relativePath)) continue;
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user