This repository has been archived by the owner on Oct 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
210 additions
and
0 deletions.
There are no files selected for viewing
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,75 @@ | ||
using Smod2; | ||
using Smod2.Events; | ||
using Smod2.EventHandlers; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using Assets._Scripts.Dissonance; | ||
using MEC; | ||
|
||
namespace SCP_Speech | ||
{ | ||
public class EventHandler : IEventHandlerWaitingForPlayers, IEventHandlerSetRole | ||
{ | ||
private readonly Plugin plugin; | ||
private static readonly Dictionary<GameObject, ReferenceHub> _hubs = new Dictionary<GameObject, ReferenceHub>(); | ||
|
||
public EventHandler(Plugin plugin) | ||
{ | ||
this.plugin = plugin; | ||
} | ||
|
||
public void OnWaitingForPlayers(WaitingForPlayersEvent ev) | ||
{ | ||
if (plugin.GetConfigBool("sp_disabled")) | ||
{ | ||
plugin.PluginManager.DisablePlugin(plugin); | ||
} | ||
} | ||
|
||
public void OnSetRole(PlayerSetRoleEvent ev) | ||
{ | ||
foreach (ReferenceHub hub in GetHubs()) | ||
{ | ||
DissonanceUserSetup speak = hub.gameObject.GetComponent<DissonanceUserSetup>(); | ||
if (hub.characterClassManager.CurClass == RoleType.Scp049) | ||
{ | ||
speak.NetworkaltIsActive = false; | ||
Timing.RunCoroutine(Speech(speak)); | ||
} | ||
} | ||
} | ||
|
||
public IEnumerator<float> Speech(DissonanceUserSetup speak) | ||
{ | ||
while (true) | ||
{ | ||
if (speak.NetworkaltIsActive) | ||
{ | ||
speak.NetworkspeakingFlags = SpeakingFlags.MimicAs939; | ||
} | ||
else | ||
{ | ||
speak.NetworkspeakingFlags = SpeakingFlags.SCPChat; | ||
} | ||
|
||
yield return Timing.WaitForSeconds(0.1f); | ||
} | ||
} | ||
|
||
public static List<ReferenceHub> GetHubs() | ||
{ | ||
List<ReferenceHub> hubs = new List<ReferenceHub>(); | ||
foreach (GameObject obj in PlayerManager.players) | ||
if (_hubs.ContainsKey(obj)) | ||
hubs.Add(_hubs[obj]); | ||
else | ||
{ | ||
ReferenceHub rh = ReferenceHub.GetHub(obj); | ||
_hubs.Add(obj, rh); | ||
hubs.Add(rh); | ||
} | ||
|
||
return hubs; | ||
} | ||
} | ||
} |
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,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("SCP Speech")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("SCP Speech")] | ||
[assembly: AssemblyCopyright("Copyright © 2020")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("3f58d94a-0eb7-4316-9cd2-3a55aa8800ac")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
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,69 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{3F58D94A-0EB7-4316-9CD2-3A55AA8800AC}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>SCPSpeech</RootNamespace> | ||
<AssemblyName>SCPSpeech</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<Deterministic>true</Deterministic> | ||
<TargetFrameworkProfile /> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>..\..\Plugin Release\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Assembly-CSharp"> | ||
<HintPath>..\..\References\Assembly-CSharp.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\..\References\Assembly-CSharp-firstpass.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Mirror"> | ||
<HintPath>..\..\References\Mirror.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Smod2"> | ||
<HintPath>..\..\References\Smod2.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="UnityEngine"> | ||
<HintPath>..\..\References\UnityEngine.dll</HintPath> | ||
</Reference> | ||
<Reference Include="UnityEngine.CoreModule"> | ||
<HintPath>..\..\References\UnityEngine.CoreModule.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="SCPSpeech.cs" /> | ||
<Compile Include="EventHandler.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
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,30 @@ | ||
using Smod2; | ||
using Smod2.Attributes; | ||
|
||
namespace SCP_Speech | ||
{ | ||
[PluginDetails( | ||
author = "TeMbI4", | ||
name = "SCP Speech", | ||
description = "Allow certain SCP to speak with other classes.", | ||
id = "TeMbI4.SCP.Speech", | ||
version = "1.0", | ||
SmodMajor = 3, | ||
SmodMinor = 8, | ||
SmodRevision = 4 | ||
)] | ||
public class SCPSpeech : Plugin | ||
{ | ||
public static SCPSpeech plugin; | ||
|
||
public override void OnEnable() { this.Info("SCP Speech has loaded :D"); } | ||
public override void OnDisable() { this.Info("SCP Speech has been unloaded"); } | ||
|
||
public override void Register() | ||
{ | ||
this.AddEventHandlers(new EventHandler(this)); | ||
|
||
this.AddConfig(new Smod2.Config.ConfigSetting("sp_disabled", false, true, "Is plugin enabled?")); | ||
} | ||
} | ||
} |