diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index 44ab1ae9c..0f3ceae21 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -296,6 +296,14 @@ namespace Barotrauma public bool IsDead { get { return isDead; } + //set + //{ + // if (isDead == value) return; + // if (isDead) + // { + // Revive(false); + // } + //} } public CauseOfDeath CauseOfDeath @@ -1234,7 +1242,7 @@ namespace Barotrauma //CoroutineManager.StartCoroutine(DeathAnim(GameMain.GameScreen.Cam)); - health = 0.0f; + //health = 0.0f; isDead = true; this.causeOfDeath = causeOfDeath; @@ -1245,9 +1253,13 @@ namespace Barotrauma { if (selectedItems[i] != null) selectedItems[i].Drop(this); } - - aiTarget.Remove(); - aiTarget = null; + + if (aiTarget!=null) + { + aiTarget.Remove(); + aiTarget = null; + } + foreach (Limb limb in AnimController.Limbs) { @@ -1258,7 +1270,6 @@ namespace Barotrauma foreach (RevoluteJoint joint in AnimController.limbJoints) { joint.MotorEnabled = false; - joint.MaxMotorTorque = 0.0f; } if (GameMain.GameSession != null) @@ -1267,6 +1278,25 @@ namespace Barotrauma } } + public void Revive(bool isNetworkMessage) + { + isDead = false; + + aiTarget = new AITarget(this); + + health = Math.Max(maxHealth * 0.1f, health); + + foreach (RevoluteJoint joint in AnimController.limbJoints) + { + joint.MotorEnabled = true; + } + + if (GameMain.GameSession != null) + { + GameMain.GameSession.ReviveCharacter(this); + } + } + public override bool FillNetworkData(NetworkEventType type, NetBuffer message, object data) { switch (type) diff --git a/Subsurface/Source/DebugConsole.cs b/Subsurface/Source/DebugConsole.cs index 887db9015..0e0ee524d 100644 --- a/Subsurface/Source/DebugConsole.cs +++ b/Subsurface/Source/DebugConsole.cs @@ -266,6 +266,11 @@ namespace Barotrauma case "godmode": Submarine.Loaded.GodMode = !Submarine.Loaded.GodMode; break; + case "dumpids": + int count = commands.Length < 2 ? 10 : int.Parse(commands[1]); + + Entity.DumpIds(count); + break; case "heal": if (Character.Controlled != null) { @@ -274,6 +279,12 @@ namespace Barotrauma Character.Controlled.Bleeding = 0.0f; } break; + case "revive": + if (Character.Controlled != null) + { + Character.Controlled.Revive(false); + } + break; case "freecamera": case "freecam": Character.Controlled = null; diff --git a/Subsurface/Source/GameSession/CrewManager.cs b/Subsurface/Source/GameSession/CrewManager.cs index 3ffdd680e..8a9722687 100644 --- a/Subsurface/Source/GameSession/CrewManager.cs +++ b/Subsurface/Source/GameSession/CrewManager.cs @@ -181,6 +181,17 @@ namespace Barotrauma if (crewFrameOpen) crewFrame.Update(deltaTime); } + public void ReviveCharacter(Character revivedCharacter) + { + GUIComponent characterBlock = listBox.GetChild(revivedCharacter) as GUIComponent; + if (characterBlock != null) characterBlock.Color = Color.Transparent; + + if (revivedCharacter is AICharacter) + { + commander.UpdateCharacters(); + } + } + public void KillCharacter(Character killedCharacter) { GUIComponent characterBlock = listBox.GetChild(killedCharacter) as GUIComponent; diff --git a/Subsurface/Source/GameSession/GameSession.cs b/Subsurface/Source/GameSession/GameSession.cs index d16c47c3e..dcc2b0f54 100644 --- a/Subsurface/Source/GameSession/GameSession.cs +++ b/Subsurface/Source/GameSession/GameSession.cs @@ -173,6 +173,11 @@ namespace Barotrauma CrewManager.KillCharacter(character); } + public void ReviveCharacter(Character character) + { + CrewManager.ReviveCharacter(character); + } + public bool LoadPrevious(GUIButton button, object obj) { SaveUtil.LoadGame(saveFile); diff --git a/Subsurface/Source/Items/CharacterInventory.cs b/Subsurface/Source/Items/CharacterInventory.cs index f1a64b3cd..71a9c912d 100644 --- a/Subsurface/Source/Items/CharacterInventory.cs +++ b/Subsurface/Source/Items/CharacterInventory.cs @@ -266,7 +266,15 @@ namespace Barotrauma if (Items[i] != null && slotRect.Contains(PlayerInput.MousePosition)) { - toolTip = string.IsNullOrEmpty(Items[i].Description) ? Items[i].Name : Items[i].Name + '\n' + Items[i].Description; + if (GameMain.DebugDraw) + { + toolTip = Items[i].ToString(); + } + else + { + toolTip = string.IsNullOrEmpty(Items[i].Description) ? Items[i].Name : Items[i].Name + '\n' + Items[i].Description; + } + highlightedSlot = slotRect; } diff --git a/Subsurface/Source/Items/Inventory.cs b/Subsurface/Source/Items/Inventory.cs index 30b6dc69d..e5f74a5d3 100644 --- a/Subsurface/Source/Items/Inventory.cs +++ b/Subsurface/Source/Items/Inventory.cs @@ -199,7 +199,7 @@ namespace Barotrauma if (slotRect.Contains(PlayerInput.MousePosition) && Items[i] != null) { highlightedSlot = slotRect; - toolTip = Items[i].Name; + toolTip = GameMain.DebugDraw ? Items[i].ToString() : Items[i].Name; } } diff --git a/Subsurface/Source/Items/ItemSpawner.cs b/Subsurface/Source/Items/ItemSpawner.cs index 9ee491204..4dea7017d 100644 --- a/Subsurface/Source/Items/ItemSpawner.cs +++ b/Subsurface/Source/Items/ItemSpawner.cs @@ -88,7 +88,7 @@ namespace Barotrauma message.Write(items[i].Prefab.Name); message.Write(items[i].ID); - message.Write(inventories[i].Owner == null ? 0 : inventories[i].Owner.ID); + message.Write((inventories[i]==null || inventories[i].Owner == null) ? (ushort)0 : inventories[i].Owner.ID); } } diff --git a/Subsurface/Source/Map/Hull.cs b/Subsurface/Source/Map/Hull.cs index 15b34b0cd..ab62b1e4e 100644 --- a/Subsurface/Source/Map/Hull.cs +++ b/Subsurface/Source/Map/Hull.cs @@ -407,12 +407,14 @@ namespace Barotrauma public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true) { + if (back) return; + if (!ShowHulls && !GameMain.DebugDraw) return; if (!editing && !GameMain.DebugDraw) return; Rectangle drawRect = - Submarine == null ? rect : new Rectangle((int)(Submarine.DrawPosition.X + rect.X), (int)(Submarine.DrawPosition.Y + rect.Y), rect.Width, rect.Height); + Submarine == null ? rect : new Rectangle((int)(Submarine.DrawPosition.X + rect.X), (int)(Submarine.DrawPosition.Y + rect.Y), rect.Width, rect.Height); GUI.DrawRectangle(spriteBatch, new Vector2(drawRect.X, -drawRect.Y), diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index 355cb5e2a..d7b626fe7 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