Skip to content
This repository has been archived by the owner on Aug 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #26 from SynapseSL/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
GrafDimenzio authored Jan 8, 2021
2 parents db26c97 + b814924 commit a62fe36
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 30 deletions.
Binary file modified Refs/Assembly-CSharp-Publicized.dll
Binary file not shown.
23 changes: 22 additions & 1 deletion Synapse/Api/Door.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Interactables.Interobjects.DoorUtils;
using vDoor = Interactables.Interobjects.DoorUtils.DoorVariant;
using Interactables.Interobjects;
using Mirror;

namespace Synapse.Api
{
Expand Down Expand Up @@ -29,7 +30,27 @@ public string Name
set => name = value;
}

public Vector3 Position => GameObject.transform.position;
public Vector3 Position
{
get => GameObject.transform.position;
set
{
NetworkServer.UnSpawn(GameObject);
GameObject.transform.position = value;
NetworkServer.Spawn(GameObject);
}
}

public Quaternion Rotation
{
get => GameObject.transform.rotation;
set
{
NetworkServer.UnSpawn(GameObject);
GameObject.transform.rotation = value;
NetworkServer.Spawn(GameObject);
}
}

public DoorPermissions DoorPermissions { get => VDoor.RequiredPermissions; set => VDoor.RequiredPermissions = value; }

