Skip to content

Commit

Permalink
Merge pull request #1 from JohnodonCode/dev
Browse files Browse the repository at this point in the history
Door!
  • Loading branch information
JohnodonCode authored Sep 15, 2021
2 parents c4dd57e + 837cba2 commit 1e7e78c
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 24 deletions.
39 changes: 39 additions & 0 deletions EasyEvents/Commands/Door.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System.Collections.Generic;
using System;
using System.Linq;
using EasyEvents.Types;
using Exiled.API.Enums;
using Exiled.API.Features;
using Door2 = Exiled.API.Features.Door;

namespace EasyEvents.Commands
{
public static class Door
{
public static void Run(List<string> args, int i)
{
if (args.Count < 2) throw new InvalidArgumentLengthException("Expected 2 arguments but got " + args.Count + " for command \"door\" at line " + i + ".");
DoorType targetDoorType = DoorType.UnknownDoor;
bool isDoor = Enum.TryParse(args[0], out targetDoorType);
if (!isDoor)
{
throw new InvalidArgumentException("Invalid argument for command \"door\" on line " + i + ", argument 0. \"" + args[0] + "\" is not a valid door name. Door names are case sensitive.");
}
else
{
List<Door2> targetDoors = new List<Door2>();
targetDoors.Add((Door2)Map.Doors.Where(x => x.Type == targetDoorType));
if (args.Count == 3)
{
if (!int.TryParse(args[2].Trim(), out var delay)) throw new InvalidArgumentException("Invalid argument for command \"door\" on line " + i + ", argument 2. Expected \"INT\" but got \"" + args[2] + "\".");

ScriptActions.GetDelay(delay).doorData.Add(new DoorData(targetDoors, args[1], i));
}
else
{
ScriptActions.scriptData.doorData.Add(new DoorData(targetDoors, args[1], i));
}
}
}
}
}
56 changes: 33 additions & 23 deletions EasyEvents/EasyEvents.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<Compile Include="Commands\CreateClass.cs" />
<Compile Include="Commands\DisableDecontamination.cs" />
<Compile Include="Commands\DisableDetonation.cs" />
<Compile Include="Commands\Door.cs" />
<Compile Include="Commands\Escape.cs" />
<Compile Include="Commands\Give.cs" />
<Compile Include="Commands\HP.cs" />
Expand All @@ -59,6 +60,7 @@
<Compile Include="ScriptActionsStore.cs" />
<Compile Include="ScriptHandler.cs" />
<Compile Include="ScriptStore.cs" />
<Compile Include="Types\DoorData.cs" />
<Compile Include="Types\GiveData.cs" />
<Compile Include="Types\HPData.cs" />
<Compile Include="Types\InfectData.cs" />
Expand All @@ -70,47 +72,54 @@
<Compile Include="Util.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="0Harmony">
<HintPath>C:\Users\johnj\Documents\Assemblies\EXILED3\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>C:\Users\johnj\Documents\Assemblies\EXILED3\Assembly-CSharp.dll</HintPath>
<Reference Include="0Harmony, Version=2.0.4.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Users\johnj\AppData\Roaming\EXILED\Plugins\dependencies\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" />
<Reference Include="Assembly-CSharp-firstpass">
<HintPath>C:\Users\johnj\Documents\Assemblies\Assembly-CSharp-firstpass.dll</HintPath>
</Reference>
<Reference Include="CommandSystem.Core">
<HintPath>C:\Users\johnj\Documents\Assemblies\EXILED3\CommandSystem.Core.dll</HintPath>
</Reference>
<Reference Include="Exiled.API">
<HintPath>C:\Users\johnj\Documents\Assemblies\EXILED3\Exiled.API.dll</HintPath>
<Reference Include="Exiled.API, Version=3.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Users\johnj\AppData\Roaming\EXILED\Plugins\dependencies\Exiled.API.dll</HintPath>
</Reference>
<Reference Include="Exiled.CreditTags">
<HintPath>C:\Users\johnj\Documents\Assemblies\EXILED3\Exiled.CreditTags.dll</HintPath>
<Reference Include="Exiled.CreditTags, Version=3.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Users\johnj\AppData\Roaming\EXILED\Plugins\Exiled.CreditTags.dll</HintPath>
</Reference>
<Reference Include="Exiled.CustomItems">
<HintPath>C:\Users\johnj\Documents\Assemblies\EXILED3\Exiled.CustomItems.dll</HintPath>
<Reference Include="Exiled.CustomItems, Version=3.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Users\johnj\AppData\Roaming\EXILED\Plugins\Exiled.CustomItems.dll</HintPath>
</Reference>
<Reference Include="Exiled.Events">
<HintPath>C:\Users\johnj\Documents\Assemblies\EXILED3\Exiled.Events.dll</HintPath>
<Reference Include="Exiled.Events, Version=3.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Users\johnj\AppData\Roaming\EXILED\Plugins\Exiled.Events.dll</HintPath>
</Reference>
<Reference Include="Exiled.Loader">
<HintPath>C:\Users\johnj\Documents\Assemblies\EXILED3\Exiled.Loader.dll</HintPath>
<Reference Include="Exiled.Loader, Version=3.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Users\johnj\AppData\Roaming\EXILED\Exiled.Loader.dll</HintPath>
</Reference>
<Reference Include="Exiled.Permissions">
<HintPath>C:\Users\johnj\Documents\Assemblies\EXILED3\Exiled.Permissions.dll</HintPath>
<Reference Include="Exiled.Permissions, Version=3.0.0.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Users\johnj\AppData\Roaming\EXILED\Plugins\Exiled.Permissions.dll</HintPath>
</Reference>
<Reference Include="Exiled.Updater">
<HintPath>C:\Users\johnj\Documents\Assemblies\EXILED3\Exiled.Updater.dll</HintPath>
<Reference Include="Exiled.Updater, Version=3.1.1.0, Culture=neutral, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Users\johnj\AppData\Roaming\EXILED\Plugins\Exiled.Updater.dll</HintPath>
</Reference>
<Reference Include="Mirror">
<HintPath>C:\Users\johnj\Documents\Assemblies\EXILED3\Mirror.dll</HintPath>
</Reference>
<Reference Include="NorthwoodLib">
<HintPath>C:\Users\johnj\Documents\Assemblies\EXILED3\NorthwoodLib.dll</HintPath>
</Reference>
<Reference Include="SemVer">
<HintPath>C:\Users\johnj\Documents\Assemblies\EXILED3\SemVer.dll</HintPath>
<Reference Include="SemVer, Version=1.3.0.0, Culture=neutral, PublicKeyToken=a89bb7dc6f7a145c, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Users\johnj\AppData\Roaming\EXILED\Plugins\dependencies\SemVer.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="Unity.Mathematics">
Expand Down Expand Up @@ -302,8 +311,9 @@
<Reference Include="UnityEngine.XRModule">
<HintPath>C:\Users\johnj\Documents\Assemblies\EXILED3\UnityEngine.XRModule.dll</HintPath>
</Reference>
<Reference Include="YamlDotNet">
<HintPath>C:\Users\johnj\Documents\Assemblies\EXILED3\YamlDotNet.dll</HintPath>
<Reference Include="YamlDotNet, Version=9.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\Users\johnj\AppData\Roaming\EXILED\Plugins\dependencies\YamlDotNet.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
33 changes: 33 additions & 0 deletions EasyEvents/ScriptActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ private static IEnumerator<float> RoundStart(ScriptActionsStore dataObj, bool ma
RunBroadcasts(dataObj);
RunHints(dataObj);
RunLights(dataObj);
RunDoors(dataObj);

if (dataObj.detonate)
{
Expand Down Expand Up @@ -522,5 +523,37 @@ private static void RunLights(ScriptActionsStore dataObj)
Map.TurnOffAllLights(lightData.time, zonetype);
}
}

