forked from Reddit-Mud/RMUD
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathControlPanel.cs
71 lines (63 loc) · 2.56 KB
/
ControlPanel.cs
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RMUD;
namespace Space
{
public class ControlPanel : MudObject
{
public enum IndicatorState
{
green,
red
}
public IndicatorState Indicator = IndicatorState.green;
public bool Broken = false;
public static void AtStartup(RuleEngine GlobalRules)
{
GlobalRules.Check<Actor, ControlPanel>("can take?")
.Do((actor, panel) =>
{
SendMessage(actor, "I can't take it. It's firmly attached.");
return SharpRuleEngine.CheckResult.Disallow;
});
GlobalRules.Perform<Actor, ControlPanel>("describe")
.When((actor, panel) => !panel.Broken)
.Do((actor, panel) =>
{
if (panel.Location is Hatch)
{
var thisSide = FindLocale(panel) as Room;
var otherSide = Portal.FindOppositeSide(panel.Location).Location as Room;
if (thisSide != null && otherSide != null && thisSide.AirLevel == otherSide.AirLevel)
panel.Indicator = IndicatorState.green;
else
panel.Indicator = IndicatorState.red;
}
SendMessage(actor, "It's a little square panel covered in buttons. There is a <s0> light on it.", panel.Indicator.ToString());
return SharpRuleEngine.PerformResult.Continue;
});
GlobalRules.Perform<Actor, ControlPanel>("describe")
.When((actor, panel) => panel.Broken)
.Do((actor, panel) =>
{
SendMessage(actor, "It's been smashed up real good.");
return SharpRuleEngine.PerformResult.Continue;
});
GlobalRules.Perform<Player, Space.ControlPanel, MudObject>("hit with")
.When((player, panel, wrench) => wrench.GetPropertyOrDefault<Weight>("weight", Weight.Normal) == Weight.Heavy)
.Do((player, panel, wrench) =>
{
SendMessage(player, "The panel smashed up good.");
panel.Broken = true;
return SharpRuleEngine.PerformResult.Stop;
});
}
public ControlPanel()
{
SimpleName("control panel", "controls");
}
}
}