Unstable v0.19.3.0
This commit is contained in:
+12
-14
@@ -10,8 +10,6 @@ namespace Barotrauma
|
||||
{
|
||||
partial class MultiPlayerCampaign : CampaignMode
|
||||
{
|
||||
public const int MinimumInitialMoney = 500;
|
||||
|
||||
[Flags]
|
||||
public enum NetFlags : UInt16
|
||||
{
|
||||
@@ -294,14 +292,14 @@ namespace Barotrauma
|
||||
|
||||
private static void WriteItems(IWriteMessage msg, Dictionary<Identifier, List<PurchasedItem>> purchasedItems)
|
||||
{
|
||||
msg.Write((byte)purchasedItems.Count);
|
||||
msg.WriteByte((byte)purchasedItems.Count);
|
||||
foreach (var storeItems in purchasedItems)
|
||||
{
|
||||
msg.Write(storeItems.Key);
|
||||
msg.Write((UInt16)storeItems.Value.Count);
|
||||
msg.WriteIdentifier(storeItems.Key);
|
||||
msg.WriteUInt16((UInt16)storeItems.Value.Count);
|
||||
foreach (var item in storeItems.Value)
|
||||
{
|
||||
msg.Write(item.ItemPrefabIdentifier);
|
||||
msg.WriteIdentifier(item.ItemPrefabIdentifier);
|
||||
msg.WriteRangedInteger(item.Quantity, 0, CargoManager.MaxQuantity);
|
||||
}
|
||||
}
|
||||
@@ -328,18 +326,18 @@ namespace Barotrauma
|
||||
|
||||
private static void WriteItems(IWriteMessage msg, Dictionary<Identifier, List<SoldItem>> soldItems)
|
||||
{
|
||||
msg.Write((byte)soldItems.Count);
|
||||
msg.WriteByte((byte)soldItems.Count);
|
||||
foreach (var storeItems in soldItems)
|
||||
{
|
||||
msg.Write(storeItems.Key);
|
||||
msg.Write((UInt16)storeItems.Value.Count);
|
||||
msg.WriteIdentifier(storeItems.Key);
|
||||
msg.WriteUInt16((UInt16)storeItems.Value.Count);
|
||||
foreach (var item in storeItems.Value)
|
||||
{
|
||||
msg.Write(item.ItemPrefab.Identifier);
|
||||
msg.Write((UInt16)item.ID);
|
||||
msg.Write(item.Removed);
|
||||
msg.Write(item.SellerID);
|
||||
msg.Write((byte)item.Origin);
|
||||
msg.WriteIdentifier(item.ItemPrefab.Identifier);
|
||||
msg.WriteUInt16((UInt16)item.ID);
|
||||
msg.WriteBoolean(item.Removed);
|
||||
msg.WriteByte(item.SellerID);
|
||||
msg.WriteByte((byte)item.Origin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.Networking;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -11,37 +13,37 @@ namespace Barotrauma
|
||||
|
||||
public void AssignTeamIDs(IEnumerable<Client> clients)
|
||||
{
|
||||
int teamWeight = 0;
|
||||
List<Client> randList = new List<Client>(clients);
|
||||
for (int i = 0; i < randList.Count; i++)
|
||||
int team1Count = 0, team2Count = 0;
|
||||
//if a client has a preference, assign them to that team
|
||||
List<Client> unassignedClients = new List<Client>(clients);
|
||||
for (int i = 0; i < unassignedClients.Count; i++)
|
||||
{
|
||||
if (randList[i].PreferredTeam == CharacterTeamType.Team1 ||
|
||||
randList[i].PreferredTeam == CharacterTeamType.Team2)
|
||||
if (unassignedClients[i].PreferredTeam == CharacterTeamType.Team1 ||
|
||||
unassignedClients[i].PreferredTeam == CharacterTeamType.Team2)
|
||||
{
|
||||
randList[i].TeamID = randList[i].PreferredTeam;
|
||||
teamWeight += randList[i].PreferredTeam == CharacterTeamType.Team1 ? -1 : 1;
|
||||
randList.RemoveAt(i);
|
||||
assignTeam(unassignedClients[i], unassignedClients[i].PreferredTeam);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i<randList.Count; i++)
|
||||
{
|
||||
Client a = randList[i];
|
||||
int oi = Rand.Range(0, randList.Count - 1);
|
||||
Client b = randList[oi];
|
||||
randList[i] = b;
|
||||
randList[oi] = a;
|
||||
}
|
||||
int halfPlayers = (randList.Count / 2) + teamWeight;
|
||||
for (int i = 0; i < randList.Count; i++)
|
||||
|
||||
//assign the rest of the clients to the team that has the least players
|
||||
while (unassignedClients.Any())
|
||||
{
|
||||
if (i < halfPlayers)
|
||||
var randomClient = unassignedClients.GetRandom(Rand.RandSync.Unsynced);
|
||||
assignTeam(randomClient, team1Count < team2Count ? CharacterTeamType.Team1 : CharacterTeamType.Team2);
|
||||
}
|
||||
|
||||
void assignTeam(Client client, CharacterTeamType team)
|
||||
{
|
||||
client.TeamID = team;
|
||||
unassignedClients.Remove(client);
|
||||
if (team == CharacterTeamType.Team1)
|
||||
{
|
||||
randList[i].TeamID = CharacterTeamType.Team1;
|
||||
team1Count++;
|
||||
}
|
||||
else
|
||||
{
|
||||
randList[i].TeamID = CharacterTeamType.Team2;
|
||||
team2Count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class TutorialPrefab : Prefab
|
||||
{
|
||||
public static readonly PrefabCollection<TutorialPrefab> Prefabs = new PrefabCollection<TutorialPrefab>();
|
||||
|
||||
public readonly int Order;
|
||||
public readonly bool DisableBotConversations;
|
||||
public readonly bool AllowCharacterSwitch;
|
||||
|
||||
public readonly ContentPath SubmarinePath = ContentPath.FromRaw("Content/Tutorials/Dugong_Tutorial.sub");
|
||||
public readonly ContentPath OutpostPath = ContentPath.FromRaw("Content/Tutorials/TutorialOutpost.sub");
|
||||
public readonly string LevelSeed;
|
||||
public readonly string LevelParams;
|
||||
|
||||
private readonly ContentXElement tutorialCharacterElement;
|
||||
public readonly ImmutableArray<Identifier> StartingItemTags;
|
||||
|
||||
public readonly Identifier EventIdentifier;
|
||||
|
||||
public TutorialPrefab(ContentFile file, ContentXElement element) : base(file, element.GetAttributeIdentifier("identifier", ""))
|
||||
{
|
||||
Order = element.GetAttributeInt("order", int.MaxValue);
|
||||
DisableBotConversations = element.GetAttributeBool("disablebotconversations", true);
|
||||
AllowCharacterSwitch = element.GetAttributeBool("allowcharacterswitch", false);
|
||||
|
||||
SubmarinePath = element.GetAttributeContentPath("submarinepath") ?? SubmarinePath;
|
||||
OutpostPath = element.GetAttributeContentPath("outpostpath") ?? OutpostPath;
|
||||
LevelSeed = element.GetAttributeString("levelseed", "nLoZLLtza");
|
||||
LevelParams = element.GetAttributeString("levelparams", "ColdCavernsTutorial");
|
||||
|
||||
tutorialCharacterElement = element.GetChildElement("characterinfo");
|
||||
if (tutorialCharacterElement != null)
|
||||
{
|
||||
StartingItemTags = tutorialCharacterElement
|
||||
.GetAttributeIdentifierArray("startingitemtags", new Identifier[0])
|
||||
.ToImmutableArray();
|
||||
}
|
||||
else
|
||||
{
|
||||
StartingItemTags = ImmutableArray<Identifier>.Empty;
|
||||
}
|
||||
|
||||
EventIdentifier = element.GetChildElement("scriptedevent")?.GetAttributeIdentifier("identifier", "") ?? Identifier.Empty;
|
||||
}
|
||||
|
||||
public CharacterInfo GetTutorialCharacterInfo()
|
||||
{
|
||||
if (tutorialCharacterElement == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Identifier speciesName = tutorialCharacterElement.GetAttributeIdentifier("speciesname", CharacterPrefab.HumanSpeciesName);
|
||||
string jobPrefabIdentifier = tutorialCharacterElement.GetAttributeString("jobidentifier", "assistant");
|
||||
var jobPrefab = JobPrefab.Prefabs.FirstOrDefault(p => p.Identifier == jobPrefabIdentifier) ?? JobPrefab.Prefabs.First();
|
||||
int jobVariant = tutorialCharacterElement.GetAttributeInt("variant", 0);
|
||||
var characterInfo = new CharacterInfo(speciesName, jobOrJobPrefab: jobPrefab, variant: jobVariant);
|
||||
foreach (var skillElement in tutorialCharacterElement.GetChildElements("skill"))
|
||||
{
|
||||
Identifier skillIdentifier = skillElement.GetAttributeIdentifier("identifier", "");
|
||||
if (skillIdentifier.IsEmpty) { continue; }
|
||||
float level = skillElement.GetAttributeFloat("level", 0.0f);
|
||||
characterInfo.SetSkillLevel(skillIdentifier, level);
|
||||
}
|
||||
return characterInfo;
|
||||
}
|
||||
|
||||
public override void Dispose() { }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user