Expand Down
24 changes: 12 additions & 12 deletions Synapse/Api/Events/EventHandler.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Synapse.Config;
using UnityEngine;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace Synapse.Api.Events
{
Expand All @@ -18,6 +17,8 @@ internal EventHandler()

private void KeyPress(SynapseEventArguments.PlayerKeyPressEventArgs ev)
{
var pos = ev.Player.Position;
pos.y += 5;
switch (ev.KeyCode)
{
case KeyCode.Alpha1:
Expand All @@ -27,22 +28,21 @@ private void KeyPress(SynapseEventArguments.PlayerKeyPressEventArgs ev)
break;

case KeyCode.Alpha2:
var msg = "";
foreach (var door in Api.Map.Get.Doors)
msg += $"Type: {door.DoorType} Name: {door}\n";

var path = Path.Combine(SynapseController.Server.Files.SynapseDirectory, "doors.txt");
if (!File.Exists(path))
File.Create(path).Close();
File.WriteAllText(path, msg);
foreach (var door in Api.Map.Get.Doors.Where(x => x.DoorType == Enum.DoorType.Airlock))
door.Position = pos;
break;

case KeyCode.Alpha3:
ev.Player.Position = Api.Map.Get.GetDoor(Enum.DoorType.Other).Position;
Api.Map.Get.GetDoor(Enum.DoorType.Gate_B).Position = pos;
break;

case KeyCode.Alpha4:
ev.Player.Position = Api.Map.Get.GetDoor(Enum.DoorType.Airlock).Position;
Api.Map.Get.GetDoor(Enum.DoorType.LCZ_012).Position = pos;
break;

case KeyCode.Alpha5:
foreach (var door in Api.Map.Get.Doors)
door.Rotation = ev.Player.transform.rotation;
break;
}
}
Expand Down
34 changes: 26 additions & 8 deletions Synapse/Api/Map.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using Mirror;
using Interactables.Interobjects;
using Interactables.Interobjects.DoorUtils;
using MapGeneration;
using Mirror;
using Synapse.Api.Enum;
using System.Collections.Generic;
using System.Linq;
using System.Management.Instrumentation;
Expand Down Expand Up @@ -78,14 +82,14 @@ public float SprintSpeed

public Door GetDoor(Enum.DoorType doorType) => Doors.FirstOrDefault(x => x.DoorType == doorType);

public Dummy CreateDummy(Vector3 pos, Quaternion rot, RoleType role = RoleType.ClassD, string name = "(null)", string badgetext = "", string badgecolor = "")
public Dummy CreateDummy(Vector3 pos, Quaternion rot, RoleType role = RoleType.ClassD, string name = "(null)", string badgetext = "", string badgecolor = "")
=> new Dummy(pos, rot, role, name, badgetext, badgecolor);

public WorkStation CreateWorkStation(Vector3 position, Vector3 rotation, Vector3 scale) => new WorkStation(position, rotation, scale);

public Ragdoll CreateRagdoll(RoleType roletype, Vector3 pos, Quaternion rot, Vector3 velocity, PlayerStats.HitInfo info, bool allowRecall, Player owner) => new Ragdoll(roletype, pos, rot, velocity, info, allowRecall, owner);

public void SendBroadcast(ushort time,string message,bool instant = false)
public void SendBroadcast(ushort time, string message, bool instant = false)
{
foreach (var ply in Server.Get.Players)
ply.SendBroadcast(time, message, instant);
Expand All @@ -105,10 +109,10 @@ public void GlitchedCassie(string words)
Server.Get.GetObjectOf<NineTailedFoxAnnouncer>().ServerOnlyAddGlitchyPhrase(words, UnityEngine.Random.Range(0.1f, 0.14f) * num2, UnityEngine.Random.Range(0.07f, 0.08f) * num2);
}

public Grenades.Grenade SpawnGrenade(Vector3 position,Vector3 velocity,float fusetime = 3f, Enum.GrenadeType grenadeType = Enum.GrenadeType.Grenade, Player player = null)
public Grenades.Grenade SpawnGrenade(Vector3 position, Vector3 velocity, float fusetime = 3f, Enum.GrenadeType grenadeType = Enum.GrenadeType.Grenade, Player player = null)
{
if(player == null)
player = Server.Get.Host;
if (player == null)
player = Server.Get.Host;

var component = player.GrenadeManager;
var component2 = Object.Instantiate(component.availableGrenades[(int)grenadeType].grenadeInstance).GetComponent<Grenades.Grenade>();
Expand All @@ -119,20 +123,34 @@ public Grenades.Grenade SpawnGrenade(Vector3 position,Vector3 velocity,float fus
return component2;
}

public void Explode(Vector3 position, Enum.GrenadeType grenadeType = Enum.GrenadeType.Grenade, Player player = null)
public void Explode(Vector3 position, Enum.GrenadeType grenadeType = Enum.GrenadeType.Grenade, Player player = null)
{
if (player == null)
player = Server.Get.Host;

var component = player.GrenadeManager;
var component2 = Object.Instantiate(component.availableGrenades[(int)grenadeType].grenadeInstance).GetComponent<Grenades.Grenade>();
component2.FullInitData(component, position, Quaternion.identity, Vector3.zero, Vector3.zero,Team.RIP);
component2.FullInitData(component, position, Quaternion.identity, Vector3.zero, Vector3.zero, Team.RIP);
component2.NetworkfuseTime = 0.10000000149011612;
NetworkServer.Spawn(component2.gameObject);
}

public void PlaceBlood(Vector3 pos, int type = 0, float size = 2) => Server.Get.Host.ClassManager.RpcPlaceBlood(pos, type, size);

public Door SpawnDoorVariant(Vector3 position, Quaternion? rotation = null, DoorPermissions permissions = null)
{
DoorVariant doorVariant = Object.Instantiate(Server.Get.Prefabs.DoorVariantPrefab);

doorVariant.transform.position = position;
doorVariant.transform.rotation = rotation ?? new Quaternion(0, 0, 0, 0);
doorVariant.RequiredPermissions = permissions ?? new DoorPermissions();
var door = new Door(doorVariant);
Get.Doors.Add(door);
NetworkServer.Spawn(doorVariant.gameObject);

return door;
}

internal void AddObjects()
{
foreach (var tesla in SynapseController.Server.GetObjectsOf<TeslaGate>())
Expand Down
12 changes: 12 additions & 0 deletions Synapse/Api/Prefabs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using UnityEngine;
using Interactables.Interobjects.DoorUtils;

namespace Synapse.Api
{
public class Prefabs
{
internal Prefabs() { }

public DoorVariant DoorVariantPrefab { get; internal set; }
}
}
24 changes: 20 additions & 4 deletions Synapse/Patches/EventsPatches/PlayerPatches/PlayerDamagePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,15 @@ private static bool Prefix(PlayerStats __instance, out bool __result, PlayerStat
}
else
{
Server.Get.Events.Player.InvokePlayerDamageEvent(player, killer, ref info,out var allow);
var allow = true;
try
{
Server.Get.Events.Player.InvokePlayerDamageEvent(player, killer, ref info, out allow);
}
catch(Exception e)
{
SynapseController.Server.Logger.Error($"Synapse-Event: PlayerDamage Event failed!!\n{e}\nStackTrace:\n{e.StackTrace}");
}

if (!allow)
{
Expand Down Expand Up @@ -245,6 +253,16 @@ private static bool Prefix(PlayerStats __instance, out bool __result, PlayerStat
else if (info.GetDamageType() == DamageTypes.Grenade)
RoundSummary.kills_by_frag++;

try
{
Server.Get.Events.Player.InvokePlayerDeathEvent(player, killer, info);
}

catch (Exception e)
{
SynapseController.Server.Logger.Error($"Synapse-Event: PlayerDeath Event failed!!\n{e}\nStackTrace:\n{e.StackTrace}");
}

if (!__instance._pocketCleanup || info.GetDamageType() != DamageTypes.Pocket)
{
referenceHub.inventory.ServerDropAll();
Expand Down Expand Up @@ -286,8 +304,6 @@ private static bool Prefix(PlayerStats __instance, out bool __result, PlayerStat
}
}

Server.Get.Events.Player.InvokePlayerDeathEvent(player, killer, info);

playerStats.SetHPAmount(100);
characterClassManager.SetClassID(RoleType.Spectator);

Expand Down Expand Up @@ -404,7 +420,7 @@ private static bool Prefix(PlayerStats __instance, out bool __result, PlayerStat
}
catch (Exception e)
{
SynapseController.Server.Logger.Error($"Synapse-Event: PlayerDamage failed!!\n{e}\nStackTrace:\n{e.StackTrace}");
SynapseController.Server.Logger.Error($"Synapse-Event: PlayerDamage Patch failed!!\n{e}\nStackTrace:\n{e.StackTrace}");
__result = false;
return true;
}
Expand Down
24 changes: 24 additions & 0 deletions Synapse/Patches/SynapsePatches/Wrapper/DoorSpawnpointPatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using HarmonyLib;
using MapGeneration;
using Synapse.Api;

namespace Synapse.Patches.SynapsePatches
{
[HarmonyPatch(typeof(DoorSpawnpoint), nameof(DoorSpawnpoint.Start))]
public class DoorSpawnpointPatch
{
private static bool Prefix(DoorSpawnpoint __instance)
{
try
{
if (Server.Get.Prefabs.DoorVariantPrefab == null)
Server.Get.Prefabs.DoorVariantPrefab = UnityEngine.Object.Instantiate(__instance.TargetPrefab);
}
catch (System.Exception e)
{
Logger.Get.Error($"Synapse-DoorSpawnpoint: DoorSpawnpoint Start Patch failed!!\n{e}");
}
return true;
}
}
}
4 changes: 2 additions & 2 deletions Synapse/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
[assembly: AssemblyCompany("Synapse-DevTeam")]
[assembly: AssemblyProduct("Synapse")]
[assembly: AssemblyCopyright("Copyright © Synapse-DevTeam 2020")]
[assembly: AssemblyVersion("2.4.1.0")]
[assembly: AssemblyFileVersion("2.4.1.0")]
[assembly: AssemblyVersion("2.4.2.0")]
[assembly: AssemblyFileVersion("2.4.2.0")]
2 changes: 2 additions & 0 deletions Synapse/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ internal Server() { }

public Map Map { get; } = new Map();

public Prefabs Prefabs { get; } = new Prefabs();

public FileLocations Files { get; } = new FileLocations();

public EventHandler Events { get; } = new EventHandler();
Expand Down
2 changes: 2 additions & 0 deletions Synapse/Synapse.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="Api\Broadcast.cs" />
<Compile Include="Api\Prefabs.cs" />
<Compile Include="Api\Scp173Controller.cs" />
<Compile Include="Api\Scp096Controller.cs" />
<Compile Include="Api\Enum\ScpAttackType.cs" />
Expand Down Expand Up @@ -158,6 +159,7 @@
<Compile Include="Patches\EventsPatches\ScpPatches\Scp173\Scp173BlinkingPatch.cs" />
<Compile Include="Patches\EventsPatches\ScpPatches\Scp939\Scp939AttackPatch.cs" />
<Compile Include="Patches\EventsPatches\ServerPatches\PreAuthenticationPatch.cs" />
<Compile Include="Patches\SynapsePatches\Wrapper\DoorSpawnpointPatch.cs" />
<Compile Include="Patches\SynapsePatches\ShootPermissionPatch.cs" />
<Compile Include="Patches\SynapsePatches\InvisiblePatch.cs" />
<Compile Include="Patches\SynapsePatches\ItemPatches\Scp914Patch.cs" />
Expand Down
6 changes: 3 additions & 3 deletions Synapse/SynapseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ internal SynapseController()
Server.PermissionHandler.Init();
Server.RoleManager.Init();
CommandHandlers.RegisterSynapseCommands();

PluginLoader.ActivatePlugins();

Server.Logger.Info("Synapse is now ready!");
Expand All @@ -54,6 +54,6 @@ private void PatchMethods()

public const int SynapseMajor = 2;
public const int SynapseMinor = 4;
public const int SynapsePatch = 1;
public const string SynapseVersion = "2.4.1";
public const int SynapsePatch = 2;
public const string SynapseVersion = "2.4.2";
}

0 comments on commit a62fe36

Please sign in to comment.