Skip to content

Commit

Permalink
1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
TenDRILLL authored Jul 20, 2023
1 parent c7786b3 commit f5dab6d
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 105 deletions.
5 changes: 2 additions & 3 deletions SigmaWarhead.sln
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SigmaWarhead", "SigmaWarhead\SigmaWarhead.csproj", "{200E4A7D-0A94-4C5B-9954-91C5E317C652}"
EndProject
Global
Expand All @@ -13,4 +12,4 @@ Global
{200E4A7D-0A94-4C5B-9954-91C5E317C652}.Release|Any CPU.ActiveCfg = Release|Any CPU
{200E4A7D-0A94-4C5B-9954-91C5E317C652}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
EndGlobal
44 changes: 0 additions & 44 deletions SigmaWarhead/EventHandler.cs

This file was deleted.

34 changes: 0 additions & 34 deletions SigmaWarhead/Plugin.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
using System.Collections.Generic;
using System.ComponentModel;

namespace SigmaWarhead
{
public sealed class Config
{
[Description("Is the Plugin enabled.")]
public bool IsEnabled { get; set; } = true;

[Description("Debug mode.")]
public bool Debug { get; private set; } = false;

[Description("C.A.S.S.I.E. voicelines.")]
public Dictionary<string, string> CassieLines { get; private set; } = new()
{
{ "launch", "Automatic .G3 jam_020_5 Sigma .G1 Warhead has been activated by .G6 pitch_0.69 O5 pitch_1.00 . Time until jam_020_3 detonation is .G2 T minus 90 seconds ." }
};

[Description("Minutes since start of round to activate Sigma Warhead.")]
public int ActivationTime { get; private set; } = 20;
}
}
using System.Collections.Generic;
using System.ComponentModel;
using Exiled.API.Interfaces;

namespace SigmaWarhead.com.github.tendrilll.sigmawarhead
{
public sealed class Config : IConfig
{
[Description("Is the Plugin enabled.")]
public bool IsEnabled { get; set; } = true;

[Description("Debug mode.")]
public bool Debug { get; set; } = false;

[Description("C.A.S.S.I.E. voicelines.")]
public Dictionary<string, string> CassieLines { get; set; } = new(){
{ "launch", "Automatic .G3 jam_020_5 Sigma .G1 Warhead has been activated by .G6 pitch_0.69 O5 pitch_1.00 . Time until jam_020_3 detonation is .G2 T minus 90 seconds ." }
};

[Description("Minutes since start of round to activate Sigma Warhead.")]
public int ActivationTime { get; set; } = 20;
}
}
65 changes: 65 additions & 0 deletions SigmaWarhead/com.github.tendrilll.sigmawarhead/EventHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System.Linq;
using Exiled.API.Features;
using Exiled.Events.EventArgs.Server;
using Server = Exiled.Events.Handlers.Server;
using MEC;

namespace SigmaWarhead.com.github.tendrilll.sigmawarhead;

public class EventHandler{
private readonly Plugin<Config> _main;
private readonly bool _debugMode;
private readonly int TimeToLaunch;
private readonly string LaunchMessage;
CoroutineHandle timer;

public EventHandler(Plugin<Config> plugin){
_main = plugin;
_debugMode = plugin.Config.Debug;
if (_debugMode) {
Log.Info("Loading EventHandler");
}

TimeToLaunch = plugin.Config.ActivationTime;
LaunchMessage = plugin.Config.CassieLines.FirstOrDefault(x => x.Key == "launch").Value;

Server.RoundStarted += StartSigma;
Server.RestartingRound += StopSigma;
Server.RoundEnded += StopSigma2;
}

public void UnregisterEvents(){
Server.RoundStarted -= StartSigma;
Server.RestartingRound -= StopSigma;
Server.RoundEnded -= StopSigma2;
}

internal void StartSigma(){
timer = Timing.CallDelayed(TimeToLaunch * 60, LaunchSigmaWarhead);
if (_debugMode)
{
Log.Debug("SigmaWarhead armed and will launch in " + TimeToLaunch + " minutes.");
}
}

internal void StopSigma(){
Timing.KillCoroutines(timer);
if (_debugMode){
Log.Info("SigmaWarhead timer destroyed.");
}
}

internal void StopSigma2(RoundEndedEventArgs args){
StopSigma();
}

internal void LaunchSigmaWarhead(){
Log.Info("SigmaWarhead launched.");
Warhead.Controller.StartDetonation(false, true);
Warhead.Controller.ForceTime(90+13); //+13 for the voiceline. Will make detonation time a variable later.
Warhead.IsLocked = true;
Cassie.Clear();
Cassie.Message(LaunchMessage, false, true, true);
StopSigma();
}
}
28 changes: 28 additions & 0 deletions SigmaWarhead/com.github.tendrilll.sigmawarhead/Plugin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using Exiled.API.Features;
using Log = Exiled.API.Features.Log;

namespace SigmaWarhead.com.github.tendrilll.sigmawarhead {
public class SigmaWarhead : Plugin<Config> {
public override string Name => "SigmaWarhead";
public override string Author => "TenDRILLL";
public override Version Version => new Version(1, 0, 2);
public EventHandler EventHandler;

public override void OnEnabled() {
Log.Info("SigmaWarhead loading...");
if (!Config.IsEnabled) {
Log.Warn("SigmaWarhead disabled from config, unloading...");
OnDisabled();
return;
}
EventHandler = new EventHandler(this);
Log.Info("SigmaWarhead loaded.");
}

public override void OnDisabled() {
EventHandler.UnregisterEvents();
Log.Info("SigmaWarhead unloaded.");
}
}
}
3 changes: 2 additions & 1 deletion SigmaWarhead/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Northwood.PluginAPI" version="12.0.0" targetFramework="net48" />
<package id="Defiant_Zombie.KSP.Skeleton.UnityEngine.CoreModule" version="1.11.2" targetFramework="net48" />
<package id="EXILED" version="7.2.0" targetFramework="net48" />
<package id="YamlDotNet" version="11.0.1" targetFramework="net48" />
</packages>

0 comments on commit f5dab6d

Please sign in to comment.