Skip to content

Commit 4678d62

Browse files
Merge pull request #4 from KrzychuWarrior/main
Some new methods
2 parents efbe30d + 6a60e87 commit 4678d62

File tree

8 files changed

+222
-2
lines changed

8 files changed

+222
-2
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using Interactables.Interobjects.DoorUtils;
2+
using LabApi.Features.Wrappers;
3+
using SER.ArgumentSystem.Arguments;
4+
using SER.ArgumentSystem.BaseArguments;
5+
using SER.MethodSystem.BaseMethods;
6+
7+
namespace SER.MethodSystem.Methods.DoorMethods;
8+
internal class BreakDoorMethod : SynchronousMethod
9+
{
10+
public override string Description => "Breaks specified doors if possible (for example, you can't destroy Gate B, but you can destroy normal HCZ doors)";
11+
12+
public override Argument[] ExpectedArguments =>
13+
[
14+
new DoorsArgument("doors")
15+
{
16+
Description="Doors to break"
17+
},
18+
new EnumArgument<DoorDamageType>("doordamagetype")
19+
{
20+
DefaultValue = DoorDamageType.ServerCommand,
21+
Description = "Type of damage to be applied on doors"
22+
}
23+
];
24+
25+
public override void Execute()
26+
{
27+
Door[] doors = Args.GetDoors("doors");
28+
foreach(Door door in doors)
29+
{
30+
if(door is BreakableDoor Brek)
31+
{
32+
Brek.TryBreak();
33+
}
34+
}
35+
}
36+
}

MethodSystem/Methods/DoorMethods/DoorInfoMethod.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using Interactables.Interobjects.DoorUtils;
23
using LabApi.Features.Enums;
34
using LabApi.Features.Wrappers;
45
using SER.ArgumentSystem.Arguments;
@@ -14,7 +15,7 @@ namespace SER.MethodSystem.Methods.DoorMethods;
1415
public class DoorInfoMethod : LiteralValueReturningMethod, IReferenceResolvingMethod
1516
{
1617
public Type ReferenceType => typeof(Door);
17-
public override Type[] LiteralReturnTypes => [typeof(TextValue), typeof(BoolValue)];
18+
public override Type[] LiteralReturnTypes => [typeof(TextValue), typeof(BoolValue), typeof(NumberValue)];
1819

1920
public override string Description => null!;
2021

@@ -27,7 +28,11 @@ public class DoorInfoMethod : LiteralValueReturningMethod, IReferenceResolvingMe
2728
"isLocked",
2829
"isUnlocked",
2930
Option.Enum<DoorName>("name"),
30-
"unityName")
31+
"unityName",
32+
"remainingHealth",
33+
"maxHealth",
34+
Option.Enum<DoorPermissionFlags>("permissions")
35+
)
3136
];
3237

