Client LuaCsForBarotrauma
CharacterAbilitySpawnItemsToContainer.cs
1
using
System.Collections.Generic;
2
3
namespace
Barotrauma.Abilities
4
{
5
class
CharacterAbilitySpawnItemsToContainer
:
CharacterAbility
6
{
7
// currently used only for spawning items to containers
8
9
private
readonly List<StatusEffect> statusEffects;
10
private
readonly List<Item> openedContainers =
new
List<Item>();
11
private
readonly
float
randomChance;
12
private
readonly
bool
oncePerContainer;
13
14
public
CharacterAbilitySpawnItemsToContainer
(
CharacterAbilityGroup
characterAbilityGroup,
ContentXElement
abilityElement) : base(characterAbilityGroup, abilityElement)
15
{
16
statusEffects =
CharacterAbilityGroup
.
ParseStatusEffects
(
CharacterTalent
, abilityElement.
GetChildElement
(
"statuseffects"
));
17
randomChance = abilityElement.
GetAttributeFloat
(
"randomchance"
, 1f);
18
oncePerContainer = abilityElement.
GetAttributeBool
(
"oncepercontainer"
,
false
);
19
}
20
21
protected
override
void
ApplyEffect
(
AbilityObject
abilityObject)
22
{
23
if
((abilityObject as
IAbilityItem
)?.
Item
is
Item
item)
24
{
25
if
(oncePerContainer)
26
{
27
if
(openedContainers.Contains(item)) {
return
; }
28
openedContainers.Add(item);
29
}
30
if
(randomChance < Rand.Range(0f, 1f, Rand.RandSync.Unsynced)) {
return
; }
31
32
foreach
(var statusEffect
in
statusEffects)
33
{
34
statusEffect.Apply(
ActionType
.OnAbility,
EffectDeltaTime
, item, item);
35
}
36
}
37
else
38
{
39
LogAbilityObjectMismatch
();
40
}
41
}
42
}
43
}
Barotrauma.Abilities.AbilityObject
Definition:
AbilityObjects.cs:6
Barotrauma.Abilities.CharacterAbilityGroup
Definition:
CharacterAbilityGroup.cs:9
Barotrauma.Abilities.CharacterAbilityGroup.ParseStatusEffects
static List< StatusEffect > ParseStatusEffects(CharacterTalent characterTalent, ContentXElement statusEffectElements)
Definition:
CharacterAbilityGroup.cs:218
Barotrauma.Abilities.CharacterAbility
Definition:
CharacterAbility.cs:7
Barotrauma.Abilities.CharacterAbility.EffectDeltaTime
float EffectDeltaTime
Used primarily for StatusEffects. Default to constant outside interval abilities.
Definition:
CharacterAbility.cs:25
Barotrauma.Abilities.CharacterAbility.LogAbilityObjectMismatch
void LogAbilityObjectMismatch()
Definition:
CharacterAbility.cs:90
Barotrauma.Abilities.CharacterAbilitySpawnItemsToContainer
Definition:
CharacterAbilitySpawnItemsToContainer.cs:6
Barotrauma.Abilities.CharacterAbilitySpawnItemsToContainer.CharacterAbilitySpawnItemsToContainer
CharacterAbilitySpawnItemsToContainer(CharacterAbilityGroup characterAbilityGroup, ContentXElement abilityElement)
Definition:
CharacterAbilitySpawnItemsToContainer.cs:14
Barotrauma.Abilities.CharacterAbilitySpawnItemsToContainer.ApplyEffect
override void ApplyEffect(AbilityObject abilityObject)
Definition:
CharacterAbilitySpawnItemsToContainer.cs:21
Barotrauma.CharacterTalent
Definition:
CharacterTalent.cs:8
Barotrauma.ContentXElement
Definition:
ContentXElement.cs:13
Barotrauma.ContentXElement.GetAttributeFloat
float GetAttributeFloat(string key, float def)
Barotrauma.ContentXElement.GetChildElement
ContentXElement? GetChildElement(string name)
Barotrauma.ContentXElement.GetAttributeBool
bool GetAttributeBool(string key, bool def)
Barotrauma.Item
Definition:
BarotraumaShared/SharedSource/Items/Item.cs:26
Barotrauma.Abilities.IAbilityItem
Definition:
AbilityInterfaces.cs:9
Barotrauma.Abilities
Definition:
AbilityCondition.cs:5
Barotrauma.ActionType
ActionType
ActionTypes define when a StatusEffect is executed.
Definition:
Enums.cs:26
Barotrauma
BarotraumaShared
SharedSource
Characters
Talents
Abilities
CharacterAbilitySpawnItemsToContainer.cs
Generated by
1.9.1