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 #39 from SynapseSL/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
GrafDimenzio authored Feb 8, 2021
2 parents 9bb52a9 + 2a8fda3 commit 46a5f11
Show file tree
Hide file tree
Showing 66 changed files with 823 additions and 214 deletions.
30 changes: 28 additions & 2 deletions Synapse/Api/Door.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using vDoor = Interactables.Interobjects.DoorUtils.DoorVariant;
using Interactables.Interobjects;
using Mirror;
using System.Collections.Generic;

namespace Synapse.Api
{
Expand Down Expand Up @@ -68,7 +69,6 @@ public Enum.DoorType DoorType
}
}

//if (Name.Contains("Airlocks")) doorType = Enum.DoorType.Airlock;
if (Name.Contains("EZ BreakableDoor")) doorType = Enum.DoorType.EZ_Door;
else if (Name.Contains("LCZ BreakableDoor")) doorType = Enum.DoorType.LCZ_Door;
else if (Name.Contains("HCZ BreakableDoor")) doorType = Enum.DoorType.HCZ_Door;
Expand All @@ -83,7 +83,17 @@ public Enum.DoorType DoorType

public bool IsBreakable => VDoor is BreakableDoor;

public bool IsOpen { get => VDoor.IsConsideredOpen(); }
public bool Open
{
get => VDoor.IsConsideredOpen();
set => VDoor.NetworkTargetState = value;
}

public bool Locked
{
get => VDoor.ActiveLocks > 0;
set => VDoor.ServerChangeLock(DoorLockReason.SpecialDoorFeature, value);
}

public bool TryBreakDoor()
{
Expand All @@ -106,6 +116,22 @@ public bool TryPry()
return false;
}

public List<Room> Rooms { get; } = new List<Room>();

public static 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);
Map.Get.Doors.Add(door);
NetworkServer.Spawn(doorVariant.gameObject);

return door;
}

public override string ToString() => Name;
}
}
3 changes: 3 additions & 0 deletions Synapse/Api/Dummy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,5 +153,8 @@ public Dummy(Vector3 pos, Quaternion rot, RoleType role = RoleType.ClassD, strin
/// Destroys the Object
/// </summary>
public void Destroy() => Object.Destroy(GameObject);

public static 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);
}
}
23 changes: 22 additions & 1 deletion Synapse/Api/Elevator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityEngine;
using Synapse.Api.Enum;

namespace Synapse.Api
{
Expand All @@ -10,7 +11,7 @@ public class Elevator

public GameObject GameObject => Lift.gameObject;

public string Name => GameObject.name;
public string Name => Lift.elevatorName;

public Vector3 Position => GameObject.transform.position;

Expand All @@ -21,5 +22,25 @@ public class Elevator
public float MaxDistance { get => Lift.maxDistance; set => Lift.maxDistance = value; }

public void Use() => Lift.UseLift();

public ElevatorType ElevatorType
{
get
{
switch (Name)
{
case "GateB": return ElevatorType.GateB;
case "GateA": return ElevatorType.GateA;
case "SCP-049": return ElevatorType.Scp049;
case "ElA": return ElevatorType.ElALeft;
case "ElA2": return ElevatorType.ElARight;
case "ElB": return ElevatorType.ElBLeft;
case "ElB2": return ElevatorType.ElBRight;
default: return ElevatorType.None;
}
}
}

public override string ToString() => Name;
}
}
15 changes: 15 additions & 0 deletions Synapse/Api/Enum/ElevatorType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Synapse.Api.Enum
{
public enum ElevatorType
{
None,
GateA,
GateB,
ElALeft,
ElARight,
ElBLeft,
ElBRight,
Nuke,
Scp049,
}
}
24 changes: 3 additions & 21 deletions Synapse/Api/Events/EventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,14 @@ internal EventHandler()

private void KeyPress(SynapseEventArguments.PlayerKeyPressEventArgs ev)
{
var pos = ev.Player.Position;
pos.y += 5;
switch (ev.KeyCode)
{
case KeyCode.Alpha1:
foreach (var player in SynapseController.Server.Players)
if (player != ev.Player)
ev.Player.Scp173Controller.IgnoredPlayers.Add(player);
ev.Player.GiveTextHint("Next spawn in : " + SynapseController.Server.Map.Round.NextRespawn.ToString());
break;

case KeyCode.Alpha2:
foreach (var door in Api.Map.Get.Doors.Where(x => x.DoorType == Enum.DoorType.Airlock))
door.Position = pos;
break;

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

case KeyCode.Alpha4:
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;
SynapseController.Server.Map.Round.NextRespawn = 20;
break;
}
}
Expand All @@ -66,7 +48,7 @@ public interface ISynapseEventArgs
}

