Build 0.17.13.0

This commit is contained in:
Markus Isberg
2022-04-22 21:48:04 +09:00
parent 6cc100d98c
commit 7a09cf3260
58 changed files with 506 additions and 184 deletions
@@ -63,8 +63,9 @@ namespace Barotrauma
{
msg.Write(Job.Prefab.Identifier);
msg.Write((byte)Job.Variant);
msg.Write((byte)Job.Skills.Count);
foreach (Skill skill in Job.Skills)
var skills = Job.GetSkills();
msg.Write((byte)skills.Count());
foreach (Skill skill in skills)
{
msg.Write(skill.Identifier);
msg.Write(skill.Level);
@@ -434,8 +434,9 @@ namespace Barotrauma
}
else
{
msg.Write((byte)Info.Job.Skills.Count);
foreach (Skill skill in Info.Job.Skills)
var skills = Info.Job.GetSkills();
msg.Write((byte)skills.Count());
foreach (Skill skill in skills)
{
msg.Write(skill.Identifier);
msg.Write(skill.Level);
@@ -2391,7 +2391,7 @@ namespace Barotrauma
if (isMax) { level = 100; }
if (skillIdentifier == "all")
{
foreach (Skill skill in character.Info.Job.Skills)
foreach (Skill skill in character.Info.Job.GetSkills())
{
character.Info.SetSkillLevel(skill.Identifier, level);
}
@@ -35,7 +35,7 @@ namespace Barotrauma
int itemValue = sellValues[item.ItemPrefab];
if (store.Balance < itemValue || item.Removed) { continue; }
store.Balance += itemValue;
campaign.GetWallet(client).TryDeduct(itemValue);
campaign.TryPurchase(client, itemValue);
storeSpecificItems.Remove(item);
}
}
@@ -178,6 +178,14 @@ namespace Barotrauma
GameMain.Server.ConnectedClients.None(c => c.InGame && (IsOwner(c) || c.HasPermission(permissions)));
}
public bool AllowedToManageWallets(Client client)
{
return
client.HasPermission(ClientPermissions.ManageCampaign) ||
client.HasPermission(ClientPermissions.ManageMoney) ||
IsOwner(client);
}
public void SaveExperiencePoints(Client client)
{
ClearSavedExperiencePoints(client);
@@ -430,7 +438,7 @@ namespace Barotrauma
}
public bool CanPurchaseSub(SubmarineInfo info, Client client)
=> GetWallet(client).CanAfford(info.Price) && GetCampaignSubs().Contains(info);
=> CanAfford(info.Price, client) && GetCampaignSubs().Contains(info);
private readonly List<CharacterCampaignData> discardedCharacters = new List<CharacterCampaignData>();
public void DiscardClientCharacterData(Client client)
@@ -755,8 +763,8 @@ namespace Barotrauma
{
switch (purchasedHullRepairs)
{
case true when personalWallet.CanAfford(hullRepairCost):
personalWallet.Deduct(hullRepairCost);
case true when GetBalance(sender) >= hullRepairCost:
TryPurchase(sender, hullRepairCost);
PurchasedHullRepairs = true;
GameAnalyticsManager.AddMoneySpentEvent(hullRepairCost, GameAnalyticsManager.MoneySink.Service, "hullrepairs");
break;
@@ -771,8 +779,8 @@ namespace Barotrauma
{
switch (purchasedItemRepairs)
{
case true when personalWallet.CanAfford(itemRepairCost):
personalWallet.Deduct(itemRepairCost);
case true when GetBalance(sender) >= itemRepairCost:
TryPurchase(sender, itemRepairCost);
PurchasedItemRepairs = true;
GameAnalyticsManager.AddMoneySpentEvent(itemRepairCost, GameAnalyticsManager.MoneySink.Service, "devicerepairs");
break;
@@ -789,7 +797,7 @@ namespace Barotrauma
{
GameMain.Server.SendDirectChatMessage(TextManager.FormatServerMessage("ReplaceShuttleDockingPortOccupied"), sender, ChatMessageType.MessageBox);
}
else if (purchasedLostShuttles && personalWallet.TryDeduct(shuttleRetrieveCost))
else if (purchasedLostShuttles && TryPurchase(sender, shuttleRetrieveCost))
{
PurchasedLostShuttles = true;
GameAnalyticsManager.AddMoneySpentEvent(shuttleRetrieveCost, GameAnalyticsManager.MoneySink.Service, "retrieveshuttle");
@@ -972,7 +980,7 @@ namespace Barotrauma
switch (transfer.Sender)
{
case Some<ushort> { Value: var id }:
if (id != sender.CharacterID && !AllowedToManageCampaign(sender, ClientPermissions.ManageMoney)) { return; }
if (id != sender.CharacterID && !AllowedToManageWallets(sender)) { return; }
Wallet wallet = GetWalletByID(id);
if (wallet is InvalidWallet) { return; }
@@ -980,7 +988,7 @@ namespace Barotrauma
TransferMoney(wallet);
break;
case None<ushort> _:
if (!AllowedToManageCampaign(sender, ClientPermissions.ManageMoney))
if (!AllowedToManageWallets(sender))
{
if (transfer.Receiver is Some<ushort> { Value: var receiverId } && receiverId == sender.CharacterID)
{
@@ -1025,7 +1033,7 @@ namespace Barotrauma
{
NetWalletSetSalaryUpdate update = INetSerializableStruct.Read<NetWalletSetSalaryUpdate>(msg);
if (!AllowedToManageCampaign(sender, ClientPermissions.ManageMoney)) { return; }
if (!AllowedToManageWallets(sender)) { return; }
Character targetCharacter = Character.CharacterList.FirstOrDefault(c => c.ID == update.Target);
targetCharacter?.Wallet.SetRewardDistribution(update.NewRewardDistribution);
@@ -1231,6 +1239,45 @@ namespace Barotrauma
}
}
public override bool TryPurchase(Client client, int price)
{
Wallet wallet = GetWallet(client);
if (!AllowedToManageWallets(client))
{
return wallet.TryDeduct(price);
}
int balance = wallet.Balance;
if (balance >= price)
{
return wallet.TryDeduct(price);
}
if (balance + Bank.Balance >= price)
{
int remainder = price - balance;
if (balance > 0) { wallet.Deduct(balance); }
Bank.Deduct(remainder);
return true ;
}
return false;
}
public override int GetBalance(Client client = null)
{
if (client is null) { return 0; }
Wallet wallet = GetWallet(client);
if (!AllowedToManageWallets(client))
{
return wallet.Balance;
}
return wallet.Balance + Bank.Balance;
}
public override void Save(XElement element)
{
element.Add(new XAttribute("campaignid", CampaignID));
@@ -188,11 +188,10 @@ namespace Barotrauma.Items.Components
//already connected, no need to do anything
if (Connections[i].Wires.Contains(newWire)) { continue; }
Connections[i].TryAddLink(newWire);
newWire.Connect(Connections[i], true, true);
Connections[i].TryAddLink(newWire);
var otherConnection = newWire.OtherConnection(Connections[i]);
if (otherConnection == null)
{
GameServer.Log(GameServer.CharacterLogName(c.Character) + " connected a wire to " +
@@ -79,6 +79,7 @@ namespace Barotrauma
Vector2? worldPosition = applyStatusEffectEventData.WorldPosition;
Character targetCharacter = applyStatusEffectEventData.TargetCharacter;
if (targetCharacter != null && targetCharacter.Removed) { targetCharacter = null; }
byte targetLimbIndex = targetLimb != null && targetCharacter != null ? (byte)Array.IndexOf(targetCharacter.AnimController.Limbs, targetLimb) : (byte)255;
msg.WriteRangedInteger((int)actionType, 0, Enum.GetValues(typeof(ActionType)).Length - 1);
@@ -520,7 +520,7 @@ namespace Barotrauma.Networking
public static void ReduceCharacterSkills(CharacterInfo characterInfo)
{
if (characterInfo?.Job == null) { return; }
foreach (Skill skill in characterInfo.Job.Skills)
foreach (Skill skill in characterInfo.Job.GetSkills())
{
var skillPrefab = characterInfo.Job.Prefab.Skills.Find(s => skill.Identifier == s.Identifier);
if (skillPrefab == null) { continue; }