Unstable 0.17.1.0

This commit is contained in:
Markus Isberg
2022-03-17 01:25:04 +09:00
parent 3974067915
commit 6d410cc1b7
302 changed files with 5878 additions and 3317 deletions
@@ -4,47 +4,16 @@ namespace Barotrauma.Networking
{
abstract class NetEntityEvent
{
public enum Type
{
Invalid,
ComponentState,
InventoryState,
Status,
Treatment,
ApplyStatusEffect,
ChangeProperty,
Control,
UpdateSkills,
Combine,
SetAttackTarget,
ExecuteAttack,
Upgrade,
AssignCampaignInteraction,
TeamChange,
ObjectiveManagerState,
AddToCrew,
UpdateExperience,
UpdateTalents,
UpdateMoney,
UpdatePermanentStats,
}
public interface IData { }
public readonly Entity Entity;
public readonly UInt16 ID;
public UInt16 EntityID
{
get;
private set;
}
public UInt16 EntityID => Entity.ID;
//arbitrary extra data that will be passed to the Write method of the serializable entity
//(the index of an itemcomponent for example)
public object[] Data
{
get;
private set;
}
public IData Data { get; private set; }
public bool Sent;
@@ -52,43 +21,18 @@ namespace Barotrauma.Networking
{
this.ID = id;
this.Entity = serializableEntity as Entity;
RefreshEntityID();
}
public void RefreshEntityID()
{
this.EntityID = this.Entity is Entity entity ? entity.ID : Entity.NullEntityID;
}
public void SetData(object[] data)
public void SetData(IData data)
{
this.Data = data;
}
public bool IsDuplicate(NetEntityEvent other)
{
if (other.Entity != this.Entity) return false;
if (other.Entity != this.Entity) { return false; }
if (Data != null && other.Data != null)
{
if (Data.Length != other.Data.Length) return false;
for (int i = 0; i < Data.Length; i++)
{
if (Data[i] == null)
{
if (other.Data[i] != null) return false;
}
else
{
if (other.Data[i] == null) return false;
if (!Data[i].Equals(other.Data[i])) return false;
}
}
return true;
}
return Data == other.Data;
return Equals(Data, other.Data);
}
}
}