-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for per-team role vehicle spawner delays, renamed some …
…team stuff
- Loading branch information
Showing
18 changed files
with
169 additions
and
78 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System.Runtime.CompilerServices; | ||
using System; | ||
using Uncreated.Warfare.Database; | ||
using DanielWillett.ReflectionTools; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
// only initialize if library exists | ||
public static class SshTunnelHelper | ||
{ | ||
public static void AddSshTunnelService(ContainerBuilder serviceCollection) | ||
{ | ||
serviceCollection.RegisterType(GetServiceType()) | ||
.SingleInstance(); | ||
} | ||
|
||
public static UniTask OpenIfAvailableAsync(ILifetimeScope serviceProvider, CancellationToken token) | ||
{ | ||
string? configuredSshKey = serviceProvider.ResolveOptional<IConfiguration>()?.GetSection("database")?["ssh_key"]; | ||
|
||
if (string.IsNullOrEmpty(configuredSshKey)) | ||
return UniTask.CompletedTask; | ||
|
||
object? service = serviceProvider.ResolveOptional(GetServiceType()); | ||
if (service != null) | ||
{ | ||
return OpenAsync(service, token); | ||
} | ||
|
||
return UniTask.CompletedTask; | ||
} | ||
|
||
private static UniTask OpenAsync(object service, CancellationToken token) | ||
{ | ||
SshTunnelService sshTunnel = (SshTunnelService)service; | ||
|
||
return sshTunnel.StartAsync(token); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static Type GetServiceType() => typeof(SshTunnelService); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Uncreated.Warfare.Layouts.Teams; | ||
public enum LayoutRole | ||
{ | ||
NotApplicable, | ||
Blufor, | ||
Opfor | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
UncreatedWarfare/Vehicles/Spawners/Delays/ActionPhaseStartDelay.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,22 @@ | ||
using System; | ||
using Cysharp.Threading.Tasks; | ||
using DanielWillett.ReflectionTools; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Stripe; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Globalization; | ||
using System.Text; | ||
using System.Text.Json; | ||
using Uncreated.Warfare.Configuration; | ||
using Uncreated.Warfare.Configuration.TypeConverters; | ||
using Uncreated.Warfare.Layouts; | ||
using YamlDotNet.Core; | ||
using YamlDotNet.Core.Events; | ||
using YamlDotNet.Serialization; | ||
|
||
namespace Uncreated.Warfare.Vehicles.Spawners.Delays; | ||
public interface ILayoutDelay | ||
public interface ILayoutDelay<TContext> where TContext : LayoutDelayContext | ||
{ | ||
TimeSpan GetTimeLeft(Layout currentLayout); | ||
} | ||
TimeSpan GetTimeLeft(TContext context); | ||
} |
18 changes: 18 additions & 0 deletions
18
UncreatedWarfare/Vehicles/Spawners/Delays/LayoutDelayContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Uncreated.Warfare.Layouts; | ||
using Uncreated.Warfare.Layouts.Teams; | ||
|
||
namespace Uncreated.Warfare.Vehicles.Spawners.Delays; | ||
public class LayoutDelayContext | ||
{ | ||
public Layout CurrentLayout { get; } | ||
public LayoutRole? AffectedTeam { get; } | ||
|
||
public LayoutDelayContext(Layout currentLayout, LayoutRole affectedTeam = LayoutRole.NotApplicable) | ||
{ | ||
CurrentLayout = currentLayout; | ||
AffectedTeam = affectedTeam; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Uncreated.Warfare.Layouts; | ||
using Uncreated.Warfare.Layouts.Phases; | ||
using Uncreated.Warfare.Layouts.Teams; | ||
|
||
namespace Uncreated.Warfare.Vehicles.Spawners.Delays; | ||
public class TimerDelay : ILayoutDelay<LayoutDelayContext> | ||
{ | ||
public TimeSpan Timer { get; set; } | ||
public LayoutRole AffectedTeam { get; set; } = LayoutRole.NotApplicable; | ||
|
||
public TimeSpan GetTimeLeft(LayoutDelayContext context) | ||
{ | ||
if (AffectedTeam != LayoutRole.NotApplicable && AffectedTeam != context.AffectedTeam) | ||
return TimeSpan.Zero; | ||
|
||
if (context.CurrentLayout.ActivePhase is ActionPhase actionPhase) | ||
{ | ||
return Timer - actionPhase.TimeElapsedSinceActive; | ||
} | ||
|
||
return Timer; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters