Client LuaCsForBarotrauma
GiveExpAction.cs
1
using
System.Linq;
2
3
namespace
Barotrauma
4
{
8
class
GiveExpAction
:
EventAction
9
{
10
[
Serialize
(0,
IsPropertySaveable
.Yes, description:
"The amount of experience to give. Cannot be negative."
)]
11
public
int
Amount
{
get
;
set
; }
12
13
[
Serialize
(
""
,
IsPropertySaveable
.Yes, description:
"Tag of the character(s) to give the experience to."
)]
14
public
Identifier
TargetTag
{
get
;
set
; }
15
16
public
GiveExpAction
(
ScriptedEvent
parentEvent,
ContentXElement
element) : base(parentEvent, element)
17
{
18
if
(
TargetTag
.IsEmpty)
19
{
20
DebugConsole.ThrowError($
"Error in event \"{parentEvent.Prefab.Identifier}\": {nameof(GiveExpAction)} without a target tag (the action needs to know whose skill to check)."
,
21
contentPackage: element.
ContentPackage
);
22
}
23
}
24
25
private
bool
isFinished =
false
;
26
27
public
override
bool
IsFinished
(ref
string
goTo)
28
{
29
return
isFinished;
30
}
31
public
override
void
Reset
()
32
{
33
isFinished =
false
;
34
}
35
36
public
override
void
Update
(
float
deltaTime)
37
{
38
if
(isFinished) {
return
; }
39
var targets =
ParentEvent
.
GetTargets
(
TargetTag
).Where(e => e is
Character
).Select(e => e as
Character
);
40
foreach
(var target
in
targets)
41
{
42
target.Info?.GiveExperience(
Amount
);
43
}
44
isFinished =
true
;
45
}
46
47
public
override
string
ToDebugString
()
48
{
49
return
$
"{ToolBox.GetDebugSymbol(isFinished)} {nameof(GiveExpAction)} -> (TargetTag: {TargetTag.ColorizeObject()}, "
+
50
$
"Amount: {Amount.ColorizeObject()})"
;
51
}
52
}
53
}
Barotrauma.Character
Definition:
BarotraumaShared/SharedSource/Characters/Character.cs:32
Barotrauma.ContentXElement
Definition:
ContentXElement.cs:13
Barotrauma.ContentXElement.ContentPackage
ContentPackage? ContentPackage
Definition:
ContentXElement.cs:14
Barotrauma.EventAction
Definition:
EventAction.cs:9
Barotrauma.EventAction.ParentEvent
readonly ScriptedEvent ParentEvent
Definition:
EventAction.cs:106
Barotrauma.GiveExpAction
Gives experience to a specific character.
Definition:
GiveExpAction.cs:9
Barotrauma.GiveExpAction.IsFinished
override bool IsFinished(ref string goTo)
Has the action finished.
Definition:
GiveExpAction.cs:27
Barotrauma.GiveExpAction.Reset
override void Reset()
Definition:
GiveExpAction.cs:31
Barotrauma.GiveExpAction.Update
override void Update(float deltaTime)
Definition:
GiveExpAction.cs:36
Barotrauma.GiveExpAction.ToDebugString
override string ToDebugString()
Rich test to display in debugdraw
Definition:
GiveExpAction.cs:47
Barotrauma.GiveExpAction.Amount
int Amount
Definition:
GiveExpAction.cs:11
Barotrauma.GiveExpAction.TargetTag
Identifier TargetTag
Definition:
GiveExpAction.cs:14
Barotrauma.GiveExpAction.GiveExpAction
GiveExpAction(ScriptedEvent parentEvent, ContentXElement element)
Definition:
GiveExpAction.cs:16
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
Definition:
AchievementManager.cs:12
Barotrauma.IsPropertySaveable
IsPropertySaveable
Definition:
SerializableProperty.cs:16
Barotrauma
BarotraumaShared
SharedSource
Events
EventActions
GiveExpAction.cs
Generated by
1.9.1