Skip to content

Commit

Permalink
Merge pull request #280 from ari-steas/QuestLogNetworking
Browse files Browse the repository at this point in the history
???
  • Loading branch information
ari-steas authored Dec 7, 2024
2 parents da6294a + 6d25916 commit 7bf6961
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ public override void UpdateAfterSimulation()
manager.Update10();
}

public override void BeforeStart()
{
if (MyAPIGateway.Session.Player == null)
return;

if (MyAPIGateway.Session.Factions.TryGetPlayerFaction(MyAPIGateway.Session.Player.IdentityId) == null)
MyVisualScriptLogicProvider.RemoveQuestlogDetails(MyAPIGateway.Session.Player.IdentityId);
}

private void OnPlayerConnected(long playerId)
{
if (!isServer) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class QuestLogManager
[ProtoMember(1)] public List<string> Objectives = new List<string>();
[ProtoMember(2)] public Dictionary<string, DateTime> TemporaryObjectives = new Dictionary<string, DateTime>();
[ProtoMember(3)] public long FactionId { get; private set; }
[ProtoMember(4)] public DateTime? ForceShowTime;
[ProtoMember(4)] public double? ForceShowTime;
/// <summary>
/// All playerIds with notifications off.
/// </summary>
Expand Down Expand Up @@ -52,8 +52,9 @@ public void Update10()
// Force showing (broadcast)
if (ForceShowTime != null)
{
if (ForceShowTime.Value > DateTime.UtcNow)
UpdateFactionQuestlog($"Faction Objectives [Force-Enabled for {(ForceShowTime.Value - DateTime.UtcNow).TotalSeconds:N0}s]", true, true);
ForceShowTime -= 1 / 6f;
if (ForceShowTime > 0)
UpdateFactionQuestlog($"Faction Objectives [Force-Enabled for {ForceShowTime:N0}s]", true, true);
else
{
UpdateFactionQuestlog(isNetworkUpdate: !MyAPIGateway.Session.IsServer);
Expand All @@ -64,7 +65,7 @@ public void Update10()

public void ForceShow(double duration)
{
ForceShowTime = DateTime.UtcNow.AddSeconds(duration);
ForceShowTime = duration;
UpdateFactionQuestlog($"Faction Objectives [Force-Enabled for {duration}s]");
}

Expand Down

0 comments on commit 7bf6961

Please sign in to comment.