Upload from upload_mods.ps1
This commit is contained in:
134
Scripts/MinEvents/MinEventActionCheckAttackTrigger.cs
Normal file
134
Scripts/MinEvents/MinEventActionCheckAttackTrigger.cs
Normal file
@@ -0,0 +1,134 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
#nullable disable
|
||||
[Preserve]
|
||||
public class MinEventActionCheckAttackTrigger : 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)
|
||||
{
|
||||
float previousAttackIndex = _params.Self.Buffs.GetCustomVar("$attackIndex_FR");
|
||||
float currentAttackIndex = 0f;
|
||||
float numSecondary = _params.Self.Buffs.GetCustomVar("$numSecondary_FR");
|
||||
|
||||
//Log.Out("RebirthUtilities-CanAttackExecute previousAttackIndex: " + previousAttackIndex);
|
||||
//Log.Out("RebirthUtilities-CanAttackExecute currentAttackIndex: " + currentAttackIndex);
|
||||
|
||||
if (_params.Self.inventory.holdingItemItemValue.ItemClass.Actions[0] != null && _params.Self.inventory.holdingItemItemValue.ItemClass.Actions[0].IsActionRunning(_params.Self.inventory.GetItemActionDataInSlot(_params.Self.inventory.holdingItemIdx, 0)))
|
||||
{
|
||||
//Log.Out("RebirthUtilities-CanAttackExecute PRIMARY");
|
||||
_params.Self.Buffs.SetCustomVar("$attackIndex_FR", 1f);
|
||||
_params.Self.Buffs.SetCustomVar("$numSecondary_FR", 0f);
|
||||
currentAttackIndex = 1f;
|
||||
}
|
||||
else if (_params.Self.inventory.holdingItemItemValue.ItemClass.Actions[1] != null && _params.Self.inventory.holdingItemItemValue.ItemClass.Actions[1].IsActionRunning(_params.Self.inventory.GetItemActionDataInSlot(_params.Self.inventory.holdingItemIdx, 1)))
|
||||
{
|
||||
//Log.Out("RebirthUtilities-CanAttackExecute SECONDARY");
|
||||
_params.Self.Buffs.SetCustomVar("$attackIndex_FR", 2f);
|
||||
numSecondary++;
|
||||
_params.Self.Buffs.SetCustomVar("$numSecondary_FR", numSecondary);
|
||||
currentAttackIndex = 2f;
|
||||
}
|
||||
|
||||
bool canProceed = false;
|
||||
|
||||
if ((previousAttackIndex == 1 && currentAttackIndex == 2) || numSecondary >= 4)
|
||||
{
|
||||
//Log.Out("RebirthUtilities-CanAttackExecute CAN PROCEED");
|
||||
canProceed = true;
|
||||
}
|
||||
|
||||
#region Rebirth
|
||||
if (!canProceed || !RebirthUtilities.CanAttackExecute(this.targets[index1], 1.25f))
|
||||
{
|
||||
//Log.Out("RebirthUtilities-CanAttackExecute SKIP");
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user