Advertisement
Second_Fry

Smod2 CmdRegisterEscape

Jul 21st, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.87 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using ServerMod2.API;
  5. using Smod2.API;
  6. using Smod2.EventHandlers;
  7. using Smod2.Events;
  8. using UnityEngine;
  9. using UnityEngine.Networking;
  10.  
  11. // Token: 0x0200015D RID: 349
  12. public partial class CharacterClassManager : NetworkBehaviour
  13. {
  14.     // Token: 0x06000898 RID: 2200 RVA: 0x000367CC File Offset: 0x000349CC
  15.     [Command(channel = 2)]
  16.     private void CmdRegisterEscape()
  17.     {
  18.         if (Vector3.Distance(base.transform.position, base.GetComponent<Escape>().worldPosition) > (float)(base.GetComponent<Escape>().radius * 2))
  19.         {
  20.             return;
  21.         }
  22.         int classid = -1;
  23.         List<Handcuffs> list = new List<Handcuffs>();
  24.         foreach (Handcuffs handcuffs in UnityEngine.Object.FindObjectsOfType<Handcuffs>())
  25.         {
  26.             if (!(handcuffs == null) && !(handcuffs.cuffTarget == null) && !(handcuffs.cuffTarget != base.gameObject))
  27.             {
  28.                 list.Add(handcuffs);
  29.             }
  30.         }
  31.         PlayerCheckEscapeEvent playerCheckEscapeEvent = new PlayerCheckEscapeEvent(new SmodPlayer(base.gameObject))
  32.         {
  33.             AllowEscape = false,
  34.             ChangeRole = Role.UNASSIGNED
  35.         };
  36.         EventManager.Manager.HandleEvent<IEventHandlerCheckEscape>(playerCheckEscapeEvent);
  37.         if (playerCheckEscapeEvent.AllowEscape && playerCheckEscapeEvent.ChangeRole != Role.UNASSIGNED)
  38.         {
  39.             foreach (Handcuffs handcuffs2 in list)
  40.             {
  41.                 handcuffs2.NetworkcuffTarget = null;
  42.             }
  43.             base.transform.Translate(0f, 200f, 0f);
  44.             this.SetPlayersClass((int)playerCheckEscapeEvent.ChangeRole, base.gameObject, true);
  45.             return;
  46.         }
  47.         CharacterClassManager component = base.GetComponent<CharacterClassManager>();
  48.         global::Team team = this.klasy[component.curClass].team;
  49.         if (team != global::Team.RSC)
  50.         {
  51.             if (team != global::Team.CDP)
  52.             {
  53.                 return;
  54.             }
  55.             RoundSummary.escaped_ds++;
  56.             if (ConfigFile.GetBool("escapee_restrained_check", false, false) && list.Count > 0)
  57.             {
  58.                 classid = 13;
  59.             }
  60.             else
  61.             {
  62.                 classid = 8;
  63.             }
  64.         }
  65.         else
  66.         {
  67.             RoundSummary.escaped_scientists++;
  68.             if (ConfigFile.GetBool("escapee_restrained_check", false, false) && list.Count > 0)
  69.             {
  70.                 classid = 8;
  71.             }
  72.             else
  73.             {
  74.                 classid = 4;
  75.             }
  76.         }
  77.         foreach (Handcuffs handcuffs3 in list)
  78.         {
  79.             handcuffs3.NetworkcuffTarget = null;
  80.         }
  81.         base.transform.Translate(0f, 200f, 0f);
  82.         this.SetPlayersClass(classid, base.gameObject, true);
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement