Client LuaCsForBarotrauma
AbilityConditionMission.cs
1
using
System;
2
using
System.Collections.Immutable;
3
using
System.Linq;
4
5
namespace
Barotrauma.Abilities
6
{
7
class
AbilityConditionMission
:
AbilityConditionData
8
{
9
private
readonly ImmutableHashSet<Identifier> missionType;
10
private
readonly
bool
isAffiliated;
11
12
public
AbilityConditionMission
(
CharacterTalent
characterTalent
,
ContentXElement
conditionElement) : base(
characterTalent
, conditionElement)
13
{
14
missionType = conditionElement.
GetAttributeIdentifierImmutableHashSet
(
"missiontype"
, ImmutableHashSet<Identifier>.Empty)!;
15
isAffiliated = conditionElement.
GetAttributeBool
(
"isaffiliated"
,
false
);
16
}
17
18
protected
override
bool
MatchesConditionSpecific
(
AbilityObject
abilityObject)
19
{
20
if
(abilityObject is
IAbilityMission
{
Mission
: { } mission })
21
{
22
if
(!isAffiliated) {
return
CheckMissionType(); }
23
24
if
(
GameMain
.
GameSession
?.
Campaign
?.
Factions
is not { } factions) {
return
false
; }
25
26
foreach
(var reputationReward
in
mission.ReputationRewards)
27
{
28
if
(reputationReward.Amount <= 0) {
continue
; }
29
if
(GetMatchingFaction(reputationReward.FactionIdentifier) is { } faction &&
30
Faction
.
GetPlayerAffiliationStatus
(faction) is
FactionAffiliation
.Positive)
31
{
32
return
CheckMissionType();
33
}
34
}
35
36
return
false
;
37
38
Faction
GetMatchingFaction(Identifier factionIdentifier) =>
39
factionIdentifier ==
"location"
40
? mission.OriginLocation?.
Faction
41
: factions.FirstOrDefault(f => factionIdentifier == f.Prefab.Identifier);
42
43
bool
CheckMissionType() => missionType.IsEmpty || missionType.Contains(mission.Prefab.Type);
44
}
45
46
LogAbilityConditionError
(abilityObject, typeof(
IAbilityMission
));
47
return
false
;
48
}
49
}
50
}
Barotrauma.Abilities.AbilityConditionData
Definition:
AbilityConditionData.cs:6
Barotrauma.Abilities.AbilityConditionData.LogAbilityConditionError
void LogAbilityConditionError(AbilityObject abilityObject, Type expectedData)
Definition:
AbilityConditionData.cs:18
Barotrauma.Abilities.AbilityCondition.characterTalent
CharacterTalent characterTalent
Definition:
AbilityCondition.cs:8
Barotrauma.Abilities.AbilityConditionMission
Definition:
AbilityConditionMission.cs:8
Barotrauma.Abilities.AbilityConditionMission.MatchesConditionSpecific
override bool MatchesConditionSpecific(AbilityObject abilityObject)
Definition:
AbilityConditionMission.cs:18
Barotrauma.Abilities.AbilityConditionMission.AbilityConditionMission
AbilityConditionMission(CharacterTalent characterTalent, ContentXElement conditionElement)
Definition:
AbilityConditionMission.cs:12
Barotrauma.Abilities.AbilityObject
Definition:
AbilityObjects.cs:6
Barotrauma.CampaignMode.Factions
IReadOnlyList< Faction > Factions
Definition:
BarotraumaShared/SharedSource/GameSession/GameModes/CampaignMode.cs:46
Barotrauma.CharacterTalent
Definition:
CharacterTalent.cs:8
Barotrauma.ContentXElement
Definition:
ContentXElement.cs:13
Barotrauma.ContentXElement.GetAttributeBool
bool GetAttributeBool(string key, bool def)
Barotrauma.ContentXElement.GetAttributeIdentifierImmutableHashSet
ImmutableHashSet< Identifier > GetAttributeIdentifierImmutableHashSet(string key, ImmutableHashSet< Identifier >? def, bool trim=true)
Barotrauma.Faction
Definition:
Factions.cs:16
Barotrauma.Faction.Faction
Faction(CampaignMetadata? metadata, FactionPrefab prefab)
Definition:
Factions.cs:20
Barotrauma.Faction.GetPlayerAffiliationStatus
static FactionAffiliation GetPlayerAffiliationStatus(Faction faction)
Get what kind of affiliation this faction has towards the player depending on who they chose to side ...
Definition:
Factions.cs:30
Barotrauma.GameMain
Definition:
GameMain.cs:25
Barotrauma.GameMain.GameSession
static GameSession?? GameSession
Definition:
GameMain.cs:88
Barotrauma.GameSession.Campaign
CampaignMode? Campaign
Definition:
BarotraumaShared/SharedSource/GameSession/GameSession.cs:128
Barotrauma.Mission
Definition:
BarotraumaShared/SharedSource/Events/Missions/Mission.cs:14
Barotrauma.Abilities.IAbilityMission
Definition:
AbilityInterfaces.cs:19
Barotrauma.Abilities
Definition:
AbilityCondition.cs:5
Barotrauma.FactionAffiliation
FactionAffiliation
Definition:
Factions.cs:9
Barotrauma
BarotraumaShared
SharedSource
Characters
Talents
Abilities
AbilityConditionals
AbilityConditionData
AbilityConditionMission.cs
Generated by
1.9.1