forked from PerpetuumOnline/PerpetuumServer
-
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathEquipModule.cs
More file actions
32 lines (27 loc) · 1.3 KB
/
EquipModule.cs
File metadata and controls
32 lines (27 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using Perpetuum.Containers;
using Perpetuum.Host.Requests;
using Perpetuum.Items;
using Perpetuum.Modules;
using Perpetuum.Players;
using Perpetuum.Robots;
namespace Perpetuum.RequestHandlers.Zone.Containers
{
public class EquipModule : ZoneChangeModule
{
public override void DoChange(IZoneRequest request, Player player, Container container)
{
RobotComponentType componentType = request.Data.GetOrDefault<string>(k.robotComponent).ToEnum<RobotComponentType>();
RobotComponent component = player.GetRobotComponentOrThrow(componentType);
int slot = request.Data.GetOrDefault<int>(k.slot);
component.GetModule(slot).ThrowIfNotNull(ErrorCodes.UsedSlot); //OPP: explicitly prohibit this to make this simpler
// component.MakeSlotFree(slot, container); // Big nope
long moduleEid = request.Data.GetOrDefault<long>(k.moduleEID);
Module module = (Module)container.GetItemOrThrow(moduleEid).Unstack(1);
module.CheckEnablerExtensionsAndThrowIfFailed(player.Character);
//Perform pre-fit check for fitting legality
player.CheckEnergySystemAndThrowIfFailed(module);
Robot robot = player;
component.EquipModuleOrThrow(module, slot, robot.Definition);
}
}
}