Client LuaCsForBarotrauma
CheckMoneyAction.cs
1
using
Barotrauma
.
Networking
;
2
using
System.Collections.Generic;
3
using
System.Linq;
4
5
namespace
Barotrauma
6
{
10
class
CheckMoneyAction
:
BinaryOptionAction
11
{
12
[
Serialize
(0,
IsPropertySaveable
.Yes, description:
"Minimum amount of money the crew or the player must have."
)]
13
public
int
Amount
{
get
;
set
; }
14
15
[
Serialize
(
""
,
IsPropertySaveable
.Yes, description:
"Tag of the player to check. If omitted, the crew's shared wallet is checked instead."
)]
16
public
Identifier
TargetTag
{
get
;
set
; }
17
18
public
CheckMoneyAction
(
ScriptedEvent
parentEvent,
ContentXElement
element) : base(parentEvent, element)
19
{
20
}
21
22
protected
override
bool
?
DetermineSuccess
()
23
{
24
Client
matchingClient =
null
;
25
bool
hasTag = !
TargetTag
.IsEmpty;
26
#if SERVER
27
IEnumerable<Entity> targets =
ParentEvent
.
GetTargets
(
TargetTag
);
28
29
if
(hasTag)
30
{
31
foreach
(
Entity
entity
in
targets)
32
{
33
if
(entity is
Character
&&
GameMain
.Server?.ConnectedClients.FirstOrDefault(c => c.Character == entity) is { } matchingCharacter)
34
{
35
matchingClient = matchingCharacter;
36
break
;
37
}
38
}
39
}
40
#endif
41
42
if
(
GameMain
.
GameSession
?.
GameMode
is
CampaignMode
campaign)
43
{
44
return
!hasTag ? campaign.Bank.CanAfford(
Amount
) : campaign.GetWallet(matchingClient).CanAfford(
Amount
);
45
}
46
return
false
;
47
}
48
49
public
override
string
ToDebugString
()
50
{
51
string
subActionStr =
""
;
52
if
(
succeeded
.HasValue)
53
{
54
subActionStr = $
"\n Sub action: {(succeeded.Value ? Success : Failure)?.CurrentSubAction.ColorizeObject()}"
;
55
}
56
return
$
"{ToolBox.GetDebugSymbol(DetermineFinished())} {nameof(CheckMoneyAction)} -> (Amount: {Amount.ColorizeObject()}"
+
57
$
" Succeeded: {(succeeded.HasValue ? succeeded.Value.ToString() : "
not determined
").ColorizeObject()})"
+
58
subActionStr;
59
}
60
}
61
}
Barotrauma.BinaryOptionAction
Definition:
BinaryOptionAction.cs:8
Barotrauma.BinaryOptionAction.succeeded
bool? succeeded
Definition:
BinaryOptionAction.cs:11
Barotrauma.CampaignMode
Definition:
BarotraumaShared/SharedSource/GameSession/GameModes/CampaignMode.cs:15
Barotrauma.Character
Definition:
BarotraumaShared/SharedSource/Characters/Character.cs:32
Barotrauma.CheckMoneyAction
Check whether the crew or a specific player has enough money.
Definition:
CheckMoneyAction.cs:11
Barotrauma.CheckMoneyAction.ToDebugString
override string ToDebugString()
Rich test to display in debugdraw
Definition:
CheckMoneyAction.cs:49
Barotrauma.CheckMoneyAction.TargetTag
Identifier TargetTag
Definition:
CheckMoneyAction.cs:16
Barotrauma.CheckMoneyAction.DetermineSuccess
override? bool DetermineSuccess()
Definition:
CheckMoneyAction.cs:22
Barotrauma.CheckMoneyAction.Amount
int Amount
Definition:
CheckMoneyAction.cs:13
Barotrauma.CheckMoneyAction.CheckMoneyAction
CheckMoneyAction(ScriptedEvent parentEvent, ContentXElement element)
Definition:
CheckMoneyAction.cs:18
Barotrauma.ContentXElement
Definition:
ContentXElement.cs:13
Barotrauma.Entity
Definition:
Entity.cs:13
Barotrauma.EventAction.ParentEvent
readonly ScriptedEvent ParentEvent
Definition:
EventAction.cs:106
Barotrauma.GameMain
Definition:
GameMain.cs:25
Barotrauma.GameMain.GameSession
static GameSession?? GameSession
Definition:
GameMain.cs:88
Barotrauma.GameSession.GameMode
GameMode? GameMode
Definition:
BarotraumaShared/SharedSource/GameSession/GameSession.cs:71
Barotrauma.Networking.Client
Definition:
LuaBarotraumaAdditions.cs:11
Barotrauma.ScriptedEvent
Definition:
ScriptedEvent.cs:9
Barotrauma.ScriptedEvent.GetTargets
IEnumerable< Entity > GetTargets(Identifier tag)
Definition:
ScriptedEvent.cs:300
Barotrauma.Serialize
Definition:
SerializableProperty.cs:23
Barotrauma.Networking
Definition:
LuaBarotraumaAdditions.cs:9
Barotrauma
Definition:
AchievementManager.cs:12
Barotrauma.IsPropertySaveable
IsPropertySaveable
Definition:
SerializableProperty.cs:16
Barotrauma
BarotraumaShared
SharedSource
Events
EventActions
CheckMoneyAction.cs
Generated by
1.9.1