Unstable 0.1500.5.0 (almost forgor edition 💀)
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using Barotrauma.Networking;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class AlienRuinMission : Mission
|
||||
{
|
||||
public override void ClientReadInitial(IReadMessage msg)
|
||||
{
|
||||
existingTargets.Clear();
|
||||
spawnedTargets.Clear();
|
||||
allTargets.Clear();
|
||||
ushort existingTargetsCount = msg.ReadUInt16();
|
||||
for (int i = 0; i < existingTargetsCount; i++)
|
||||
{
|
||||
ushort targetId = msg.ReadUInt16();
|
||||
if (targetId == Entity.NullEntityID) { continue; }
|
||||
Entity target = Entity.FindEntityByID(targetId);
|
||||
if (target == null) { continue; }
|
||||
existingTargets.Add(target);
|
||||
allTargets.Add(target);
|
||||
}
|
||||
ushort spawnedTargetsCount = msg.ReadUInt16();
|
||||
for (int i = 0; i < spawnedTargetsCount; i++)
|
||||
{
|
||||
var enemy = Character.ReadSpawnData(msg);
|
||||
existingTargets.Add(enemy);
|
||||
allTargets.Add(enemy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -14,6 +15,10 @@ namespace Barotrauma
|
||||
get { return shownMessages; }
|
||||
}
|
||||
|
||||
public bool DisplayTargetHudIcons => Prefab.DisplayTargetHudIcons;
|
||||
|
||||
public virtual IEnumerable<Entity> HudIconTargets => Enumerable.Empty<Entity>();
|
||||
|
||||
public Color GetDifficultyColor()
|
||||
{
|
||||
int v = Difficulty ?? MissionPrefab.MinDifficulty;
|
||||
@@ -92,7 +97,7 @@ namespace Barotrauma
|
||||
};
|
||||
}
|
||||
|
||||
public void ClientRead(IReadMessage msg)
|
||||
public virtual void ClientRead(IReadMessage msg)
|
||||
{
|
||||
State = msg.ReadInt16();
|
||||
}
|
||||
|
||||
@@ -18,13 +18,54 @@ namespace Barotrauma
|
||||
private set;
|
||||
}
|
||||
|
||||
public bool DisplayTargetHudIcons
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public float HudIconMaxDistance
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public Sprite HudIcon
|
||||
{
|
||||
get
|
||||
{
|
||||
return hudIcon ?? Icon;
|
||||
}
|
||||
}
|
||||
|
||||
public Color HudIconColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return hudIconColor ?? IconColor;
|
||||
}
|
||||
}
|
||||
|
||||
private Sprite hudIcon;
|
||||
private Color? hudIconColor;
|
||||
|
||||
partial void InitProjSpecific(XElement element)
|
||||
{
|
||||
DisplayTargetHudIcons = element.GetAttributeBool("displaytargethudicons", false);
|
||||
HudIconMaxDistance = element.GetAttributeFloat("hudiconmaxdistance", 1000.0f);
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
if (!subElement.Name.ToString().Equals("icon", StringComparison.OrdinalIgnoreCase)) { continue; }
|
||||
Icon = new Sprite(subElement);
|
||||
IconColor = subElement.GetAttributeColor("color", Color.White);
|
||||
string name = subElement.Name.ToString();
|
||||
if (name.Equals("icon", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Icon = new Sprite(subElement);
|
||||
IconColor = subElement.GetAttributeColor("color", Color.White);
|
||||
}
|
||||
else if (name.Equals("hudicon", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
hudIcon = new Sprite(subElement);
|
||||
hudIconColor = subElement.GetAttributeColor("color");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
using Barotrauma.Networking;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class ScanMission : Mission
|
||||
{
|
||||
public override IEnumerable<Entity> HudIconTargets
|
||||
{
|
||||
get
|
||||
{
|
||||
if (State == 0)
|
||||
{
|
||||
return scanTargets.Where(kvp => !kvp.Value).Select(kvp => kvp.Key);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Enumerable.Empty<Entity>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void ClientReadInitial(IReadMessage msg)
|
||||
{
|
||||
startingItems.Clear();
|
||||
ushort itemCount = msg.ReadUInt16();
|
||||
for (int i = 0; i < itemCount; i++)
|
||||
{
|
||||
startingItems.Add(Item.ReadSpawnData(msg));
|
||||
}
|
||||
if (startingItems.Contains(null))
|
||||
{
|
||||
throw new Exception($"Error in ScanMission.ClientReadInitial: item list contains null (mission: {Prefab.Identifier})");
|
||||
}
|
||||
if (startingItems.Count != itemCount)
|
||||
{
|
||||
throw new Exception($"Error in ScanMission.ClientReadInitial: item count does not match the server count ({itemCount} != {startingItems.Count}, mission: {Prefab.Identifier})");
|
||||
}
|
||||
scanners.Clear();
|
||||
GetScanners();
|
||||
ClientReadScanTargetStatus(msg);
|
||||
}
|
||||
|
||||
public override void ClientRead(IReadMessage msg)
|
||||
{
|
||||
base.ClientRead(msg);
|
||||
ClientReadScanTargetStatus(msg);
|
||||
}
|
||||
|
||||
private void ClientReadScanTargetStatus(IReadMessage msg)
|
||||
{
|
||||
scanTargets.Clear();
|
||||
byte targetsToScan = msg.ReadByte();
|
||||
for (int i = 0; i < targetsToScan; i++)
|
||||
{
|
||||
ushort id = msg.ReadUInt16();
|
||||
bool scanned = msg.ReadBoolean();
|
||||
Entity entity = Entity.FindEntityByID(id);
|
||||
scanTargets.Add(entity as WayPoint, scanned);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user