public void Self_Driving() { IAutopilotable c = new Tesla(); IAutopilotable h = new Trike(); Assert.True(c.hasAutopilot()); Assert.False(c.hasAutopilot()); }
private static void Main(string[] args) { ICar seat = new Seat("Leon", "Grey"); ICar tesla = new Tesla("Model 3", "Red", 2); Console.WriteLine(seat.ToString()); Console.WriteLine(tesla.ToString()); }
public static void Main() { ICar seat = new Seat("Leon", "Grey"); ICar tesla = new Tesla("Model 3", "Red", 2); Console.WriteLine(seat); Console.WriteLine(tesla); }
public void Run() { ICar seat = new Seat("Leon", "Grey"); ICar tesla = new Tesla("Model 3", "Red", 2); Console.WriteLine(seat.ToString()); Console.WriteLine(tesla.ToString()); }
static void Main(string[] args) { ICar seat = new Seat("Leon", "Grey"); IElectricCar tesla = new Tesla("Model 3", "Red", 2); Console.WriteLine(seat); Console.WriteLine(tesla); }
public DriveControl(int numOfCars = 100) { for (int i = 0; i < numOfCars; i++) { Tesla t = new Tesla(rnd.Next(1000, 5000)); t.OnTrackChanged += this.TrackChanged; cars.Add(t); } }
static void Main(string[] args) { Console.WriteLine("Create a cars collection"); Console.WriteLine("How much cars do you want to collect? Enter a number"); int _quantity = Convert.ToInt32(Console.ReadLine()); Collection collection = new Collection(_quantity); for (int i = 0; i < _quantity; i++) { Console.WriteLine($"Choose a mark of the car #{i + 1}"); Console.WriteLine("\n1 - Mercedez\n2 - Bugatti\n3 - Tesla\n"); int choice = Convert.ToInt32(Console.ReadLine()); if (choice > 3 || choice < 1) { Console.WriteLine("Wrong data"); Environment.Exit(-1); } Console.WriteLine("Enter the name of model"); string name_of_model = Console.ReadLine(); Console.WriteLine("Enter the max speed of your car"); int maxSpeed = Convert.ToInt32((Console.ReadLine())); Console.WriteLine("Enter the price of your car"); int price = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter the type of engine"); string type_of_engine = Console.ReadLine(); switch (choice) { case 1: collection[i] = new Mercedez_Benz(name_of_model, maxSpeed, price, type_of_engine, 2); break; case 2: collection[i] = new Bugatti(name_of_model, maxSpeed, price, type_of_engine, 1); break; case 3: collection[i] = new Tesla(name_of_model, maxSpeed, price, type_of_engine, 3); break; } } collection.showInfo(); Console.WriteLine("Press any key . . . \n"); Console.ReadKey(); Console.WriteLine("Choose a car which you wanna ride (enter the number)"); int c = Convert.ToInt32(Console.ReadLine()); if (c < 1 || c > collection.Quantity) { Environment.Exit(-1); } else { RideOnACar(collection[c - 1]); } Console.ReadKey(); }
static void Main() { // 100/100 - и за двата варианта, но по-добре с наледяване и на класа и на интерфейсите1 ICar seat = new Seat("Leon", "Grey"); ICar tesla = new Tesla("Model 3", "Red", 2); Console.WriteLine(seat.ToString()); Console.WriteLine(tesla.ToString()); }
public void StartEngine_NewTesla_ReturnsTeslaSound() { //arrange const string expected = "-- silence ---"; var test = new Tesla(); //act var actual = test.StartEngine(); //assert Assert.Equal(expected, actual); }
public static void Main() { // Build a collection of all vehicles that fly // With a single `foreach`, have each vehicle Fly() var airplane = new KingJet(200, "White", 9); var helecopter = new BlackHawk(150, "Black", 5); List <Aircraft> aircrafts = new List <Aircraft>(); aircrafts.Add(airplane); aircrafts.Add(helecopter); foreach (var aircraft in aircrafts) { aircraft.Fly(); } // Build a collection of all vehicles that operate on roads // With a single `foreach`, have each road vehicle Drive() var audi = new Audi("Snow White", 32, 5); var tesla = new Tesla("Black", 0, 5); List <CarBase> cars = new List <CarBase>(); cars.Add(audi); cars.Add(tesla); foreach (var car in cars) { car.Drive(); } // Build a collection of all vehicles that operate on water // With a single `foreach`, have each water vehicle Drive() var speed = new Speedboat(100, "Blue", 7); var jetski = new Jetski(20, "Yellow", 2); List <Watercraft> boats = new List <Watercraft>(); boats.Add(speed); boats.Add(jetski); foreach (var boat in boats) { boat.Driving(); } Console.ReadLine(); }
internal void InvokeTriggerTeslaEv(Player player, Tesla tesla, ref bool trigger) { trigger = true; var ev = new TriggerTeslaEventArgs { Player = player, Tesla = tesla, Trigger = trigger }; TriggerTeslaEvent?.Invoke(ev); trigger = ev.Trigger; }
internal void InvokeTriggerTeslaEv(Player player, Tesla tesla, bool hurtrange, out bool trigger) { trigger = true; var ev = new TriggerTeslaEventArgs { Player = player, Tesla = tesla, HurtRange = hurtrange, Trigger = trigger }; TriggerTeslaEvent.Invoke(ev); trigger = ev.Trigger; }
static void Main(string[] args) { var gasVehicle = new Toyota(); gasVehicle.Start(0); // needs to implement the Start method in Toyota Class gasVehicle.Speed(70, 1); // needs to implement the Speed method in Toyota Class gasVehicle.Stop(); // needs to implement the Stop methos in Toyota Class var electricalVehicle = new Tesla(true); electricalVehicle.Start(1); // uses over ridden method in Testa Class electricalVehicle.Speed(90, 1); // internal method electricalVehicle.Stop(); //code reuse from the Vehicle abstract class var virtulaVehicle = new Vehicle(true); // will not work as this a abstract class }
public void ShowCurrentSpeed_NewTesla_ReturnsTeslaSpeed() { //arrange const string expected = "24"; var test = new Tesla(); test.SpeedUp(); test.SpeedUp(); test.SpeedUp(); test.SlowDown(); //act var actual = test.ShowCurrentSpeed(); //assert Assert.Equal(expected, actual); }
static void Main(string[] args) { var zero = new Zero(); var tesla = new Tesla(); var cessna = new Cessna(); var ram = new Ram(); var mazda = new Mazda(); zero.MainColor = "White"; tesla.MaximumOccupancy = 5; zero.Drive(); tesla.Drive(); cessna.Drive(); ram.Drive(); mazda.Drive(); }
public static void Do() { Console.WriteLine("== Observer Pattern =="); Tesla tesla = new Tesla("Tesla", 700.00M); tesla.AddWatcher(new Person("Person 1", tesla)); tesla.AddWatcher(new Person("Person 2", tesla)); tesla.AddWatcher(new Person("Person 3", tesla)); Console.WriteLine(tesla.SetPrice(800)); Console.WriteLine("== Template method Pattern =="); Transport car = new Car(); Console.WriteLine(car.run()); Transport plane = new Plane(); Console.WriteLine(plane.run()); }
public void TrackChanged(Tesla car) { if (car.CurrentTrack == Track.Nothing) { car.LightsOn = false; car.TrackSpeedMultiplier = 1f; } else if (car.CurrentTrack == Track.Bridge) { car.LightsOn = false; car.TrackSpeedMultiplier = 0.8f; } else if (car.CurrentTrack == Track.Tunnel) { car.LightsOn = true; car.TrackSpeedMultiplier = 5f; } }
static void Main(string[] args) { string[] seatInput = Console.ReadLine().Split(' '); string[] teslaINput = Console.ReadLine().Split(); ICar seat = new Seat(seatInput[0], seatInput[2]); ICar tesla = new Tesla(teslaINput[0], teslaINput[3], int.Parse(teslaINput[5])); List <ICar> cars = new List <ICar>(); cars.Add(seat); cars.Add(tesla); foreach (ICar car in cars) { car.Start(); car.Stop(); } }
internal void Invoke079TeslaInteract( Player player, float energyNeeded, Room room, Tesla tesla, Scp079EventMisc.InteractionResult intendedResult, out Scp079EventMisc.InteractionResult actualResult ) { var ev = new Scp079TeslaInteractEventArgs { Scp079 = player, Result = intendedResult, EnergyNeeded = energyNeeded, Room = room, Tesla = tesla }; TeslaInteract?.Invoke(ev); actualResult = ev.Result; }
public static void Main() { //var radius = int.Parse(Console.ReadLine()); //IDrawable circle = new Circle(radius); //var width = int.Parse(Console.ReadLine()); //var height = int.Parse(Console.ReadLine()); //IDrawable rect = new Rectangle(width, height); //circle.Draw(); //rect.Draw(); ICar seat = new Seat("Leon", "Grey"); ICar tesla = new Tesla("Model 3", "Red", 2); Console.WriteLine(seat.ToString()); Console.WriteLine(tesla.ToString()); var arr = new int[] { 1, 2, 3 }; var narr = arr; }
public static void Main() { JohnDoe johnDoe = new JohnDoe(firstName: "John", lastName: "Doe", socialSecurityNumber: "1234", email: "*****@*****.**", phoneNumber: "0745781254", salary: 600000); customerList.Add(johnDoe); Tesla teslaX = new Tesla(id: 0, brand: "Tesla", model: "X", color: "Red", licensePlate: "1234", price: 500000, year: 2015); carList.Add(teslaX); Tesla teslaRoadster = new Tesla(id: 1, brand: "Tesla", model: "Roadster", color: "Red", licensePlate: "1234", price: 1000000, year: 2020); carList.Add(teslaRoadster); Volvo volvoV40 = new Volvo(id: 2, brand: "Volvo", model: "V40", color: "Black", licensePlate: "4321", price: 600000, year: 2019); carList.Add(volvoV40); Ceo ceo = new Ceo(firstName: "Ceo", lastName: "Ceo", socialSecurityNumber: "19801205-1234", email: "*****@*****.**", phoneNumber: "072132132", salary: 300000, position: "CEO"); staffList.Add(ceo); bool shouldRun = true; while (shouldRun) { Clear(); WriteLine("1. List staffs"); WriteLine("2. List customers"); WriteLine("3. List cars"); WriteLine("4. Buy car"); WriteLine("5. Exit"); ConsoleKeyInfo keyPressed = ReadKey(true); Clear(); switch (keyPressed.Key) { case ConsoleKey.D1: foreach (var staff in staffList) { if (staff == null) { continue; } WriteLine("Position | Firstname | Lastname | SocialSecurityNumber"); WriteLine("---------------------------------------------------------"); WriteLine($"{staff.Position} {staff.FirstName} {staff.LastName} {staff.SocialSecurityNumber}"); ReadKey(); } break; case ConsoleKey.D2: foreach (var customer in customerList) { if (customer == null) { continue; } WriteLine("Firstname | Lastname | SocialSecurityNumber"); WriteLine("---------------------------------------------"); WriteLine($"{customer.FirstName} {customer.LastName} {customer.SocialSecurityNumber}"); ReadKey(); } break; case ConsoleKey.D3: foreach (var car in carList) { if (car == null) { continue; } WriteLine("Year | Brand | Model | License Plate | Price"); WriteLine("-------------------------------------------------"); WriteLine($"{car.Year} {car.Brand} {car.Model} {car.LicensePlate} {car.Price}"); ReadKey(); } break; case ConsoleKey.D4: WriteLine("Please enter your Social Security Number:"); SetCursorPosition(41, 0); string socialSecurityNumber = ReadLine(); foreach (var cust in customerList) { foreach (var staff in staffList) { if (cust.SocialSecurityNumber == socialSecurityNumber) { Clear(); WriteLine($"Hello {cust.FirstName} {cust.LastName}"); WriteLine($"Im {staff.FirstName} {staff.LastName} and I'm here to help you with your purchase!"); WriteLine(); WriteLine("Please enter the license plate number:"); SetCursorPosition(38, 3); string licensePlate = ReadLine(); foreach (var cars in carList) { if (cars == null) { continue; } if (cars.LicensePlate == licensePlate) { Clear(); WriteLine($"Congrats you just bought a {cars.Brand} {cars.Model}"); carList.RemoveAt(0); Thread.Sleep(2000); break; } else { Clear(); WriteLine("No vehicle got that license plate number"); Thread.Sleep(2000); break; } } } else { Clear(); WriteLine("Wrong Social Security Number / Customer dosen't exist"); Thread.Sleep(2000); break; } } } break; case ConsoleKey.D5: shouldRun = false; break; } } }
public TrackChangedArgs(Tesla tesla) { this.tesla = tesla; }
private static bool Scp079Interact(Scp079PlayerScript __instance, Command079 command, string args, GameObject target) { args ??= ""; try { if (!__instance._interactRateLimit.CanExecute(true)) { return(false); } if (!__instance.iAm079) { return(false); } string[] array = args.Split(':'); GameCore.Console.AddDebugLog("SCP079", "Command received from a client: " + command, MessageImportance.LessImportant, false); __instance.RefreshCurrentRoom(); if (!__instance.CheckInteractableLegitness(__instance.CurrentRoom, target, true)) { return(false); } DoorVariant doorVariant = null; // F you, compiler bool gotDoorVariant = target?.TryGetComponent(out doorVariant) ?? false; List <string> list = GameCore.ConfigFile.ServerConfig.GetStringList("scp079_door_blacklist") ?? new List <string>(); switch (command) { case Command079.Door: { if (AlphaWarheadController.Host.inProgress) { return(false); } if (target == null) { GameCore.Console.AddDebugLog("SCP079", "The door command requires a target.", MessageImportance.LessImportant, false); return(false); } if (!gotDoorVariant) { return(false); } if (doorVariant.TryGetComponent(out DoorNametagExtension doorNametagExtension) && list.Count > 0 && list.Contains(doorNametagExtension.GetName)) { GameCore.Console.AddDebugLog("SCP079", "Door access denied by the server.", MessageImportance.LeastImportant, false); return(false); } string text = doorVariant.RequiredPermissions.RequiredPermissions.ToString(); float manaFromLabel = __instance.GetManaFromLabel("Door Interaction " + (text.Contains(",") ? text.Split(',')[0] : text), __instance.abilities); var action = doorVariant.TargetState ? Scp079EventMisc.DoorAction.Closing : Scp079EventMisc.DoorAction.Opening; var intendedResult = manaFromLabel <= __instance.Mana ? Scp079EventMisc.InteractionResult.Allow : Scp079EventMisc.InteractionResult.NoEnergy; SynapseController.Server.Events.Scp.Scp079.Invoke079DoorInteract( __instance.gameObject.GetPlayer(), action, intendedResult, manaFromLabel, doorVariant.GetDoor(), out var actualResult ); switch (actualResult) { case Scp079EventMisc.InteractionResult.Allow: { bool targetState = doorVariant.TargetState; doorVariant.ServerInteract(ReferenceHub.GetHub(__instance.gameObject), 0); if (targetState != doorVariant.TargetState) { __instance.Mana -= manaFromLabel; __instance.AddInteractionToHistory(target, true); GameCore.Console.AddDebugLog("SCP079", "Door state changed.", MessageImportance.LeastImportant, false); return(false); } GameCore.Console.AddDebugLog("SCP079", "Door state failed to change.", MessageImportance.LeastImportant, false); return(false); } case Scp079EventMisc.InteractionResult.Disallow: { GameCore.Console.AddDebugLog("SCP079", "Door access denied by the server.", MessageImportance.LeastImportant, false); return(false); } case Scp079EventMisc.InteractionResult.NoEnergy: { GameCore.Console.AddDebugLog("SCP079", "Not enough mana.", MessageImportance.LeastImportant, false); // might wanna change __instance.Mana to 0, // the client may do another check when being told that the player has not enough mana, // resulting in realizing they do indeed have enough mana __instance.RpcNotEnoughMana(manaFromLabel, __instance.Mana); return(false); } } return(false); } case Command079.Doorlock: { if (AlphaWarheadController.Host.inProgress) { return(false); } if (target == null) { GameCore.Console.AddDebugLog("SCP079", "The door lock command requires a target.", MessageImportance.LessImportant, false); return(false); } if (doorVariant == null) { return(false); } ; if (doorVariant.TryGetComponent(out DoorNametagExtension doorNametagExtension2) && list.Count > 0 && list.Contains(doorNametagExtension2.GetName)) { GameCore.Console.AddDebugLog("SCP079", "Door access denied by the server.", MessageImportance.LeastImportant, false); return(false); } float manaFromLabel = __instance.GetManaFromLabel("Door Lock Minimum", __instance.abilities); var action = ((DoorLockReason)doorVariant.ActiveLocks).HasFlag(DoorLockReason.Regular079) ? Scp079EventMisc.DoorAction.Unlocking : Scp079EventMisc.DoorAction.Locking; Scp079EventMisc.InteractionResult intendedResult; if (action == Scp079EventMisc.DoorAction.Unlocking) { intendedResult = __instance.lockedDoors.Contains(doorVariant.netId) ? Scp079EventMisc.InteractionResult.Allow : Scp079EventMisc.InteractionResult.Disallow; } else { intendedResult = manaFromLabel <= __instance.Mana ? Scp079EventMisc.InteractionResult.Allow : Scp079EventMisc.InteractionResult.NoEnergy; } SynapseController.Server.Events.Scp.Scp079.Invoke079DoorInteract( __instance.gameObject.GetPlayer(), action, intendedResult, manaFromLabel, doorVariant.GetDoor(), out var actualResult ); switch (actualResult) { case Scp079EventMisc.InteractionResult.Allow when action == Scp079EventMisc.DoorAction.Unlocking: { if (!__instance.lockedDoors.Contains(doorVariant.netId)) { return(false); } __instance.lockedDoors.Remove(doorVariant.netId); doorVariant.ServerChangeLock(DoorLockReason.Regular079, false); return(false); } case Scp079EventMisc.InteractionResult.Allow when action == Scp079EventMisc.DoorAction.Locking: { if (!__instance.lockedDoors.Contains(doorVariant.netId)) { __instance.lockedDoors.Add(doorVariant.netId); } doorVariant.ServerChangeLock(DoorLockReason.Regular079, true); __instance.AddInteractionToHistory(doorVariant.gameObject, true); __instance.Mana -= __instance.GetManaFromLabel("Door Lock Start", __instance.abilities); return(false); } case Scp079EventMisc.InteractionResult.Disallow: { return(false); } case Scp079EventMisc.InteractionResult.NoEnergy: { // might wanna change __instance.Mana to 0, // the client may do another check when being told that the player has not enough mana, // resulting in realizing they do indeed have enough mana __instance.RpcNotEnoughMana(manaFromLabel, __instance.Mana); return(false); } } return(false); } case Command079.Speaker: { string speakerQualifiedName = __instance.CurrentRoom.transform.parent.name + "/" + __instance.CurrentRoom.name + "/Scp079Speaker"; GameObject speaker = GameObject.Find(speakerQualifiedName); float manaFromLabel = __instance.GetManaFromLabel("Speaker Start", __instance.abilities); Scp079EventMisc.InteractionResult intendedResult; if (speaker == null) { intendedResult = Scp079EventMisc.InteractionResult.Disallow; } else if (manaFromLabel * 1.5f <= __instance.Mana) { intendedResult = Scp079EventMisc.InteractionResult.Allow; } else { intendedResult = Scp079EventMisc.InteractionResult.NoEnergy; } SynapseController.Server.Events.Scp.Scp079.Invoke079SpeakerInteract( __instance.gameObject.GetPlayer(), manaFromLabel, intendedResult, out var actualResult ); switch (actualResult) { case Scp079EventMisc.InteractionResult.Allow: { __instance.Mana -= manaFromLabel; __instance.Speaker = speakerQualifiedName; __instance.AddInteractionToHistory(speaker, true); return(false); } case Scp079EventMisc.InteractionResult.Disallow: { return(false); } case Scp079EventMisc.InteractionResult.NoEnergy: { // might wanna change __instance.Mana to 0, // the client may do another check when being told that the player has not enough mana, // resulting in realizing they do indeed have enough mana __instance.RpcNotEnoughMana(manaFromLabel, __instance.Mana); return(false); } } return(false); } case Command079.StopSpeaker: __instance.Speaker = string.Empty; return(false); case Command079.ElevatorTeleport: { Synapse.Api.Logger.Get.Debug("Teleport"); float manaFromLabel = __instance.GetManaFromLabel("Elevator Teleport", __instance.abilities); if (manaFromLabel > __instance.Mana) { __instance.RpcNotEnoughMana(manaFromLabel, __instance.Mana); return(false); } Camera079 camera = null; foreach (Scp079Interactable scp079Interactable in __instance.nearbyInteractables) { if (scp079Interactable.type == Scp079Interactable.InteractableType.ElevatorTeleport) { camera = scp079Interactable.optionalObject.GetComponent <Camera079>(); } } if (camera != null) { __instance.RpcSwitchCamera(camera.cameraId, false); __instance.Mana -= manaFromLabel; __instance.AddInteractionToHistory(target, true); return(false); } if (ConsoleDebugMode.CheckImportance("SCP079", MessageImportance.LeastImportant, out Color32 color)) { Scp079Interactable scp079Interactable2 = null; Dictionary <Scp079Interactable.InteractableType, byte> dictionary = new Dictionary <Scp079Interactable.InteractableType, byte>(); foreach (Scp079Interactable scp079Interactable3 in __instance.nearbyInteractables) { if (dictionary.ContainsKey(scp079Interactable3.type)) { Dictionary <Scp079Interactable.InteractableType, byte> dictionary2 = dictionary; Scp079Interactable.InteractableType type = scp079Interactable3.type; byte b = dictionary2[type]; dictionary2[type] = (byte)(b + 1); } else { dictionary[scp079Interactable3.type] = 1; } if (scp079Interactable3.type == Scp079Interactable.InteractableType.ElevatorTeleport) { scp079Interactable2 = scp079Interactable3; } } string text2; if (scp079Interactable2 == null) { text2 = "None of the " + __instance.nearbyInteractables.Count + " were an ElevatorTeleport, found: "; using (Dictionary <Scp079Interactable.InteractableType, byte> .Enumerator enumerator2 = dictionary.GetEnumerator()) { while (enumerator2.MoveNext()) { KeyValuePair <Scp079Interactable.InteractableType, byte> keyValuePair = enumerator2.Current; text2 = string.Concat(new object[] { text2, keyValuePair.Value, "x", keyValuePair.Key.ToString().Substring(keyValuePair.Key.ToString().Length - 4), " " }); } goto IL_755; } } if (scp079Interactable2.optionalObject == null) { text2 = "Optional object is missing."; } else if (scp079Interactable2.optionalObject.GetComponent <Camera079>() == null) { string str = ""; Transform transform = scp079Interactable2.optionalObject.transform; for (int i = 0; i < 5; i++) { str = transform.name + str; if (!(transform.parent != null)) { break; } transform = transform.parent; } text2 = "Camera is missing at " + str; } else { text2 = "Unknown error"; } IL_755: GameCore.Console.AddDebugLog("SCP079", "Could not find the second elevator: " + text2, MessageImportance.LeastImportant, false); return(false); } return(false); } case Command079.ElevatorUse: { float manaFromLabel = __instance.GetManaFromLabel("Elevator Use", __instance.abilities); string elevatorName = string.Empty; if (array.Length > 0) { elevatorName = array[0]; } Elevator synElevator = Map.Get.Elevators.Find(_ => _.Name == elevatorName); Scp079EventMisc.InteractionResult intendedResult; if (manaFromLabel <= __instance.Mana) { intendedResult = Scp079EventMisc.InteractionResult.NoEnergy; } else if (synElevator == null || (AlphaWarheadController.Host.timeToDetonation == 0f || !synElevator.Operative || synElevator.Locked)) { intendedResult = Scp079EventMisc.InteractionResult.Disallow; } else { intendedResult = Scp079EventMisc.InteractionResult.Allow; } intendedResult = manaFromLabel <= __instance.Mana ? Scp079EventMisc.InteractionResult.Allow : Scp079EventMisc.InteractionResult.NoEnergy; SynapseController.Server.Events.Scp.Scp079.Invoke079ElevatorUse( __instance.gameObject.GetPlayer(), manaFromLabel, synElevator, intendedResult, out var actualResult ); switch (actualResult) { case Scp079EventMisc.InteractionResult.Allow: { if (synElevator.Use()) { __instance.Mana -= manaFromLabel; bool flag3 = false; foreach (Lift.Elevator elevator in synElevator.Lift.elevators) { __instance.AddInteractionToHistory(elevator.door.GetComponentInParent <Scp079Interactable>().gameObject, !flag3); flag3 = true; } } return(false); } case Scp079EventMisc.InteractionResult.Disallow: { return(false); } case Scp079EventMisc.InteractionResult.NoEnergy: { // might wanna change __instance.Mana to 0, // the client may do another check when being told that the player has not enough mana, // resulting in realizing they do indeed have enough mana __instance.RpcNotEnoughMana(manaFromLabel, __instance.Mana); return(false); } } return(false); } case Command079.Tesla: { float manaFromLabel = __instance.GetManaFromLabel("Tesla Gate Burst", __instance.abilities); if (__instance.CurrentRoom != null) { TeslaGate vanillaTesla = __instance.CurrentRoom.GetComponentInChildren <TeslaGate>(); Tesla synapseTesla = vanillaTesla != null?Server.Get.Map.Teslas.Find(_ => _.Gate == vanillaTesla) : null; var intendedResult = manaFromLabel <= __instance.Mana ? Scp079EventMisc.InteractionResult.Allow : Scp079EventMisc.InteractionResult.NoEnergy; SynapseController.Server.Events.Scp.Scp079.Invoke079TeslaInteract( __instance.gameObject.GetPlayer(), manaFromLabel, synapseTesla?.Room, synapseTesla, intendedResult, out var actualResult ); switch (actualResult) { case Scp079EventMisc.InteractionResult.Allow: { if (vanillaTesla != null) { vanillaTesla.RpcInstantBurst(); } __instance.AddInteractionToHistory(vanillaTesla.gameObject, true); __instance.Mana -= manaFromLabel; return(false); } case Scp079EventMisc.InteractionResult.Disallow: { return(false); } case Scp079EventMisc.InteractionResult.NoEnergy: { // might wanna change __instance.Mana to 0, // the client may do another check when being told that the player has not enough mana, // resulting in realizing they do indeed have enough mana __instance.RpcNotEnoughMana(manaFromLabel, __instance.Mana); return(false); } } return(false); } throw new Exception("Unable to find Tesla Gate in a null room"); } case Command079.Lockdown: { if (AlphaWarheadController.Host.inProgress) { GameCore.Console.AddDebugLog("SCP079", "Lockdown cannot commence, Warhead in progress.", MessageImportance.LessImportant, false); return(false); } float manaFromLabel = __instance.GetManaFromLabel("Room Lockdown", __instance.abilities); GameCore.Console.AddDebugLog("SCP079", "Attempting lockdown...", MessageImportance.LeastImportant, false); if (__instance.CurrentRoom != null) { HashSet <Scp079Interactable> roomInteractablesHashSet = Scp079Interactable.InteractablesByRoomId[__instance.CurrentRoom.UniqueId]; HashSet <DoorVariant> doorHashSet = new HashSet <DoorVariant>(); GameCore.Console.AddDebugLog("SCP079", "Loaded all interactables", MessageImportance.LeastImportant, false); GameObject lockdownInteractable = null; foreach (Scp079Interactable interactable in roomInteractablesHashSet) { if (interactable != null) { if (interactable.type != Scp079Interactable.InteractableType.Door) { if (interactable.type == Scp079Interactable.InteractableType.Lockdown) { lockdownInteractable = interactable.gameObject; } } else if (interactable.TryGetComponent(out DoorVariant doorVariant2) && (object)doorVariant2 is IDamageableDoor damageableDoor && damageableDoor.IsDestroyed) { GameCore.Console.AddDebugLog("SCP079", "Lockdown can't initiate, one of the doors were destroyed.", MessageImportance.LessImportant, false); return(false); } } } if (__instance.CurrentLDCooldown > 0f) { GameCore.Console.AddDebugLog("SCP079", "Lockdown still on cooldown.", MessageImportance.LessImportant, false); return(false); } GameCore.Console.AddDebugLog("SCP079", "Looking for doors to lock...", MessageImportance.LeastImportant, false); foreach (Scp079Interactable scp079Interactable5 in roomInteractablesHashSet) { if (!(scp079Interactable5 == null) && scp079Interactable5.TryGetComponent(out DoorVariant doorVariant3)) { bool doorLocked = doorVariant3.ActiveLocks == (ushort)DoorLockReason.None; if (!doorLocked) { DoorLockMode mode = DoorLockUtils.GetMode((DoorLockReason)doorVariant3.ActiveLocks); doorLocked = (mode.HasFlagFast(DoorLockMode.CanClose) || mode.HasFlagFast(DoorLockMode.ScpOverride)); } if (doorLocked) { if (doorVariant3.TargetState) { doorVariant3.NetworkTargetState = false; } doorVariant3.ServerChangeLock(DoorLockReason.Lockdown079, true); doorVariant3.UnlockLater(__instance.LockdownDuration, DoorLockReason.Lockdown079); doorHashSet.Add(doorVariant3); } } } var intendedResult = manaFromLabel <= __instance.Mana ? Scp079EventMisc.InteractionResult.Allow : Scp079EventMisc.InteractionResult.NoEnergy; bool lightsOut = true; SynapseController.Server.Events.Scp.Scp079.Invoke079RoomLockdown( __instance.gameObject.GetPlayer(), manaFromLabel, Server.Get.Map.Rooms.Find(_ => _.GameObject == __instance.CurrentRoom), // FIX ref lightsOut, intendedResult, out var actualResult ); switch (actualResult) { case Scp079EventMisc.InteractionResult.Allow: { foreach (FlickerableLightController flickerableLightController in __instance.CurrentRoom.GetComponentsInChildren <FlickerableLightController>()) { if (flickerableLightController != null) { flickerableLightController.ServerFlickerLights(8f); } } __instance.CurrentLDCooldown = __instance.LockdownCooldown + __instance.LockdownDuration; __instance.TargetSetLockdownCooldown(__instance.connectionToClient, __instance.CurrentLDCooldown); GameCore.Console.AddDebugLog("SCP079", "Lockdown initiated.", MessageImportance.LessImportant, false); __instance.AddInteractionToHistory(lockdownInteractable, true); __instance.Mana -= __instance.GetManaFromLabel("Room Lockdown", __instance.abilities); return(false); } case Scp079EventMisc.InteractionResult.Disallow: { return(false); } case Scp079EventMisc.InteractionResult.NoEnergy: { // might wanna change __instance.Mana to 0, // the client may do another check when being told that the player has not enough mana, // resulting in realizing they do indeed have enough mana __instance.RpcNotEnoughMana(manaFromLabel, __instance.Mana); GameCore.Console.AddDebugLog("SCP079", "Lockdown cannot commence, not enough mana.", MessageImportance.LessImportant, false); return(false); } } } else { GameCore.Console.AddDebugLog("SCP079", "Room couldn't be specified.", MessageImportance.Normal, false); } return(false); } default: return(false); } } catch (Exception e) { Synapse.Api.Logger.Get.Error($"Synapse-Event: Scp079BulkPatch failed!!\n{e}"); return(false); } }