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 #85 from SynapseSL/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
GrafDimenzio authored Dec 17, 2021
2 parents 669c831 + 9ef66b3 commit 221dc51
Show file tree
Hide file tree
Showing 40 changed files with 563 additions and 206 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testbuild.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: TestBuild

on: [pull_request]
on: [push, pull_request]

env:
# Path to the solution file relative to the root of the project.
Expand Down
Binary file modified Refs/Assembly-CSharp-Publicized.dll
Binary file not shown.
1 change: 0 additions & 1 deletion Synapse/Api/Dummy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ public Dummy(Vector3 pos, Vector2 rot, RoleType role = RoleType.ClassD, string n
Player.QueryProcessor.NetworkPlayerId = QueryProcessor._idIterator;
Player.QueryProcessor._ipAddress = Server.Get.Host.IpAddress;
Player.ClassManager.CurClass = role;
Player.MaxHealth = Player.ClassManager.Classes.SafeGet((int)Player.RoleType).maxHP;
Player.Health = Player.MaxHealth;
Player.NicknameSync.Network_myNickSync = name;
Player.RankName = badgetext;
Expand Down
10 changes: 8 additions & 2 deletions Synapse/Api/Events/EventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@ internal EventHandler()
Server.UpdateEvent += OnUpdate;
#if DEBUG
Player.PlayerKeyPressEvent += KeyPress;
Player.PlayerShootEvent += Shoot;
#endif
}

private void Shoot(SynapseEventArguments.PlayerShootEventArgs ev)
{
Logger.Get.Warn(ev.TargetPosition);
}

private void KeyPress(SynapseEventArguments.PlayerKeyPressEventArgs ev)
{
switch (ev.KeyCode)
{
case KeyCode.Alpha1:
Logger.Get.Debug(ev.Player.ItemInHand.ID);

foreach (var station in Api.Map.Get.WorkStations)
Logger.Get.Warn(station.GameObject.name);
break;
}
}
Expand Down
23 changes: 15 additions & 8 deletions Synapse/Api/Events/PlayerEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using UnityEngine;
using InventorySystem.Items.MicroHID;
using System;
using PlayerStatsSystem;
using Synapse.Api.Enum;

namespace Synapse.Api.Events
Expand Down Expand Up @@ -117,25 +118,31 @@ internal void InvokePlayerSpeakEvent(DissonanceUserSetup userSetup, ref bool int
allow = ev.Allow;
}

internal void InvokePlayerDeathEvent(Player victim, Player killer, PlayerStats.HitInfo info)
internal void InvokePlayerDeathEvent(Player victim, Player killer, ItemType Weapon)
{
var ev = new PlayerDeathEventArgs {HitInfo = info, Killer = killer, Victim = victim};
var ev = new PlayerDeathEventArgs
{
Killer = killer,
Victim = victim,
Weapon = Weapon
};
PlayerDeathEvent?.Invoke(ev);
}

internal void InvokePlayerDamageEvent(Player victim, Player killer, ref PlayerStats.HitInfo info, out bool allow)
internal void InvokePlayerDamageEvent(Player victim, Player killer, ref float Damage, ItemType Weapon, out bool Allow)
{
var ev = new PlayerDamageEventArgs
{
HitInfo = info,
Killer = killer,
Victim = victim
Victim = victim,
Damage = Damage,
Weapon = Weapon
};

PlayerDamageEvent?.Invoke(ev);

info = ev.HitInfo;
allow = ev.Allow;
Damage = ev.Damage;
Allow = ev.Allow;
}

internal void InvokeLoadComponentsEvent(GameObject gameObject)
Expand Down
21 changes: 8 additions & 13 deletions Synapse/Api/Events/SynapseEventArguments/PlayerEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using InventorySystem.Items.MicroHID;
using Synapse.Api.Enum;
using System;
using PlayerStatsSystem;
using Synapse.Api;

// ReSharper disable UnusedAutoPropertyAccessor.Global
namespace Synapse.Api.Events.SynapseEventArguments
Expand Down Expand Up @@ -66,27 +68,20 @@ public class PlayerDeathEventArgs : EventHandler.ISynapseEventArgs

public Player Killer { get; internal set; }

public PlayerStats.HitInfo HitInfo { get; internal set; }
public float Damage { get; set; }

public ItemType Weapon { get; internal set; }
}

