Merge branch 'master' of https://github.com/Regalis11/Barotrauma
Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs
This commit is contained in:
@@ -15,6 +15,8 @@ namespace Barotrauma
|
||||
{
|
||||
protected float soundTimer;
|
||||
protected float soundInterval;
|
||||
protected float nameTimer;
|
||||
protected bool nameVisible;
|
||||
|
||||
private List<CharacterSound> sounds;
|
||||
|
||||
@@ -202,6 +204,34 @@ namespace Barotrauma
|
||||
if (Lights.LightManager.ViewTarget == this) Lights.LightManager.ViewTarget = null;
|
||||
}
|
||||
|
||||
partial void UpdateProjSpecific(float deltaTime, Camera cam)
|
||||
{
|
||||
if (info != null)
|
||||
{
|
||||
nameTimer -= deltaTime;
|
||||
if (nameTimer <= 0.0f)
|
||||
{
|
||||
if (controlled == null)
|
||||
{
|
||||
nameVisible = true;
|
||||
}
|
||||
|
||||
//if the character is not in the camera view, the name can't be visible and we can avoid the expensive visibility checks
|
||||
else if (WorldPosition.X < cam.WorldView.X || WorldPosition.X > cam.WorldView.Right ||
|
||||
WorldPosition.Y > cam.WorldView.Y || WorldPosition.Y < cam.WorldView.Y - cam.WorldView.Height)
|
||||
{
|
||||
nameVisible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Ideally it shouldn't send the character entirely if we can't see them but /shrug, this isn't the most hacker-proof game atm
|
||||
nameVisible = controlled.CanSeeCharacter(this);
|
||||
}
|
||||
nameTimer = Rand.Range(0.5f, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddAllToGUIUpdateList()
|
||||
{
|
||||
for (int i = 0; i < CharacterList.Count; i++)
|
||||
@@ -240,48 +270,7 @@ namespace Barotrauma
|
||||
|
||||
if (aiTarget != null) aiTarget.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
/*if (memPos != null && memPos.Count > 0 && controlled == this)
|
||||
{
|
||||
PosInfo serverPos = memPos.Last();
|
||||
Vector2 remoteVec = ConvertUnits.ToDisplayUnits(serverPos.Position);
|
||||
if (Submarine != null)
|
||||
{
|
||||
remoteVec += Submarine.DrawPosition;
|
||||
}
|
||||
remoteVec.Y = -remoteVec.Y;
|
||||
|
||||
PosInfo localPos = memLocalPos.Find(m => m.ID == serverPos.ID);
|
||||
int mpind = memLocalPos.FindIndex(lp => lp.ID == localPos.ID);
|
||||
PosInfo localPos1 = mpind > 0 ? memLocalPos[mpind - 1] : null;
|
||||
PosInfo localPos2 = mpind < memLocalPos.Count-1 ? memLocalPos[mpind + 1] : null;
|
||||
|
||||
Vector2 localVec = ConvertUnits.ToDisplayUnits(localPos.Position);
|
||||
Vector2 localVec1 = localPos1 != null ? ConvertUnits.ToDisplayUnits(((PosInfo)localPos1).Position) : Vector2.Zero;
|
||||
Vector2 localVec2 = localPos2 != null ? ConvertUnits.ToDisplayUnits(((PosInfo)localPos2).Position) : Vector2.Zero;
|
||||
if (Submarine != null)
|
||||
{
|
||||
localVec += Submarine.DrawPosition;
|
||||
localVec1 += Submarine.DrawPosition;
|
||||
localVec2 += Submarine.DrawPosition;
|
||||
}
|
||||
localVec.Y = -localVec.Y;
|
||||
localVec1.Y = -localVec1.Y;
|
||||
localVec2.Y = -localVec2.Y;
|
||||
|
||||
//GUI.DrawLine(spriteBatch, remoteVec, localVec, Color.Yellow, 0, 10);
|
||||
if (localPos1 != null) GUI.DrawLine(spriteBatch, remoteVec, localVec1, Color.Lime, 0, 2);
|
||||
if (localPos2 != null) GUI.DrawLine(spriteBatch, remoteVec + Vector2.One, localVec2 + Vector2.One, Color.Red, 0, 2);
|
||||
}
|
||||
|
||||
Vector2 mouseDrawPos = CursorWorldPosition;
|
||||
mouseDrawPos.Y = -mouseDrawPos.Y;
|
||||
GUI.DrawLine(spriteBatch, mouseDrawPos - new Vector2(0, 5), mouseDrawPos + new Vector2(0, 5), Color.Red, 0, 10);
|
||||
|
||||
Vector2 closestItemPos = closestItem != null ? closestItem.DrawPosition : Vector2.Zero;
|
||||
closestItemPos.Y = -closestItemPos.Y;
|
||||
GUI.DrawLine(spriteBatch, closestItemPos - new Vector2(0, 5), closestItemPos + new Vector2(0, 5), Color.Lime, 0, 10);*/
|
||||
|
||||
|
||||
if (this == controlled || GUI.DisableHUD) return;
|
||||
|
||||
Vector2 pos = DrawPosition;
|
||||
@@ -291,30 +280,33 @@ namespace Barotrauma
|
||||
{
|
||||
GUI.SpeechBubbleIcon.Draw(spriteBatch, pos - Vector2.UnitY * 100.0f,
|
||||
speechBubbleColor * Math.Min(speechBubbleTimer, 1.0f), 0.0f,
|
||||
Math.Min((float)speechBubbleTimer, 1.0f));
|
||||
Math.Min(speechBubbleTimer, 1.0f));
|
||||
}
|
||||
|
||||
if (this == controlled) return;
|
||||
|
||||
if (info != null)
|
||||
|
||||
if (nameVisible && info != null)
|
||||
{
|
||||
string name = Info.DisplayName;
|
||||
if (controlled == null && name != Info.Name) name += " (Disguised)";
|
||||
|
||||
Vector2 namePos = new Vector2(pos.X, pos.Y - 110.0f - (5.0f / cam.Zoom)) - GUI.Font.MeasureString(Info.Name) * 0.5f / cam.Zoom;
|
||||
Vector2 screenSize = new Vector2(GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
Vector2 viewportSize = new Vector2(cam.WorldView.Width, cam.WorldView.Height);
|
||||
namePos.X -= cam.WorldView.X; namePos.Y += cam.WorldView.Y;
|
||||
namePos *= screenSize / viewportSize;
|
||||
namePos.X = (float)Math.Floor(namePos.X); namePos.Y = (float)Math.Floor(namePos.Y);
|
||||
namePos *= viewportSize / screenSize;
|
||||
namePos.X += cam.WorldView.X; namePos.Y -= cam.WorldView.Y;
|
||||
Vector2 screenSize = new Vector2(GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
Vector2 viewportSize = new Vector2(cam.WorldView.Width, cam.WorldView.Height);
|
||||
namePos.X -= cam.WorldView.X; namePos.Y += cam.WorldView.Y;
|
||||
namePos *= screenSize / viewportSize;
|
||||
namePos.X = (float)Math.Floor(namePos.X); namePos.Y = (float)Math.Floor(namePos.Y);
|
||||
namePos *= viewportSize / screenSize;
|
||||
namePos.X += cam.WorldView.X; namePos.Y -= cam.WorldView.Y;
|
||||
|
||||
Color nameColor = Color.White;
|
||||
|
||||
if (Character.Controlled != null && TeamID != Character.Controlled.TeamID)
|
||||
if (Controlled != null && TeamID != Controlled.TeamID)
|
||||
{
|
||||
nameColor = Color.Red;
|
||||
}
|
||||
GUI.Font.DrawString(spriteBatch, Info.Name, namePos + new Vector2(1.0f / cam.Zoom, 1.0f / cam.Zoom), Color.Black, 0.0f, Vector2.Zero, 1.0f / cam.Zoom, SpriteEffects.None, 0.001f);
|
||||
GUI.Font.DrawString(spriteBatch, Info.Name, namePos, nameColor, 0.0f, Vector2.Zero, 1.0f / cam.Zoom, SpriteEffects.None, 0.0f);
|
||||
GUI.Font.DrawString(spriteBatch, name, namePos + new Vector2(1.0f / cam.Zoom, 1.0f / cam.Zoom), Color.Black, 0.0f, Vector2.Zero, 1.0f / cam.Zoom, SpriteEffects.None, 0.001f);
|
||||
GUI.Font.DrawString(spriteBatch, name, namePos, nameColor, 0.0f, Vector2.Zero, 1.0f / cam.Zoom, SpriteEffects.None, 0.0f);
|
||||
|
||||
if (GameMain.DebugDraw)
|
||||
{
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace Barotrauma
|
||||
private static Sprite noiseOverlay, damageOverlay;
|
||||
|
||||
private static GUIButton cprButton;
|
||||
|
||||
private static GUIButton grabHoldButton;
|
||||
|
||||
private static GUIButton suicideButton;
|
||||
|
||||
@@ -41,6 +43,8 @@ namespace Barotrauma
|
||||
|
||||
if (cprButton != null && cprButton.Visible) cprButton.AddToGUIUpdateList();
|
||||
|
||||
if (grabHoldButton != null && cprButton.Visible) grabHoldButton.AddToGUIUpdateList();
|
||||
|
||||
if (suicideButton != null && suicideButton.Visible) suicideButton.AddToGUIUpdateList();
|
||||
|
||||
if (!character.IsUnconscious && character.Stun <= 0.0f)
|
||||
@@ -89,6 +93,8 @@ namespace Barotrauma
|
||||
|
||||
if (cprButton != null && cprButton.Visible) cprButton.Update(deltaTime);
|
||||
|
||||
if (grabHoldButton != null && grabHoldButton.Visible) grabHoldButton.Update(deltaTime);
|
||||
|
||||
if (suicideButton != null && suicideButton.Visible) suicideButton.Update(deltaTime);
|
||||
|
||||
if (damageOverlayTimer > 0.0f) damageOverlayTimer -= deltaTime;
|
||||
@@ -195,9 +201,37 @@ namespace Barotrauma
|
||||
};
|
||||
}
|
||||
|
||||
if (grabHoldButton == null)
|
||||
{
|
||||
grabHoldButton = new GUIButton(
|
||||
new Rectangle(character.SelectedCharacter.Inventory.SlotPositions[0].ToPoint() + new Point(320, -60), new Point(130, 20)),
|
||||
"Grabbing: " + (character.AnimController.GrabLimb == LimbType.Torso ? "Torso" : "Hands"), "");
|
||||
|
||||
grabHoldButton.OnClicked = (button, userData) =>
|
||||
{
|
||||
if (Character.Controlled == null || Character.Controlled.SelectedCharacter == null) return false;
|
||||
|
||||
Character.Controlled.AnimController.GrabLimb = Character.Controlled.AnimController.GrabLimb == LimbType.None ? LimbType.Torso : LimbType.None;
|
||||
|
||||
foreach (Limb limb in Character.Controlled.SelectedCharacter.AnimController.Limbs)
|
||||
{
|
||||
limb.pullJoint.Enabled = false;
|
||||
}
|
||||
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
GameMain.Client.CreateEntityEvent(Character.Controlled, new object[] { NetEntityEvent.Type.Control });
|
||||
}
|
||||
|
||||
grabHoldButton.Text = "Grabbing: " + (Character.Controlled.AnimController.GrabLimb == LimbType.Torso ? "Torso" : "Hands");
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
//cprButton.Visible = character.GetSkillLevel("Medical") > 20.0f;
|
||||
|
||||
if (cprButton.Visible) cprButton.Draw(spriteBatch);
|
||||
if (grabHoldButton.Visible) grabHoldButton.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
if (character.FocusedCharacter != null && character.FocusedCharacter.CanBeSelected)
|
||||
@@ -208,7 +242,7 @@ namespace Barotrauma
|
||||
string focusName = character.FocusedCharacter.SpeciesName;
|
||||
if (character.FocusedCharacter.Info != null)
|
||||
{
|
||||
focusName = character.FocusedCharacter.Info.Name;
|
||||
focusName = character.FocusedCharacter.Info.DisplayName;
|
||||
}
|
||||
Vector2 textPos = startPos;
|
||||
textPos -= new Vector2(GUI.Font.MeasureString(focusName).X / 2, 20);
|
||||
|
||||
@@ -17,15 +17,19 @@ namespace Barotrauma
|
||||
switch ((NetEntityEvent.Type)extraData[0])
|
||||
{
|
||||
case NetEntityEvent.Type.InventoryState:
|
||||
msg.WriteRangedInteger(0, 2, 0);
|
||||
msg.WriteRangedInteger(0, 3, 0);
|
||||
inventory.ClientWrite(msg, extraData);
|
||||
break;
|
||||
case NetEntityEvent.Type.Repair:
|
||||
msg.WriteRangedInteger(0, 2, 1);
|
||||
msg.WriteRangedInteger(0, 3, 1);
|
||||
msg.Write(AnimController.Anim == AnimController.Animation.CPR);
|
||||
break;
|
||||
case NetEntityEvent.Type.Status:
|
||||
msg.WriteRangedInteger(0, 2, 2);
|
||||
msg.WriteRangedInteger(0, 3, 2);
|
||||
break;
|
||||
case NetEntityEvent.Type.Control:
|
||||
msg.WriteRangedInteger(0, 3, 3);
|
||||
msg.Write((UInt16)AnimController.GrabLimb);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -91,6 +95,7 @@ namespace Barotrauma
|
||||
bool crouching = msg.ReadBoolean();
|
||||
keys[(int)InputType.Crouch].Held = crouching;
|
||||
keys[(int)InputType.Crouch].SetState(false, crouching);
|
||||
AnimController.GrabLimb = (LimbType)msg.ReadUInt16();
|
||||
}
|
||||
|
||||
bool hasAttackLimb = msg.ReadBoolean();
|
||||
@@ -367,6 +372,9 @@ namespace Barotrauma
|
||||
SetStun(0.0f, true, true);
|
||||
}
|
||||
|
||||
bool ragdolled = msg.ReadBoolean();
|
||||
IsRagdolled = ragdolled;
|
||||
|
||||
bool huskInfected = msg.ReadBoolean();
|
||||
if (huskInfected)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user