Skip to content

Commit

Permalink
uouo
Browse files Browse the repository at this point in the history
  • Loading branch information
NOTIF-API authored Oct 30, 2023
1 parent ab4a697 commit 50e8bbf
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 65 deletions.
15 changes: 1 addition & 14 deletions SCP-600V/API/Role.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class Role
/// <returns>returns true if the player is SCP-600 or not null</returns>
public static bool IsScp600(Player player)
{
if (player != null & player.SessionVariables.ContainsKey("IsSCP600"))
if (player != null & player.SessionVariables.ContainsKey("IsSCP600") | CustomRole.Get(typeof(Scp600Base)).Check(player))
{
return true;
}
Expand Down Expand Up @@ -70,18 +70,5 @@ public static void Spawn(Player player)
}
}
}
/// <summary>
/// Allows you to get the number of people who do not have the role Breeder on the server
/// </summary>
/// <param name="team">Team to check</param>
/// <returns>returns the number of players in the team excluding scp</returns>
public static int AmountTeamNotScp(Team team) => Player.List.Count(x => x != null & !x.SessionVariables.ContainsKey("IsSCP600") & x.Role.Team == team);
/// <summary>
/// Determine if a player who is an SCP is in the team
/// </summary>
/// <param name="team">Team to check</param>
/// <returns>returns true if the SCP player is on the team</returns>
public static bool ScpInTeam(Team team) => Player.List.Any(x => x != null & x.Role.Team == team & x.SessionVariables.ContainsKey("IsSCP600"));

}
}
5 changes: 5 additions & 0 deletions SCP-600V/EventHandler/GameEvents.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
using Exiled.API.Enums;
using Exiled.API.Extensions;
using Exiled.API.Features;
using Exiled.API.Features.Components;
using Exiled.API.Features.Pickups;
using Exiled.Events.EventArgs.Player;
using Exiled.Events.EventArgs.Scp173;
using PlayerRoles;
using SCP_600V.API.Role;
using System.Linq;