public class PlayerDamageEventArgs : EventHandler.ISynapseEventArgs
{
public Player Killer { get; internal set; }

public Player Victim { get; internal set; }

public float DamageAmount
{
get => HitInfo.Amount;
set
{
var info = HitInfo;
info.Amount = value;
HitInfo = info;
}
}

public PlayerStats.HitInfo HitInfo { get; set; }
public float Damage { get; set; }

public ItemType Weapon { get; internal set; }

public bool Allow { get; set; } = true;
}
Expand Down
7 changes: 4 additions & 3 deletions Synapse/Api/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using InventorySystem.Items.Firearms.Attachments;
using MapGeneration;
using Mirror;
using PlayerStatsSystem;
using Scp914;
using Synapse.Api.Enum;
using Synapse.Api.Items;
Expand Down Expand Up @@ -161,9 +162,9 @@ public Dummy CreateDummy(Vector3 pos, Quaternion rot, RoleType role = RoleType.C
public WorkStation CreateWorkStation(Vector3 position, Vector3 rotation, Vector3 scale)
=> new WorkStation(position, rotation, scale);

[Obsolete("Moved to Ragdoll.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.NickName);
//[Obsolete("Moved to Ragdoll.CreateRagdoll()", true)]
//public Ragdoll CreateRagdoll(RoleType roletype, Vector3 pos, Quaternion rot, DamageHandlerBase handler, Player owner)
// => new Ragdoll(roletype, pos, rot, handler, owner);

[Obsolete("Moved to Door.SpawnDoorVariant()", true)]
public Door SpawnDoorVariant(Vector3 position, Quaternion? rotation = null, DoorPermissions permissions = null)
Expand Down
50 changes: 20 additions & 30 deletions Synapse/Api/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
using InventorySystem;
using InventorySystem.Disarming;
using InventorySystem.Items;
using InventorySystem.Items.Firearms;
using InventorySystem.Items.Firearms.Attachments;
using InventorySystem.Searching;
using MapGeneration;
using Mirror;
using Mirror.LiteNetLib4Mirror;
using PlayerStatsSystem;
using RemoteAdmin;
using Synapse.Api.Enum;
using Synapse.Api.Events.SynapseEventArguments;
Expand Down Expand Up @@ -74,10 +76,10 @@ public void ChangeRoleAtPosition(RoleType role)
RoleChangeClassIdPatch.ForceLite = false;
}

public void Kill(DamageTypes.DamageType damageType = default)
public void Kill(DamageHandlerBase damageType = default)
{
Health = 1;
Hurt(100);
damageType ??= new UniversalDamageHandler(10000, DeathTranslations.Unknown);
PlayerStats.KillPlayer(damageType);
}

public void GiveTextHint(string message, float duration = 5f)
Expand Down Expand Up @@ -123,15 +125,12 @@ public void RaLogout()
Hub.serverRoles.TargetCloseRemoteAdmin();
}

public void Heal(float hp) => PlayerStats.HealHPAmount(hp);
public void Heal(float hp) => Health += hp;

public void Hurt(int amount, DamageTypes.DamageType damagetype = default, Player attacker = null)
public void Hurt(int amount, DamageHandlerBase damageType = default)
{
if (damagetype == default)
damagetype = DamageTypes.None;

if (attacker == null) attacker = this;
attacker.PlayerStats.HurtPlayer(new PlayerStats.HitInfo(amount, attacker.NickName, damagetype, attacker.PlayerId, true), gameObject);
damageType ??= new UniversalDamageHandler(amount, DeathTranslations.Unknown);
PlayerStats.DealDamage(damageType);
}

public void OpenReportWindow(string text) => GameConsoleTransmission.SendToClient(Connection, "[REPORTING] " + text, "white");
Expand Down Expand Up @@ -547,27 +546,19 @@ public Vector3 Scale

public float Health
{
get => PlayerStats.Health;
set => PlayerStats.Health = value;
get => Hub.playerStats.GetModule<HealthStat>().CurValue;
set => Hub.playerStats.GetModule<HealthStat>().CurValue = value;
}

public int MaxHealth
{
get => PlayerStats.maxHP;
set => PlayerStats.maxHP = value;
}
public float MaxHealth => Hub.playerStats.GetModule<HealthStat>().MaxValue;

public float ArtificialHealth
{
get => PlayerStats.GetAhpValue();
set => PlayerStats.SafeSetAhpValue(value);
get => Hub.playerStats.GetModule<AhpStat>().CurValue;
set => Hub.playerStats.GetModule<AhpStat>().CurValue = value;
}

public int MaxArtificialHealth
{
get => PlayerStats.MaxArtificialHealth;
set => PlayerStats.MaxArtificialHealth = value;
}
public int MaxArtificialHealth => (int) Hub.playerStats.GetModule<AhpStat>().MaxValue;

public float Stamina
{
Expand Down Expand Up @@ -609,7 +600,7 @@ public Player Cuffer
{
get
{
if (!DisarmedPlayers.Entries.Any(x => x.DisarmedPlayer == NetworkIdentity.netId)) return null;
if (DisarmedPlayers.Entries.All(x => x.DisarmedPlayer != NetworkIdentity.netId)) return null;

var id = DisarmedPlayers.Entries.FirstOrDefault(x => x.DisarmedPlayer == NetworkIdentity.netId).Disarmer;
if (id == 0)
Expand Down Expand Up @@ -932,25 +923,25 @@ public void TriggerEscape()
switch (RealTeam)
{
case Team.MTF when changeTeam:
RoundSummary.escaped_scientists++;
RoundSummary.EscapedScientists++;
tickets.GrantTickets(Respawning.SpawnableTeamType.NineTailedFox,
GameCore.ConfigFile.ServerConfig.GetInt("respawn_tickets_mtf_classd_cuffed_count", 1), false);
break;

case Team.MTF when !changeTeam:
RoundSummary.escaped_scientists++;
RoundSummary.EscapedScientists++;
tickets.GrantTickets(Respawning.SpawnableTeamType.NineTailedFox,
GameCore.ConfigFile.ServerConfig.GetInt("respawn_tickets_mtf_scientist_count", 1), false);
break;

case Team.CHI when changeTeam:
RoundSummary.escaped_ds++;
RoundSummary.EscapedClassD++;
tickets.GrantTickets(Respawning.SpawnableTeamType.NineTailedFox,
GameCore.ConfigFile.ServerConfig.GetInt("respawn_tickets_ci_scientist_cuffed_count", 1), false);
break;

case Team.CHI when !changeTeam:
RoundSummary.escaped_ds++;
RoundSummary.EscapedClassD++;
tickets.GrantTickets(Respawning.SpawnableTeamType.NineTailedFox,
GameCore.ConfigFile.ServerConfig.GetInt("respawn_tickets_ci_classd_count", 1), false);
break;
Expand All @@ -959,7 +950,6 @@ public void TriggerEscape()
else
{
CustomRole.Escape();
return;
}
}
}
Expand Down
37 changes: 20 additions & 17 deletions Synapse/Api/Ragdoll.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using Mirror;
using UnityEngine;
using System.Linq;
using PlayerStatsSystem;

namespace Synapse.Api
{
public class Ragdoll
{
internal Ragdoll(global::Ragdoll rag) => ragdoll = rag;

public Ragdoll(RoleType roletype, Vector3 pos, Quaternion rot, Vector3 velocity, PlayerStats.HitInfo info, bool allowRecall, string owner)
/*public Ragdoll(RoleType roletype, Vector3 pos, Quaternion rot, Vector3 velocity, PlayerStats.HitInfo info, bool allowRecall, string owner)
{
var role = Server.Get.Host.ClassManager.Classes.SafeGet((int)roletype);
var gameobject = UnityEngine.Object.Instantiate(role.model_ragdoll, pos + role.ragdoll_offset.position, Quaternion.Euler(rot.eulerAngles + role.ragdoll_offset.rotation));
Expand All @@ -18,6 +19,20 @@ public Ragdoll(RoleType roletype, Vector3 pos, Quaternion rot, Vector3 velocity,
ragdoll.NetworkallowRecall = allowRecall;
ragdoll.NetworkPlayerVelo = velocity;
Map.Get.Ragdolls.Add(this);
}*/

public Ragdoll(RoleType roleType, Vector3 pos, Quaternion rot, DamageHandlerBase handler, Player owner)
{
GameObject gameObject = Server.Get.Host.ClassManager.Classes.SafeGet((int) roleType).model_ragdoll;
//GameObject gameObject = Object.Instantiate(role.model_ragdoll, pos + role.model_offset.position,
// Quaternion.Euler(rot.eulerAngles + role.model_offset.rotation));
if (gameObject == null || !Object.Instantiate(gameObject).TryGetComponent(out ragdoll))
{
return;
}
ragdoll = gameObject.GetComponent<global::Ragdoll>();
ragdoll.NetworkInfo = new RagdollInfo(owner.Hub, handler, pos, rot);
NetworkServer.Spawn(gameObject);
}

private readonly global::Ragdoll ragdoll;
Expand All @@ -28,7 +43,7 @@ public Ragdoll(RoleType roletype, Vector3 pos, Quaternion rot, Vector3 velocity,

public RoleType RoleType
{
get => Server.Get.Host.ClassManager.Classes.FirstOrDefault(role => role.fullName == ragdoll.owner.FullName).roleId;
get => ragdoll.Info.RoleType;
}

public Vector3 Position
Expand All @@ -55,19 +70,7 @@ public Vector3 Scale

public Player Owner
{
get => Server.Get.GetPlayer(ragdoll.owner.PlayerId);
set
{
ragdoll.owner.PlayerId = value.PlayerId;
ragdoll.owner.Nick = value.NickName;
ragdoll.owner.ownerHLAPI_id = value.GetComponent<Dissonance.Integrations.MirrorIgnorance.MirrorIgnorancePlayer>().PlayerId;
}
}

public bool AllowRecall
{
get => ragdoll.allowRecall;
set => ragdoll.allowRecall = value;
get => Server.Get.GetPlayer(ragdoll.Info.OwnerHub.playerId);
}

public void Destroy()
Expand All @@ -76,7 +79,7 @@ public void Destroy()
Map.Get.Ragdolls.Remove(this);
}

public static 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.NickName);
public static Ragdoll CreateRagdoll(RoleType roletype, Vector3 pos, Quaternion rot, DamageHandlerBase handler, Player owner)
=> new Ragdoll(roletype, pos, rot, handler, owner);
}
}
Loading

0 comments on commit 221dc51

Please sign in to comment.