103 lines
3.8 KiB
C#
103 lines
3.8 KiB
C#
using System.Collections.Generic;
|
|
using System.Xml.Linq;
|
|
using UnityEngine.Scripting;
|
|
|
|
#nullable disable
|
|
[Preserve]
|
|
public class MinEventActionAddAoEBuff : MinEventActionBuffModifierBase
|
|
{
|
|
[PublicizedFrom(EAccessModifier.Private)]
|
|
public float duration;
|
|
[PublicizedFrom(EAccessModifier.Private)]
|
|
public bool durationAltered;
|
|
[PublicizedFrom(EAccessModifier.Private)]
|
|
public bool cvarRef;
|
|
[PublicizedFrom(EAccessModifier.Private)]
|
|
public string refCvarName = string.Empty;
|
|
|
|
public override void Execute(MinEventParams _params)
|
|
{
|
|
bool _netSync = !_params.Self.isEntityRemote | _params.IsLocal;
|
|
int _instigatorId = -1;
|
|
if (_params.Buff != null)
|
|
_instigatorId = _params.Buff.InstigatorId;
|
|
if (_instigatorId == -1)
|
|
_instigatorId = _params.Self.entityId;
|
|
for (int index1 = 0; index1 < this.targets.Count; ++index1)
|
|
{
|
|
#region Rebirth
|
|
if (!RebirthUtilities.CanAttackExecute(this.targets[index1]))
|
|
{
|
|
continue;
|
|
}
|
|
#endregion
|
|
|
|
//Log.Out("RebirthUtilities-CanAttackExecute PROCEEDING target: " + this.targets[index1].EntityClass.entityClassName);
|
|
|
|
string[] strArray = this.buffNames;
|
|
if (this.buffOneOnly && this.buffWeights != null)
|
|
{
|
|
float randomFloat = this.targets[index1].rand.RandomFloat;
|
|
float num = 0.0f;
|
|
for (int index2 = 0; index2 < this.buffWeights.Length; ++index2)
|
|
{
|
|
num += this.buffWeights[index2];
|
|
if ((double) num >= (double) randomFloat)
|
|
{
|
|
strArray = new string[1]
|
|
{
|
|
this.buffNames[index2]
|
|
};
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else if (this.buffWeights != null)
|
|
{
|
|
List<string> stringList = new List<string>();
|
|
for (int index3 = 0; index3 < this.buffWeights.Length; ++index3)
|
|
{
|
|
float randomFloat = this.targets[index1].rand.RandomFloat;
|
|
if ((double) this.buffWeights[index3] >= (double) randomFloat)
|
|
stringList.Add(this.buffNames[index3]);
|
|
}
|
|
strArray = stringList.ToArray();
|
|
}
|
|
for (int index4 = 0; index4 < strArray.Length; ++index4)
|
|
{
|
|
string _name = strArray[index4];
|
|
BuffClass buff = BuffManager.GetBuff(_name);
|
|
if (buff != null)
|
|
{
|
|
if (this.durationAltered && this.cvarRef)
|
|
this.duration = !this.targets[index1].Buffs.HasCustomVar(this.refCvarName) ? buff.InitialDurationMax : this.targets[index1].Buffs.GetCustomVar(this.refCvarName);
|
|
if (this.durationAltered)
|
|
{
|
|
int num1 = (int) this.targets[index1].Buffs.AddBuff(_name, _instigatorId, _netSync, _buffDuration: this.duration);
|
|
}
|
|
else
|
|
{
|
|
int num2 = (int) this.targets[index1].Buffs.AddBuff(_name, _instigatorId, _netSync);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public override bool ParseXmlAttribute(XAttribute _attribute)
|
|
{
|
|
bool xmlAttribute = base.ParseXmlAttribute(_attribute);
|
|
if (xmlAttribute || !(_attribute.Name.LocalName == "duration"))
|
|
return xmlAttribute;
|
|
if (_attribute.Value.StartsWith("@"))
|
|
{
|
|
this.cvarRef = true;
|
|
this.refCvarName = _attribute.Value.Substring(1);
|
|
}
|
|
else
|
|
this.duration = StringParsers.ParseFloat(_attribute.Value);
|
|
this.durationAltered = true;
|
|
return true;
|
|
}
|
|
}
|