private static void RunDoors(ScriptActionsStore dataObj)
{
foreach (var doorData in dataObj.doorData)
{
foreach(Door door in doorData.doors)
{
switch (doorData.action)
{
case "break":
case "destroy":
door.BreakDoor();
break;
case "open":
door.IsOpen = true;
break;
case "close":
door.IsOpen = false;
break;
case "lock":
door.ChangeLock(DoorLockType.DecontLockdown);
break;
case "unlock":
door.ChangeLock(DoorLockType.None);
break;
default:
throw new InvalidArgumentException("Invalid argument for command \"door\" on line " + doorData.i + ", argument 1. \"" + doorData.action + "\" is not a valid door action.");
}
}

}
}
}
}
2 changes: 2 additions & 0 deletions EasyEvents/ScriptActionsStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class ScriptActionsStore

public List<SizeData> sizeData = new List<SizeData>();

public List<DoorData> doorData = new List<DoorData>();

public bool disableDecontamination = false;

public List<RoleInfo> last = new List<RoleInfo>();
Expand Down
4 changes: 4 additions & 0 deletions EasyEvents/ScriptHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public static void RunScript(string inputText)

switch (cmd)
{
case "door":
Door.Run(args, i);
break;

case "spawn":
Spawn.Run(args, i);
break;
Expand Down
2 changes: 1 addition & 1 deletion EasyEvents/ScriptStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private static Dictionary<string, string> GetDefaultEvents()
var events = new Dictionary<string, string>();

events.Add("hideandseek", "//Please note that order doesn't matter in events. You can reorder all of your commands and your event will not change.\n\n//Create the hider and seeker classes\ncreateclass seeker Scientist\ncreateclass hider ClassD\n\n//Make it so that 10% of players will be seekers, with a minimum of 2 seekers. The rest will be hiders.\nspawn g:seeker,10,2 g:hider\n\n//Everytime a player is killed, they will become a seeker.\ninfect g:hider g:seeker\n\n//Teleport seekers to the guard tower\nteleport g:seeker 55 1020 -45\n\n//Send broadcasts to hiders and seekers giving them information about their role.\nbroadcast g:seeker 5 \"You are a seeker. Kill all hiders. You will be released in 2 minutes.\"\nbroadcast g:hider 5 \"You are a hider. You have 2 minutes to hide until the seekers get released.\"\n\n//Give the seekers their items\ngive g:seeker GunLogicer\ngive g:seeker Radio\ngive g:seeker KeycardO5\ngive g:seeker Flashlight\n\n//Give the seekers enough hp that they cannot be killed\nhp g:seeker 10000\n\n//Turn off the lights forever after 2 minutes (120 seconds)\nlights ALL 100000 120\n\n//Teleport seekers to the LCZ_ARMORY after 2 minutes (120 seconds)\nteleport g:seeker LCZ_ARMORY 120\n\n//Send broadcasts telling everyone that the seekers have been released after 2 minutes (120 seconds)\nbroadcast all 5 \"The seekers have been released!\" 120\n\n//Make the last hider standing the winner\nlast g:hider");

events.Add("civmtf", "//Please note that order doesn't matter in events. You can reorder all of your commands and your event will not change.\n\n//Lock the round so it doesn't end\nroundlock\n\n//Create the CI and MTF classes\ncreateclass ci ChaosConscript\ncreateclass mtf NtfSergeant\n\n//Lock doors so the CI and NTF cant get into the facility or attack eachother\ndoor GateA lock\ndoor GateB lock\ndoor SurfaceGate close\ndoor SurfaceGate lock\n\n//Spawn the CI and NTF\nspawn g:ci,50,0 g:mtf,50,0\n\nbroadcast all 5 \"MTF vs Chaos: Get ready to fight!\"\n\n//Open the gate!\ndoor SurfaceGate open 15");
return events;
}
}
Expand Down
19 changes: 19 additions & 0 deletions EasyEvents/Types/DoorData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Exiled.API.Features;
using System.Collections.Generic;

namespace EasyEvents.Types
{
public class DoorData
{
public List<Door> doors;
public string action;
public int i;

public DoorData(List<Door> doors, string action, int i)
{
this.doors = doors;
this.action = action.ToLower();
this.i = i;
}
}
}

0 comments on commit 1e7e78c

Please sign in to comment.