#region HookedEvents
private SynapseConfiguration conf => SynapseController.Server.Configs.SynapseConfiguration;
private SynapseConfiguration conf => SynapseController.Server.Configs.synapseConfiguration;

private void PlayerJoin(SynapseEventArguments.PlayerJoinEventArgs ev)
{
Expand Down
5 changes: 2 additions & 3 deletions Synapse/Api/Events/MapEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@ internal MapEvents() { }
public event EventHandler.OnSynapseEvent<Scp914ActivateEventArgs> Scp914ActivateEvent;

#region Invoke
internal void InvokeTriggerTeslaEv(Player player,Tesla tesla,bool hurtrange,out bool trigger)
internal void InvokeTriggerTeslaEv(Player player, Tesla tesla, ref bool trigger)
{
trigger = true;
var ev = new TriggerTeslaEventArgs
{
Player = player,
Tesla = tesla,
HurtRange = hurtrange,
Trigger = trigger
};

TriggerTeslaEvent.Invoke(ev);
TriggerTeslaEvent?.Invoke(ev);

trigger = ev.Trigger;
}
Expand Down
3 changes: 2 additions & 1 deletion Synapse/Api/Events/RoundEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal void InvokeSpawnPlayersEvent(ref Dictionary<Player, int> spawnplayers,
allow = ev.Allow;
}

internal void InvokeTeamRespawn(ref List<Player> players,ref Respawning.SpawnableTeamType teamType, out bool allow)
internal void InvokeTeamRespawn(ref List<Player> players,ref Respawning.SpawnableTeamType teamType, out bool allow,out int teamid)
{
var ev = new TeamRespawnEventArgs
{
Expand All @@ -69,6 +69,7 @@ internal void InvokeTeamRespawn(ref List<Player> players,ref Respawning.Spawnabl
players = ev.Players;
teamType = ev.Team;
allow = ev.Allow;
teamid = ev.TeamID;
}
#endregion
}
Expand Down
7 changes: 6 additions & 1 deletion Synapse/Api/Events/ServerEvents.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using LiteNetLib;
using Synapse.Api.Events.SynapseEventArguments;
using System;

namespace Synapse.Api.Events
{
Expand All @@ -11,7 +12,9 @@ internal ServerEvents() { }

public event EventHandler.OnSynapseEvent<RemoteAdminCommandEventArgs> RemoteAdminCommandEvent;

public event EventHandler.OnSynapseEvent<ConsoleCommandEventArgs> ConsoleCommandEvent;
public event EventHandler.OnSynapseEvent<ConsoleCommandEventArgs> ConsoleCommandEvent;

public event Action UpdateEvent;

internal void InvokePreAuthenticationEvent(string userid, ref bool allow, ref string reason, ConnectionRequest request)
{
Expand All @@ -35,5 +38,7 @@ internal void InvokeConsoleCommandEvent(Player player, string command)
var ev = new ConsoleCommandEventArgs {Command = command, Player = player};
ConsoleCommandEvent?.Invoke(ev);
}

internal void InvokeUpdateEvent() => UpdateEvent?.Invoke();
}
}
2 changes: 0 additions & 2 deletions Synapse/Api/Events/SynapseEventArguments/MapEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ public class TriggerTeslaEventArgs : EventHandler.ISynapseEventArgs

public Player Player { get; internal set; }

public bool HurtRange { get; internal set; }

public bool Trigger { get; set; }
}

Expand Down
32 changes: 31 additions & 1 deletion Synapse/Api/Events/SynapseEventArguments/RoundEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,37 @@ public class SpawnPlayersEventArgs: EventHandler.ISynapseEventArgs

public class TeamRespawnEventArgs : EventHandler.ISynapseEventArgs
{
public Respawning.SpawnableTeamType Team { get; set; }
private int team;

public Respawning.SpawnableTeamType Team
{
get
{
switch (team)
{
case 1: return Respawning.SpawnableTeamType.NineTailedFox;
case 2: return Respawning.SpawnableTeamType.ChaosInsurgency;
default: return Respawning.SpawnableTeamType.None;
}
}
set
{
switch (value)
{
case Respawning.SpawnableTeamType.NineTailedFox:
team = 1;
break;
case Respawning.SpawnableTeamType.ChaosInsurgency:
team = 2;
break;
default:
team = -1;
break;
}
}
}

public int TeamID { get => team; set => team = value; }

public List<Player> Players { get; set; }

Expand Down
59 changes: 45 additions & 14 deletions Synapse/Api/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using MapGeneration;
using Mirror;
using Synapse.Api.Enum;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Instrumentation;
Expand Down Expand Up @@ -78,16 +79,14 @@ public float SprintSpeed

public int Seed => MapGeneration.SeedSynchronizer.Seed;

public Room GetRoom(RoomInformation.RoomType roomType) => Rooms.FirstOrDefault(x => x.RoomType == roomType);
public Room GetRoom(RoomInformation.RoomType roomType)
=> Rooms.FirstOrDefault(x => x.RoomType == roomType);

public Door GetDoor(Enum.DoorType doorType) => Doors.FirstOrDefault(x => x.DoorType == doorType);
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 = "")
=> 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 Elevator GetElevator(Enum.ElevatorType elevatorType)
=> Elevators.FirstOrDefault(x => x.ElevatorType == elevatorType);