3338
public override void Execute()
@@ -43,6 +48,9 @@ public override void Execute()
4348
"isclosed" => new BoolValue(!door.IsOpened),
4449
"islocked" => new BoolValue(door.IsLocked),
4550
"isunlocked" => new BoolValue(!door.IsLocked),
51+
"remaininghealth" => new NumberValue(door is BreakableDoor bDoor ? (decimal)bDoor.Health : -1),
52+
"maxhealth" => new NumberValue(door is BreakableDoor bDoor ? (decimal)bDoor.MaxHealth : -1),
53+
"permissions" => new TextValue(door.Permissions.ToString()),
4654
_ => throw new AndrzejFuckedUpException()
4755
};
4856
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using LabApi.Features.Wrappers;
2+
using SER.ArgumentSystem.Arguments;
3+
using SER.ArgumentSystem.BaseArguments;
4+
using SER.MethodSystem.BaseMethods;
5+
6+
namespace SER.MethodSystem.Methods.DoorMethods;
7+
public class RepairDoorMethod : SynchronousMethod
8+
{
9+
public override string Description => "Repairs specified doors if possible (for example, you can't repair Gate B, but you can repair normal HCZ doors)";
10+
11+
public override Argument[] ExpectedArguments =>
12+
[
13+
new DoorsArgument("doors")
14+
{
15+
Description="Doors to repair"
16+
}
17+
];
18+
19+
public override void Execute()
20+
{
21+
Door[] doors = Args.GetDoors("doors");
22+
foreach(Door door in doors)
23+
{
24+
if(door is BreakableDoor brek)
25+
{
26+
brek.TryRepair();
27+
}
28+
}
29+
}
30+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using LabApi.Features.Wrappers;
2+
using SER.ArgumentSystem.Arguments;
3+
using SER.ArgumentSystem.BaseArguments;
4+
using SER.MethodSystem.BaseMethods;
5+
6+
namespace SER.MethodSystem.Methods.DoorMethods;
7+
public class SetDoorHealthMethod : SynchronousMethod
8+
{
9+
public override string Description => "Sets remaining health for specified doors if possible (for example, you can't set health for Gate B, but you can set health for normal HCZ doors)";
10+
11+
public override Argument[] ExpectedArguments =>
12+
[
13+
new DoorsArgument("doors"),
14+
new FloatArgument("health")
15+
];
16+
17+
public override void Execute()
18+
{
19+
float HP = Args.GetFloat("health");
20+
Door[] doors = Args.GetDoors("doors");
21+
foreach(Door door in doors)
22+
{
23+
if(door is BreakableDoor brek)
24+
{
25+
brek.Health = HP;
26+
}
27+
}
28+
}
29+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Interactables.Interobjects.DoorUtils;
2+
using LabApi.Features.Wrappers;
3+
using SER.ArgumentSystem.Arguments;
4+
using SER.ArgumentSystem.BaseArguments;
5+
using SER.MethodSystem.BaseMethods;
6+
7+
namespace SER.MethodSystem.Methods.DoorMethods;
8+
public class SetDoorMaxHealthMethod : SynchronousMethod
9+
{
10+
public override string Description => "Sets max health for specified doors if possible";
11+
12+
public override Argument[] ExpectedArguments =>
13+
[
14+
new DoorsArgument("doors"),
15+
new FloatArgument("maxhealth")
16+
];
17+
18+
public override void Execute()
19+
{
20+
float MaxHP = Args.GetFloat("maxhealth");
21+
Door[] doors = Args.GetDoors("doors");
22+
foreach (Door door in doors)
23+
{
24+
if (door is BreakableDoor brek)
25+
{
26+
brek.MaxHealth = MaxHP;
27+
}
28+
}
29+
}
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using LabApi.Features.Wrappers;
2+
using SER.ArgumentSystem.Arguments;
3+
using SER.ArgumentSystem.BaseArguments;
4+
using SER.MethodSystem.BaseMethods;
5+
using System.Collections.Generic;
6+
7+
namespace SER.MethodSystem.Methods.PlayerMethods;
8+
public class SetDisplayNameMethod : SynchronousMethod
9+
{
10+
public override string Description => "Sets display name for specified players";
11+
12+
public override Argument[] ExpectedArguments =>
13+
[
14+
new PlayersArgument("players"),
15+
new TextArgument("displayname")
16+
{
17+
Description = "Leave empty quotes if you want to remove display name from players"
18+
}
19+
];
20+
21+
public override void Execute()
22+
{
23+
string disp = Args.GetText("displayname");
24+
List<Player> pls = Args.GetPlayers("players");
25+
foreach(Player p in pls)
26+
{
27+
p.DisplayName = disp;
28+
}
29+
}
30+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using LabApi.Features.Wrappers;
2+
using PlayerRoles.FirstPersonControl.Thirdperson.Subcontrollers;
3+
using SER.ArgumentSystem.Arguments;
4+
using SER.ArgumentSystem.BaseArguments;
5+
using SER.MethodSystem.BaseMethods;
6+
using System.Collections.Generic;
7+
8+
namespace SER.MethodSystem.Methods.PlayerMethods;
9+
public class SetEmoteMethod : SynchronousMethod
10+
{
11+
public override string Description => "Sets emotion for specified players";
12+
13+
public override Argument[] ExpectedArguments => [
14+
new PlayersArgument("players"),
15+
new EnumArgument<EmotionPresetType>("emotion")
16+
17+
];
18+
19+
public override void Execute()
20+
{
21+
EmotionPresetType emo = Args.GetEnum<EmotionPresetType>("emotion");
22+
List<Player> pls = Args.GetPlayers("players");
23+
foreach(Player p in pls)
24+
{
25+
p.Emotion = emo;
26+
}
27+
}
28+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using LabApi.Features.Wrappers;
2+
using SER.ArgumentSystem.Arguments;
3+
using SER.ArgumentSystem.BaseArguments;
4+
using SER.MethodSystem.BaseMethods;
5+
using System.Collections.Generic;
6+
7+
namespace SER.MethodSystem.Methods.PlayerMethods;
8+
public class SetInfoAreaMethod : SynchronousMethod
9+
{
10+
public override string Description => "Sets InfoArea for specified players";
11+
12+
public override Argument[] ExpectedArguments => [
13+
new PlayersArgument("players"),
14+
new EnumArgument<PlayerInfoArea>("infoarea")
15+
{
16+
ConsumesRemainingValues = true,
17+
}
18+
];
19+
20+
public override void Execute()
21+
{
22+
List<Player> pls = Args.GetPlayers("players");
23+
PlayerInfoArea area = Args.GetEnum<PlayerInfoArea>("infoarea");
24+
foreach(Player p in pls)
25+
{
26+
p.InfoArea = area;
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)