Attachable items aren't automatically attached when loading a sub in edit screen, bunch of new item sprites, Aegir Mark II, client reconnect bugfixes
@@ -2,6 +2,7 @@
|
||||
name="Button"
|
||||
type="Controller"
|
||||
linkable="true"
|
||||
tags="smallitem"
|
||||
pickdistance="150.0"
|
||||
price="10">
|
||||
|
||||
|
||||
BIN
Subsurface/Content/Items/Diving/divingSuit.ogg
Normal file
|
Before Width: | Height: | Size: 520 B After Width: | Height: | Size: 9.3 KiB |
|
Before Width: | Height: | Size: 498 B After Width: | Height: | Size: 9.6 KiB |
|
Before Width: | Height: | Size: 528 B After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 520 B |
BIN
Subsurface/Content/Items/OxygenGenerator/oxygengenerator.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
@@ -4,7 +4,7 @@
|
||||
linkable="true">
|
||||
|
||||
|
||||
<Sprite texture ="battery.png" depth="0.8"/>
|
||||
<Sprite texture ="oxygengenerator.png" depth="0.8"/>
|
||||
|
||||
<OxygenGenerator powerconsumption="1000.0" minvoltage="0.5" canbeselected = "true">
|
||||
<StatusEffect type="OnActive" target="Contained" targetnames="Oxygen Tank" Condition="2.0"/>
|
||||
|
||||
|
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 97 KiB |
@@ -18,7 +18,7 @@
|
||||
<item name="Screwdriver"/>
|
||||
</fixrequirement>
|
||||
|
||||
<Sprite texture = "reactor.png" depth="0.8"/>
|
||||
<Sprite texture = "reactor.png" sourcerect="0,0,321,192" depth="0.8"/>
|
||||
|
||||
<Reactor canbeselected = "true">
|
||||
<GuiFrame rect="0,0,0.6,0.7" alignment="Center" color="0.0,0.0,0.0,0.8"/>
|
||||
|
||||
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 53 KiB |
@@ -66,12 +66,14 @@ namespace Subsurface
|
||||
|
||||
protected override void DropItem(Item item)
|
||||
{
|
||||
bool enabled = draggingItem.body.Enabled;
|
||||
if (item.body == null) return;
|
||||
|
||||
bool enabled = item.body.Enabled;
|
||||
item.Drop(character);
|
||||
|
||||
if (!enabled)
|
||||
{
|
||||
draggingItem.body.SetTransform(character.SimPosition, 0.0f);
|
||||
item.SetTransform(character.SimPosition, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace Subsurface.Items.Components
|
||||
Msg = "";
|
||||
}
|
||||
|
||||
if (attachedByDefault || Screen.Selected == GameMain.EditMapScreen) Use(1.0f);
|
||||
if (attachedByDefault || (Screen.Selected == GameMain.EditMapScreen && Submarine.Loaded!=null)) Use(1.0f);
|
||||
|
||||
|
||||
//holdAngle = ToolBox.GetAttributeFloat(element, "holdangle", 0.0f);
|
||||
|
||||
@@ -131,9 +131,9 @@ namespace Subsurface.Items.Components
|
||||
|
||||
public override bool Use(float deltaTime, Character activator = null)
|
||||
{
|
||||
if (character.SelectedConstruction != item)
|
||||
if (activator.SelectedConstruction != item)
|
||||
{
|
||||
character = null;
|
||||
activator = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -299,7 +299,7 @@ namespace Subsurface.Items.Components
|
||||
|
||||
if (selectedNodeIndex == null && !MapEntity.SelectedAny)
|
||||
{
|
||||
if (PlayerInput.LeftButtonDown())
|
||||
if (PlayerInput.LeftButtonDown() && PlayerInput.GetOldMouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Released)
|
||||
{
|
||||
MapEntity.SelectEntity(item);
|
||||
selectedNodeIndex = i;
|
||||
|
||||
@@ -130,10 +130,14 @@ namespace Subsurface.Items.Components
|
||||
{
|
||||
base.Update(deltaTime, cam);
|
||||
|
||||
item.SetTransform(picker.SimPosition, 0.0f);
|
||||
|
||||
Item[] containedItems = item.ContainedItems;
|
||||
|
||||
ApplyStatusEffects(ActionType.OnWearing, deltaTime, picker);
|
||||
|
||||
PlaySound(ActionType.OnWearing, picker.Position);
|
||||
|
||||
if (containedItems == null) return;
|
||||
for (int j = 0; j<containedItems.Length; j++)
|
||||
{
|
||||
|
||||
@@ -27,8 +27,7 @@ namespace Subsurface
|
||||
protected ItemPrefab prefab;
|
||||
|
||||
private List<string> tags;
|
||||
|
||||
|
||||
|
||||
public Hull CurrentHull;
|
||||
|
||||
//components that determine the functionality of the item
|
||||
@@ -79,6 +78,22 @@ namespace Subsurface
|
||||
get { return prefab.PickDistance; }
|
||||
}
|
||||
|
||||
protected Color spriteColor;
|
||||
[Editable, HasDefaultValue("1.0,1.0,1.0,1.0", true)]
|
||||
public string SpriteColor
|
||||
{
|
||||
get { return ToolBox.Vector4ToString(spriteColor.ToVector4()); }
|
||||
set
|
||||
{
|
||||
spriteColor = new Color(ToolBox.ParseToVector4(value));
|
||||
}
|
||||
}
|
||||
|
||||
public Color Color
|
||||
{
|
||||
get { return spriteColor; }
|
||||
}
|
||||
|
||||
public float Condition
|
||||
{
|
||||
get { return condition; }
|
||||
@@ -104,22 +119,6 @@ namespace Subsurface
|
||||
get { return condition; }
|
||||
}
|
||||
|
||||
private Color spriteColor;
|
||||
[Editable, HasDefaultValue("1.0,1.0,1.0,1.0", true)]
|
||||
public string SpriteColor
|
||||
{
|
||||
get { return ToolBox.Vector4ToString(spriteColor.ToVector4()); }
|
||||
set
|
||||
{
|
||||
spriteColor = new Color(ToolBox.ParseToVector4(value));
|
||||
}
|
||||
}
|
||||
|
||||
public Color Color
|
||||
{
|
||||
get { return spriteColor; }
|
||||
}
|
||||
|
||||
[Editable, HasDefaultValue("", true)]
|
||||
public string Tags
|
||||
{
|
||||
@@ -242,6 +241,8 @@ namespace Subsurface
|
||||
{
|
||||
prefab = itemPrefab;
|
||||
|
||||
spriteColor = prefab.SpriteColor;
|
||||
|
||||
linkedTo = new ObservableCollection<MapEntity>();
|
||||
components = new List<ItemComponent>();
|
||||
FixRequirements = new List<FixRequirement>();
|
||||
@@ -323,11 +324,15 @@ namespace Subsurface
|
||||
}
|
||||
|
||||
|
||||
public void SetTransform(Vector2 position, float rotation)
|
||||
public void SetTransform(Vector2 simPosition, float rotation)
|
||||
{
|
||||
body.SetTransform(position, rotation);
|
||||
if (body != null)
|
||||
{
|
||||
body.SetTransform(simPosition, rotation);
|
||||
}
|
||||
|
||||
Vector2 displayPos = ConvertUnits.ToDisplayUnits(body.SimPosition);
|
||||
|
||||
Vector2 displayPos = ConvertUnits.ToDisplayUnits(simPosition);
|
||||
|
||||
rect.X = (int)(displayPos.X - rect.Width / 2.0f);
|
||||
rect.Y = (int)(displayPos.Y + rect.Height / 2.0f);
|
||||
|
||||
@@ -157,6 +157,9 @@ namespace Subsurface
|
||||
|
||||
offsetOnSelected = ToolBox.GetAttributeFloat(element, "offsetonselected", 0.0f);
|
||||
|
||||
string spriteColorStr = ToolBox.GetAttributeString(element, "spritecolor", "1.0,1.0,1.0,1.0");
|
||||
SpriteColor = new Color(ToolBox.ParseToVector4(spriteColorStr));
|
||||
|
||||
price = ToolBox.GetAttributeInt(element, "price", 0);
|
||||
|
||||
Triggers = new List<Rectangle>();
|
||||
|
||||
@@ -53,7 +53,6 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static bool SelectedAny
|
||||
{
|
||||
get { return selectedList.Count > 0; }
|
||||
|
||||
@@ -56,6 +56,12 @@ namespace Subsurface
|
||||
get { return resizeVertical; }
|
||||
}
|
||||
|
||||
public Color SpriteColor
|
||||
{
|
||||
get;
|
||||
protected set;
|
||||
}
|
||||
|
||||
public int Price
|
||||
{
|
||||
get { return price; }
|
||||
|
||||
@@ -68,12 +68,12 @@ namespace Subsurface
|
||||
}
|
||||
}
|
||||
|
||||
public static StructurePrefab Load(XElement el)
|
||||
public static StructurePrefab Load(XElement element)
|
||||
{
|
||||
StructurePrefab sp = new StructurePrefab();
|
||||
sp.name = el.Name.ToString();
|
||||
sp.name = element.Name.ToString();
|
||||
|
||||
Vector4 sourceVector = ToolBox.GetAttributeVector4(el, "sourcerect", new Vector4(0,0,1,1));
|
||||
Vector4 sourceVector = ToolBox.GetAttributeVector4(element, "sourcerect", new Vector4(0,0,1,1));
|
||||
|
||||
Rectangle sourceRect = new Rectangle(
|
||||
(int)sourceVector.X,
|
||||
@@ -81,32 +81,35 @@ namespace Subsurface
|
||||
(int)sourceVector.Z,
|
||||
(int)sourceVector.W);
|
||||
|
||||
if (el.Attribute("sprite") != null)
|
||||
if (element.Attribute("sprite") != null)
|
||||
{
|
||||
sp.sprite = new Sprite(el.Attribute("sprite").Value, sourceRect, Vector2.Zero);
|
||||
sp.sprite = new Sprite(element.Attribute("sprite").Value, sourceRect, Vector2.Zero);
|
||||
|
||||
sp.sprite.Depth = ToolBox.GetAttributeFloat(el, "depth", 0.0f);
|
||||
sp.sprite.Depth = ToolBox.GetAttributeFloat(element, "depth", 0.0f);
|
||||
|
||||
if (ToolBox.GetAttributeBool(el, "fliphorizontal", false)) sp.sprite.effects = SpriteEffects.FlipHorizontally;
|
||||
if (ToolBox.GetAttributeBool(el, "flipvertical", false)) sp.sprite.effects = SpriteEffects.FlipVertically;
|
||||
if (ToolBox.GetAttributeBool(element, "fliphorizontal", false)) sp.sprite.effects = SpriteEffects.FlipHorizontally;
|
||||
if (ToolBox.GetAttributeBool(element, "flipvertical", false)) sp.sprite.effects = SpriteEffects.FlipVertically;
|
||||
}
|
||||
|
||||
sp.size = Vector2.Zero;
|
||||
sp.size.X = ToolBox.GetAttributeFloat(el, "width", 0.0f);
|
||||
sp.size.Y = ToolBox.GetAttributeFloat(el, "height", 0.0f);
|
||||
|
||||
sp.maxHealth = ToolBox.GetAttributeFloat(el, "health", 100.0f);
|
||||
|
||||
sp.resizeHorizontal = ToolBox.GetAttributeBool(el, "resizehorizontal", false);
|
||||
sp.resizeVertical = ToolBox.GetAttributeBool(el, "resizevertical", false);
|
||||
sp.size.X = ToolBox.GetAttributeFloat(element, "width", 0.0f);
|
||||
sp.size.Y = ToolBox.GetAttributeFloat(element, "height", 0.0f);
|
||||
|
||||
sp.isPlatform = ToolBox.GetAttributeBool(el, "platform", false);
|
||||
sp.stairDirection = (Direction)Enum.Parse(typeof(Direction), ToolBox.GetAttributeString(el, "stairdirection", "None"));
|
||||
string spriteColorStr = ToolBox.GetAttributeString(element, "spritecolor", "1.0,1.0,1.0,1.0");
|
||||
sp.SpriteColor = new Color(ToolBox.ParseToVector4(spriteColorStr));
|
||||
|
||||
sp.castShadow = ToolBox.GetAttributeBool(el, "castshadow", false);
|
||||
sp.maxHealth = ToolBox.GetAttributeFloat(element, "health", 100.0f);
|
||||
|
||||
sp.resizeHorizontal = ToolBox.GetAttributeBool(element, "resizehorizontal", false);
|
||||
sp.resizeVertical = ToolBox.GetAttributeBool(element, "resizevertical", false);
|
||||
|
||||
sp.isPlatform = ToolBox.GetAttributeBool(element, "platform", false);
|
||||
sp.stairDirection = (Direction)Enum.Parse(typeof(Direction), ToolBox.GetAttributeString(element, "stairdirection", "None"), true);
|
||||
|
||||
sp.castShadow = ToolBox.GetAttributeBool(element, "castshadow", false);
|
||||
|
||||
|
||||
sp.hasBody = ToolBox.GetAttributeBool(el, "body", false);
|
||||
sp.hasBody = ToolBox.GetAttributeBool(element, "body", false);
|
||||
|
||||
return sp;
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@ namespace Subsurface.Networking
|
||||
client.Start();
|
||||
|
||||
outmsg.Write((byte)PacketTypes.Login);
|
||||
outmsg.Write(myID);
|
||||
outmsg.Write(password);
|
||||
outmsg.Write(GameMain.Version.ToString());
|
||||
outmsg.Write(GameMain.SelectedPackage.Name);
|
||||
@@ -244,6 +245,7 @@ namespace Subsurface.Networking
|
||||
|
||||
if (client.ConnectionStatus == NetConnectionStatus.Disconnected)
|
||||
{
|
||||
GameMain.NetLobbyScreen.RemovePlayer(myID);
|
||||
if (reconnectBox==null)
|
||||
{
|
||||
reconnectBox = new GUIMessageBox("CONNECTION LOST", "You have been disconnected from the server. Reconnecting...", new string[0]);
|
||||
|
||||
@@ -13,6 +13,10 @@ namespace Subsurface.Networking
|
||||
|
||||
public List<Client> connectedClients = new List<Client>();
|
||||
|
||||
//for keeping track of disconnected clients in case the reconnect shortly after
|
||||
private List<Client> disconnectedClients = new List<Client>();
|
||||
|
||||
//is the server running
|
||||
bool started;
|
||||
|
||||
private NetServer server;
|
||||
@@ -30,10 +34,6 @@ namespace Subsurface.Networking
|
||||
|
||||
private string password;
|
||||
|
||||
// private Client myClient;
|
||||
|
||||
//private CharacterInfo myCharacter;
|
||||
|
||||
public GameServer(string name, int port, bool isPublic = false, string password = "", bool attemptUPnP = false, int maxPlayers = 10)
|
||||
{
|
||||
var endRoundButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 290, 20, 150, 25), "End round", Alignment.TopLeft, GUI.Style, inGameHUD);
|
||||
@@ -217,6 +217,13 @@ namespace Subsurface.Networking
|
||||
inGameHUD.Update((float)Physics.step);
|
||||
}
|
||||
|
||||
for (int i = disconnectedClients.Count - 1; i >= 0; i-- )
|
||||
{
|
||||
disconnectedClients[i].deleteDisconnectedTimer -= deltaTime;
|
||||
if (disconnectedClients[i].deleteDisconnectedTimer > 0.0f) continue;
|
||||
disconnectedClients.RemoveAt(i);
|
||||
}
|
||||
|
||||
NetIncomingMessage inc = server.ReadMessage();
|
||||
if (inc != null)
|
||||
{
|
||||
@@ -282,80 +289,7 @@ namespace Subsurface.Networking
|
||||
switch (inc.MessageType)
|
||||
{
|
||||
case NetIncomingMessageType.ConnectionApproval:
|
||||
if (inc.ReadByte() != (byte)PacketTypes.Login) break;
|
||||
|
||||
DebugConsole.NewMessage("New player has joined the server", Color.White);
|
||||
|
||||
|
||||
Client existingClient = connectedClients.Find(c=> c.Connection == inc.SenderConnection);
|
||||
if (existingClient==null)
|
||||
{
|
||||
string userPassword = "", version = "", packageName="", packageHash="", name = "";
|
||||
try
|
||||
{
|
||||
userPassword = inc.ReadString();
|
||||
version = inc.ReadString();
|
||||
packageName = inc.ReadString();
|
||||
packageHash = inc.ReadString();
|
||||
name = inc.ReadString();
|
||||
}
|
||||
catch
|
||||
{
|
||||
inc.SenderConnection.Deny("Connection error - server failed to read your ConnectionApproval message");
|
||||
DebugConsole.NewMessage("Connection error - server failed to read the ConnectionApproval message", Color.Red);
|
||||
break;
|
||||
}
|
||||
|
||||
if (userPassword != password)
|
||||
{
|
||||
inc.SenderConnection.Deny("Wrong password!");
|
||||
|
||||
break;
|
||||
}
|
||||
else if (version != GameMain.Version.ToString())
|
||||
{
|
||||
inc.SenderConnection.Deny("Subsurface version " + GameMain.Version + " required to connect to the server (Your version: " + version + ")");
|
||||
DebugConsole.NewMessage("Connection error - wrong game version", Color.Red);
|
||||
break;
|
||||
}
|
||||
else if (packageName != GameMain.SelectedPackage.Name)
|
||||
{
|
||||
inc.SenderConnection.Deny("Your content package ("+packageName+") doesn't match the server's version (" + GameMain.SelectedPackage.Name + ")");
|
||||
DebugConsole.NewMessage("Connection error - wrong content package name", Color.Red);
|
||||
break;
|
||||
}
|
||||
else if (packageHash != GameMain.SelectedPackage.MD5hash.Hash)
|
||||
{
|
||||
inc.SenderConnection.Deny("Your content package (MD5: " + packageHash + ") doesn't match the server's version (MD5: " + GameMain.SelectedPackage.MD5hash.Hash + ")");
|
||||
DebugConsole.NewMessage("Connection error - wrong content package hash", Color.Red);
|
||||
break;
|
||||
}
|
||||
else if (connectedClients.Find(c => c.name.ToLower() == name.ToLower())!=null)
|
||||
{
|
||||
inc.SenderConnection.Deny("The name ''" + name + "'' is already in use. Please choose another name.");
|
||||
DebugConsole.NewMessage("Connection error - name already in use", Color.Red);
|
||||
break;
|
||||
}
|
||||
|
||||
int id = 1;
|
||||
while (connectedClients.Find(c => c.ID==id)!=null)
|
||||
{
|
||||
id++;
|
||||
}
|
||||
Client newClient = new Client(name, id);
|
||||
newClient.Connection = inc.SenderConnection;
|
||||
newClient.version = version;
|
||||
|
||||
connectedClients.Add(newClient);
|
||||
|
||||
inc.SenderConnection.Approve();
|
||||
}
|
||||
else
|
||||
{
|
||||
inc.SenderConnection.Deny();
|
||||
}
|
||||
//Character ch = new Character("Content/Characters/Human/human.xml");
|
||||
|
||||
HandleConnectionApproval(inc);
|
||||
break;
|
||||
case NetIncomingMessageType.StatusChanged:
|
||||
Debug.WriteLine(inc.SenderConnection + " status changed. " + (NetConnectionStatus)inc.SenderConnection.Status);
|
||||
@@ -424,6 +358,13 @@ namespace Subsurface.Networking
|
||||
}
|
||||
else if (inc.SenderConnection.Status == NetConnectionStatus.Disconnected)
|
||||
{
|
||||
var connectedClient = connectedClients.Find(c => c.Connection == inc.SenderConnection);
|
||||
if (connectedClient != null && !disconnectedClients.Contains(connectedClient))
|
||||
{
|
||||
connectedClient.deleteDisconnectedTimer = NetConfig.DeleteDisconnectedTime;
|
||||
disconnectedClients.Add(connectedClient);
|
||||
}
|
||||
|
||||
DisconnectClient(inc.SenderConnection);
|
||||
}
|
||||
|
||||
@@ -476,6 +417,104 @@ namespace Subsurface.Networking
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleConnectionApproval(NetIncomingMessage inc)
|
||||
{
|
||||
if (inc.ReadByte() != (byte)PacketTypes.Login) return;
|
||||
|
||||
DebugConsole.NewMessage("New player has joined the server", Color.White);
|
||||
|
||||
if (connectedClients.Find(c => c.Connection == inc.SenderConnection)!=null)
|
||||
{
|
||||
inc.SenderConnection.Deny("Connection error - already joined");
|
||||
return;
|
||||
}
|
||||
|
||||
int userID;
|
||||
string userPassword = "", version = "", packageName = "", packageHash = "", name = "";
|
||||
try
|
||||
{
|
||||
userID = inc.ReadInt32();
|
||||
userPassword = inc.ReadString();
|
||||
version = inc.ReadString();
|
||||
packageName = inc.ReadString();
|
||||
packageHash = inc.ReadString();
|
||||
name = inc.ReadString();
|
||||
}
|
||||
catch
|
||||
{
|
||||
inc.SenderConnection.Deny("Connection error - server failed to read your ConnectionApproval message");
|
||||
DebugConsole.NewMessage("Connection error - server failed to read the ConnectionApproval message", Color.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
if (userPassword != password)
|
||||
{
|
||||
inc.SenderConnection.Deny("Wrong password!");
|
||||
DebugConsole.NewMessage(name +" couldn't join the server (wrong password)", Color.Red);
|
||||
return;
|
||||
}
|
||||
else if (version != GameMain.Version.ToString())
|
||||
{
|
||||
inc.SenderConnection.Deny("Subsurface version " + GameMain.Version + " required to connect to the server (Your version: " + version + ")");
|
||||
DebugConsole.NewMessage(name + " couldn't join the server (wrong game version)", Color.Red);
|
||||
return;
|
||||
}
|
||||
else if (packageName != GameMain.SelectedPackage.Name)
|
||||
{
|
||||
inc.SenderConnection.Deny("Your content package (" + packageName + ") doesn't match the server's version (" + GameMain.SelectedPackage.Name + ")");
|
||||
DebugConsole.NewMessage(name + " couldn't join the server (wrong content package name)", Color.Red);
|
||||
return;
|
||||
}
|
||||
else if (packageHash != GameMain.SelectedPackage.MD5hash.Hash)
|
||||
{
|
||||
inc.SenderConnection.Deny("Your content package (MD5: " + packageHash + ") doesn't match the server's version (MD5: " + GameMain.SelectedPackage.MD5hash.Hash + ")");
|
||||
DebugConsole.NewMessage(name + " couldn't join the server (wrong content package hash)", Color.Red);
|
||||
return;
|
||||
}
|
||||
else if (connectedClients.Find(c => c.name.ToLower() == name.ToLower() && c.ID!=userID) != null)
|
||||
{
|
||||
inc.SenderConnection.Deny("The name ''" + name + "'' is already in use. Please choose another name.");
|
||||
DebugConsole.NewMessage(name + " couldn't join the server (name already in use)", Color.Red);
|
||||
return;
|
||||
}
|
||||
|
||||
//existing user re-joining
|
||||
if (userID > 0)
|
||||
{
|
||||
Client existingClient = connectedClients.Find(c => c.ID == userID);
|
||||
if (existingClient == null)
|
||||
{
|
||||
existingClient = disconnectedClients.Find(c => c.ID == userID);
|
||||
if (existingClient != null)
|
||||
{
|
||||
disconnectedClients.Remove(existingClient);
|
||||
connectedClients.Add(existingClient);
|
||||
}
|
||||
}
|
||||
if (existingClient != null)
|
||||
{
|
||||
existingClient.Connection = inc.SenderConnection;
|
||||
inc.SenderConnection.Approve();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
userID = Rand.Range(1, 1000000);
|
||||
while (connectedClients.Find(c => c.ID == userID) != null)
|
||||
{
|
||||
userID++;
|
||||
}
|
||||
|
||||
Client newClient = new Client(name, userID);
|
||||
newClient.Connection = inc.SenderConnection;
|
||||
newClient.version = version;
|
||||
|
||||
connectedClients.Add(newClient);
|
||||
|
||||
inc.SenderConnection.Approve();
|
||||
}
|
||||
|
||||
|
||||
private void SendMessage(NetOutgoingMessage msg, NetDeliveryMethod deliveryMethod, NetConnection excludedConnection)
|
||||
{
|
||||
List<NetConnection> recipients = new List<NetConnection>();
|
||||
@@ -495,7 +534,6 @@ namespace Subsurface.Networking
|
||||
{
|
||||
if (NetworkEvent.events.Count == 0) return;
|
||||
|
||||
//System.Diagnostics.Debug.WriteLine("*************************");
|
||||
foreach (NetworkEvent networkEvent in NetworkEvent.events)
|
||||
{
|
||||
//System.Diagnostics.Debug.WriteLine("networkevent "+networkEvent.ID);
|
||||
@@ -615,13 +653,13 @@ namespace Subsurface.Networking
|
||||
foreach (Client client in connectedClients)
|
||||
{
|
||||
msg.Write(client.ID);
|
||||
WriteCharacterData(msg, client.name, client.character);
|
||||
WriteCharacterData(msg, client.character.Name, client.character);
|
||||
}
|
||||
|
||||
if (myCharacter != null)
|
||||
{
|
||||
msg.Write(-1);
|
||||
WriteCharacterData(msg, myCharacter.Name, Character.Controlled);
|
||||
WriteCharacterData(msg, myCharacter.Info.Name, Character.Controlled);
|
||||
}
|
||||
|
||||
SendMessage(msg, NetDeliveryMethod.ReliableUnordered, null);
|
||||
@@ -648,8 +686,7 @@ namespace Subsurface.Networking
|
||||
{
|
||||
|
||||
var messageBox = new GUIMessageBox("The round has ended", endMessage);
|
||||
|
||||
|
||||
|
||||
Character.Controlled = null;
|
||||
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
|
||||
GameMain.LightManager.LosEnabled = false;
|
||||
@@ -1056,6 +1093,8 @@ namespace Subsurface.Networking
|
||||
public List<JobPrefab> jobPreferences;
|
||||
public JobPrefab assignedJob;
|
||||
|
||||
public float deleteDisconnectedTimer;
|
||||
|
||||
public Client(string name, int ID)
|
||||
{
|
||||
this.name = name;
|
||||
|
||||
@@ -20,5 +20,7 @@ namespace Subsurface.Networking
|
||||
|
||||
//if the ragdoll is closer than this, don't try to correct its position
|
||||
public const float AllowedRagdollDistance = 0.1f;
|
||||
|
||||
public const float DeleteDisconnectedTime = 10.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,6 +120,7 @@ namespace Subsurface
|
||||
{
|
||||
GUIImage img = new GUIImage(new Rectangle(0, 0, 40, 40), ep.sprite, Alignment.Left, frame);
|
||||
img.Scale = Math.Min(Math.Min(40.0f / img.SourceRect.Width, 40.0f / img.SourceRect.Height), 1.0f);
|
||||
img.Color = ep.SpriteColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,25 +11,25 @@ namespace Subsurface
|
||||
{
|
||||
enum PanelTab { Crew = 0, Map = 1, CurrentLocation = 2, Store = 3 }
|
||||
|
||||
GUIFrame leftPanel;
|
||||
GUIFrame[] rightPanel;
|
||||
private GUIFrame leftPanel;
|
||||
private GUIFrame[] rightPanel;
|
||||
|
||||
GUIButton startButton;
|
||||
private GUIButton startButton;
|
||||
|
||||
int selectedRightPanel;
|
||||
private int selectedRightPanel;
|
||||
|
||||
GUIListBox characterList;
|
||||
GUIListBox hireList;
|
||||
private GUIListBox characterList;
|
||||
private GUIListBox hireList;
|
||||
|
||||
GUIListBox selectedItemList, itemList;
|
||||
private GUIListBox selectedItemList, itemList;
|
||||
|
||||
SinglePlayerMode gameMode;
|
||||
private SinglePlayerMode gameMode;
|
||||
|
||||
GUIFrame previewFrame;
|
||||
private GUIFrame previewFrame;
|
||||
|
||||
GUIButton buyButton;
|
||||
private GUIButton buyButton;
|
||||
|
||||
Level selectedLevel;
|
||||
private Level selectedLevel;
|
||||
|
||||
float mapZoom = 3.0f;
|
||||
|
||||
@@ -271,6 +271,7 @@ namespace Subsurface
|
||||
if (ep.sprite != null)
|
||||
{
|
||||
GUIImage img = new GUIImage(new Rectangle(0, 0, 40, 40), ep.sprite, Alignment.Left, frame);
|
||||
img.Color = ep.SpriteColor;
|
||||
img.Scale = Math.Min(Math.Min(40.0f / img.SourceRect.Width, 40.0f / img.SourceRect.Height), 1.0f);
|
||||
}
|
||||
}
|
||||
@@ -373,8 +374,25 @@ namespace Subsurface
|
||||
|
||||
public bool SelectRightPanel(GUIButton button, object selection)
|
||||
{
|
||||
try { selectedRightPanel = (int)selection; }
|
||||
try
|
||||
{
|
||||
selectedRightPanel = (int)selection;
|
||||
}
|
||||
catch { return false; }
|
||||
|
||||
|
||||
if (button != null)
|
||||
{
|
||||
button.Selected = true;
|
||||
foreach (GUIComponent child in leftPanel.children)
|
||||
{
|
||||
GUIButton otherButton = child as GUIButton;
|
||||
if (otherButton == null || otherButton == button) continue;
|
||||
|
||||
otherButton.Selected = false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -157,7 +157,8 @@ namespace Subsurface
|
||||
{
|
||||
base.Select();
|
||||
|
||||
selectedTab = 0;
|
||||
SelectTab(null, 0);
|
||||
//selectedTab = 0;
|
||||
}
|
||||
|
||||
public bool SelectTab(GUIButton button, object obj)
|
||||
|
||||
@@ -421,7 +421,6 @@ namespace Subsurface
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public void AddPlayer(Client client)
|
||||
{
|
||||
GUITextBlock textBlock = new GUITextBlock(
|
||||
@@ -433,6 +432,17 @@ namespace Subsurface
|
||||
textBlock.UserData = client;
|
||||
}
|
||||
|
||||
public void RemovePlayer(int clientID)
|
||||
{
|
||||
GUIComponent child = playerList.children.Find(c =>
|
||||
{
|
||||
Client client = c.UserData as Client;
|
||||
return (client.ID == clientID);
|
||||
});
|
||||
|
||||
if (child != null) playerList.RemoveChild(child);
|
||||
}
|
||||
|
||||
public void RemovePlayer(Client client)
|
||||
{
|
||||
if (client == null) return;
|
||||
|
||||
@@ -370,6 +370,9 @@
|
||||
<Content Include="Content\Items\MiniMap\fabricator.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\OxygenGenerator\oxygengenerator.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Weapons\explosives.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
@@ -613,11 +616,9 @@
|
||||
<Content Include="Content\Items\MiniMap\reactor.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\OxygenGenerator\battery.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Items\OxygenGenerator\oxygengenerator.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="Content\Items\Diving\oxygentank.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
@@ -807,6 +808,9 @@
|
||||
<None Include="Content\effects.mgfx">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Content\Items\Diving\divingSuit.ogg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Content\Items\Electricity\powerOn.ogg">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
||||