Merge branch 'master' of https://github.com/Regalis11/barotrauma
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -16,3 +16,4 @@ bld/
|
||||
#performance reports & sessions
|
||||
*.vsp
|
||||
*.psess
|
||||
.vs/
|
||||
|
||||
@@ -340,13 +340,6 @@ namespace Barotrauma
|
||||
new GUIMessageBox("", string.Join(" ", args));
|
||||
}));
|
||||
|
||||
commands.Add(new Command("autorestart", "autorestart: Toggle autorestart on/off when hosting a server.", (string[] args) =>
|
||||
{
|
||||
if (GameMain.Server == null) return;
|
||||
GameMain.NetLobbyScreen.ToggleAutoRestart();
|
||||
NewMessage(GameMain.Server.AutoRestart ? "Automatic restart enabled." : "Automatic restart disabled.", Color.White);
|
||||
}));
|
||||
|
||||
commands.Add(new Command("debugdraw", "debugdraw: Toggle the debug drawing mode on/off.", (string[] args) =>
|
||||
{
|
||||
GameMain.DebugDraw = !GameMain.DebugDraw;
|
||||
|
||||
@@ -17,6 +17,9 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
public override IEnumerable<object> UpdateState()
|
||||
{
|
||||
Character Controlled = Character.Controlled;
|
||||
if (Controlled == null) yield return CoroutineStatus.Success;
|
||||
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
var wire = item.GetComponent<Wire>();
|
||||
@@ -38,9 +41,9 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
Door tutorialDoor = Item.ItemList.Find(i => i.HasTag("tutorialdoor")).GetComponent<Door>();
|
||||
|
||||
while (!tutorialDoor.IsOpen && Character.Controlled.WorldPosition.X < tutorialDoor.Item.WorldPosition.X)
|
||||
while (!tutorialDoor.IsOpen && Controlled.WorldPosition.X < tutorialDoor.Item.WorldPosition.X)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(2.0f);
|
||||
@@ -51,7 +54,7 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
while (infoBox != null)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
//-----------------------------------
|
||||
@@ -61,30 +64,30 @@ namespace Barotrauma.Tutorials
|
||||
Reactor reactor = Item.ItemList.Find(i => i.HasTag("tutorialreactor")).GetComponent<Reactor>();
|
||||
reactor.MeltDownTemp = 20000.0f;
|
||||
|
||||
while (Vector2.Distance(Character.Controlled.Position, reactor.Item.Position) > 200.0f)
|
||||
while (Vector2.Distance(Controlled.Position, reactor.Item.Position) > 200.0f)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
infoBox = CreateInfoFrame("The reactor requires fuel rods to generate power. You can grab one from the steel cabinet by walking next to it and pressing E.");
|
||||
|
||||
while (Character.Controlled.SelectedConstruction == null || Character.Controlled.SelectedConstruction.Name != "Steel Cabinet")
|
||||
while (Controlled.SelectedConstruction == null || Controlled.SelectedConstruction.Name != "Steel Cabinet")
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
infoBox = CreateInfoFrame("Pick up one of the fuel rods either by double-clicking or dragging and dropping it into your inventory.");
|
||||
|
||||
while (!HasItem("Fuel Rod"))
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
infoBox = CreateInfoFrame("Select the reactor by walking next to it and pressing E.");
|
||||
|
||||
while (Character.Controlled.SelectedConstruction != reactor.Item)
|
||||
while (Controlled.SelectedConstruction != reactor.Item)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
@@ -92,14 +95,14 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
while (reactor.AvailableFuel <= 0.0f)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
infoBox = CreateInfoFrame("The reactor is now fueled up. Try turning it on by increasing the fission rate.");
|
||||
|
||||
while (reactor.FissionRate <= 0.0f)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
@@ -109,7 +112,7 @@ namespace Barotrauma.Tutorials
|
||||
while (infoBox != null)
|
||||
{
|
||||
reactor.ShutDownTemp = Math.Min(reactor.ShutDownTemp, 5000.0f);
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
@@ -121,7 +124,7 @@ namespace Barotrauma.Tutorials
|
||||
{
|
||||
reactor.AutoTemp = false;
|
||||
reactor.ShutDownTemp = Math.Min(reactor.ShutDownTemp, 5000.0f);
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
@@ -131,7 +134,7 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
while (!reactor.AutoTemp)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
@@ -141,18 +144,18 @@ namespace Barotrauma.Tutorials
|
||||
Steering steering = Item.ItemList.Find(i => i.HasTag("tutorialsteering")).GetComponent<Steering>();
|
||||
Radar radar = steering.Item.GetComponent<Radar>();
|
||||
|
||||
while (Vector2.Distance(Character.Controlled.Position, steering.Item.Position) > 150.0f)
|
||||
while (Vector2.Distance(Controlled.Position, steering.Item.Position) > 150.0f)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
CoroutineManager.StartCoroutine(KeepReactorRunning(reactor));
|
||||
|
||||
infoBox = CreateInfoFrame("Select the navigation terminal by walking next to it and pressing E.");
|
||||
|
||||
while (Character.Controlled.SelectedConstruction != steering.Item)
|
||||
while (Controlled.SelectedConstruction != steering.Item)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
@@ -161,19 +164,19 @@ namespace Barotrauma.Tutorials
|
||||
+ " running or the lights would've gone out, so it's most likely a problem with the wiring."
|
||||
+ " Deselect the terminal by pressing E to start checking the wiring.");
|
||||
|
||||
while (Character.Controlled.SelectedConstruction == steering.Item)
|
||||
while (Controlled.SelectedConstruction == steering.Item)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
yield return new WaitForSeconds(1.0f);
|
||||
|
||||
infoBox = CreateInfoFrame("You need a screwdriver to check the wiring of the terminal."
|
||||
+ " Equip a screwdriver by pulling it to either of the slots with a hand symbol, and then use it on the terminal by left clicking.");
|
||||
|
||||
while (Character.Controlled.SelectedConstruction != steering.Item ||
|
||||
Character.Controlled.SelectedItems.FirstOrDefault(i => i != null && i.Name == "Screwdriver") == null)
|
||||
while (Controlled.SelectedConstruction != steering.Item ||
|
||||
Controlled.SelectedItems.FirstOrDefault(i => i != null && i.Name == "Screwdriver") == null)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
|
||||
@@ -183,27 +186,27 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
while (!HasItem("Wire"))
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
infoBox = CreateInfoFrame("Head back to the navigation terminal to fix the wiring.");
|
||||
|
||||
PowerTransfer junctionBox = Item.ItemList.Find(i => i != null && i.HasTag("tutorialjunctionbox")).GetComponent<PowerTransfer>();
|
||||
|
||||
while ((Character.Controlled.SelectedConstruction != junctionBox.Item &&
|
||||
Character.Controlled.SelectedConstruction != steering.Item) ||
|
||||
Character.Controlled.SelectedItems.FirstOrDefault(i => i != null && i.Name == "Screwdriver") == null)
|
||||
while ((Controlled.SelectedConstruction != junctionBox.Item &&
|
||||
Controlled.SelectedConstruction != steering.Item) ||
|
||||
Controlled.SelectedItems.FirstOrDefault(i => i != null && i.Name == "Screwdriver") == null)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
if (Character.Controlled.SelectedItems.FirstOrDefault(i => i != null && i.GetComponent<Wire>() != null) == null)
|
||||
if (Controlled.SelectedItems.FirstOrDefault(i => i != null && i.GetComponent<Wire>() != null) == null)
|
||||
{
|
||||
infoBox = CreateInfoFrame("Equip the wire by dragging it to one of the slots with a hand symbol.");
|
||||
|
||||
while (Character.Controlled.SelectedItems.FirstOrDefault(i => i != null && i.GetComponent<Wire>() != null) == null)
|
||||
while (Controlled.SelectedItems.FirstOrDefault(i => i != null && i.GetComponent<Wire>() != null) == null)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,16 +216,16 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
while (steeringConnection.Wires.FirstOrDefault(w => w != null) == null)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
|
||||
}
|
||||
|
||||
infoBox = CreateInfoFrame("Now you have to connect the other end of the wire to a power source. "
|
||||
+ "The junction box in the room just below the command room should do.");
|
||||
|
||||
while (Character.Controlled.SelectedConstruction != null)
|
||||
while (Controlled.SelectedConstruction != null)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(2.0f);
|
||||
@@ -231,31 +234,31 @@ namespace Barotrauma.Tutorials
|
||||
+ "remove the previous attachment by right clicking. Or if you don't care for neatly laid out wiring, you can just "
|
||||
+ "run it straight to the junction box.");
|
||||
|
||||
while (Character.Controlled.SelectedConstruction == null || Character.Controlled.SelectedConstruction.GetComponent<PowerTransfer>() == null)
|
||||
while (Controlled.SelectedConstruction == null || Controlled.SelectedConstruction.GetComponent<PowerTransfer>() == null)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
infoBox = CreateInfoFrame("Connect the wire to the junction box by pulling it to the power connection, the same way you did with the navigation terminal.");
|
||||
|
||||
while (radar.Voltage < 0.1f)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
infoBox = CreateInfoFrame("Great! Now we should be able to get moving.");
|
||||
|
||||
|
||||
while (Character.Controlled.SelectedConstruction != steering.Item)
|
||||
while (Controlled.SelectedConstruction != steering.Item)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
infoBox = CreateInfoFrame("You can take a look at the area around the sub by selecting the \"Sonar\" checkbox.");
|
||||
|
||||
while (!radar.IsActive)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
@@ -264,7 +267,7 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
while (steering.TargetVelocity == Vector2.Zero && steering.TargetVelocity.Length() < 50.0f)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
yield return new WaitForSeconds(4.0f);
|
||||
|
||||
@@ -273,14 +276,14 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
while (infoBox != null)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
infoBox = CreateInfoFrame("Steer the submarine downwards, heading further into the cavern.");
|
||||
|
||||
while (Submarine.MainSub.WorldPosition.Y > 40000.0f)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
yield return new WaitForSeconds(1.0f);
|
||||
|
||||
@@ -329,7 +332,7 @@ namespace Barotrauma.Tutorials
|
||||
}
|
||||
if (broken) break;
|
||||
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
} while (!broken);
|
||||
|
||||
//fix everything except the command windows
|
||||
@@ -366,12 +369,12 @@ namespace Barotrauma.Tutorials
|
||||
Door commandDoor3 = Item.ItemList.Find(i => i.HasTag("commanddoor3")).GetComponent<Door>();
|
||||
|
||||
//wait until the player is out of the room and the doors are closed
|
||||
while (Character.Controlled.WorldPosition.X > commandDoor1.Item.WorldPosition.X ||
|
||||
while (Controlled.WorldPosition.X > commandDoor1.Item.WorldPosition.X ||
|
||||
(commandDoor1.IsOpen || (commandDoor2.IsOpen || commandDoor3.IsOpen)))
|
||||
{
|
||||
//prevent the hull from filling up completely and crushing the player
|
||||
steering.Item.CurrentHull.WaterVolume = Math.Min(steering.Item.CurrentHull.WaterVolume, steering.Item.CurrentHull.Volume * 0.9f);
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
|
||||
@@ -383,7 +386,7 @@ namespace Barotrauma.Tutorials
|
||||
while (!HasItem("Diving Mask") && !HasItem("Diving Suit"))
|
||||
{
|
||||
if (!divingMaskSelected &&
|
||||
Character.Controlled.FocusedItem != null && Character.Controlled.FocusedItem.Name == "Diving Suit")
|
||||
Controlled.FocusedItem != null && Controlled.FocusedItem.Name == "Diving Suit")
|
||||
{
|
||||
infoBox = CreateInfoFrame("There can only be one item in each inventory slot, so you need to take off "
|
||||
+ "the jumpsuit if you wish to wear a diving suit.");
|
||||
@@ -391,7 +394,7 @@ namespace Barotrauma.Tutorials
|
||||
divingMaskSelected = true;
|
||||
}
|
||||
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
if (HasItem("Diving Mask"))
|
||||
@@ -409,7 +412,7 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
while (!HasItem("Oxygen Tank"))
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(5.0f);
|
||||
@@ -418,7 +421,7 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
var railGun = Item.ItemList.Find(i => i.GetComponent<Turret>() != null);
|
||||
|
||||
while (Vector2.Distance(Character.Controlled.Position, railGun.Position) > 500)
|
||||
while (Vector2.Distance(Controlled.Position, railGun.Position) > 500)
|
||||
{
|
||||
yield return new WaitForSeconds(1.0f);
|
||||
}
|
||||
@@ -437,9 +440,9 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
var loader = Item.ItemList.Find(i => i.Name == "Railgun Loader").GetComponent<ItemContainer>();
|
||||
|
||||
while (Math.Abs(Character.Controlled.Position.Y - loader.Item.Position.Y) > 80)
|
||||
while (Math.Abs(Controlled.Position.Y - loader.Item.Position.Y) > 80)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
infoBox = CreateInfoFrame("Grab one of the shells. You can load it by selecting the railgun loader and dragging the shell to. "
|
||||
@@ -451,30 +454,30 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
capacitor1.Charge += 5.0f;
|
||||
capacitor2.Charge += 5.0f;
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
infoBox = CreateInfoFrame("Now we're ready to shoot! Select the railgun controller.");
|
||||
|
||||
while (Character.Controlled.SelectedConstruction == null || Character.Controlled.SelectedConstruction.Name != "Railgun Controller")
|
||||
while (Controlled.SelectedConstruction == null || Controlled.SelectedConstruction.Name != "Railgun Controller")
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
moloch.AnimController.SetPosition(ConvertUnits.ToSimUnits(Character.Controlled.WorldPosition + Vector2.UnitY * 600.0f));
|
||||
moloch.AnimController.SetPosition(ConvertUnits.ToSimUnits(Controlled.WorldPosition + Vector2.UnitY * 600.0f));
|
||||
|
||||
infoBox = CreateInfoFrame("Use the right mouse button to aim and wait for the creature to come closer. When you're ready to shoot, "
|
||||
+ "press the left mouse button.");
|
||||
|
||||
while (!moloch.IsDead)
|
||||
{
|
||||
if (moloch.WorldPosition.Y > Character.Controlled.WorldPosition.Y + 600.0f)
|
||||
if (moloch.WorldPosition.Y > Controlled.WorldPosition.Y + 600.0f)
|
||||
{
|
||||
moloch.AIController.SteeringManager.SteeringManual(CoroutineManager.DeltaTime, Character.Controlled.WorldPosition - moloch.WorldPosition);
|
||||
moloch.AIController.SteeringManager.SteeringManual(CoroutineManager.DeltaTime, Controlled.WorldPosition - moloch.WorldPosition);
|
||||
}
|
||||
|
||||
moloch.AIController.SelectTarget(Character.Controlled.AiTarget);
|
||||
yield return CoroutineStatus.Running;
|
||||
moloch.AIController.SelectTarget(Controlled.AiTarget);
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
Submarine.MainSub.GodMode = false;
|
||||
@@ -484,7 +487,7 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
while (!HasItem("Welding Tool"))
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
infoBox = CreateInfoFrame("The welding tool requires fuel to work. Grab a welding fuel tank and attach it to the tool " +
|
||||
@@ -492,11 +495,11 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
do
|
||||
{
|
||||
var weldingTool = Character.Controlled.Inventory.Items.FirstOrDefault(i => i != null && i.Name == "Welding Tool");
|
||||
var weldingTool = Controlled.Inventory.Items.FirstOrDefault(i => i != null && i.Name == "Welding Tool");
|
||||
if (weldingTool != null &&
|
||||
weldingTool.ContainedItems.FirstOrDefault(contained => contained != null && contained.Name == "Welding Fuel Tank") != null) break;
|
||||
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
} while (true);
|
||||
|
||||
|
||||
@@ -525,9 +528,9 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
Pump pump = Item.ItemList.Find(i => i.HasTag("tutorialpump")).GetComponent<Pump>();
|
||||
|
||||
while (Vector2.Distance(Character.Controlled.Position, pump.Item.Position) > 100.0f)
|
||||
while (Vector2.Distance(Controlled.Position, pump.Item.Position) > 100.0f)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
infoBox = CreateInfoFrame("The two pumps inside the ballast tanks "
|
||||
@@ -537,7 +540,7 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
while (infoBox != null)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
|
||||
@@ -547,7 +550,7 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
while (pump.FlowPercentage > 0.0f || pump.CurrFlow <= 0.0f || !pump.IsActive)
|
||||
{
|
||||
if (!brokenMsgShown && pump.Voltage < pump.MinVoltage && Character.Controlled.SelectedConstruction == pump.Item)
|
||||
if (!brokenMsgShown && pump.Voltage < pump.MinVoltage && Controlled.SelectedConstruction == pump.Item)
|
||||
{
|
||||
brokenMsgShown = true;
|
||||
|
||||
@@ -556,11 +559,11 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (Character.Controlled.SelectedConstruction!=null &&
|
||||
Character.Controlled.SelectedConstruction.GetComponent<PowerTransfer>() != null &&
|
||||
Character.Controlled.SelectedConstruction.Condition == 0.0f)
|
||||
if (Controlled.SelectedConstruction!=null &&
|
||||
Controlled.SelectedConstruction.GetComponent<PowerTransfer>() != null &&
|
||||
Controlled.SelectedConstruction.Condition == 0.0f)
|
||||
{
|
||||
brokenBox = Character.Controlled.SelectedConstruction;
|
||||
brokenBox = Controlled.SelectedConstruction;
|
||||
|
||||
infoBox = CreateInfoFrame("Here's our problem: this junction box is broken. Luckily engineers are adept at fixing electrical devices - "
|
||||
+"you just need to find a spare wire and click the \"Fix\"-button to repair the box.");
|
||||
@@ -569,7 +572,7 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
if (pump.Voltage > pump.MinVoltage) break;
|
||||
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,14 +587,14 @@ namespace Barotrauma.Tutorials
|
||||
brokenBox = null;
|
||||
}
|
||||
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
infoBox = CreateInfoFrame("The pump is up and running. Wait for the water to be drained out.");
|
||||
|
||||
while (pump.Item.CurrentHull.WaterVolume > 1000.0f)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
infoBox = CreateInfoFrame("That was all there is to this tutorial! Now you should be able to handle " +
|
||||
@@ -599,7 +602,7 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
yield return new WaitForSeconds(4.0f);
|
||||
|
||||
Character.Controlled = null;
|
||||
Controlled = null;
|
||||
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
GameMain.LightManager.LosEnabled = false;
|
||||
|
||||
@@ -607,7 +610,7 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
while (cinematic.Running)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
yield return Controlled.IsDead ? CoroutineStatus.Success : CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
Submarine.Unload();
|
||||
|
||||
@@ -8,26 +8,11 @@ using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
public enum WindowMode
|
||||
{
|
||||
Windowed, Fullscreen, BorderlessWindowed
|
||||
}
|
||||
|
||||
public partial class GameSettings
|
||||
{
|
||||
private GUIFrame settingsFrame;
|
||||
private GUIButton applyButton;
|
||||
|
||||
private float soundVolume, musicVolume;
|
||||
|
||||
private WindowMode windowMode;
|
||||
|
||||
public List<string> jobNamePreferences;
|
||||
|
||||
private KeyOrMouse[] keyMapping;
|
||||
|
||||
private bool unsavedSettings;
|
||||
|
||||
public GUIFrame SettingsFrame
|
||||
{
|
||||
get
|
||||
@@ -41,263 +26,7 @@ namespace Barotrauma
|
||||
{
|
||||
return keyMapping[(int)inputType];
|
||||
}
|
||||
|
||||
public int GraphicsWidth { get; set; }
|
||||
public int GraphicsHeight { get; set; }
|
||||
|
||||
public bool VSyncEnabled { get; set; }
|
||||
|
||||
public bool EnableSplashScreen { get; set; }
|
||||
|
||||
//public bool FullScreenEnabled { get; set; }
|
||||
|
||||
public WindowMode WindowMode
|
||||
{
|
||||
get { return windowMode; }
|
||||
set { windowMode = value; }
|
||||
}
|
||||
|
||||
public List<string> JobNamePreferences
|
||||
{
|
||||
get { return jobNamePreferences; }
|
||||
set
|
||||
{
|
||||
// Begin saving coroutine. Remove any existing save coroutines if one is running.
|
||||
if (CoroutineManager.IsCoroutineRunning("saveCoroutine")) { CoroutineManager.StopCoroutines("saveCoroutine"); }
|
||||
CoroutineManager.StartCoroutine(ApplyUnsavedChanges(), "saveCoroutine");
|
||||
|
||||
jobNamePreferences = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool UnsavedSettings
|
||||
{
|
||||
get
|
||||
{
|
||||
return unsavedSettings;
|
||||
}
|
||||
private set
|
||||
{
|
||||
unsavedSettings = value;
|
||||
|
||||
if (applyButton != null)
|
||||
{
|
||||
//applyButton.Selected = unsavedSettings;
|
||||
applyButton.Enabled = unsavedSettings;
|
||||
applyButton.Text = unsavedSettings ? "Apply*" : "Apply";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float SoundVolume
|
||||
{
|
||||
get { return soundVolume; }
|
||||
set
|
||||
{
|
||||
soundVolume = MathHelper.Clamp(value, 0.0f, 1.0f);
|
||||
Sounds.SoundManager.MasterVolume = soundVolume;
|
||||
}
|
||||
}
|
||||
|
||||
public float MusicVolume
|
||||
{
|
||||
get { return musicVolume; }
|
||||
set
|
||||
{
|
||||
musicVolume = MathHelper.Clamp(value, 0.0f, 1.0f);
|
||||
SoundPlayer.MusicVolume = musicVolume;
|
||||
}
|
||||
}
|
||||
|
||||
partial void InitProjSpecific(XDocument doc)
|
||||
{
|
||||
if (doc == null)
|
||||
{
|
||||
GraphicsWidth = 1024;
|
||||
GraphicsHeight = 678;
|
||||
|
||||
MasterServerUrl = "";
|
||||
|
||||
SelectedContentPackage = ContentPackage.list.Any() ? ContentPackage.list[0] : new ContentPackage("");
|
||||
|
||||
JobNamePreferences = new List<string>();
|
||||
foreach (JobPrefab job in JobPrefab.List)
|
||||
{
|
||||
JobNamePreferences.Add(job.Name);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
XElement graphicsMode = doc.Root.Element("graphicsmode");
|
||||
GraphicsWidth = graphicsMode.GetAttributeInt("width", 0);
|
||||
GraphicsHeight = graphicsMode.GetAttributeInt("height", 0);
|
||||
VSyncEnabled = graphicsMode.GetAttributeBool("vsync", true);
|
||||
|
||||
if (GraphicsWidth == 0 || GraphicsHeight == 0)
|
||||
{
|
||||
GraphicsWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
|
||||
GraphicsHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
|
||||
}
|
||||
|
||||
//FullScreenEnabled = ToolBox.GetAttributeBool(graphicsMode, "fullscreen", true);
|
||||
|
||||
var windowModeStr = graphicsMode.GetAttributeString("displaymode", "Fullscreen");
|
||||
if (!Enum.TryParse<WindowMode>(windowModeStr, out windowMode))
|
||||
{
|
||||
windowMode = WindowMode.Fullscreen;
|
||||
}
|
||||
|
||||
SoundVolume = doc.Root.GetAttributeFloat("soundvolume", 1.0f);
|
||||
MusicVolume = doc.Root.GetAttributeFloat("musicvolume", 0.3f);
|
||||
|
||||
EnableSplashScreen = doc.Root.GetAttributeBool("enablesplashscreen", true);
|
||||
|
||||
keyMapping = new KeyOrMouse[Enum.GetNames(typeof(InputType)).Length];
|
||||
keyMapping[(int)InputType.Up] = new KeyOrMouse(Keys.W);
|
||||
keyMapping[(int)InputType.Down] = new KeyOrMouse(Keys.S);
|
||||
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.RadioChat] = new KeyOrMouse(Keys.OemPipe);
|
||||
keyMapping[(int)InputType.CrewOrders] = new KeyOrMouse(Keys.C);
|
||||
|
||||
keyMapping[(int)InputType.Select] = new KeyOrMouse(Keys.E);
|
||||
|
||||
keyMapping[(int)InputType.Use] = new KeyOrMouse(0);
|
||||
keyMapping[(int)InputType.Aim] = new KeyOrMouse(1);
|
||||
|
||||
foreach (XElement subElement in doc.Root.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "keymapping":
|
||||
foreach (XAttribute attribute in subElement.Attributes())
|
||||
{
|
||||
InputType inputType;
|
||||
if (Enum.TryParse(attribute.Name.ToString(), true, out inputType))
|
||||
{
|
||||
int mouseButton;
|
||||
if (int.TryParse(attribute.Value.ToString(), out mouseButton))
|
||||
{
|
||||
keyMapping[(int)inputType] = new KeyOrMouse(mouseButton);
|
||||
}
|
||||
else
|
||||
{
|
||||
Keys key;
|
||||
if (Enum.TryParse(attribute.Value.ToString(), true, out key))
|
||||
{
|
||||
keyMapping[(int)inputType] = new KeyOrMouse(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "gameplay":
|
||||
JobNamePreferences = new List<string>();
|
||||
foreach (XElement ele in subElement.Element("jobpreferences").Elements("job"))
|
||||
{
|
||||
JobNamePreferences.Add(ele.GetAttributeString("name", ""));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (InputType inputType in Enum.GetValues(typeof(InputType)))
|
||||
{
|
||||
if (keyMapping[(int)inputType] == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Key binding for the input type \"" + inputType + " not set!");
|
||||
keyMapping[(int)inputType] = new KeyOrMouse(Keys.D1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UnsavedSettings = false;
|
||||
}
|
||||
|
||||
public void Save(string filePath)
|
||||
{
|
||||
UnsavedSettings = false;
|
||||
|
||||
XDocument doc = new XDocument();
|
||||
|
||||
if (doc.Root == null)
|
||||
{
|
||||
doc.Add(new XElement("config"));
|
||||
}
|
||||
|
||||
doc.Root.Add(
|
||||
new XAttribute("masterserverurl", MasterServerUrl),
|
||||
new XAttribute("autocheckupdates", AutoCheckUpdates),
|
||||
new XAttribute("musicvolume", musicVolume),
|
||||
new XAttribute("soundvolume", soundVolume),
|
||||
new XAttribute("verboselogging", VerboseLogging),
|
||||
new XAttribute("enablesplashscreen", EnableSplashScreen));
|
||||
|
||||
if (WasGameUpdated)
|
||||
{
|
||||
doc.Root.Add(new XAttribute("wasgameupdated", true));
|
||||
}
|
||||
|
||||
XElement gMode = doc.Root.Element("graphicsmode");
|
||||
if (gMode == null)
|
||||
{
|
||||
gMode = new XElement("graphicsmode");
|
||||
doc.Root.Add(gMode);
|
||||
}
|
||||
|
||||
if (GraphicsWidth == 0 || GraphicsHeight == 0)
|
||||
{
|
||||
gMode.ReplaceAttributes(new XAttribute("displaymode", windowMode));
|
||||
}
|
||||
else
|
||||
{
|
||||
gMode.ReplaceAttributes(
|
||||
new XAttribute("width", GraphicsWidth),
|
||||
new XAttribute("height", GraphicsHeight),
|
||||
new XAttribute("vsync", VSyncEnabled),
|
||||
new XAttribute("displaymode", windowMode));
|
||||
}
|
||||
|
||||
|
||||
if (SelectedContentPackage != null)
|
||||
{
|
||||
doc.Root.Add(new XElement("contentpackage",
|
||||
new XAttribute("path", SelectedContentPackage.Path)));
|
||||
}
|
||||
|
||||
var keyMappingElement = new XElement("keymapping");
|
||||
doc.Root.Add(keyMappingElement);
|
||||
for (int i = 0; i < keyMapping.Length; i++)
|
||||
{
|
||||
if (keyMapping[i].MouseButton == null)
|
||||
{
|
||||
keyMappingElement.Add(new XAttribute(((InputType)i).ToString(), keyMapping[i].Key));
|
||||
}
|
||||
else
|
||||
{
|
||||
keyMappingElement.Add(new XAttribute(((InputType)i).ToString(), keyMapping[i].MouseButton));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
var gameplay = new XElement("gameplay");
|
||||
|
||||
var jobPreferences = new XElement("jobpreferences");
|
||||
foreach (string jobName in JobNamePreferences)
|
||||
{
|
||||
jobPreferences.Add(new XElement("job", new XAttribute("name", jobName)));
|
||||
}
|
||||
|
||||
gameplay.Add(jobPreferences);
|
||||
doc.Root.Add(gameplay);
|
||||
|
||||
doc.Save(filePath);
|
||||
}
|
||||
|
||||
private bool ChangeSoundVolume(GUIScrollBar scrollBar, float barScroll)
|
||||
{
|
||||
UnsavedSettings = true;
|
||||
@@ -396,6 +125,7 @@ namespace Barotrauma
|
||||
|
||||
new GUITextBlock(new Rectangle(x, y, 20, 20), "Content package", "", Alignment.TopLeft, Alignment.TopLeft, settingsFrame);
|
||||
var contentPackageDD = new GUIDropDown(new Rectangle(x, y + 20, 200, 20), "", "", settingsFrame);
|
||||
contentPackageDD.OnSelected = SelectContentPackage;
|
||||
|
||||
foreach (ContentPackage contentPackage in ContentPackage.list)
|
||||
{
|
||||
@@ -453,6 +183,13 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool SelectContentPackage(GUIComponent select,object userData)
|
||||
{
|
||||
GameMain.Config.SelectedContentPackage = (ContentPackage)userData;
|
||||
UnsavedSettings = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
private IEnumerable<object> WaitForKeyPress(GUITextBox keyBox)
|
||||
{
|
||||
yield return CoroutineStatus.Running;
|
||||
@@ -494,14 +231,7 @@ namespace Barotrauma
|
||||
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
private IEnumerable<object> ApplyUnsavedChanges()
|
||||
{
|
||||
yield return new WaitForSeconds(10.0f);
|
||||
|
||||
Save("config.xml");
|
||||
}
|
||||
|
||||
|
||||
private bool ApplyClicked(GUIButton button, object userData)
|
||||
{
|
||||
Save("config.xml");
|
||||
|
||||
@@ -66,7 +66,6 @@
|
||||
<Compile Include="Source\Characters\Character.cs" />
|
||||
<Compile Include="Source\DebugConsole.cs" />
|
||||
<Compile Include="Source\GameMain.cs" />
|
||||
<Compile Include="Source\GameSettings.cs" />
|
||||
<Compile Include="Source\Items\Components\ItemComponent.cs" />
|
||||
<Compile Include="Source\Items\Components\ItemLabel.cs" />
|
||||
<Compile Include="Source\Items\Components\Machines\Steering.cs" />
|
||||
|
||||
@@ -63,12 +63,12 @@ namespace Barotrauma
|
||||
FarseerPhysics.Settings.VelocityIterations = 1;
|
||||
FarseerPhysics.Settings.PositionIterations = 1;
|
||||
|
||||
Config = new GameSettings("serverconfig.xml");
|
||||
Config = new GameSettings("config.xml");
|
||||
if (Config.WasGameUpdated)
|
||||
{
|
||||
UpdaterUtil.CleanOldFiles();
|
||||
Config.WasGameUpdated = false;
|
||||
Config.Save("serverconfig.xml");
|
||||
Config.Save("config.xml");
|
||||
}
|
||||
|
||||
GameScreen = new GameScreen();
|
||||
@@ -131,19 +131,25 @@ namespace Barotrauma
|
||||
Init();
|
||||
StartServer();
|
||||
|
||||
Timing.Accumulator = 0.0;
|
||||
|
||||
DateTime prevTime = DateTime.Now;
|
||||
|
||||
while (ShouldRun)
|
||||
{
|
||||
Timing.Accumulator += ((float)(DateTime.Now.Subtract(prevTime).Milliseconds) / 1000.0)/Timing.Step;
|
||||
prevTime = DateTime.Now;
|
||||
while (Timing.Accumulator>0.0)
|
||||
{
|
||||
DebugConsole.Update();
|
||||
if (Screen.Selected != null) Screen.Selected.Update((float)Timing.Step);
|
||||
Server.Update((float)Timing.Step);
|
||||
CoroutineManager.Update((float)Timing.Step, (float)Timing.Step);
|
||||
|
||||
DebugConsole.Update();
|
||||
if (Screen.Selected != null) Screen.Selected.Update((float)Timing.Step);
|
||||
Server.Update((float)Timing.Step);
|
||||
CoroutineManager.Update((float)Timing.Step, (float)Timing.Step);
|
||||
|
||||
Timing.Accumulator -= 1.0;
|
||||
}
|
||||
int frameTime = DateTime.Now.Subtract(prevTime).Milliseconds;
|
||||
Thread.Sleep(Math.Max((int)(Timing.Step * 1000.0) - frameTime,0));
|
||||
Thread.Sleep(Math.Max((int)(Timing.Step * 1000.0) - frameTime/2,0));
|
||||
}
|
||||
|
||||
CloseServer();
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
public enum WindowMode
|
||||
{
|
||||
Windowed, Fullscreen, BorderlessWindowed
|
||||
}
|
||||
|
||||
public partial class GameSettings
|
||||
{
|
||||
public void Save(string filePath)
|
||||
{
|
||||
XDocument doc = new XDocument();
|
||||
|
||||
if (doc.Root == null)
|
||||
{
|
||||
doc.Add(new XElement("config"));
|
||||
}
|
||||
|
||||
doc.Root.Add(
|
||||
new XAttribute("masterserverurl", MasterServerUrl),
|
||||
new XAttribute("autocheckupdates", AutoCheckUpdates),
|
||||
new XAttribute("verboselogging", VerboseLogging));
|
||||
|
||||
if (WasGameUpdated)
|
||||
{
|
||||
doc.Root.Add(new XAttribute("wasgameupdated", true));
|
||||
}
|
||||
|
||||
if (SelectedContentPackage != null)
|
||||
{
|
||||
doc.Root.Add(new XElement("contentpackage",
|
||||
new XAttribute("path", SelectedContentPackage.Path)));
|
||||
}
|
||||
|
||||
doc.Save(filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ namespace Barotrauma
|
||||
}
|
||||
}));
|
||||
|
||||
commands.Add(new Command("clientlist", "clientlist: List all the clients connected to the server.", (string[] args) =>
|
||||
commands.Add(new Command("clientlist", "clientlist: List all the clients connected to the server.", (string[] args) =>
|
||||
{
|
||||
if (GameMain.Server == null) return;
|
||||
NewMessage("***************", Color.Cyan);
|
||||
@@ -264,35 +264,149 @@ namespace Barotrauma
|
||||
NewMessage("Crew AI enabled", Color.White);
|
||||
}));
|
||||
|
||||
commands.Add(new Command("autorestartinterval", "autorestartinterval [seconds]: Set how long the server waits between rounds before automatically starting a new one.", (string[] args) =>
|
||||
commands.Add(new Command("autorestart", "autorestart [true/false]: Enable or disable round auto-restart.", (string[] args) =>
|
||||
{
|
||||
if (GameMain.Server == null) return;
|
||||
bool enabled = GameMain.Server.AutoRestart;
|
||||
if (args.Length > 0)
|
||||
{
|
||||
bool.TryParse(args[0], out enabled);
|
||||
}
|
||||
else
|
||||
{
|
||||
enabled = !enabled;
|
||||
}
|
||||
if (enabled != GameMain.Server.AutoRestart)
|
||||
{
|
||||
if (GameMain.Server.AutoRestartInterval <= 0) GameMain.Server.AutoRestartInterval = 10;
|
||||
GameMain.Server.AutoRestartTimer = GameMain.Server.AutoRestartInterval;
|
||||
GameMain.Server.AutoRestart = enabled;
|
||||
#if CLIENT
|
||||
GameMain.NetLobbyScreen.SetAutoRestart(enabled, GameMain.Server.AutoRestartTimer);
|
||||
#endif
|
||||
GameMain.NetLobbyScreen.LastUpdateID++;
|
||||
}
|
||||
NewMessage(GameMain.Server.AutoRestart ? "Automatic restart enabled." : "Automatic restart disabled.", Color.White);
|
||||
}));
|
||||
|
||||
commands.Add(new Command("autorestartinterval", "autorestartinterval [seconds]: Set how long the server waits between rounds before automatically starting a new one. If set to 0, autorestart is disabled.", (string[] args) =>
|
||||
{
|
||||
if (GameMain.Server == null) return;
|
||||
if (args.Length > 0)
|
||||
{
|
||||
int parsedInt = 0;
|
||||
if (int.TryParse(args[0], out parsedInt) && parsedInt >= 0)
|
||||
if (int.TryParse(args[0], out parsedInt))
|
||||
{
|
||||
GameMain.Server.AutoRestartInterval = parsedInt;
|
||||
NewMessage("Autorestart interval set to " + GameMain.Server.AutoRestartInterval + " seconds.", Color.White);
|
||||
if (parsedInt >= 0)
|
||||
{
|
||||
GameMain.Server.AutoRestart = true;
|
||||
GameMain.Server.AutoRestartInterval = parsedInt;
|
||||
if (GameMain.Server.AutoRestartTimer >= GameMain.Server.AutoRestartInterval) GameMain.Server.AutoRestartTimer = GameMain.Server.AutoRestartInterval;
|
||||
NewMessage("Autorestart interval set to " + GameMain.Server.AutoRestartInterval + " seconds.", Color.White);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.Server.AutoRestart = false;
|
||||
NewMessage("Autorestart disabled.", Color.White);
|
||||
}
|
||||
#if CLIENT
|
||||
GameMain.NetLobbyScreen.SetAutoRestart(GameMain.Server.AutoRestart, GameMain.Server.AutoRestartTimer);
|
||||
#endif
|
||||
GameMain.NetLobbyScreen.LastUpdateID++;
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
|
||||
commands.Add(new Command("autorestarttimer", "autorestarttimer [seconds]: Set the current autorestart countdown to the specified value.", (string[] args) =>
|
||||
{
|
||||
if (GameMain.Server == null) return;
|
||||
if (args.Length > 0)
|
||||
{
|
||||
int parsedInt = 0;
|
||||
if (int.TryParse(args[0], out parsedInt) && parsedInt >= 0)
|
||||
if (int.TryParse(args[0], out parsedInt))
|
||||
{
|
||||
GameMain.Server.AutoRestartTimer = parsedInt;
|
||||
if (parsedInt >= 0)
|
||||
{
|
||||
GameMain.Server.AutoRestart = true;
|
||||
GameMain.Server.AutoRestartTimer = parsedInt;
|
||||
if (GameMain.Server.AutoRestartInterval <= GameMain.Server.AutoRestartTimer) GameMain.Server.AutoRestartInterval = GameMain.Server.AutoRestartTimer;
|
||||
GameMain.NetLobbyScreen.LastUpdateID++;
|
||||
NewMessage("Autorestart timer set to " + GameMain.Server.AutoRestartTimer + " seconds.", Color.White);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.Server.AutoRestart = false;
|
||||
NewMessage("Autorestart disabled.", Color.White);
|
||||
}
|
||||
#if CLIENT
|
||||
GameMain.NetLobbyScreen.SetAutoRestart(GameMain.Server.AutoRestart, GameMain.Server.AutoRestartTimer);
|
||||
#endif
|
||||
GameMain.NetLobbyScreen.LastUpdateID++;
|
||||
NewMessage("Autorestart timer set to " + GameMain.Server.AutoRestartTimer + " seconds.", Color.White);
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
commands.Add(new Command("giveperm", "giveperm [id]: Grants administrative permissions to the player with the specified client ID.", (string[] args) =>
|
||||
{
|
||||
if (GameMain.Server == null) return;
|
||||
if (args.Length < 1) return;
|
||||
|
||||
int id;
|
||||
int.TryParse(args[0], out id);
|
||||
var client = GameMain.Server.ConnectedClients.Find(c => c.ID == id);
|
||||
if (client == null)
|
||||
{
|
||||
ThrowError("Client id \"" + id + "\" not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
ShowQuestionPrompt("Permission to grant to \"" + client.Name + "\"?", (perm) =>
|
||||
{
|
||||
ClientPermissions permission = ClientPermissions.None;
|
||||
if (perm.ToLower() == "all")
|
||||
{
|
||||
permission = ClientPermissions.EndRound | ClientPermissions.Kick | ClientPermissions.Ban | ClientPermissions.SelectSub | ClientPermissions.SelectMode | ClientPermissions.ManageCampaign;
|
||||
}
|
||||
else
|
||||
{
|
||||
Enum.TryParse<ClientPermissions>(perm, out permission);
|
||||
}
|
||||
client.SetPermissions(client.Permissions | permission);
|
||||
GameMain.Server.UpdateClientPermissions(client);
|
||||
DebugConsole.NewMessage("Granted "+perm+" permissions to "+client.Name+".",Color.White);
|
||||
});
|
||||
}));
|
||||
|
||||
commands.Add(new Command("revokeperm", "revokeperm [id]: Revokes administrative permissions to the player with the specified client ID.", (string[] args) =>
|
||||
{
|
||||
if (GameMain.Server == null) return;
|
||||
if (args.Length < 1) return;
|
||||
|
||||
int id;
|
||||
int.TryParse(args[0], out id);
|
||||
var client = GameMain.Server.ConnectedClients.Find(c => c.ID == id);
|
||||
if (client == null)
|
||||
{
|
||||
ThrowError("Client id \"" + id + "\" not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
ShowQuestionPrompt("Permission to revoke from \"" + client.Name + "\"?", (perm) =>
|
||||
{
|
||||
ClientPermissions permission = ClientPermissions.None;
|
||||
if (perm.ToLower() == "all")
|
||||
{
|
||||
permission = ClientPermissions.EndRound | ClientPermissions.Kick | ClientPermissions.Ban | ClientPermissions.SelectSub | ClientPermissions.SelectMode | ClientPermissions.ManageCampaign;
|
||||
}
|
||||
else
|
||||
{
|
||||
Enum.TryParse<ClientPermissions>(perm, out permission);
|
||||
}
|
||||
client.SetPermissions(client.Permissions & ~permission);
|
||||
GameMain.Server.UpdateClientPermissions(client);
|
||||
DebugConsole.NewMessage("Revoked " + perm + " permissions from " + client.Name + ".", Color.White);
|
||||
});
|
||||
}));
|
||||
|
||||
commands.Add(new Command("kick", "kick [name]: Kick a player out of the server.", (string[] args) =>
|
||||
{
|
||||
|
||||
@@ -1,12 +1,104 @@
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
#if CLIENT
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
#endif
|
||||
using System;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
public enum WindowMode
|
||||
{
|
||||
Windowed, Fullscreen, BorderlessWindowed
|
||||
}
|
||||
|
||||
public partial class GameSettings
|
||||
{
|
||||
public int GraphicsWidth { get; set; }
|
||||
public int GraphicsHeight { get; set; }
|
||||
|
||||
public bool VSyncEnabled { get; set; }
|
||||
|
||||
public bool EnableSplashScreen { get; set; }
|
||||
|
||||
//public bool FullScreenEnabled { get; set; }
|
||||
|
||||
private KeyOrMouse[] keyMapping;
|
||||
|
||||
private WindowMode windowMode;
|
||||
|
||||
public List<string> jobNamePreferences;
|
||||
|
||||
public WindowMode WindowMode
|
||||
{
|
||||
get { return windowMode; }
|
||||
set { windowMode = value; }
|
||||
}
|
||||
|
||||
public List<string> JobNamePreferences
|
||||
{
|
||||
get { return jobNamePreferences; }
|
||||
set
|
||||
{
|
||||
// Begin saving coroutine. Remove any existing save coroutines if one is running.
|
||||
if (CoroutineManager.IsCoroutineRunning("saveCoroutine")) { CoroutineManager.StopCoroutines("saveCoroutine"); }
|
||||
CoroutineManager.StartCoroutine(ApplyUnsavedChanges(), "saveCoroutine");
|
||||
|
||||
jobNamePreferences = value;
|
||||
}
|
||||
}
|
||||
|
||||
private bool unsavedSettings;
|
||||
|
||||
public bool UnsavedSettings
|
||||
{
|
||||
get
|
||||
{
|
||||
return unsavedSettings;
|
||||
}
|
||||
private set
|
||||
{
|
||||
unsavedSettings = value;
|
||||
#if CLIENT
|
||||
if (applyButton != null)
|
||||
{
|
||||
//applyButton.Selected = unsavedSettings;
|
||||
applyButton.Enabled = unsavedSettings;
|
||||
applyButton.Text = unsavedSettings ? "Apply*" : "Apply";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
private float soundVolume, musicVolume;
|
||||
|
||||
public float SoundVolume
|
||||
{
|
||||
get { return soundVolume; }
|
||||
set
|
||||
{
|
||||
soundVolume = MathHelper.Clamp(value, 0.0f, 1.0f);
|
||||
#if CLIENT
|
||||
Sounds.SoundManager.MasterVolume = soundVolume;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public float MusicVolume
|
||||
{
|
||||
get { return musicVolume; }
|
||||
set
|
||||
{
|
||||
musicVolume = MathHelper.Clamp(value, 0.0f, 1.0f);
|
||||
#if CLIENT
|
||||
SoundPlayer.MusicVolume = musicVolume;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public ContentPackage SelectedContentPackage { get; set; }
|
||||
|
||||
public string MasterServerUrl { get; set; }
|
||||
@@ -25,17 +117,6 @@ namespace Barotrauma
|
||||
public void Load(string filePath)
|
||||
{
|
||||
XDocument doc = XMLExtensions.TryLoadXml(filePath);
|
||||
|
||||
if (doc == null)
|
||||
{
|
||||
DebugConsole.ThrowError("No config file found");
|
||||
|
||||
MasterServerUrl = "";
|
||||
|
||||
SelectedContentPackage = ContentPackage.list.Any() ? ContentPackage.list[0] : new ContentPackage("");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
MasterServerUrl = doc.Root.GetAttributeString("masterserverurl", "");
|
||||
|
||||
@@ -44,7 +125,111 @@ namespace Barotrauma
|
||||
|
||||
VerboseLogging = doc.Root.GetAttributeBool("verboselogging", false);
|
||||
|
||||
InitProjSpecific(doc);
|
||||
if (doc == null)
|
||||
{
|
||||
GraphicsWidth = 1024;
|
||||
GraphicsHeight = 678;
|
||||
|
||||
MasterServerUrl = "";
|
||||
|
||||
SelectedContentPackage = ContentPackage.list.Any() ? ContentPackage.list[0] : new ContentPackage("");
|
||||
|
||||
JobNamePreferences = new List<string>();
|
||||
foreach (JobPrefab job in JobPrefab.List)
|
||||
{
|
||||
JobNamePreferences.Add(job.Name);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
XElement graphicsMode = doc.Root.Element("graphicsmode");
|
||||
GraphicsWidth = graphicsMode.GetAttributeInt("width", 0);
|
||||
GraphicsHeight = graphicsMode.GetAttributeInt("height", 0);
|
||||
VSyncEnabled = graphicsMode.GetAttributeBool("vsync", true);
|
||||
|
||||
#if CLIENT
|
||||
if (GraphicsWidth == 0 || GraphicsHeight == 0)
|
||||
{
|
||||
GraphicsWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
|
||||
GraphicsHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
|
||||
}
|
||||
#endif
|
||||
|
||||
//FullScreenEnabled = ToolBox.GetAttributeBool(graphicsMode, "fullscreen", true);
|
||||
|
||||
var windowModeStr = graphicsMode.GetAttributeString("displaymode", "Fullscreen");
|
||||
if (!Enum.TryParse<WindowMode>(windowModeStr, out windowMode))
|
||||
{
|
||||
windowMode = WindowMode.Fullscreen;
|
||||
}
|
||||
|
||||
SoundVolume = doc.Root.GetAttributeFloat("soundvolume", 1.0f);
|
||||
MusicVolume = doc.Root.GetAttributeFloat("musicvolume", 0.3f);
|
||||
|
||||
EnableSplashScreen = doc.Root.GetAttributeBool("enablesplashscreen", true);
|
||||
|
||||
keyMapping = new KeyOrMouse[Enum.GetNames(typeof(InputType)).Length];
|
||||
keyMapping[(int)InputType.Up] = new KeyOrMouse(Keys.W);
|
||||
keyMapping[(int)InputType.Down] = new KeyOrMouse(Keys.S);
|
||||
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.RadioChat] = new KeyOrMouse(Keys.OemPipe);
|
||||
keyMapping[(int)InputType.CrewOrders] = new KeyOrMouse(Keys.C);
|
||||
|
||||
keyMapping[(int)InputType.Select] = new KeyOrMouse(Keys.E);
|
||||
|
||||
keyMapping[(int)InputType.Use] = new KeyOrMouse(0);
|
||||
keyMapping[(int)InputType.Aim] = new KeyOrMouse(1);
|
||||
|
||||
foreach (XElement subElement in doc.Root.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "keymapping":
|
||||
foreach (XAttribute attribute in subElement.Attributes())
|
||||
{
|
||||
InputType inputType;
|
||||
if (Enum.TryParse(attribute.Name.ToString(), true, out inputType))
|
||||
{
|
||||
int mouseButton;
|
||||
if (int.TryParse(attribute.Value.ToString(), out mouseButton))
|
||||
{
|
||||
keyMapping[(int)inputType] = new KeyOrMouse(mouseButton);
|
||||
}
|
||||
else
|
||||
{
|
||||
Keys key;
|
||||
if (Enum.TryParse(attribute.Value.ToString(), true, out key))
|
||||
{
|
||||
keyMapping[(int)inputType] = new KeyOrMouse(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "gameplay":
|
||||
JobNamePreferences = new List<string>();
|
||||
foreach (XElement ele in subElement.Element("jobpreferences").Elements("job"))
|
||||
{
|
||||
JobNamePreferences.Add(ele.GetAttributeString("name", ""));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (InputType inputType in Enum.GetValues(typeof(InputType)))
|
||||
{
|
||||
if (keyMapping[(int)inputType] == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Key binding for the input type \"" + inputType + " not set!");
|
||||
keyMapping[(int)inputType] = new KeyOrMouse(Keys.D1);
|
||||
}
|
||||
}
|
||||
|
||||
UnsavedSettings = false;
|
||||
|
||||
foreach (XElement subElement in doc.Root.Elements())
|
||||
{
|
||||
@@ -61,7 +246,93 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Save(string filePath)
|
||||
{
|
||||
UnsavedSettings = false;
|
||||
|
||||
partial void InitProjSpecific(XDocument doc);
|
||||
XDocument doc = new XDocument();
|
||||
|
||||
if (doc.Root == null)
|
||||
{
|
||||
doc.Add(new XElement("config"));
|
||||
}
|
||||
|
||||
doc.Root.Add(
|
||||
new XAttribute("masterserverurl", MasterServerUrl),
|
||||
new XAttribute("autocheckupdates", AutoCheckUpdates),
|
||||
new XAttribute("musicvolume", musicVolume),
|
||||
new XAttribute("soundvolume", soundVolume),
|
||||
new XAttribute("verboselogging", VerboseLogging),
|
||||
new XAttribute("enablesplashscreen", EnableSplashScreen));
|
||||
|
||||
if (WasGameUpdated)
|
||||
{
|
||||
doc.Root.Add(new XAttribute("wasgameupdated", true));
|
||||
}
|
||||
|
||||
XElement gMode = doc.Root.Element("graphicsmode");
|
||||
if (gMode == null)
|
||||
{
|
||||
gMode = new XElement("graphicsmode");
|
||||
doc.Root.Add(gMode);
|
||||
}
|
||||
|
||||
if (GraphicsWidth == 0 || GraphicsHeight == 0)
|
||||
{
|
||||
gMode.ReplaceAttributes(new XAttribute("displaymode", windowMode));
|
||||
}
|
||||
else
|
||||
{
|
||||
gMode.ReplaceAttributes(
|
||||
new XAttribute("width", GraphicsWidth),
|
||||
new XAttribute("height", GraphicsHeight),
|
||||
new XAttribute("vsync", VSyncEnabled),
|
||||
new XAttribute("displaymode", windowMode));
|
||||
}
|
||||
|
||||
|
||||
if (SelectedContentPackage != null)
|
||||
{
|
||||
doc.Root.Add(new XElement("contentpackage",
|
||||
new XAttribute("path", SelectedContentPackage.Path)));
|
||||
}
|
||||
|
||||
var keyMappingElement = new XElement("keymapping");
|
||||
doc.Root.Add(keyMappingElement);
|
||||
for (int i = 0; i < keyMapping.Length; i++)
|
||||
{
|
||||
if (keyMapping[i].MouseButton == null)
|
||||
{
|
||||
keyMappingElement.Add(new XAttribute(((InputType)i).ToString(), keyMapping[i].Key));
|
||||
}
|
||||
else
|
||||
{
|
||||
keyMappingElement.Add(new XAttribute(((InputType)i).ToString(), keyMapping[i].MouseButton));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
var gameplay = new XElement("gameplay");
|
||||
|
||||
var jobPreferences = new XElement("jobpreferences");
|
||||
foreach (string jobName in JobNamePreferences)
|
||||
{
|
||||
jobPreferences.Add(new XElement("job", new XAttribute("name", jobName)));
|
||||
}
|
||||
|
||||
gameplay.Add(jobPreferences);
|
||||
doc.Root.Add(gameplay);
|
||||
|
||||
doc.Save(filePath);
|
||||
}
|
||||
|
||||
private IEnumerable<object> ApplyUnsavedChanges()
|
||||
{
|
||||
yield return new WaitForSeconds(10.0f);
|
||||
|
||||
Save("config.xml");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,6 +347,9 @@ namespace Barotrauma.Items.Components
|
||||
if (returnNull)
|
||||
{
|
||||
var itemContainer = projectileContainer.GetComponent<ItemContainer>();
|
||||
if (itemContainer == null) continue;
|
||||
if (itemContainer.Inventory == null) continue;
|
||||
if (itemContainer.Inventory.Items == null) continue;
|
||||
for (int i = 0; i < itemContainer.Inventory.Items.Length; i++)
|
||||
{
|
||||
projectiles.Add(itemContainer.Inventory.Items[i]?.GetComponent<Projectile>());
|
||||
|
||||
@@ -72,9 +72,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
name = name.Replace(":", "");
|
||||
name = name.Replace(";", "");
|
||||
|
||||
AdminAuthPass = "";
|
||||
|
||||
|
||||
this.name = name;
|
||||
this.isPublic = isPublic;
|
||||
this.maxPlayers = maxPlayers;
|
||||
|
||||
@@ -61,21 +61,7 @@ namespace Barotrauma.Networking
|
||||
private BanList banList;
|
||||
|
||||
private string password;
|
||||
|
||||
private string adminAuthPass = "";
|
||||
public string AdminAuthPass
|
||||
{
|
||||
set
|
||||
{
|
||||
DebugConsole.NewMessage("Admin auth pass changed!",Color.Yellow);
|
||||
adminAuthPass = "";
|
||||
if (value.Length > 0)
|
||||
{
|
||||
adminAuthPass = Encoding.UTF8.GetString(Lidgren.Network.NetUtility.ComputeSHAHash(Encoding.UTF8.GetBytes(value)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public float AutoRestartTimer;
|
||||
|
||||
private bool autoRestart;
|
||||
|
||||
Reference in New Issue
Block a user