Fixed ChangeProperty network events
This commit is contained in:
@@ -4,6 +4,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using Barotrauma.Items.Components;
|
||||||
|
|
||||||
namespace Barotrauma
|
namespace Barotrauma
|
||||||
{
|
{
|
||||||
@@ -461,6 +462,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private void TrySendNetworkUpdate(ISerializableEntity entity, SerializableProperty property)
|
private void TrySendNetworkUpdate(ISerializableEntity entity, SerializableProperty property)
|
||||||
{
|
{
|
||||||
|
if (entity is ItemComponent)
|
||||||
|
{
|
||||||
|
entity = ((ItemComponent)entity).Item;
|
||||||
|
}
|
||||||
|
|
||||||
if (GameMain.Server != null)
|
if (GameMain.Server != null)
|
||||||
{
|
{
|
||||||
IServerSerializable serverSerializable = entity as IServerSerializable;
|
IServerSerializable serverSerializable = entity as IServerSerializable;
|
||||||
|
|||||||
@@ -1409,6 +1409,39 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
msg.Write((bool)value);
|
msg.Write((bool)value);
|
||||||
}
|
}
|
||||||
|
else if (value is Color)
|
||||||
|
{
|
||||||
|
Color color = (Color)value;
|
||||||
|
msg.Write(color.R);
|
||||||
|
msg.Write(color.G);
|
||||||
|
msg.Write(color.B);
|
||||||
|
msg.Write(color.A);
|
||||||
|
}
|
||||||
|
else if (value is Vector2)
|
||||||
|
{
|
||||||
|
msg.Write(((Vector2)value).X);
|
||||||
|
msg.Write(((Vector2)value).Y);
|
||||||
|
}
|
||||||
|
else if (value is Vector3)
|
||||||
|
{
|
||||||
|
msg.Write(((Vector3)value).X);
|
||||||
|
msg.Write(((Vector3)value).Y);
|
||||||
|
msg.Write(((Vector3)value).Z);
|
||||||
|
}
|
||||||
|
else if (value is Vector4)
|
||||||
|
{
|
||||||
|
msg.Write(((Vector4)value).X);
|
||||||
|
msg.Write(((Vector4)value).Y);
|
||||||
|
msg.Write(((Vector4)value).Z);
|
||||||
|
msg.Write(((Vector4)value).W);
|
||||||
|
}
|
||||||
|
else if (value is Rectangle)
|
||||||
|
{
|
||||||
|
msg.Write(((Rectangle)value).X);
|
||||||
|
msg.Write(((Rectangle)value).Y);
|
||||||
|
msg.Write(((Rectangle)value).Width);
|
||||||
|
msg.Write(((Rectangle)value).Height);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException("Serializing item properties of the type \"" + value.GetType() + "\" not supported");
|
throw new System.NotImplementedException("Serializing item properties of the type \"" + value.GetType() + "\" not supported");
|
||||||
@@ -1446,6 +1479,26 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
property.TrySetValue(msg.ReadBoolean());
|
property.TrySetValue(msg.ReadBoolean());
|
||||||
}
|
}
|
||||||
|
else if (type == typeof(Color))
|
||||||
|
{
|
||||||
|
property.TrySetValue(new Color(msg.ReadByte(), msg.ReadByte(),msg.ReadByte(),msg.ReadByte()));
|
||||||
|
}
|
||||||
|
else if (type == typeof(Vector2))
|
||||||
|
{
|
||||||
|
property.TrySetValue(new Vector2(msg.ReadFloat(), msg.ReadFloat()));
|
||||||
|
}
|
||||||
|
else if (type == typeof(Vector3))
|
||||||
|
{
|
||||||
|
property.TrySetValue(new Vector3(msg.ReadFloat(), msg.ReadFloat(), msg.ReadFloat()));
|
||||||
|
}
|
||||||
|
else if (type == typeof(Vector4))
|
||||||
|
{
|
||||||
|
property.TrySetValue(new Vector4(msg.ReadFloat(), msg.ReadFloat(), msg.ReadFloat(), msg.ReadFloat()));
|
||||||
|
}
|
||||||
|
else if (type == typeof(Rectangle))
|
||||||
|
{
|
||||||
|
property.TrySetValue(new Vector4(msg.ReadInt32(), msg.ReadInt32(), msg.ReadInt32(), msg.ReadInt32()));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user