namespace SCP_600V.EventHandler
{
Expand Down
31 changes: 7 additions & 24 deletions SCP-600V/EventHandler/RoundEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,9 @@ namespace SCP_600V.EventHandler
{
internal class RoundEvents
{
// makes sure that the game does not end if there are conditions interfering with the end
/*internal void OnEndingRound(EndingRoundEventArgs e)
{
bool scp = false;
bool human = false;
int mtf = Role.AmountTeamNotScp(Team.FoundationForces);
int d = Role.AmountTeamNotScp(Team.ClassD);
int s = Role.AmountTeamNotScp(Team.SCPs);
if (mtf > 0 || d > 0)
{
human = true;
}
if (s > 0 || Role.Scp600Players().Count() > 0)
{
scp = true;
}
if (human & scp)
{
e.IsRoundEnded = false;
}
}*/
// determines whether a player will be selected for role 600 or not
/// <summary>
/// determines whether a player will be selected for role 600 or not
/// </summary>
internal void OnRoundStarted()
{
bool Spawnable = IsSpawnable();
Expand All @@ -52,6 +31,10 @@ internal void OnRoundStarted()
return;
}
}
/// <summary>
/// determines by random selection whether an event will occur
/// </summary>
/// <returns><para>returns True if the event can occur</para><para>returns False if the event cannot occur</para></returns>
internal bool IsSpawnable()
{
if (UnityEngine.Random.value <= Sai.Instance.Config.PercentToSpawn/100)
Expand Down
8 changes: 7 additions & 1 deletion SCP-600V/Events/EventArg/SpawnedEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Exiled.API.Features;
using PlayerRoles;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down Expand Up @@ -26,13 +27,18 @@ public class SpawnedEventArgs: EventArgs
/// Health
/// </summary>
public float Healt { get; private set; } = 400f;
/// <summary>
/// the role the player had before being called
/// </summary>
public RoleTypeId PlayerOldRole { get; private set; }

public SpawnedEventArgs(Player player, Vector3 position, int maxHealt, float healt)
public SpawnedEventArgs(Player player, Vector3 position, int maxHealt, float healt, RoleTypeId role)
{
Player = player;
Position = position;
MaxHealt = maxHealt;
Healt = healt;
PlayerOldRole = role;
}
}
}
18 changes: 2 additions & 16 deletions SCP-600V/Events/Scp600Handler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,11 @@ public class Scp600Handler

internal void InvokeSpawning(SpawningEventArgs e)
{
if (OnSpawning != null)
{
OnSpawning.Invoke(e);
}
else
{
Log.Debug("No have subscriders to event OnSpawning");
}
OnSpawning?.Invoke(e);
}
internal void InvokeSpawned(SpawnedEventArgs e)
{
if (OnSpawned != null)
{
OnSpawned.Invoke(e);
}
else
{
Log.Debug("No have subscriders to event OnSpawned");
}
OnSpawned?.Invoke(e);
}
}
}
3 changes: 2 additions & 1 deletion SCP-600V/Extension/Scp600Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public override void AddRole(Player player)
{
if (this.Role != RoleTypeId.None)
{
RoleTypeId _ArgRole = player.Role.Type;
Vector3 pos = player.Position;
player.Role.Set(this.Role, RoleSpawnFlags.None);
Timing.CallDelayed(1f, () =>
Expand Down Expand Up @@ -133,7 +134,7 @@ public override void AddRole(Player player)
}
});
Events.EventArg.SpawnedEventArgs e = new Events.EventArg.SpawnedEventArgs(player, pos, this.MaxHealth, (float)this.MaxHealth);
Events.EventArg.SpawnedEventArgs e = new Events.EventArg.SpawnedEventArgs(player, pos, this.MaxHealth, (float)this.MaxHealth, _ArgRole);
new Scp600Handler().InvokeSpawned(e);
}
}
Expand Down
4 changes: 2 additions & 2 deletions SCP-600V/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
// Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.3.3.0")]
[assembly: AssemblyFileVersion("2.3.3.0")]
[assembly: AssemblyVersion("2.3.4.0")]
[assembly: AssemblyFileVersion("2.3.4.0")]
[assembly: NeutralResourcesLanguage("ru-RU")]
33 changes: 26 additions & 7 deletions SCP-600V/Sai.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,25 @@ namespace SCP_600V
{
internal class Sai: Plugin<Config>
{

/// <summary>
/// A static variable called Instance is created to gain access to the plugin configurations and other parameters
/// </summary>
public static Sai Instance { get; private set; }
/// <summary>
/// The harmony class that is needed for the plugin to work correctly
/// </summary>
private Harmony _harma;
/// <summary>
/// The class where game event handlers are located
/// </summary>
private GameEvents _gameEvents;
/// <summary>
/// The class where game event handlers regarding rounds are located (end, start)
/// </summary>
private RoundEvents _roundEvents;

/// <summary>
/// Called when the plugin starts
/// </summary>
public override void OnEnabled()
{
base.OnEnabled();
Expand All @@ -30,6 +43,9 @@ public override void OnEnabled()

this.RegisterEvent();
}
/// <summary>
/// Called when the plugin is disabled
/// </summary>
public override void OnDisabled()
{
base.OnDisabled();
Expand All @@ -42,26 +58,29 @@ public override void OnDisabled()

this.UnRegisterEvent();
}
/// <summary>
/// Called to register for an event
/// </summary>
private void RegisterEvent()
{
_gameEvents = new GameEvents();
_roundEvents = new RoundEvents();

Handler.Server.RoundStarted += _roundEvents.OnRoundStarted;
//Handler.Server.EndingRound += _roundEvents.OnEndingRound;
Handler.Player.EnteringPocketDimension += _gameEvents.EnterignPocketDemens;
//Handler.Player.Escaping += _gameEvents.OnEscape;
Handler.Player.Hurting += _gameEvents.HurtingPlayer;
}

/// <summary>
/// Called if you need to unsubscribe from all events
/// </summary>
private void UnRegisterEvent()
{
_roundEvents = null;
_gameEvents = null;

Handler.Server.RoundStarted -= _roundEvents.OnRoundStarted;
//Handler.Server.EndingRound -= _roundEvents.OnEndingRound;
Handler.Player.EnteringPocketDimension -= _gameEvents.EnterignPocketDemens;
//Handler.Player.Escaping -= _gameEvents.OnEscape;
Handler.Player.Hurting -= _gameEvents.HurtingPlayer;
}
}
}

0 comments on commit 50e8bbf

Please sign in to comment.