Skip to content
This repository has been archived by the owner on Sep 12, 2020. It is now read-only.

Commit

Permalink
Merge pull request #12 from SynapseSL/development
Browse files Browse the repository at this point in the history
Full Release 1.0
  • Loading branch information
moelrobi authored Jul 24, 2020
2 parents fd54940 + f3772de commit 26b3db3
Show file tree
Hide file tree
Showing 40 changed files with 992 additions and 651 deletions.
31 changes: 31 additions & 0 deletions Synapse/Api/Decontamination.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using LightContainmentZoneDecontamination;
using Mirror;

namespace Synapse.Api
{
public static class Decontamination
{
public static DecontaminationController Controller { get => DecontaminationController.Singleton; }

public static bool IsDecontaminationDisabled
{
get => Controller._disableDecontamination;
set
{
if (value)
{
Controller._stopUpdating = false;
Controller.RoundStartTime = NetworkTime.time;
}
Controller._disableDecontamination = value;
}
}

public static bool IsDecontaminationInProgress => Controller._decontaminationBegun;

/// <summary>
/// Starts the Decontamination
/// </summary>
public static void StartDecontamination() => Controller.FinishDecontamination();
}
}
64 changes: 18 additions & 46 deletions Synapse/Api/PlayerExtensions.cs → Synapse/Api/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,19 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using Mirror;
using Synapse.Api.Enums;
using Synapse.Api.Plugin;
using UnityEngine;

