Faction Test v1.0.1.0
This commit is contained in:
+7
-1
@@ -8,7 +8,8 @@ partial class CheckObjectiveAction : BinaryOptionAction
|
||||
public enum CheckType
|
||||
{
|
||||
Added,
|
||||
Completed
|
||||
Completed,
|
||||
Incomplete
|
||||
}
|
||||
|
||||
[Serialize(CheckType.Completed, IsPropertySaveable.Yes)]
|
||||
@@ -30,8 +31,13 @@ partial class CheckObjectiveAction : BinaryOptionAction
|
||||
{
|
||||
CheckType.Added => true,
|
||||
CheckType.Completed => segment.IsCompleted,
|
||||
CheckType.Incomplete => !segment.IsCompleted,
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
else if (Type == CheckType.Incomplete)
|
||||
{
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma;
|
||||
@@ -13,11 +14,22 @@ partial class UIHighlightAction : EventAction
|
||||
bool useCircularFlash = false;
|
||||
if (Id != ElementId.None)
|
||||
{
|
||||
FindAndFlashComponents(c => Equals(Id, c.UserData));
|
||||
var predicate = (GUIComponent c) => c is not null && Equals(Id, c.UserData);
|
||||
if (!FindAndFlashAddedComponents(predicate))
|
||||
{
|
||||
if (predicate(GUIMessageBox.VisibleBox))
|
||||
{
|
||||
Flash(GUIMessageBox.VisibleBox);
|
||||
}
|
||||
else
|
||||
{
|
||||
FindAndFlashMessageBoxComponents(predicate);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!EntityIdentifier.IsEmpty)
|
||||
{
|
||||
FindAndFlashComponents(c =>
|
||||
FindAndFlashAddedComponents(c =>
|
||||
c.UserData is MapEntityPrefab mep && mep.Identifier == EntityIdentifier || c.UserData is MapEntity me && me.Prefab.Identifier == EntityIdentifier);
|
||||
}
|
||||
else if (!OrderIdentifier.IsEmpty)
|
||||
@@ -26,26 +38,26 @@ partial class UIHighlightAction : EventAction
|
||||
bool foundMinimapNode = false;
|
||||
if (!OrderTargetTag.IsEmpty)
|
||||
{
|
||||
foundMinimapNode = FindAndFlashComponents(c =>
|
||||
foundMinimapNode = FindAndFlashAddedComponents(c =>
|
||||
c.UserData is CrewManager.MinimapNodeData nodeData && nodeData.Order is Order order &&
|
||||
order.Identifier == OrderIdentifier && order.Option == OrderOption && order.TargetEntity is Item item && item.HasTag(OrderTargetTag));
|
||||
}
|
||||
if (!foundMinimapNode)
|
||||
{
|
||||
FindAndFlashComponents(c => c.UserData is Order order && order.Identifier == OrderIdentifier && order.Option == OrderOption,
|
||||
FindAndFlashAddedComponents(c => c.UserData is Order order && order.Identifier == OrderIdentifier && order.Option == OrderOption,
|
||||
c => c.UserData is Order order && order.Identifier == OrderIdentifier,
|
||||
c => Equals(OrderCategory, c.UserData));
|
||||
}
|
||||
}
|
||||
|
||||
bool FindAndFlashComponents(params Func<GUIComponent, bool>[] predicates)
|
||||
bool FindAndFlashComponents(IEnumerable<GUIComponent> components, params Func<GUIComponent, bool>[] predicates)
|
||||
{
|
||||
foreach (var predicate in predicates)
|
||||
{
|
||||
if (HighlightMultiple)
|
||||
{
|
||||
bool found = false;
|
||||
foreach (var component in GUI.GetAdditions())
|
||||
foreach (var component in components)
|
||||
{
|
||||
if (predicate(component))
|
||||
{
|
||||
@@ -55,7 +67,7 @@ partial class UIHighlightAction : EventAction
|
||||
};
|
||||
return found;
|
||||
}
|
||||
else if (GUI.GetAdditions().FirstOrDefault(predicate) is GUIComponent component)
|
||||
else if (components.FirstOrDefault(predicate) is GUIComponent component)
|
||||
{
|
||||
Flash(component);
|
||||
return true;
|
||||
@@ -64,6 +76,10 @@ partial class UIHighlightAction : EventAction
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FindAndFlashAddedComponents(params Func<GUIComponent, bool>[] predicates) => FindAndFlashComponents(GUI.GetAdditions(), predicates);
|
||||
|
||||
bool FindAndFlashMessageBoxComponents(params Func<GUIComponent, bool>[] predicates) => FindAndFlashComponents(GUIMessageBox.VisibleBox?.GetAllChildren() ?? Enumerable.Empty<GUIComponent>(), predicates);
|
||||
|
||||
void Flash(GUIComponent component)
|
||||
{
|
||||
if (component.FlashTimer <= 0.0f)
|
||||
|
||||
@@ -661,18 +661,36 @@ namespace Barotrauma
|
||||
case NetworkEventType.MISSION:
|
||||
Identifier missionIdentifier = msg.ReadIdentifier();
|
||||
int locationIndex = msg.ReadInt32();
|
||||
int destinationIndex = msg.ReadInt32();
|
||||
|
||||
string missionName = msg.ReadString();
|
||||
MissionPrefab? prefab = MissionPrefab.Prefabs.Find(mp => mp.Identifier == missionIdentifier);
|
||||
if (prefab != null)
|
||||
{
|
||||
new GUIMessageBox(string.Empty, TextManager.GetWithVariable("missionunlocked", "[missionname]", missionName),
|
||||
new GUIMessageBox(string.Empty, TextManager.GetWithVariable("missionunlocked", "[missionname]", missionName),
|
||||
Array.Empty<LocalizedString>(), type: GUIMessageBox.Type.InGame, icon: prefab.Icon, relativeSize: new Vector2(0.3f, 0.15f), minSize: new Point(512, 128))
|
||||
{
|
||||
IconColor = prefab.IconColor
|
||||
};
|
||||
if (GameMain.GameSession?.Map is { } map && locationIndex > 0 && locationIndex < map.Locations.Count)
|
||||
if (GameMain.GameSession?.Map is { } map && locationIndex >= 0 && locationIndex < map.Locations.Count)
|
||||
{
|
||||
map.Discover(map.Locations[locationIndex], checkTalents: false);
|
||||
Location location = map.Locations[locationIndex];
|
||||
map.Discover(location, checkTalents: false);
|
||||
|
||||
LocationConnection? connection = null;
|
||||
if (destinationIndex != locationIndex && destinationIndex >= 0 && destinationIndex < map.Locations.Count)
|
||||
{
|
||||
Location destination = map.Locations[destinationIndex];
|
||||
connection = map.Connections.FirstOrDefault(c => c.Locations.Contains(location) && c.Locations.Contains(destination));
|
||||
}
|
||||
if (connection != null)
|
||||
{
|
||||
location.UnlockMission(prefab, connection);
|
||||
}
|
||||
else
|
||||
{
|
||||
location.UnlockMission(prefab);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -10,8 +10,7 @@ namespace Barotrauma
|
||||
|
||||
public override RichString GetMissionRewardText(Submarine sub)
|
||||
{
|
||||
LocalizedString rewardText = TextManager.GetWithVariable("currencyformat", "[credits]", string.Format(CultureInfo.InvariantCulture, "{0:N0}", GetReward(sub)));
|
||||
|
||||
LocalizedString rewardText = GetRewardAmountText(sub);
|
||||
LocalizedString retVal;
|
||||
if (rewardPerCrate.HasValue)
|
||||
{
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace Barotrauma
|
||||
{
|
||||
new CameraTransition(boss, GameMain.GameScreen.Cam, null, Alignment.Center, panDuration: 8, fadeOut: false, startZoom: 1.0f, endZoom: 0.3f * GUI.yScale)
|
||||
{
|
||||
RunWhilePaused = false,
|
||||
EndWaitDuration = 3.0f
|
||||
};
|
||||
}
|
||||
@@ -40,6 +41,7 @@ namespace Barotrauma
|
||||
{
|
||||
new CameraTransition(boss, GameMain.GameScreen.Cam, null, Alignment.Center, panDuration: 3, fadeOut: false, endZoom: 0.1f * GUI.yScale)
|
||||
{
|
||||
RunWhilePaused = false,
|
||||
EndWaitDuration = float.PositiveInfinity
|
||||
};
|
||||
}, delay: 3.0f);
|
||||
@@ -52,6 +54,7 @@ namespace Barotrauma
|
||||
{
|
||||
new CameraTransition(boss, GameMain.GameScreen.Cam, null, Alignment.Center, panDuration: 5.0f, fadeOut: false, losFadeIn: false, startZoom: 1.0f, endZoom: 0.4f * GUI.yScale)
|
||||
{
|
||||
RunWhilePaused = false,
|
||||
EndWaitDuration = cameraWaitDuration
|
||||
};
|
||||
}
|
||||
|
||||
@@ -32,10 +32,28 @@ namespace Barotrauma
|
||||
return ToolBox.GradientLerp(t, GUIStyle.Green, GUIStyle.Orange, GUIStyle.Red);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the amount of marks you get from the reward (e.g. "3,000 mk")
|
||||
/// </summary>
|
||||
protected LocalizedString GetRewardAmountText(Submarine sub)
|
||||
{
|
||||
int baseReward = GetReward(sub);
|
||||
int finalReward = GetFinalReward(sub);
|
||||
string rewardAmountText = string.Format(CultureInfo.InvariantCulture, "{0:N0}", baseReward);
|
||||
if (finalReward > baseReward)
|
||||
{
|
||||
rewardAmountText += $" + {string.Format(CultureInfo.InvariantCulture, "{0:N0}", finalReward - baseReward)}";
|
||||
}
|
||||
return TextManager.GetWithVariable("currencyformat", "[credits]", rewardAmountText);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the full reward text of the mission (e.g. "Reward: 2,000 mk" or "Reward: 500 mk x 2 (out of max 5) = 1,000 mk")
|
||||
/// </summary>
|
||||
public virtual RichString GetMissionRewardText(Submarine sub)
|
||||
{
|
||||
LocalizedString rewardText = TextManager.GetWithVariable("currencyformat", "[credits]", string.Format(CultureInfo.InvariantCulture, "{0:N0}", GetReward(sub)));
|
||||
return RichString.Rich(TextManager.GetWithVariable("missionreward", "[reward]", "‖color:gui.orange‖"+rewardText+"‖end‖"));
|
||||
LocalizedString rewardText = GetRewardAmountText(sub);
|
||||
return RichString.Rich(TextManager.GetWithVariable("missionreward", "[reward]", "‖color:gui.orange‖" + rewardText + "‖end‖"));
|
||||
}
|
||||
|
||||
public RichString GetReputationRewardText()
|
||||
@@ -43,27 +61,30 @@ namespace Barotrauma
|
||||
List<LocalizedString> reputationRewardTexts = new List<LocalizedString>();
|
||||
foreach (var reputationReward in ReputationRewards)
|
||||
{
|
||||
FactionPrefab targetFaction;
|
||||
FactionPrefab targetFactionPrefab;
|
||||
if (reputationReward.Key == "location" )
|
||||
{
|
||||
targetFaction = OriginLocation.Faction?.Prefab;
|
||||
targetFactionPrefab = OriginLocation.Faction?.Prefab;
|
||||
}
|
||||
else
|
||||
{
|
||||
FactionPrefab.Prefabs.TryGet(reputationReward.Key, out targetFaction);
|
||||
FactionPrefab.Prefabs.TryGet(reputationReward.Key, out targetFactionPrefab);
|
||||
}
|
||||
|
||||
if (targetFactionPrefab == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
LocalizedString name;
|
||||
if (targetFaction != null)
|
||||
float totalReputationChange = reputationReward.Value;
|
||||
if (GameMain.GameSession?.Campaign?.Factions.Find(f => f.Prefab == targetFactionPrefab) is Faction faction)
|
||||
{
|
||||
name = $"‖color:{XMLExtensions.ToStringHex(targetFaction.IconColor)}‖{targetFaction.Name}‖end‖";
|
||||
totalReputationChange = reputationReward.Value * faction.Reputation.GetReputationChangeMultiplier(reputationReward.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
name = TextManager.Get(reputationReward.Key);
|
||||
}
|
||||
float normalizedValue = MathUtils.InverseLerp(-100.0f, 100.0f, reputationReward.Value);
|
||||
string formattedValue = ((int)reputationReward.Value).ToString("+#;-#;0"); //force plus sign for positive numbers
|
||||
|
||||
LocalizedString name = $"‖color:{XMLExtensions.ToStringHex(targetFactionPrefab.IconColor)}‖{targetFactionPrefab.Name}‖end‖";
|
||||
float normalizedValue = MathUtils.InverseLerp(-100.0f, 100.0f, totalReputationChange);
|
||||
string formattedValue = ((int)Math.Round(totalReputationChange)).ToString("+#;-#;0"); //force plus sign for positive numbers
|
||||
LocalizedString rewardText = TextManager.GetWithVariables(
|
||||
"reputationformat",
|
||||
("[reputationname]", name),
|
||||
|
||||
Reference in New Issue
Block a user