public void SendBroadcast(ushort time, string message, bool instant = false)
{
Expand All @@ -101,7 +100,8 @@ public void AnnounceScpDeath(string scp)
GlitchedCassie(text);
}

public void Cassie(string words, bool makehold = true, bool makenoise = true) => Respawning.RespawnEffectsController.PlayCassieAnnouncement(words, makehold, makenoise);
public void Cassie(string words, bool makehold = true, bool makenoise = true)
=> Respawning.RespawnEffectsController.PlayCassieAnnouncement(words, makehold, makenoise);

public void GlitchedCassie(string words)
{
Expand All @@ -115,7 +115,7 @@ public Grenades.Grenade SpawnGrenade(Vector3 position, Vector3 velocity, float f
player = Server.Get.Host;

var component = player.GrenadeManager;
var component2 = Object.Instantiate(component.availableGrenades[(int)grenadeType].grenadeInstance).GetComponent<Grenades.Grenade>();
var component2 = UnityEngine.Object.Instantiate(component.availableGrenades[(int)grenadeType].grenadeInstance).GetComponent<Grenades.Grenade>();
component2.FullInitData(component, position, Quaternion.Euler(component2.throwStartAngle), velocity, component2.throwAngularVelocity, player == Server.Get.Host ? Team.RIP : player.Team);
component2.NetworkfuseTime = NetworkTime.time + (double)fusetime;
NetworkServer.Spawn(component2.gameObject);
Expand All @@ -129,17 +129,31 @@ public void Explode(Vector3 position, Enum.GrenadeType grenadeType = Enum.Grenad
player = Server.Get.Host;

var component = player.GrenadeManager;
var component2 = Object.Instantiate(component.availableGrenades[(int)grenadeType].grenadeInstance).GetComponent<Grenades.Grenade>();
var component2 = UnityEngine.Object.Instantiate(component.availableGrenades[(int)grenadeType].grenadeInstance).GetComponent<Grenades.Grenade>();
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 void PlaceBlood(Vector3 pos, int type = 0, float size = 2)
=> Server.Get.Host.ClassManager.RpcPlaceBlood(pos, type, size);

[Obsolete("Instantiate a Dummy instead", true)]
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);

[Obsolete("Moved to Workstation.CreateWorkStation()", true)]
public WorkStation CreateWorkStation(Vector3 position, Vector3 rotation, Vector3 scale)
=> new WorkStation(position, rotation, scale);

[Obsolete("Moved to Door.CreateRagdoll()", true)]
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);

[Obsolete("Moved to Door.SpawnDoorVariant()", true)]
public Door SpawnDoorVariant(Vector3 position, Quaternion? rotation = null, DoorPermissions permissions = null)
{
DoorVariant doorVariant = Object.Instantiate(Server.Get.Prefabs.DoorVariantPrefab);
DoorVariant doorVariant = UnityEngine.Object.Instantiate(Server.Get.Prefabs.DoorVariantPrefab);

doorVariant.transform.position = position;
doorVariant.transform.rotation = rotation ?? new Quaternion(0, 0, 0, 0);
Expand All @@ -162,8 +176,25 @@ internal void AddObjects()
foreach (var station in Server.Get.GetObjectsOf<global::WorkStation>())
WorkStations.Add(new WorkStation(station));

foreach (var door in SynapseController.Server.GetObjectsOf<Interactables.Interobjects.DoorUtils.DoorVariant>())
foreach (var door in SynapseController.Server.GetObjectsOf<DoorVariant>())
Doors.Add(new Door(door));

foreach (var interactable in Interface079.singleton.allInteractables)
{
foreach (var zoneroom in interactable.currentZonesAndRooms)
{
try
{
var room = Rooms.FirstOrDefault(x => x.RoomName == zoneroom.currentRoom);
var door = interactable.GetComponentInParent<Interactables.Interobjects.DoorUtils.DoorVariant>();
if (room == null || door == null) continue;
var sdoor = door.GetDoor();
sdoor.Rooms.Add(room);
room.Doors.Add(sdoor);
}
catch { }
}
}
}

internal void ClearObjects()
Expand Down
Loading

0 comments on commit 46a5f11

Please sign in to comment.