namespace Synapse.Api
{
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
[SuppressMessage("ReSharper", "UnusedMember.Global")]
public static class PlayerExtensions
public static class Extensions
{
private static MethodInfo _sendSpawnMessage;
public static MethodInfo SendSpawnMessage
{
get
{
if (_sendSpawnMessage == null)
_sendSpawnMessage = typeof(NetworkServer).GetMethod("SendSpawnMessage",BindingFlags.Instance | BindingFlags.InvokeMethod
| BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Public);

return _sendSpawnMessage;
}
}

/// <summary>Gives a player a message in the RemoteAdmin</summary>
/// <param name="sender">The User who you send the Message</param>
/// <param name="message">The Message you want to send</param>
Expand Down Expand Up @@ -64,58 +53,41 @@ public static void RaMessage(this CommandSender sender, string message, bool suc
sender.RaReply($"{Assembly.GetCallingAssembly().GetName().Name}#" + message, success, true, category);
}

/// <summary>
/// Gives all players on the server
/// </summary>
public static IEnumerable<Player> GetAllPlayers()
{
return (from gameObject in PlayerManager.players
where gameObject != PlayerManager.localPlayer && gameObject != null
select gameObject.GetPlayer()).ToList();
}

/// <summary>
/// Gives all players on the server with this Role
/// </summary>
/// <param name="role"></param>
public static IEnumerable<Player> GetAllPlayers(this RoleType role) => GetAllPlayers().Where(x => x.Role == role);
public static IEnumerable<Player> GetAllPlayers(this RoleType role) => Player.GetAllPlayers().Where(x => x.Role == role);

/// <summary>
/// Gives you the player object
/// </summary>
public static Player GetPlayer(this MonoBehaviour mono) => mono.GetComponent<Player>();

public static IEnumerable<Player> GetAllPlayers(this RoleType[] roles) => Player.GetAllPlayers().Where(x => roles.Any(r => x.Role == r));

public static IEnumerable<Player> GetAllPlayers(this Team[] teams) => Player.GetAllPlayers().Where(x => teams.Any(t => x.Team == t));

/// <summary>
/// Gives you the player object
/// Gives all players on the server in this Team
/// </summary>
public static Player GetPlayer(this PlayableScps.PlayableScp scp) => scp.Hub.GetPlayer();
/// <param name="team"></param>
/// <returns></returns>
public static IEnumerable<Player> GetAllPlayers(this Team team) => Player.GetAllPlayers().Where(x => x.Team == team);

/// <summary>
/// Gives you the player object
/// </summary>
public static Player GetPlayer(this GameObject gameObject) => gameObject.GetComponent<Player>();
public static Player GetPlayer(this MonoBehaviour mono) => mono.GetComponent<Player>();

/// <summary>
/// Gives you the player object
/// </summary>
public static Player GetPlayer(int id) => GetAllPlayers().FirstOrDefault(p => p.PlayerId == id);
public static Player GetPlayer(this PlayableScps.PlayableScp scp) => scp.Hub.GetPlayer();

/// <summary>
/// Gives you the player object
/// </summary>
public static Player GetPlayer(string arg)
{
if (short.TryParse(arg, out var playerId))
return GetPlayer(playerId);
public static Player GetPlayer(this GameObject gameObject) => gameObject.GetComponent<Player>();

if (!arg.EndsWith("@steam") && !arg.EndsWith("@discord") && !arg.EndsWith("@northwood") &&
!arg.EndsWith("@patreon"))
return GetAllPlayers().FirstOrDefault(p => p.NickName.ToLower().Contains(arg.ToLower()));
foreach (var player in GetAllPlayers())
if (player.UserId == arg)
return player;
public static string GetVersionString(this PluginDetails details) => $"{details.SynapseMajor}.{details.SynapseMinor}.{details.SynapsePatch}";

return GetAllPlayers().FirstOrDefault(p => p.NickName.ToLower().Contains(arg.ToLower()));
}
public static int GetVersionNumber(this PluginDetails details) => details.SynapseMajor * 100 + details.SynapseMinor * 10 + details.SynapsePatch;
}
}
File renamed without changes.
68 changes: 5 additions & 63 deletions Synapse/Api/Map.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using LightContainmentZoneDecontamination;
using Synapse.Permissions;
using Synapse.Config;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
Expand All @@ -12,21 +11,6 @@ namespace Synapse.Api
[SuppressMessage("ReSharper", "UnusedMember.Global")]
public static class Map
{
/// <summary>
/// Gives you the WarheadController.
/// </summary>
public static AlphaWarheadController WarheadController => Player.Server.GetComponent<AlphaWarheadController>();

/// <summary>
/// Activates/Deactivates the RoundLock (if the Round can end)
/// </summary>
public static bool RoundLock { get => RoundSummary.RoundLock; set => RoundSummary.RoundLock = value; }

/// <summary>
/// Activates/Deactivates the LobbyLock (if the Lobby can continue counting down)
/// </summary>
public static bool LobbyLock { get => GameCore.RoundStart.LobbyLock; set => GameCore.RoundStart.LobbyLock = value; }

/// <summary>
/// Activates/Deactivates the FriendlyFire on the server
/// </summary>
Expand All @@ -37,9 +21,7 @@ public static class Map
/// </summary>
public static List<Lift> Lifts => Object.FindObjectsOfType<Lift>().ToList();

private static Broadcast BroadcastComponent => Player.Server.GetComponent<Broadcast>();

private static List<Room> _rooms = new List<Room>();
private static Broadcast BroadcastComponent => Player.Host.GetComponent<Broadcast>();

/// <summary>
/// Gives you a list of all rooms
Expand All @@ -48,27 +30,12 @@ public static List<Room> Rooms
{
get
{
if (_rooms == null || _rooms.Count == 0)
_rooms = Object.FindObjectsOfType<Transform>().Where(transform => transform.CompareTag("Room"))
return Object.FindObjectsOfType<Transform>().Where(transform => transform.CompareTag("Room") || transform.name == "Root_*&*Outside Cams")
.Select(obj => new Room {Name = obj.name, Position = obj.position, Transform = obj.transform})
.ToList();

return _rooms;
}
}

/// <summary>
/// Is the nuke detonated?
/// </summary>
public static bool IsNukeDetonated =>
WarheadController.detonated;

/// <summary>
/// Is the nuke in progress?
/// </summary>
public static bool IsNukeInProgress =>
WarheadController.inProgress;

/// <summary>
/// How many generators are activated?
/// </summary>
Expand Down Expand Up @@ -182,39 +149,14 @@ public static Vector3 GetRandomSpawnPoint(this RoleType type)
/// <param name="msg"></param>
/// <param name="makeHold"></param>
/// <param name="makeNoise"></param>
public static void CassieMessage(string msg, bool makeHold, bool makeNoise) => Player.Server.GetComponent<MTFRespawn>().RpcPlayCustomAnnouncement(msg, makeHold, makeNoise);

/// <summary>
/// Starts the Decontamination
/// </summary>
public static void StartDecontamination() => DecontaminationController.Singleton.FinishDecontamination();
public static void CassieMessage(string msg, bool makeHold, bool makeNoise) => Respawning.RespawnEffectsController.PlayCassieAnnouncement(msg, makeHold, makeNoise);


/// <summary>
/// Starts the nuke
/// </summary>
public static void StartNuke()
{
var alpha = PlayerManager.localPlayer.GetComponent<AlphaWarheadController>();
alpha.InstantPrepare();
alpha.StartDetonation();
}

/// <summary>
/// Spawns a Item on the Map
/// </summary>
public static Pickup SpawnItem(ItemType itemType, float durability, Vector3 position, Quaternion rotation = default, int sight = 0, int barrel = 0, int other = 0)
=> Player.Server.Inventory.SetPickup(itemType, durability, position, rotation, sight, barrel, other);

/// <summary>
/// Stops the nuke
/// </summary>
public static void StopNuke() => WarheadController.CancelDetonation();

/// <summary>
/// Detonates the nuke
/// </summary>
public static void DetonateNuke() => WarheadController.Detonate();
=> Player.Host.Inventory.SetPickup(itemType, durability, position, rotation, sight, barrel, other);

/// <summary>
/// Has the group the permission?
Expand Down
Loading

0 comments on commit 26b3db3

Please sign in to comment.