From a3595e10250fe3233bf22670f0582a438667d540 Mon Sep 17 00:00:00 2001
From: Nameless <85962933+Misfiy@users.noreply.github.com>
Date: Sun, 11 Aug 2024 10:59:58 +0200
Subject: [PATCH] Additions (#29)
* Add a bunch
* Fix
* Security
* Make changes
* remove unused usings
* Getting inventory
* oops
* Dev commit
* use exiled
---------
Co-authored-by: Yamato <66829532+louis1706@users.noreply.github.com>
---
EXILED/Exiled.API/Enums/HazardType.cs | 37 +++++++++++
.../Extensions/BitwiseExtensions.cs | 63 +++++++++++++++++++
.../Exiled.API/Extensions/RoleExtensions.cs | 23 ++++---
.../Features/Hazards/AmnesticCloudHazard.cs | 22 ++++++-
EXILED/Exiled.API/Features/Hazards/Hazard.cs | 13 ++++
.../Features/Hazards/SinkholeHazard.cs | 4 ++
.../Features/Hazards/TantrumHazard.cs | 44 +++++++++++++
EXILED/Exiled.API/Features/Map.cs | 56 +----------------
EXILED/Exiled.API/Features/Player.cs | 2 +-
EXILED/Exiled.API/Features/PrefabHelper.cs | 19 +++++-
EXILED/Exiled.API/Features/Roles/FpcRole.cs | 11 +++-
EXILED/Exiled.API/Features/Server.cs | 9 +++
EXILED/Exiled.Events/Commands/TpsCommand.cs | 46 ++++++++++++++
.../EventArgs/Player/ChangingRoleEventArgs.cs | 22 +++----
14 files changed, 290 insertions(+), 81 deletions(-)
create mode 100644 EXILED/Exiled.API/Enums/HazardType.cs
create mode 100644 EXILED/Exiled.API/Extensions/BitwiseExtensions.cs
create mode 100644 EXILED/Exiled.Events/Commands/TpsCommand.cs
diff --git a/EXILED/Exiled.API/Enums/HazardType.cs b/EXILED/Exiled.API/Enums/HazardType.cs
new file mode 100644
index 000000000..f05f8852f
--- /dev/null
+++ b/EXILED/Exiled.API/Enums/HazardType.cs
@@ -0,0 +1,37 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (c) Exiled Team. All rights reserved.
+// Licensed under the CC BY-SA 3.0 license.
+//
+// -----------------------------------------------------------------------
+
+namespace Exiled.API.Enums
+{
+ using Exiled.API.Features.Hazards;
+
+ ///
+ /// Unique identifier for a .
+ ///
+ public enum HazardType
+ {
+ ///
+ /// SCP-939 amnestic cloud.
+ ///
+ AmnesticCloud,
+
+ ///
+ /// Sinkhole spawned at start of round.
+ ///
+ Sinkhole,
+
+ ///
+ /// SCP-173 tantrum.
+ ///
+ Tantrum,
+
+ ///
+ /// Should never happen
+ ///
+ Unknown,
+ }
+}
\ No newline at end of file
diff --git a/EXILED/Exiled.API/Extensions/BitwiseExtensions.cs b/EXILED/Exiled.API/Extensions/BitwiseExtensions.cs
new file mode 100644
index 000000000..2f8473784
--- /dev/null
+++ b/EXILED/Exiled.API/Extensions/BitwiseExtensions.cs
@@ -0,0 +1,63 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (c) Exiled Team. All rights reserved.
+// Licensed under the CC BY-SA 3.0 license.
+//
+// -----------------------------------------------------------------------
+
+namespace Exiled.API.Extensions
+{
+ using System;
+
+ ///
+ /// Extensions for bitwise operations.
+ ///
+ public static class BitwiseExtensions
+ {
+ ///
+ /// Adds the specified flags to the given enum value.
+ ///
+ /// The type of the enum.
+ /// The enum value to add flags to.
+ /// The flags to add.
+ /// The enum value with the specified flags added.
+ public static T AddFlags(this T flags, params T[] newFlags)
+ where T : Enum => flags.ModifyFlags(true, newFlags);
+
+ ///
+ /// Removes the specified flags from the given enum value.
+ ///
+ /// The type of the enum.
+ /// The enum value to remove flags from.
+ /// The flags to remove.
+ /// The enum value with the specified flags removed.
+ public static T RemoveFlags(this T flags, params T[] oldFlags)
+ where T : Enum => flags.ModifyFlags(false, oldFlags);
+
+ ///
+ /// Sets the specified flag to the given value, default is true.
+ ///
+ /// The flags enum to modify.
+ /// The value to set the flag to.
+ /// The flags to modify.
+ /// The type of the enum.
+ /// The flags enum with the flag set to the given value.
+ public static T ModifyFlags(this T flags, bool value, params T[] changeFlags)
+ where T : Enum
+ {
+ long currentValue = Convert.ToInt64(flags);
+
+ foreach (T flag in changeFlags)
+ {
+ long flagValue = Convert.ToInt64(flag);
+
+ if (value)
+ currentValue |= flagValue;
+ else
+ currentValue &= ~flagValue;
+ }
+
+ return (T)Enum.ToObject(typeof(T), currentValue);
+ }
+ }
+}
\ No newline at end of file
diff --git a/EXILED/Exiled.API/Extensions/RoleExtensions.cs b/EXILED/Exiled.API/Extensions/RoleExtensions.cs
index e9186ba71..c674af1bf 100644
--- a/EXILED/Exiled.API/Extensions/RoleExtensions.cs
+++ b/EXILED/Exiled.API/Extensions/RoleExtensions.cs
@@ -140,18 +140,22 @@ public static SpawnLocation GetRandomSpawnLocation(this RoleTypeId roleType)
return null;
}
+ ///
+ /// Gets the starting of a .
+ ///
+ /// The .
+ /// The that the role receives on spawn.
+ public static InventoryRoleInfo GetInventory(this RoleTypeId role)
+ => StartingInventories.DefinedInventories.TryGetValue(role, out InventoryRoleInfo info)
+ ? info
+ : new(Array.Empty(), new());
+
///
/// Gets the starting items of a .
///
/// The .
/// An of that the role receives on spawn. Will be empty for classes that do not spawn with items.
- public static ItemType[] GetStartingInventory(this RoleTypeId roleType)
- {
- if (StartingInventories.DefinedInventories.TryGetValue(roleType, out InventoryRoleInfo info))
- return info.Items;
-
- return Array.Empty();
- }
+ public static ItemType[] GetStartingInventory(this RoleTypeId roleType) => GetInventory(roleType).Items;
///
/// Gets the starting ammo of a .
@@ -160,10 +164,9 @@ public static ItemType[] GetStartingInventory(this RoleTypeId roleType)
/// An of that the role receives on spawn. Will be empty for classes that do not spawn with ammo.
public static Dictionary GetStartingAmmo(this RoleTypeId roleType)
{
- if (StartingInventories.DefinedInventories.TryGetValue(roleType, out InventoryRoleInfo info))
- return info.Ammo.ToDictionary(kvp => kvp.Key.GetAmmoType(), kvp => kvp.Value);
+ InventoryRoleInfo info = roleType.GetInventory();
- return new();
+ return info.Ammo.ToDictionary(kvp => kvp.Key.GetAmmoType(), kvp => kvp.Value);
}
}
}
\ No newline at end of file
diff --git a/EXILED/Exiled.API/Features/Hazards/AmnesticCloudHazard.cs b/EXILED/Exiled.API/Features/Hazards/AmnesticCloudHazard.cs
index c385c143f..31c9ad244 100644
--- a/EXILED/Exiled.API/Features/Hazards/AmnesticCloudHazard.cs
+++ b/EXILED/Exiled.API/Features/Hazards/AmnesticCloudHazard.cs
@@ -3,10 +3,11 @@
// Copyright (c) Exiled Team. All rights reserved.
// Licensed under the CC BY-SA 3.0 license.
//
-// -----------------------------------------------------------------------
+// ------------------------------------------------------------------------
namespace Exiled.API.Features.Hazards
{
+ using Exiled.API.Enums;
using PlayerRoles.PlayableScps.Scp939;
///
@@ -14,6 +15,8 @@ namespace Exiled.API.Features.Hazards
///
public class AmnesticCloudHazard : TemporaryHazard
{
+ private static Scp939AmnesticCloudInstance amnesticCloudPrefab;
+
///
/// Initializes a new instance of the class.
///
@@ -26,9 +29,26 @@ public AmnesticCloudHazard(Scp939AmnesticCloudInstance hazard)
Owner = Player.Get(Ability.Owner);
}
+ ///
+ /// Gets the amnestic cloud prefab.
+ ///
+ public static Scp939AmnesticCloudInstance AmnesticCloudPrefab
+ {
+ get
+ {
+ if (amnesticCloudPrefab == null)
+ amnesticCloudPrefab = PrefabHelper.GetPrefab(PrefabType.AmnesticCloudHazard);
+
+ return amnesticCloudPrefab;
+ }
+ }
+
///
public new Scp939AmnesticCloudInstance Base { get; }
+ ///
+ public override HazardType Type => HazardType.AmnesticCloud;
+
///
/// Gets the for this instance.
///
diff --git a/EXILED/Exiled.API/Features/Hazards/Hazard.cs b/EXILED/Exiled.API/Features/Hazards/Hazard.cs
index 253825530..09bd880d3 100644
--- a/EXILED/Exiled.API/Features/Hazards/Hazard.cs
+++ b/EXILED/Exiled.API/Features/Hazards/Hazard.cs
@@ -11,6 +11,7 @@ namespace Exiled.API.Features.Hazards
using System.Collections.Generic;
using System.Linq;
+ using Exiled.API.Enums;
using Exiled.API.Features.Core;
using Exiled.API.Interfaces;
using global::Hazards;
@@ -48,6 +49,11 @@ public Hazard(EnvironmentalHazard hazard)
///
public EnvironmentalHazard Base { get; }
+ ///
+ /// Gets the associated with the current Hazard.
+ ///
+ public virtual HazardType Type { get; } = HazardType.Unknown;
+
///
/// Gets or sets the list with all affected by this hazard players.
///
@@ -153,6 +159,13 @@ public static T Get(EnvironmentalHazard environmentalHazard)
/// of based on predicate.
public static IEnumerable Get(Func predicate) => List.Where(predicate);
+ ///
+ /// Gets an of .
+ ///
+ /// The to get.
+ /// of based on type.
+ public static IEnumerable Get(HazardType type) => Get(h => h.Type == type);
+
///
/// Checks if player is in hazard zone.
///
diff --git a/EXILED/Exiled.API/Features/Hazards/SinkholeHazard.cs b/EXILED/Exiled.API/Features/Hazards/SinkholeHazard.cs
index e8e0c4f3a..34cbaacd5 100644
--- a/EXILED/Exiled.API/Features/Hazards/SinkholeHazard.cs
+++ b/EXILED/Exiled.API/Features/Hazards/SinkholeHazard.cs
@@ -7,6 +7,7 @@
namespace Exiled.API.Features.Hazards
{
+ using Exiled.API.Enums;
using global::Hazards;
///
@@ -28,5 +29,8 @@ public SinkholeHazard(SinkholeEnvironmentalHazard hazard)
/// Gets the .
///
public new SinkholeEnvironmentalHazard Base { get; }
+
+ ///
+ public override HazardType Type => HazardType.Sinkhole;
}
}
\ No newline at end of file
diff --git a/EXILED/Exiled.API/Features/Hazards/TantrumHazard.cs b/EXILED/Exiled.API/Features/Hazards/TantrumHazard.cs
index 15f54b5ac..906bd4faf 100644
--- a/EXILED/Exiled.API/Features/Hazards/TantrumHazard.cs
+++ b/EXILED/Exiled.API/Features/Hazards/TantrumHazard.cs
@@ -7,7 +7,9 @@
namespace Exiled.API.Features.Hazards
{
+ using Exiled.API.Enums;
using global::Hazards;
+ using Mirror;
using RelativePositioning;
using UnityEngine;
@@ -16,6 +18,8 @@ namespace Exiled.API.Features.Hazards
///
public class TantrumHazard : TemporaryHazard
{
+ private static TantrumEnvironmentalHazard tantrumPrefab;
+
///
/// Initializes a new instance of the class.
///
@@ -26,11 +30,28 @@ public TantrumHazard(TantrumEnvironmentalHazard hazard)
Base = hazard;
}
+ ///
+ /// Gets the tantrum prefab.
+ ///
+ public static TantrumEnvironmentalHazard TantrumPrefab
+ {
+ get
+ {
+ if (tantrumPrefab == null)
+ tantrumPrefab = PrefabHelper.GetPrefab(PrefabType.TantrumObj);
+
+ return tantrumPrefab;
+ }
+ }
+
///
/// Gets the .
///
public new TantrumEnvironmentalHazard Base { get; }
+ ///
+ public override HazardType Type => HazardType.Tantrum;
+
///
/// Gets or sets a value indicating whether or not sizzle should be played.
///
@@ -57,5 +78,28 @@ public Transform CorrectPosition
get => Base._correctPosition;
set => Base._correctPosition = value;
}
+
+ ///
+ /// Places a Tantrum (SCP-173's ability) in the indicated position.
+ ///
+ /// The position where you want to spawn the Tantrum.
+ /// Whether or not the tantrum will apply the effect.
+ /// If is , the tantrum is moved slightly up from its original position. Otherwise, the collision will not be detected and the slowness will not work.
+ /// The instance.
+ public static TantrumHazard PlaceTantrum(Vector3 position, bool isActive = true)
+ {
+ TantrumEnvironmentalHazard tantrum = Object.Instantiate(TantrumPrefab);
+
+ if (!isActive)
+ tantrum.SynchronizedPosition = new(position);
+ else
+ tantrum.SynchronizedPosition = new(position + (Vector3.up * 0.25f));
+
+ tantrum._destroyed = !isActive;
+
+ NetworkServer.Spawn(tantrum.gameObject);
+
+ return Get(tantrum);
+ }
}
}
\ No newline at end of file
diff --git a/EXILED/Exiled.API/Features/Map.cs b/EXILED/Exiled.API/Features/Map.cs
index 4e8f2b094..3f1f6fc1a 100644
--- a/EXILED/Exiled.API/Features/Map.cs
+++ b/EXILED/Exiled.API/Features/Map.cs
@@ -28,9 +28,6 @@ namespace Exiled.API.Features
using LightContainmentZoneDecontamination;
using MapGeneration;
using MapGeneration.Distributors;
- using Mirror;
- using PlayerRoles;
- using PlayerRoles.PlayableScps.Scp173;
using PlayerRoles.PlayableScps.Scp939;
using PlayerRoles.Ragdolls;
using RelativePositioning;
@@ -39,8 +36,6 @@ namespace Exiled.API.Features
using Utils.Networking;
using Object = UnityEngine.Object;
- using Scp173GameRole = PlayerRoles.PlayableScps.Scp173.Scp173Role;
- using Scp939GameRole = PlayerRoles.PlayableScps.Scp939.Scp939Role;
///
/// A set of tools to easily handle the in-game map.
@@ -57,48 +52,17 @@ public static class Map
///
internal static readonly List TeleportsValue = new(8);
- private static TantrumEnvironmentalHazard tantrumPrefab;
- private static Scp939AmnesticCloudInstance amnesticCloudPrefab;
-
private static AmbientSoundPlayer ambientSoundPlayer;
///
/// Gets the tantrum prefab.
///
- public static TantrumEnvironmentalHazard TantrumPrefab
- {
- get
- {
- if (tantrumPrefab == null)
- {
- Scp173GameRole scp173Role = (Scp173GameRole)RoleTypeId.Scp173.GetRoleBase();
-
- if (scp173Role.SubroutineModule.TryGetSubroutine(out Scp173TantrumAbility scp173TantrumAbility))
- tantrumPrefab = scp173TantrumAbility._tantrumPrefab;
- }
-
- return tantrumPrefab;
- }
- }
+ public static TantrumEnvironmentalHazard TantrumPrefab => TantrumHazard.TantrumPrefab; // TODO: Remove this.
///
/// Gets the amnestic cloud prefab.
///
- public static Scp939AmnesticCloudInstance AmnesticCloudPrefab
- {
- get
- {
- if (amnesticCloudPrefab == null)
- {
- Scp939GameRole scp939Role = (Scp939GameRole)RoleTypeId.Scp939.GetRoleBase();
-
- if (scp939Role.SubroutineModule.TryGetSubroutine(out Scp939AmnesticCloudAbility ability))
- amnesticCloudPrefab = ability._instancePrefab;
- }
-
- return amnesticCloudPrefab;
- }
- }
+ public static Scp939AmnesticCloudInstance AmnesticCloudPrefab => AmnesticCloudHazard.AmnesticCloudPrefab; // TODO: Remove this.
///
/// Gets a value indicating whether decontamination has begun in the light containment zone.
@@ -281,21 +245,7 @@ public static void PlayAmbientSound(int id)
/// Whether or not the tantrum will apply the effect.
/// If is , the tantrum is moved slightly up from its original position. Otherwise, the collision will not be detected and the slowness will not work.
/// The instance.
- public static TantrumHazard PlaceTantrum(Vector3 position, bool isActive = true)
- {
- TantrumEnvironmentalHazard tantrum = Object.Instantiate(TantrumPrefab);
-
- if (!isActive)
- tantrum.SynchronizedPosition = new RelativePosition(position);
- else
- tantrum.SynchronizedPosition = new RelativePosition(position + (Vector3.up * 0.25f));
-
- tantrum._destroyed = !isActive;
-
- NetworkServer.Spawn(tantrum.gameObject);
-
- return Hazard.Get(tantrum);
- }
+ public static TantrumHazard PlaceTantrum(Vector3 position, bool isActive = true) => TantrumHazard.PlaceTantrum(position, isActive); // TODO: Remove this.
///
/// Destroy all objects.
diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs
index 0a0b6c83e..0885000f7 100644
--- a/EXILED/Exiled.API/Features/Player.cs
+++ b/EXILED/Exiled.API/Features/Player.cs
@@ -3406,7 +3406,7 @@ public void ChangeEffectIntensity(string effectName, byte intensity, float durat
/// Whether or not the tantrum will apply the effect.
/// If is , the tantrum is moved slightly up from its original position. Otherwise, the collision will not be detected and the slowness will not work.
/// The instance..
- public TantrumHazard PlaceTantrum(bool isActive = true) => Map.PlaceTantrum(Position, isActive);
+ public TantrumHazard PlaceTantrum(bool isActive = true) => TantrumHazard.PlaceTantrum(Position, isActive);
///
/// Gives a new to the player.
diff --git a/EXILED/Exiled.API/Features/PrefabHelper.cs b/EXILED/Exiled.API/Features/PrefabHelper.cs
index de97e15d5..fd18e9fe9 100644
--- a/EXILED/Exiled.API/Features/PrefabHelper.cs
+++ b/EXILED/Exiled.API/Features/PrefabHelper.cs
@@ -41,6 +41,21 @@ public static PrefabAttribute GetPrefabAttribute(this PrefabType prefabType)
return type.GetField(Enum.GetName(type, prefabType)).GetCustomAttribute();
}
+ ///
+ /// Gets the prefab of the specified .
+ ///
+ /// The to get prefab of.
+ /// The to get.
+ /// Returns the prefab component as {T}.
+ public static T GetPrefab(PrefabType type)
+ where T : Component
+ {
+ if (!Stored.TryGetValue(type, out GameObject gameObject) || !gameObject.TryGetComponent(out T component))
+ return null;
+
+ return component;
+ }
+
///
/// Spawns a prefab on server.
///
@@ -68,9 +83,7 @@ public static GameObject Spawn(PrefabType prefabType, Vector3 position = default
public static T Spawn(PrefabType prefabType, Vector3 position = default, Quaternion rotation = default)
where T : Component
{
- if (!Stored.TryGetValue(prefabType, out GameObject gameObject) || !gameObject.TryGetComponent(out T component))
- return null;
- T obj = UnityEngine.Object.Instantiate(component, position, rotation);
+ T obj = UnityEngine.Object.Instantiate(GetPrefab(prefabType), position, rotation);
NetworkServer.Spawn(obj.gameObject);
return obj;
}
diff --git a/EXILED/Exiled.API/Features/Roles/FpcRole.cs b/EXILED/Exiled.API/Features/Roles/FpcRole.cs
index dcf4e27cb..4ca71d8c8 100644
--- a/EXILED/Exiled.API/Features/Roles/FpcRole.cs
+++ b/EXILED/Exiled.API/Features/Roles/FpcRole.cs
@@ -50,9 +50,18 @@ protected FpcRole(FpcStandardRoleBase baseRole)
public FpcStandardRoleBase FirstPersonController { get; }
///
- /// Gets or sets the player's relative position.
+ /// Gets or sets the player's relative position as perceived by the server.
///
public RelativePosition RelativePosition
+ {
+ get => new(Owner.Position);
+ set => Owner.Position = value.Position;
+ }
+
+ ///
+ /// Gets or sets the player's relative position as perceived by the client.
+ ///
+ public RelativePosition ClientRelativePosition
{
get => FirstPersonController.FpcModule.Motor.ReceivedPosition;
set => FirstPersonController.FpcModule.Motor.ReceivedPosition = value;
diff --git a/EXILED/Exiled.API/Features/Server.cs b/EXILED/Exiled.API/Features/Server.cs
index 908096434..b1b05e8c1 100644
--- a/EXILED/Exiled.API/Features/Server.cs
+++ b/EXILED/Exiled.API/Features/Server.cs
@@ -111,6 +111,15 @@ public static string Name
///
public static double Tps => Math.Round(1f / Time.smoothDeltaTime);
+ ///
+ /// Gets or sets the max ticks per second of the server.
+ ///
+ public static short MaxTps
+ {
+ get => ServerStatic.ServerTickrate;
+ set => ServerStatic.ServerTickrate = value;
+ }
+
///
/// Gets the actual frametime of the server.
///
diff --git a/EXILED/Exiled.Events/Commands/TpsCommand.cs b/EXILED/Exiled.Events/Commands/TpsCommand.cs
new file mode 100644
index 000000000..2d7412919
--- /dev/null
+++ b/EXILED/Exiled.Events/Commands/TpsCommand.cs
@@ -0,0 +1,46 @@
+// -----------------------------------------------------------------------
+//
+// Copyright (c) Exiled Team. All rights reserved.
+// Licensed under the CC BY-SA 3.0 license.
+//
+// -----------------------------------------------------------------------
+
+namespace Exiled.Events.Commands
+{
+ using System;
+
+ using CommandSystem;
+ using Exiled.API.Features;
+
+ ///
+ /// Command for showing current server TPS.
+ ///
+ [CommandHandler(typeof(RemoteAdminCommandHandler))]
+ [CommandHandler(typeof(GameConsoleCommandHandler))]
+ public class TpsCommand : ICommand
+ {
+ ///
+ public string Command { get; } = "tps";
+
+ ///
+ public string[] Aliases { get; } = Array.Empty();
+
+ ///
+ public string Description { get; } = "Shows the current TPS of the server";
+
+ ///
+ public bool Execute(ArraySegment arguments, ICommandSender sender, out string response)
+ {
+ double diff = Server.Tps / Server.MaxTps;
+ string color = diff switch
+ {
+ > 0.9 => "green",
+ > 0.5 => "yellow",
+ _ => "red"
+ };
+
+ response = $"{Server.Tps}/{Server.MaxTps}";
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/EXILED/Exiled.Events/EventArgs/Player/ChangingRoleEventArgs.cs b/EXILED/Exiled.Events/EventArgs/Player/ChangingRoleEventArgs.cs
index 552d70a73..c8ab4d9ba 100644
--- a/EXILED/Exiled.Events/EventArgs/Player/ChangingRoleEventArgs.cs
+++ b/EXILED/Exiled.Events/EventArgs/Player/ChangingRoleEventArgs.cs
@@ -11,11 +11,10 @@ namespace Exiled.Events.EventArgs.Player
using API.Enums;
using API.Features;
+ using Exiled.API.Extensions;
using Exiled.API.Features.Pools;
using Interfaces;
-
- using InventorySystem.Configs;
-
+ using InventorySystem;
using PlayerRoles;
///
@@ -70,17 +69,16 @@ public RoleTypeId NewRole
get => newRole;
set
{
- if (StartingInventories.DefinedInventories.ContainsKey(value))
- {
- Items.Clear();
- Ammo.Clear();
+ InventoryRoleInfo inventory = value.GetInventory();
+
+ Items.Clear();
+ Ammo.Clear();
- foreach (ItemType itemType in StartingInventories.DefinedInventories[value].Items)
- Items.Add(itemType);
+ foreach (ItemType itemType in inventory.Items)
+ Items.Add(itemType);
- foreach (KeyValuePair ammoPair in StartingInventories.DefinedInventories[value].Ammo)
- Ammo.Add(ammoPair.Key, ammoPair.Value);
- }
+ foreach (KeyValuePair ammoPair in inventory.Ammo)
+ Ammo.Add(ammoPair.Key, ammoPair.Value);
newRole = value;
}