Unstable 0.17.3.0
This commit is contained in:
@@ -153,6 +153,13 @@ namespace Barotrauma
|
||||
|
||||
swarmSpawned = true;
|
||||
}
|
||||
#if DEBUG || UNSTABLE
|
||||
if (State == 1 && !level.CheckBeaconActive())
|
||||
{
|
||||
DebugConsole.ThrowError("Beacon became inactive!");
|
||||
State = 2;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public override void End()
|
||||
|
||||
@@ -248,7 +248,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (Submarine.MainSub != null && Submarine.MainSub.AtEndExit)
|
||||
{
|
||||
int deliveredItemCount = items.Count(i => i.CurrentHull != null && !i.Removed && i.Condition > 0.0f);
|
||||
int deliveredItemCount = items.Count(it => IsItemDelivered(it));
|
||||
if (deliveredItemCount / (float)items.Count >= requiredDeliveryAmount)
|
||||
{
|
||||
GiveReward();
|
||||
@@ -267,5 +267,12 @@ namespace Barotrauma
|
||||
items.Clear();
|
||||
failed = !completed;
|
||||
}
|
||||
|
||||
private bool IsItemDelivered(Item item)
|
||||
{
|
||||
if (item.Removed || item.Condition <= 0.0f || Submarine.MainSub == null) { return false; }
|
||||
var submarine = item.Submarine ?? item.GetRootContainer()?.Submarine;
|
||||
return submarine == Submarine.MainSub || Submarine.MainSub.GetConnectedSubs().Contains(submarine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,17 +419,17 @@ namespace Barotrauma
|
||||
public static int DistributeRewardsToCrew(IEnumerable<Character> crew, int totalReward)
|
||||
{
|
||||
int remainingRewards = totalReward;
|
||||
HashSet<Character> nonBotCrew = crew.Where(c => !c.IsBot).ToHashSet();
|
||||
float sum = nonBotCrew.Sum(c => c.Wallet.RewardDistribution);
|
||||
if (sum == 0) { return remainingRewards; }
|
||||
foreach (Character character in nonBotCrew)
|
||||
float sum = GetRewardDistibutionSum(crew);
|
||||
if (MathUtils.NearlyEqual(sum, 0)) { return remainingRewards; }
|
||||
foreach (Character character in crew)
|
||||
{
|
||||
float rewardWeight = character.Wallet.RewardDistribution / sum;
|
||||
int reward = (int)Math.Floor(totalReward * rewardWeight);
|
||||
reward = Math.Max(remainingRewards, reward);
|
||||
int rewardDistribution = character.Wallet.RewardDistribution;
|
||||
float rewardWeight = sum > 100 ? rewardDistribution / sum : rewardDistribution / 100f;
|
||||
int reward = (int)(totalReward * rewardWeight);
|
||||
reward = Math.Min(remainingRewards, reward);
|
||||
character.Wallet.Give(reward);
|
||||
remainingRewards -= reward;
|
||||
if (0 >= remainingRewards) { break; }
|
||||
if (remainingRewards <= 0) { break; }
|
||||
}
|
||||
|
||||
return remainingRewards;
|
||||
@@ -442,26 +442,27 @@ namespace Barotrauma
|
||||
|
||||
IEnumerable<Character> characters = crewManager.GetCharacters();
|
||||
#if SERVER
|
||||
return GameMain.Server.ConnectedClients.Select(c => c.Character).Where(IsAlive).Concat(characters);
|
||||
return GameMain.Server.ConnectedClients.Select(c => c.Character).Where(c => c?.Info != null && !c.IsDead).Concat(characters);
|
||||
#elif CLIENT
|
||||
return characters;
|
||||
#endif
|
||||
static bool IsAlive(Character c) { return c?.Info != null && !c.IsDead; }
|
||||
}
|
||||
|
||||
public static int GetRewardDistibutionSum(IEnumerable<Character> crew, int rewardDistribution = 0) => crew.Sum(c => c.Wallet.RewardDistribution) + rewardDistribution;
|
||||
|
||||
public static (int Amount, int Percentage) GetRewardShare(int rewardDistribution, IEnumerable<Character> crew, Option<int> reward)
|
||||
|
||||
public static (int Amount, int Percentage, float Sum) GetRewardShare(int rewardDistribution, IEnumerable<Character> crew, Option<int> reward)
|
||||
{
|
||||
float sum = crew.Sum(c => c.Wallet.RewardDistribution) + rewardDistribution;
|
||||
if (sum == 0) { return (0, 0); }
|
||||
float sum = GetRewardDistibutionSum(crew, rewardDistribution);
|
||||
if (MathUtils.NearlyEqual(sum, 0)) { return (0, 0, sum); }
|
||||
|
||||
float rewardWeight = rewardDistribution / sum;
|
||||
float rewardWeight = sum > 100 ? rewardDistribution / sum : rewardDistribution / 100f;
|
||||
int rewardPercentage = (int)(rewardWeight * 100);
|
||||
|
||||
return reward switch
|
||||
{
|
||||
Some<int> { Value: var amount } => ((int)(amount * rewardWeight), rewardPercentage),
|
||||
None<int> _ => (0, rewardPercentage),
|
||||
Some<int> { Value: var amount } => ((int)(amount * rewardWeight), rewardPercentage, sum),
|
||||
None<int> _ => (0, rewardPercentage, sum),
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
};
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ namespace Barotrauma
|
||||
}
|
||||
GiveReward();
|
||||
completed = true;
|
||||
if (level?.LevelData != null && Prefab.Tags.Any(t => t.Equals("huntinggrounds", StringComparison.OrdinalIgnoreCase) || t.Equals("huntinggroundsnoreward", StringComparison.OrdinalIgnoreCase)))
|
||||
if (level?.LevelData != null && Prefab.Tags.Any(t => t.Equals("huntinggrounds", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
level.LevelData.HasHuntingGrounds = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user