4 using FarseerPhysics.Collision;
5 using Microsoft.Xna.Framework;
6 using Microsoft.Xna.Framework.Graphics;
12 private GUIMessageBox autodockingVerification;
19 get {
return Vector2.Zero; }
22 public void Draw(SpriteBatch spriteBatch,
bool editing,
float itemDepth = -1, Color? overrideColor =
null)
24 if (dockingState == 0.0f)
return;
26 if (overlaySprite !=
null)
29 drawPos.Y = -drawPos.Y;
34 drawPos.Y -= rect.Height / 2;
38 spriteBatch.Draw(overlaySprite.
Texture,
41 rect.Center.X + (
int)(rect.Width / 2 * (1.0f - dockingState)), rect.Y,
42 (
int)(rect.Width / 2 * dockingState), rect.Height),
43 overrideColor ?? Color.White);
48 spriteBatch.Draw(overlaySprite.
Texture,
49 drawPos - Vector2.UnitX * (rect.Width / 2 * dockingState),
52 (
int)(rect.Width / 2 * dockingState), rect.Height),
53 overrideColor ?? Color.White);
58 drawPos.X -= rect.Width / 2;
62 spriteBatch.Draw(overlaySprite.
Texture,
63 drawPos - Vector2.UnitY * (rect.Height / 2 * dockingState),
66 rect.Width, (
int)(rect.Height / 2 * dockingState)),
67 overrideColor ?? Color.White);
71 spriteBatch.Draw(overlaySprite.
Texture,
74 rect.X, rect.Y + rect.Height / 2 + (
int)(rect.Height / 2 * (1.0f - dockingState)),
75 rect.Width, (
int)(rect.Height / 2 * dockingState)),
76 overrideColor ?? Color.White);
85 for (
int i = 0; i < bodies.Length; i++)
88 if (body ==
null)
continue;
90 body.FixtureList[0].GetAABB(out AABB aabb, 0);
92 Vector2 bodyDrawPos = ConvertUnits.ToDisplayUnits(
new Vector2(aabb.LowerBound.X, aabb.UpperBound.Y));
95 bodyDrawPos.Y = -bodyDrawPos.Y;
97 GUI.DrawRectangle(spriteBatch,
99 ConvertUnits.ToDisplayUnits(aabb.Extents * 2),
100 Color.Gray,
false, 0.0f, 4);
104 if (doorBody !=
null && doorBody.Enabled)
106 doorBody.FixtureList[0].GetAABB(out AABB aabb, 0);
108 Vector2 bodyDrawPos = ConvertUnits.ToDisplayUnits(
new Vector2(aabb.LowerBound.X, aabb.UpperBound.Y));
110 bodyDrawPos.Y = -bodyDrawPos.Y;
112 GUI.DrawRectangle(spriteBatch,
114 ConvertUnits.ToDisplayUnits(aabb.Extents * 2),
115 Color.Gray,
false, 0, 8);
119 partial
void RemoveConvexHulls()
121 for (
int i = 0; i < convexHulls.Length; i++)
123 convexHulls[i]?.Remove();
124 convexHulls[i] =
null;
132 for (
int i = 0; i < 2; i++)
134 if (hulls[i] ==
null)
continue;
154 if (targetEntity ==
null || !(targetEntity is
Item))
156 DebugConsole.ThrowError(
"Invalid docking port network event (can't dock to " + (targetEntity?.ToString() ??
"null") +
")");
163 DebugConsole.ThrowError(
"Invalid docking port network event (" + targetEntity +
" doesn't have a docking port component)");
170 string errorMsg =
"Error while reading a docking port network event (Dock method did not create a joint between the ports)." +
175 errorMsg +=
"\nAlready docked.";
179 errorMsg +=
"\nTrying to dock the submarine to itself.";
181 GameAnalyticsManager.AddErrorEventOnce(
"DockingPort.ClientRead:JointNotCreated", GameAnalyticsManager.ErrorSeverity.Error, errorMsg);
192 Lock(isNetworkMessage:
true);
204 msg.
WriteByte((
byte)allowOutpostAutoDocking);
virtual Vector2 DrawPosition
static Entity FindEntityByID(ushort ID)
Find an entity based on the ID
DockingPort DockingTarget
void ClientEventWrite(IWriteMessage msg, NetEntityEvent.IData extraData=null)
void Undock(bool applyEffects=true)
void Lock(bool isNetworkMessage, bool applyEffects=true)
void ClientEventRead(IReadMessage msg, float sendingTime)
void Draw(SpriteBatch spriteBatch, bool editing, float itemDepth=-1, Color? overrideColor=null)
void Dock(DockingPort target)
readonly List< MapEntity > linkedTo
readonly Dictionary< Submarine, DockingPort > ConnectedDockingPorts
override Vector2? Position
Interface for entities that the clients can send events to the server
Interface for entities that the server can send events to the clients