Separate interfaces for entities that the clients/server can send updates for (+ placeholder implementations)
May or may not be useful
This commit is contained in:
@@ -43,7 +43,7 @@ namespace Barotrauma.Items.Components
|
||||
/// <summary>
|
||||
/// The base class for components holding the different functionalities of the item
|
||||
/// </summary>
|
||||
class ItemComponent : IPropertyObject
|
||||
class ItemComponent : IPropertyObject, IClientSerializable, IServerSerializable
|
||||
{
|
||||
protected Item item;
|
||||
|
||||
@@ -74,6 +74,12 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private string msg;
|
||||
|
||||
protected ushort netStateID;
|
||||
public ushort NetStateID
|
||||
{
|
||||
get { return netStateID; }
|
||||
}
|
||||
|
||||
[HasDefaultValue(0.0f, false)]
|
||||
public float PickingTime
|
||||
{
|
||||
@@ -577,22 +583,6 @@ namespace Barotrauma.Items.Components
|
||||
return (average+100.0f)/2.0f;
|
||||
}
|
||||
|
||||
//public bool CheckFailure(Character Character)
|
||||
//{
|
||||
// foreach (Skill skill in requiredSkills)
|
||||
// {
|
||||
// int characterLevel = Character.GetSkillLevel(skill.Name);
|
||||
// if (characterLevel > skill.Level) continue;
|
||||
|
||||
// item.ApplyStatusEffects(ActionType.OnFailure, 1.0f, Character);
|
||||
// //Item.ApplyStatusEffects();
|
||||
// return true;
|
||||
|
||||
// }
|
||||
|
||||
// return false;
|
||||
//}
|
||||
|
||||
public bool HasRequiredContainedItems(bool addMessage)
|
||||
{
|
||||
List<RelatedItem> requiredContained = requiredItems.FindAll(ri=> ri.Type == RelatedItem.RelationType.Contained);
|
||||
@@ -668,6 +658,12 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ClientWrite(NetOutgoingMessage msg) { }
|
||||
public virtual void ServerRead(NetIncomingMessage msg) { }
|
||||
|
||||
public virtual void ServerWrite(NetOutgoingMessage msg) { }
|
||||
public virtual void ClientRead(NetIncomingMessage msg) { }
|
||||
|
||||
public virtual XElement Save(XElement parentElement)
|
||||
{
|
||||
XElement componentElement = new XElement(name);
|
||||
@@ -681,26 +677,6 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
ObjectProperty.SaveProperties(this, componentElement);
|
||||
|
||||
//var saveProperties = ObjectProperty.GetProperties<Saveable>(this);
|
||||
//foreach (var property in saveProperties)
|
||||
//{
|
||||
// object value = property.GetValue();
|
||||
// if (value == null) continue;
|
||||
|
||||
// bool dontSave = false;
|
||||
// foreach (var ini in property.Attributes.OfType<Initable>())
|
||||
// {
|
||||
// if (ini.defaultValue != value) continue;
|
||||
|
||||
// dontSave = true;
|
||||
// break;
|
||||
// }
|
||||
|
||||
// if (dontSave) continue;
|
||||
|
||||
// componentElement.Add(new XAttribute(property.Name.ToLower(), value));
|
||||
//}
|
||||
|
||||
parentElement.Add(componentElement);
|
||||
return componentElement;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Barotrauma
|
||||
OnImpact
|
||||
}
|
||||
|
||||
class Item : MapEntity, IDamageable, IPropertyObject
|
||||
class Item : MapEntity, IDamageable, IPropertyObject, IServerSerializable
|
||||
{
|
||||
public static List<Item> ItemList = new List<Item>();
|
||||
private ItemPrefab prefab;
|
||||
@@ -55,6 +55,12 @@ namespace Barotrauma
|
||||
//a dictionary containing lists of the status effects in all the components of the item
|
||||
private Dictionary<ActionType, List<StatusEffect>> statusEffectLists;
|
||||
|
||||
private ushort netStateID;
|
||||
public ushort NetStateID
|
||||
{
|
||||
get { return netStateID; }
|
||||
}
|
||||
|
||||
public readonly Dictionary<string, ObjectProperty> properties;
|
||||
public Dictionary<string, ObjectProperty> ObjectProperties
|
||||
{
|
||||
@@ -1383,12 +1389,6 @@ namespace Barotrauma
|
||||
|
||||
public void Drop(Character dropper = null)
|
||||
{
|
||||
//if (dropper == Character.Controlled)
|
||||
// new NetworkEvent(NetworkEventType.DropItem, ID, true);
|
||||
|
||||
|
||||
//if (dropper != null) GameServer.Log(dropper.Name + " dropped " + Name, Color.Orange);
|
||||
|
||||
foreach (ItemComponent ic in components) ic.Drop(dropper);
|
||||
|
||||
if (Container != null) Container.RemoveContained(this);
|
||||
@@ -1514,6 +1514,9 @@ namespace Barotrauma
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
public void ServerWrite(NetOutgoingMessage msg) { }
|
||||
public void ClientRead(NetIncomingMessage msg) { }
|
||||
|
||||
public static void Load(XElement element, Submarine submarine)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user