3 using Microsoft.Xna.Framework;
35 get {
return tainted; }
38 if (!value) {
return; }
54 get {
return selectedTaintedEffect?.
Identifier ?? Identifier.Empty; }
65 if (!
string.IsNullOrEmpty(nameId))
67 materialName = TextManager.Get(nameId);
69 if (!
string.IsNullOrEmpty(
Effect))
73 a.AfflictionType ==
Effect).GetRandomUnsynced();
90 if (character ==
null) {
return; }
93 if (targetCharacter !=
null) {
return; }
95 if (selectedEffect !=
null)
97 targetCharacter = character;
99 float selectedEffectStrength = GetCombinedEffectStrength();
102 if (affliction !=
null)
104 affliction.Strength = selectedEffectStrength;
106 affliction.SetStrength(selectedEffectStrength);
109 item.CreateServerEvent(
this);
112 if (tainted && selectedTaintedEffect !=
null)
114 float selectedTaintedEffectStrength = GetCombinedTaintedEffectStrength();
117 if (affliction !=
null)
119 affliction.Strength = selectedTaintedEffectStrength;
121 affliction.SetStrength(selectedTaintedEffectStrength);
123 targetCharacter = character;
125 item.CreateServerEvent(
this);
136 base.Update(deltaTime, cam);
137 if (targetCharacter !=
null)
147 if (affliction !=
null) { affliction.Strength = GetCombinedEffectStrength(); }
149 if (taintedAffliction !=
null) { taintedAffliction.Strength = GetCombinedTaintedEffectStrength(); }
151 targetCharacter =
null;
171 float taintedProbability = GetTaintedProbabilityOnRefine(otherGeneticMaterial, user);
173 if (taintedProbability >= Rand.Range(0.0f, 1.0f))
186 if (GetTaintedProbabilityOnCombine(user) >= Rand.Range(0.0f, 1.0f))
194 private float GetCombinedEffectStrength()
196 float effectStrength = 0.0f;
200 if (geneticMaterial ==
null || !geneticMaterial.IsActive) {
continue; }
201 if (geneticMaterial.selectedEffect == selectedEffect)
206 return effectStrength;
209 private float GetCombinedTaintedEffectStrength()
211 float taintedEffectStrength = 0.0f;
215 if (geneticMaterial ==
null || !geneticMaterial.IsActive) {
continue; }
216 if (selectedTaintedEffect !=
null && geneticMaterial.selectedTaintedEffect == selectedTaintedEffect)
218 taintedEffectStrength += otherItem.ConditionPercentage / 100.0f * selectedTaintedEffect.
MaxStrength;
221 return taintedEffectStrength;
224 private float GetTaintedProbabilityOnRefine(
GeneticMaterial otherGeneticMaterial, Character user)
226 if (user ==
null) {
return 1.0f; }
227 float probability = MathHelper.Lerp(0.0f, 0.99f, Math.Max(
item.
Condition, otherGeneticMaterial.Item.Condition) / 100.0f);
229 return MathHelper.Clamp(probability, 0.0f, 1.0f);
232 private static float GetTaintedProbabilityOnCombine(Character user)
234 if (user ==
null) {
return 1.0f; }
235 float probability = 1.0f - user.GetStatValue(
StatTypes.GeneticMaterialTaintedProbabilityReductionOnCombine);
236 return MathHelper.Clamp(probability, 0.0f, 1.0f);
239 private void MakeTainted()
241 if (GameMain.NetworkMember?.IsClient ??
false) {
return; }
244 item.CreateServerEvent(
this);
250 foreach (XElement subElement
in element.Elements())
254 Identifier nameId = subElement.GetAttributeIdentifier(
"nameidentifier",
"");
257 return prefab.Name.
Replace(
"[type]", TextManager.Get(nameId).Fallback(nameId.Value));
AfflictionPrefab is a prefab that defines a type of affliction that can be applied to a character....
Affliction Instantiate(float strength, Character source=null)
readonly float MaxStrength
The maximum strength this affliction can have.
static readonly PrefabCollection< AfflictionPrefab > Prefabs
void ApplyAffliction(Limb targetLimb, Affliction affliction, bool allowStacking=true, bool ignoreUnkillability=false)
IReadOnlyCollection< Affliction > GetAllAfflictions()
CharacterHealth CharacterHealth
bool HasEquippedItem(Item item, InvSlotType? slotType=null, Func< InvSlotType, bool > predicate=null)
float GetStatValue(StatTypes statType, bool includeSaved=true)
CharacterInventory Inventory
bool IsInLimbSlot(Item item, InvSlotType limbSlot)
string? GetAttributeString(string key, string? def)
List< Item > FindAllItems(Func< Item, bool > predicate=null, bool recursive=false, List< Item > list=null)
ItemInventory OwnInventory
void ApplyStatusEffects(ActionType type, float deltaTime, Character character=null, Limb limb=null, Entity useTarget=null, bool isNetworkEvent=false, Vector2? worldPosition=null)
Executes all StatusEffects of the specified type. Note that condition checks are ignored here: that s...
IEnumerable< Item > ContainedItems
float ConditionPercentage
override bool TryPutItem(Item item, Character user, IEnumerable< InvSlotType > allowedSlots=null, bool createNetworkEvent=true, bool ignoreCondition=false)
If there is room, puts the item in the inventory and returns true, otherwise returns false
override void Update(float deltaTime, Camera cam)
float ConditionIncreaseOnCombineMin
Identifier???? SelectedTaintedEffect
bool CanBeCombinedWith(GeneticMaterial otherGeneticMaterial)
float ConditionIncreaseOnCombineMax
GeneticMaterial(Item item, ContentXElement element)
override void Equip(Character character)
CombineResult Combine(GeneticMaterial otherGeneticMaterial, Character user)
static LocalizedString TryCreateName(ItemPrefab prefab, XElement element)
The base class for components holding the different functionalities of the item
void ApplyStatusEffects(ActionType type, float deltaTime, Character character=null, Limb targetLimb=null, Entity useTarget=null, Character user=null, Vector2? worldPosition=null, float afflictionMultiplier=1.0f)
float DegreeOfSuccess(Character character)
Returns 0.0f-1.0f based on how well the Character can use the itemcomponent
LocalizedString Replace(Identifier find, LocalizedString replace, StringComparison stringComparison=StringComparison.Ordinal)
readonly Identifier Identifier
Interface for entities that the server can send events to the clients
ActionType
ActionTypes define when a StatusEffect is executed.
StatTypes
StatTypes are used to alter several traits of a character. They are mostly used by talents.