Client LuaCsForBarotrauma
AbilityCondition.cs
1
using
System;
2
using
System.Collections.Generic;
3
4
namespace
Barotrauma.Abilities
5
{
6
abstract
class
AbilityCondition
7
{
8
protected
CharacterTalent
characterTalent
;
9
protected
Character
character
;
10
protected
bool
invert
;
11
12
public
virtual
bool
AllowClientSimulation
=>
true
;
13
14
public
AbilityCondition
(
CharacterTalent
characterTalent
,
ContentXElement
conditionElement)
15
{
16
this.characterTalent =
characterTalent
??
throw
new
ArgumentNullException(nameof(
characterTalent
));
17
character
=
characterTalent
.
Character
;
18
invert
= conditionElement.
GetAttributeBool
(
"invert"
,
false
);
19
}
20
public
abstract
bool
MatchesCondition
(
AbilityObject
abilityObject);
21
public
abstract
bool
MatchesCondition
();
22
23
24
// tools
25
protected
enum
TargetType
26
{
27
Any
= 0,
28
Enemy
= 1,
29
Ally = 2,
30
NotSelf = 3,
31
Alive = 4,
32
Monster = 5,
33
InFriendlySubmarine = 6
34
};
35
36
protected
List<TargetType>
ParseTargetTypes
(
string
[] targetTypeStrings)
37
{
38
List<TargetType> targetTypes =
new
List<TargetType>();
39
foreach
(
string
targetTypeString
in
targetTypeStrings)
40
{
41
if
(!Enum.TryParse(targetTypeString,
true
, out
TargetType
targetType))
42
{
43
DebugConsole.ThrowError(
"Invalid target type type \""
+ targetTypeString +
"\" in CharacterTalent ("
+
characterTalent
.
DebugIdentifier
+
")"
,
44
contentPackage:
characterTalent
.
Prefab
.
ContentPackage
);
45
}
46
targetTypes.Add(targetType);
47
}
48
return
targetTypes;
49
}
50
51
protected
bool
IsViableTarget
(IEnumerable<TargetType> targetTypes,
Character
targetCharacter)
52
{
53
if
(targetCharacter ==
null
) {
return
false
; }
54
55
bool
isViable =
true
;
56
foreach
(
TargetType
targetType
in
targetTypes)
57
{
58
if
(!
IsViableTarget
(targetType, targetCharacter))
59
{
60
isViable =
false
;
61
break
;
62
}
63
}
64
return
isViable;
65
}
66
67
private
bool
IsViableTarget
(
TargetType
targetType,
Character
targetCharacter)
68
{
69
switch
(targetType)
70
{
71
case
TargetType
.Enemy:
72
return
!
HumanAIController
.
IsFriendly
(
character
, targetCharacter);
73
case
TargetType
.Ally:
74
return
HumanAIController
.
IsFriendly
(
character
, targetCharacter);
75
case
TargetType
.NotSelf:
76
return
targetCharacter !=
character
;
77
case
TargetType
.Alive:
78
return
!targetCharacter.
IsDead
;
79
case
TargetType
.Monster:
80
return
!targetCharacter.
IsHuman
;
81
case
TargetType
.InFriendlySubmarine:
82
return
targetCharacter.
Submarine
!=
null
&& targetCharacter.
Submarine
.
TeamID
==
character
.
TeamID
;
83
default
:
84
return
true
;
85
}
86
}
87
88
}
89
}
Barotrauma.Abilities.AbilityCondition
Definition:
AbilityCondition.cs:7
Barotrauma.Abilities.AbilityCondition.ParseTargetTypes
List< TargetType > ParseTargetTypes(string[] targetTypeStrings)
Definition:
AbilityCondition.cs:36
Barotrauma.Abilities.AbilityCondition.AllowClientSimulation
virtual bool AllowClientSimulation
Definition:
AbilityCondition.cs:12
Barotrauma.Abilities.AbilityCondition.MatchesCondition
abstract bool MatchesCondition()
Barotrauma.Abilities.AbilityCondition.MatchesCondition
abstract bool MatchesCondition(AbilityObject abilityObject)
Barotrauma.Abilities.AbilityCondition.TargetType
TargetType
Definition:
AbilityCondition.cs:26
Barotrauma.Abilities.AbilityCondition.AbilityCondition
AbilityCondition(CharacterTalent characterTalent, ContentXElement conditionElement)
Definition:
AbilityCondition.cs:14
Barotrauma.Abilities.AbilityCondition.invert
bool invert
Definition:
AbilityCondition.cs:10
Barotrauma.Abilities.AbilityCondition.IsViableTarget
bool IsViableTarget(IEnumerable< TargetType > targetTypes, Character targetCharacter)
Definition:
AbilityCondition.cs:51
Barotrauma.Abilities.AbilityCondition.character
Character character
Definition:
AbilityCondition.cs:9
Barotrauma.Abilities.AbilityCondition.characterTalent
CharacterTalent characterTalent
Definition:
AbilityCondition.cs:8
Barotrauma.Abilities.AbilityObject
Definition:
AbilityObjects.cs:6
Barotrauma.Character
Definition:
BarotraumaShared/SharedSource/Characters/Character.cs:32
Barotrauma.Character.IsDead
bool IsDead
Definition:
BarotraumaShared/SharedSource/Characters/Character.cs:1147
Barotrauma.Character.IsHuman
bool IsHuman
Definition:
BarotraumaShared/SharedSource/Characters/Character.cs:518
Barotrauma.Character.TeamID
CharacterTeamType TeamID
Definition:
BarotraumaShared/SharedSource/Characters/Character.cs:210
Barotrauma.CharacterTalent
Definition:
CharacterTalent.cs:8
Barotrauma.CharacterTalent.Prefab
readonly TalentPrefab Prefab
Definition:
CharacterTalent.cs:12
Barotrauma.CharacterTalent.DebugIdentifier
string DebugIdentifier
Definition:
CharacterTalent.cs:10
Barotrauma.CharacterTalent.Character
Character Character
Definition:
CharacterTalent.cs:9
Barotrauma.ContentXElement
Definition:
ContentXElement.cs:13
Barotrauma.ContentXElement.GetAttributeBool
bool GetAttributeBool(string key, bool def)
Barotrauma.Entity.Submarine
Submarine Submarine
Definition:
Entity.cs:53
Barotrauma.HumanAIController
Definition:
BarotraumaShared/SharedSource/Characters/AI/HumanAIController.cs:12
Barotrauma.HumanAIController.IsFriendly
static bool IsFriendly(Character me, Character other, bool onlySameTeam=false)
Definition:
BarotraumaShared/SharedSource/Characters/AI/HumanAIController.cs:2273
Barotrauma.Prefab.ContentPackage
ContentPackage? ContentPackage
Definition:
Prefab.cs:37
Barotrauma.Submarine.TeamID
CharacterTeamType TeamID
Definition:
BarotraumaShared/SharedSource/Map/Submarine.cs:28
Barotrauma.Abilities
Definition:
AbilityCondition.cs:5
Barotrauma.AttackContext.Any
@ Any
Barotrauma.SpawnType.Enemy
@ Enemy
Barotrauma
BarotraumaShared
SharedSource
Characters
Talents
Abilities
AbilityConditionals
AbilityCondition.cs
Generated by
1.9.1