Upload from upload_mods.ps1
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
public class MinEventActionAddBuffToTargetAndSelf : MinEventActionAddBuff
|
||||
{
|
||||
public override bool CanExecute(MinEventTypes _eventType, MinEventParams _params)
|
||||
{
|
||||
bool flag = base.CanExecute(_eventType, _params);
|
||||
if (targetType == TargetTypes.selfAOE)
|
||||
flag = true;
|
||||
if (flag && targetType != TargetTypes.self)
|
||||
targets.Add(_params.Self);
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
21
Scripts/MinEventActions/MinEventActionAddItemToInventory.cs
Normal file
21
Scripts/MinEventActions/MinEventActionAddItemToInventory.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
public class MinEventActionAddItemToInventory : MinEventActionItemAccessBase
|
||||
{
|
||||
private ItemStack itemStackCache = new ItemStack();
|
||||
|
||||
public override bool CanExecute(MinEventTypes _eventType, MinEventParams _params)
|
||||
{
|
||||
if (itemValueCache == null)
|
||||
{
|
||||
itemValueCache = ItemClass.GetItem(itemName);
|
||||
itemStackCache.itemValue = itemValueCache;
|
||||
}
|
||||
return !_params.Self.isEntityRemote && base.CanExecute(_eventType, _params);
|
||||
}
|
||||
|
||||
public override void Execute(MinEventParams _params)
|
||||
{
|
||||
itemStackCache.count = GetCount(_params);
|
||||
_params.Self.TryStackItem(itemStackCache);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
public class MinEventActionAddRoundsToInventory : MinEventActionAmmoAccessBase
|
||||
{
|
||||
private ItemStack itemStackCache = new ItemStack();
|
||||
|
||||
public override void Execute(MinEventParams _params)
|
||||
{
|
||||
var _ranged = _params.ItemValue.ItemClass.Actions[_params.ItemActionData.indexInEntityOfAction] as ItemActionRanged;
|
||||
string ammoName = _ranged.MagazineItemNames[_params.ItemValue.SelectedAmmoTypeIndex];
|
||||
if (!RoundsInInventory.TryGetValue(ammoName, out var ammoValue))
|
||||
return;
|
||||
itemStackCache.itemValue = ammoValue;
|
||||
itemStackCache.count = GetCount(_params);
|
||||
_params.Self.TryStackItem(itemStackCache);
|
||||
}
|
||||
}
|
||||
|
||||
28
Scripts/MinEventActions/MinEventActionAddRoundsToMagazine.cs
Normal file
28
Scripts/MinEventActions/MinEventActionAddRoundsToMagazine.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Xml.Linq;
|
||||
|
||||
public class MinEventActionAddRoundsToMagazine : MinEventActionAmmoAccessBase
|
||||
{
|
||||
private float maxPerc = -1;
|
||||
public override void Execute(MinEventParams _params)
|
||||
{
|
||||
_params.ItemValue.Meta += GetCount(_params);
|
||||
if (maxPerc > 0)
|
||||
_params.ItemValue.Meta = Utils.FastMin((int)((_params.ItemValue.ItemClass.Actions[0] as ItemActionRanged).GetMaxAmmoCount(_params.ItemActionData) * maxPerc), _params.ItemValue.Meta);
|
||||
_params.Self?.inventory?.CallOnToolbeltChangedInternal();
|
||||
}
|
||||
|
||||
public override bool ParseXmlAttribute(XAttribute _attribute)
|
||||
{
|
||||
if (base.ParseXmlAttribute(_attribute))
|
||||
return true;
|
||||
|
||||
if (_attribute.Name.LocalName == "max")
|
||||
{
|
||||
maxPerc = float.Parse(_attribute.Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
56
Scripts/MinEventActions/MinEventActionAmmoAccessBase.cs
Normal file
56
Scripts/MinEventActions/MinEventActionAmmoAccessBase.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System.Xml.Linq;
|
||||
|
||||
public class MinEventActionAmmoAccessBase : MinEventActionItemCountRandomBase
|
||||
{
|
||||
private bool useMag = false;
|
||||
private bool useRounds = false;
|
||||
private bool revert = false;
|
||||
private float perc = 1;
|
||||
protected override int GetCount(MinEventParams _params)
|
||||
{
|
||||
if (!useMag || !(_params.ItemValue.ItemClass.Actions[_params.ItemActionData.indexInEntityOfAction] is ItemActionRanged _ranged))
|
||||
return base.GetCount(_params);
|
||||
|
||||
if (!useRounds)
|
||||
return (int)(_ranged.GetMaxAmmoCount(_params.ItemActionData) * perc);
|
||||
|
||||
if (!revert)
|
||||
return (int)((_params.ItemValue.Meta) * perc);
|
||||
|
||||
return (int)((_ranged.GetMaxAmmoCount(_params.ItemActionData) - _params.ItemValue.Meta) * perc);
|
||||
}
|
||||
|
||||
public override bool CanExecute(MinEventTypes _eventType, MinEventParams _params)
|
||||
{
|
||||
return !_params.Self.isEntityRemote && base.CanExecute(_eventType, _params) && _params.ItemActionData is ItemActionRanged.ItemActionDataRanged && _params.ItemValue.ItemClass.Actions[_params.ItemActionData.indexInEntityOfAction] is ItemActionRanged;
|
||||
}
|
||||
|
||||
public override bool ParseXmlAttribute(XAttribute _attribute)
|
||||
{
|
||||
if (base.ParseXmlAttribute(_attribute))
|
||||
return true;
|
||||
|
||||
if (_attribute.Name.LocalName == "count" && _attribute.Value.Contains("MagazineSize"))
|
||||
{
|
||||
useMag = true;
|
||||
string str = _attribute.Value;
|
||||
if (str.StartsWith("%"))
|
||||
{
|
||||
useRounds = true;
|
||||
str = str.Substring(1);
|
||||
}
|
||||
|
||||
if (str.StartsWith("!"))
|
||||
{
|
||||
revert = true;
|
||||
str = str.Substring(1);
|
||||
}
|
||||
|
||||
string[] arr = str.Split(new char[] { '*' }, 2, System.StringSplitOptions.RemoveEmptyEntries);
|
||||
if (arr.Length == 2)
|
||||
return float.TryParse(arr[1], out perc);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
using KFCommonUtilityLib.Scripts.NetPackages;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class MinEventActionAttachPrefabToEntitySync : MinEventActionAttachPrefabToEntity
|
||||
{
|
||||
private static Dictionary<string, GameObject> dict_loaded = new Dictionary<string, GameObject>();
|
||||
//public override bool CanExecute(MinEventTypes _eventType, MinEventParams _params)
|
||||
//{
|
||||
// return base.CanExecute(_eventType, _params) && (_params.IsLocal || (_params.Self && !_params.Self.isEntityRemote));
|
||||
//}
|
||||
|
||||
public override void Execute(MinEventParams _params)
|
||||
{
|
||||
base.Execute(_params);
|
||||
if (ConnectionManager.Instance.IsServer)
|
||||
{
|
||||
ConnectionManager.Instance.SendPackage(NetPackageManager.GetPackage<NetPackageRemoteAttachPrefab>().Setup(_params.Self.entityId, prefab, parent_transform_path, local_offset, local_rotation, local_scale), false, -1, -1, _params.Self.entityId);
|
||||
}
|
||||
else if (_params.IsLocal || (_params.Self && !_params.Self.isEntityRemote))
|
||||
{
|
||||
ConnectionManager.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageRemoteAttachPrefab>().Setup(_params.Self.entityId, prefab, parent_transform_path, local_offset, local_rotation, local_scale));
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ParseXmlAttribute(XAttribute _attribute)
|
||||
{
|
||||
bool flag = false;
|
||||
if (_attribute.Name.LocalName == "prefab")
|
||||
{
|
||||
prefab = _attribute.Value;
|
||||
if (dict_loaded.TryGetValue(_attribute.Value, out GameObject go) && go)
|
||||
{
|
||||
goToInstantiate = go;
|
||||
flag = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = base.ParseXmlAttribute(_attribute);
|
||||
dict_loaded[_attribute.Value] = goToInstantiate;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
flag = base.ParseXmlAttribute(_attribute);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
public static void RemoteAttachPrefab(EntityAlive entity, string prefab, string path, Vector3 local_offset, Vector3 local_rotation, Vector3 local_scale)
|
||||
{
|
||||
Transform transform = entity.RootTransform;
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
transform = GameUtils.FindDeepChildActive(transform, path);
|
||||
}
|
||||
if (transform == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
GameObject goToInstantiate = dict_loaded[prefab];
|
||||
string text = "tempPrefab_" + goToInstantiate.name;
|
||||
Transform transform2 = GameUtils.FindDeepChild(transform, text);
|
||||
if (transform2 == null)
|
||||
{
|
||||
GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(goToInstantiate);
|
||||
if (gameObject == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
transform2 = gameObject.transform;
|
||||
gameObject.name = text;
|
||||
Utils.SetLayerRecursively(gameObject, transform.gameObject.layer, null);
|
||||
transform2.parent = transform;
|
||||
transform2.localPosition = local_offset;
|
||||
transform2.localRotation = Quaternion.Euler(local_rotation.x, local_rotation.y, local_rotation.z);
|
||||
transform2.localScale = local_scale;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
public class MinEventActionBroadcastPlaySoundLocal : MinEventActionPlaySound
|
||||
{
|
||||
public override bool CanExecute(MinEventTypes _eventType, MinEventParams _params)
|
||||
{
|
||||
return targetType == TargetTypes.self && !_params.Self.isEntityRemote && base.CanExecute(_eventType, _params);
|
||||
}
|
||||
}
|
||||
|
||||
248
Scripts/MinEventActions/MinEventActionCVarExpression.cs
Normal file
248
Scripts/MinEventActions/MinEventActionCVarExpression.cs
Normal file
@@ -0,0 +1,248 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
using CodeWriter.ExpressionParser;
|
||||
using UnityEngine;
|
||||
|
||||
public class MinEventActionCVarExpression : MinEventActionTargetedBase
|
||||
{
|
||||
private enum VariableType
|
||||
{
|
||||
None,
|
||||
CVar,
|
||||
RandomInt,
|
||||
RandomFloat,
|
||||
TierList
|
||||
}
|
||||
|
||||
private class VariableInfo
|
||||
{
|
||||
public VariableType varType;
|
||||
public string cvarName;
|
||||
public float[] valueList;
|
||||
public float randomMin;
|
||||
public float randomMax;
|
||||
}
|
||||
public string cvarName;
|
||||
public MinEventActionModifyCVar.OperationTypes operation;
|
||||
private bool isValid = false;
|
||||
private ExpressionContext<float> context;
|
||||
private Expression<float> compiledExpr;
|
||||
private VariableInfo[] variableInfos;
|
||||
private MinEventParams minEventContext;
|
||||
private EntityAlive target;
|
||||
|
||||
public override bool CanExecute(MinEventTypes _eventType, MinEventParams _params)
|
||||
{
|
||||
if (cvarName != null && cvarName.StartsWith("_"))
|
||||
{
|
||||
Log.Out("CVar '{0}' is readonly", new object[] { cvarName });
|
||||
return false;
|
||||
}
|
||||
if (!isValid)
|
||||
{
|
||||
Log.Out("Invalid expression!");
|
||||
return false;
|
||||
}
|
||||
return base.CanExecute(_eventType, _params);
|
||||
}
|
||||
|
||||
public override void Execute(MinEventParams _params)
|
||||
{
|
||||
if (_params.Self.isEntityRemote && !_params.IsLocal)
|
||||
{
|
||||
return;
|
||||
}
|
||||
minEventContext = _params;
|
||||
if (compiledExpr == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < targets.Count; i++)
|
||||
{
|
||||
target = targets[i];
|
||||
float cvar = target.Buffs.GetCustomVar(cvarName);
|
||||
float value = compiledExpr.Invoke();
|
||||
switch (operation)
|
||||
{
|
||||
case MinEventActionModifyCVar.OperationTypes.set:
|
||||
case MinEventActionModifyCVar.OperationTypes.setvalue:
|
||||
cvar = value;
|
||||
break;
|
||||
case MinEventActionModifyCVar.OperationTypes.add:
|
||||
cvar += value;
|
||||
break;
|
||||
case MinEventActionModifyCVar.OperationTypes.subtract:
|
||||
cvar -= value;
|
||||
break;
|
||||
case MinEventActionModifyCVar.OperationTypes.multiply:
|
||||
cvar *= value;
|
||||
break;
|
||||
case MinEventActionModifyCVar.OperationTypes.divide:
|
||||
cvar /= ((value == 0f) ? 0.0001f : value);
|
||||
break;
|
||||
case MinEventActionModifyCVar.OperationTypes.percentadd:
|
||||
cvar += cvar * value;
|
||||
break;
|
||||
case MinEventActionModifyCVar.OperationTypes.percentsubtract:
|
||||
cvar -= cvar * value;
|
||||
break;
|
||||
}
|
||||
target.Buffs.SetCustomVar(cvarName, cvar);
|
||||
}
|
||||
minEventContext = null;
|
||||
target = null;
|
||||
}
|
||||
|
||||
public override bool ParseXmlAttribute(XAttribute _attribute)
|
||||
{
|
||||
bool flag = base.ParseXmlAttribute(_attribute);
|
||||
if (!flag)
|
||||
{
|
||||
switch(_attribute.Name.LocalName)
|
||||
{
|
||||
case "cvar":
|
||||
cvarName = _attribute.Value;
|
||||
flag = true;
|
||||
break;
|
||||
case "expression":
|
||||
isValid = true;
|
||||
string expr = _attribute.Value;
|
||||
context = new ExpressionContext<float>();
|
||||
List<VariableInfo> variableInfos = new List<VariableInfo>();
|
||||
Dictionary<string, int> varStrs = new Dictionary<string, int>();
|
||||
while (true)
|
||||
{
|
||||
int nextVarStart = expr.IndexOf('[');
|
||||
if (nextVarStart < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
int nextVarEnd = expr.IndexOf(']', nextVarStart);
|
||||
if (nextVarEnd < 0)
|
||||
{
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
string varStr = expr.Substring(nextVarStart + 1, nextVarEnd - nextVarStart - 1);
|
||||
VariableInfo variableInfo = null;
|
||||
if (varStr.StartsWith("@"))
|
||||
{
|
||||
if (!varStrs.ContainsKey(varStr))
|
||||
{
|
||||
variableInfo = new VariableInfo();
|
||||
variableInfo.varType = VariableType.CVar;
|
||||
variableInfo.cvarName = varStr.Substring(1);
|
||||
varStrs.Add(varStr, variableInfos.Count);
|
||||
}
|
||||
}
|
||||
else if (varStr.StartsWith("randomInt", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
variableInfo = new VariableInfo();
|
||||
variableInfo.varType = VariableType.RandomInt;
|
||||
Vector2 vector = StringParsers.ParseVector2(varStr.Substring(varStr.IndexOf('(') + 1, varStr.IndexOf(')') - (varStr.IndexOf('(') + 1)));
|
||||
variableInfo.randomMin = (int)vector.x;
|
||||
variableInfo.randomMax = (int)vector.y;
|
||||
}
|
||||
else if (varStr.StartsWith("randomFloat", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
variableInfo = new VariableInfo();
|
||||
variableInfo.varType = VariableType.RandomFloat;
|
||||
Vector2 vector = StringParsers.ParseVector2(varStr.Substring(varStr.IndexOf('(') + 1, varStr.IndexOf(')') - (varStr.IndexOf('(') + 1)));
|
||||
variableInfo.randomMin = vector.x;
|
||||
variableInfo.randomMax = vector.y;
|
||||
}
|
||||
else if (varStr.Contains(','))
|
||||
{
|
||||
if (!varStrs.ContainsKey(varStr))
|
||||
{
|
||||
variableInfo = new VariableInfo();
|
||||
variableInfo.varType = VariableType.TierList;
|
||||
string[] array = varStr.Split(',', StringSplitOptions.None);
|
||||
variableInfo.valueList = new float[array.Length];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
variableInfo.valueList[i] = float.Parse(array[i]);
|
||||
}
|
||||
varStrs.Add(varStr, variableInfos.Count);
|
||||
}
|
||||
}
|
||||
else if (float.TryParse(varStr, out _))
|
||||
{
|
||||
|
||||
expr = expr.Remove(nextVarEnd).Remove(nextVarStart);
|
||||
}
|
||||
else
|
||||
{
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
int curIndex = varStrs.TryGetValue(varStr, out var index) ? index : variableInfos.Count;
|
||||
string varName = "x" + curIndex;
|
||||
expr = expr.Remove(nextVarStart, nextVarEnd - nextVarStart + 1).Insert(nextVarStart, varName);
|
||||
//Log.Out($"cur index {curIndex} var name {varStr} is new var {curIndex == variableInfos.Count}");
|
||||
if (curIndex == variableInfos.Count)
|
||||
{
|
||||
context.RegisterVariable(varName, () => { return EvaluateVar(curIndex); });
|
||||
}
|
||||
if (variableInfo != null)
|
||||
{
|
||||
variableInfos.Add(variableInfo);
|
||||
}
|
||||
}
|
||||
if (!isValid)
|
||||
{
|
||||
Log.Out("Invalid expression: {0}", new object[] { expr });
|
||||
return false;
|
||||
}
|
||||
Log.Out($"Compiling expr {expr}...");
|
||||
compiledExpr = FloatExpressionParser.Instance.Compile(expr, context, true);
|
||||
this.variableInfos = variableInfos.ToArray();
|
||||
flag = true;
|
||||
break;
|
||||
case "operation":
|
||||
this.operation = EnumUtils.Parse<MinEventActionModifyCVar.OperationTypes>(_attribute.Value, true);
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
private float EvaluateVar(int index)
|
||||
{
|
||||
var variableInfo = variableInfos[index];
|
||||
switch (variableInfo.varType)
|
||||
{
|
||||
case VariableType.CVar:
|
||||
return target.Buffs.GetCustomVar(variableInfo.cvarName);
|
||||
case VariableType.RandomInt:
|
||||
return Mathf.Clamp(minEventContext.Self.rand.RandomRange((int)variableInfo.randomMin, (int)variableInfo.randomMax + 1), variableInfo.randomMin, variableInfo.randomMax);
|
||||
case VariableType.RandomFloat:
|
||||
return Mathf.Clamp(minEventContext.Self.rand.RandomRange(variableInfo.randomMin, variableInfo.randomMax + 1), variableInfo.randomMin, variableInfo.randomMax);
|
||||
case VariableType.TierList:
|
||||
if (minEventContext.ParentType == MinEffectController.SourceParentType.ItemClass || minEventContext.ParentType == MinEffectController.SourceParentType.ItemModifierClass)
|
||||
{
|
||||
if (!minEventContext.ItemValue.IsEmpty())
|
||||
{
|
||||
int tier = (int)(minEventContext.ItemValue.Quality - 1);
|
||||
if (tier >= 0)
|
||||
{
|
||||
return variableInfo.valueList[tier];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (minEventContext.ParentType == MinEffectController.SourceParentType.ProgressionClass && minEventContext.ProgressionValue != null)
|
||||
{
|
||||
int level = minEventContext.ProgressionValue.CalculatedLevel(minEventContext.Self);
|
||||
if (level >= 0)
|
||||
{
|
||||
return variableInfo.valueList[level];
|
||||
}
|
||||
}
|
||||
return 0f;
|
||||
default:
|
||||
return 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
public class MinEventActionDecreaseProgressionLevelAndRefundSP : MinEventActionSetProgressionLevel
|
||||
{
|
||||
public override void Execute(MinEventParams _params)
|
||||
{
|
||||
EntityPlayerLocal entityPlayerLocal = this.targets[0] as EntityPlayerLocal;
|
||||
if (this.targets != null)
|
||||
{
|
||||
ProgressionValue progressionValue = entityPlayerLocal.Progression.GetProgressionValue(this.progressionName);
|
||||
if (progressionValue != null)
|
||||
{
|
||||
if (this.level >= 0 && this.level < progressionValue.Level)
|
||||
{
|
||||
ProgressionClass progressionClass = progressionValue.ProgressionClass;
|
||||
int spcount = 0;
|
||||
for (int i = this.level + 1; i <= progressionValue.Level; i++)
|
||||
spcount += progressionClass.CalculatedCostForLevel(i);
|
||||
progressionValue.Level = this.level;
|
||||
entityPlayerLocal.Progression.SkillPoints += spcount;
|
||||
entityPlayerLocal.Progression.bProgressionStatsChanged = true;
|
||||
entityPlayerLocal.bPlayerStatsChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
23
Scripts/MinEventActions/MinEventActionItemAccessBase.cs
Normal file
23
Scripts/MinEventActions/MinEventActionItemAccessBase.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System.Xml.Linq;
|
||||
|
||||
public class MinEventActionItemAccessBase : MinEventActionItemCountRandomBase
|
||||
{
|
||||
protected string itemName;
|
||||
protected ItemValue itemValueCache = null;
|
||||
|
||||
public override bool ParseXmlAttribute(XAttribute _attribute)
|
||||
{
|
||||
if (base.ParseXmlAttribute(_attribute))
|
||||
return true;
|
||||
|
||||
switch (_attribute.Name.LocalName)
|
||||
{
|
||||
case "item":
|
||||
itemName = _attribute.Value;
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
60
Scripts/MinEventActions/MinEventActionItemCountRandomBase.cs
Normal file
60
Scripts/MinEventActions/MinEventActionItemCountRandomBase.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System.Xml.Linq;
|
||||
using UnityEngine;
|
||||
public class MinEventActionItemCountRandomBase : MinEventActionBase
|
||||
{
|
||||
private bool useRange = false;
|
||||
private bool useRandom = false;
|
||||
private bool useCvar = false;
|
||||
private int[] random;
|
||||
private Vector2i range;
|
||||
private string cvarRef;
|
||||
private int constant;
|
||||
|
||||
protected virtual int GetCount(MinEventParams _params)
|
||||
{
|
||||
if (useRandom)
|
||||
return random[Random.Range(0, random.Length)];
|
||||
else if (useRange)
|
||||
return Random.Range(range.x, range.y + 1);
|
||||
else if (useCvar)
|
||||
return (int)_params.Self.GetCVar(cvarRef);
|
||||
else
|
||||
return constant;
|
||||
}
|
||||
|
||||
public override bool ParseXmlAttribute(XAttribute _attribute)
|
||||
{
|
||||
if (base.ParseXmlAttribute(_attribute))
|
||||
return true;
|
||||
|
||||
switch (_attribute.Name.LocalName)
|
||||
{
|
||||
case "count":
|
||||
string str = _attribute.Value;
|
||||
if (str.StartsWith("random"))
|
||||
{
|
||||
useRandom = true;
|
||||
string[] values = str.Substring(str.IndexOf('(') + 1, str.IndexOf(')') - str.IndexOf('(') - 1).Split(',');
|
||||
random = new int[values.Length];
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
random[i] = int.Parse(values[i]);
|
||||
}
|
||||
else if (str.StartsWith("range"))
|
||||
{
|
||||
useRange = true;
|
||||
range = StringParsers.ParseVector2i(str.Substring(str.IndexOf('(') + 1, str.IndexOf(')') - str.IndexOf('(') - 1));
|
||||
}
|
||||
else if (str.StartsWith("@"))
|
||||
{
|
||||
useCvar = true;
|
||||
cvarRef = str.Substring(1);
|
||||
}
|
||||
else
|
||||
return int.TryParse(str, out constant);
|
||||
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
using KFCommonUtilityLib;
|
||||
using System.Xml.Linq;
|
||||
|
||||
public class MinEventActionModifyCVarWithLocalCache : MinEventActionModifyCVar
|
||||
{
|
||||
int targetHash;
|
||||
private int actionIndex = -1;
|
||||
public override bool CanExecute(MinEventTypes _eventType, MinEventParams _params)
|
||||
{
|
||||
bool flag = !_params.Self.isEntityRemote && (actionIndex < 0 ? _params.ItemActionData : _params.ItemActionData.invData.actionData[actionIndex]) is IModuleContainerFor<ActionModuleLocalPassiveCache.LocalPassiveCacheData> && base.CanExecute(_eventType, _params);
|
||||
//Log.Out($"can execute {flag} is remote {_params.Self.isEntityRemote} action index {actionIndex} cache {targetHash.ToString()} action {(actionIndex < 0 ? _params.ItemActionData : _params.ItemActionData.invData.actionData[actionIndex]).GetType().Name}");
|
||||
return flag;
|
||||
}
|
||||
|
||||
public override void Execute(MinEventParams _params)
|
||||
{
|
||||
if (_params.Self.isEntityRemote && !_params.IsLocal)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ActionModuleLocalPassiveCache.LocalPassiveCacheData _data = ((IModuleContainerFor<ActionModuleLocalPassiveCache.LocalPassiveCacheData>)(actionIndex < 0 ? _params.ItemActionData : _params.ItemActionData.invData.actionData[actionIndex])).Instance;
|
||||
float value = _data.GetCachedValue(targetHash);
|
||||
//Log.Out($"cache {targetHash.ToString()} value {value}");
|
||||
for (int i = 0; i < targets.Count; i++)
|
||||
{
|
||||
float num = targets[i].Buffs.GetCustomVar(cvarName);
|
||||
switch (operation)
|
||||
{
|
||||
case OperationTypes.set:
|
||||
case OperationTypes.setvalue:
|
||||
num = value;
|
||||
break;
|
||||
case OperationTypes.add:
|
||||
num += value;
|
||||
break;
|
||||
case OperationTypes.subtract:
|
||||
num -= value;
|
||||
break;
|
||||
case OperationTypes.multiply:
|
||||
num *= value;
|
||||
break;
|
||||
case OperationTypes.divide:
|
||||
num /= ((value == 0f) ? 0.0001f : value);
|
||||
break;
|
||||
}
|
||||
targets[i].Buffs.SetCustomVar(cvarName, num, (targets[i].isEntityRemote && !_params.Self.isEntityRemote) || _params.IsLocal);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ParseXmlAttribute(XAttribute _attribute)
|
||||
{
|
||||
bool flag = false;
|
||||
string name = _attribute.Name.LocalName;
|
||||
if (name != null)
|
||||
{
|
||||
if (name == "cache")
|
||||
{
|
||||
targetHash = _attribute.Value.GetHashCode();
|
||||
flag = true;
|
||||
}
|
||||
else if (name == "action_index")
|
||||
{
|
||||
actionIndex = int.Parse(_attribute.Value);
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
flag = base.ParseXmlAttribute(_attribute);
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using System.Xml.Linq;
|
||||
|
||||
class MinEventActionModifyCVarWithSelfRef : MinEventActionModifyCVar
|
||||
{
|
||||
public override bool CanExecute(MinEventTypes _eventType, MinEventParams _params)
|
||||
{
|
||||
return base.CanExecute(_eventType, _params);
|
||||
}
|
||||
|
||||
public override void Execute(MinEventParams _params)
|
||||
{
|
||||
if (cvarRef)
|
||||
{
|
||||
if (_params.Self.isEntityRemote && !_params.IsLocal)
|
||||
{
|
||||
return;
|
||||
}
|
||||
value = _params.Self.Buffs.GetCustomVar(refCvarName);
|
||||
for (int i = 0; i < targets.Count; i++)
|
||||
{
|
||||
float num = targets[i].Buffs.GetCustomVar(cvarName);
|
||||
switch (operation)
|
||||
{
|
||||
case OperationTypes.set:
|
||||
case OperationTypes.setvalue:
|
||||
num = value;
|
||||
break;
|
||||
case OperationTypes.add:
|
||||
num += value;
|
||||
break;
|
||||
case OperationTypes.subtract:
|
||||
num -= value;
|
||||
break;
|
||||
case OperationTypes.multiply:
|
||||
num *= value;
|
||||
break;
|
||||
case OperationTypes.divide:
|
||||
num /= ((value == 0f) ? 0.0001f : value);
|
||||
break;
|
||||
}
|
||||
targets[i].Buffs.SetCustomVar(cvarName, num, (targets[i].isEntityRemote && !_params.Self.isEntityRemote) || _params.IsLocal);
|
||||
}
|
||||
}
|
||||
else
|
||||
base.Execute(_params);
|
||||
}
|
||||
}
|
||||
|
||||
101
Scripts/MinEventActions/MinEventActionOverrideZoomFOV.cs
Normal file
101
Scripts/MinEventActions/MinEventActionOverrideZoomFOV.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
using HarmonyLib;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class MinEventActionOverrideZoomFOV : MinEventActionBase
|
||||
{
|
||||
private int fov = 0;
|
||||
//private static Type zoomDataType = typeof(ItemActionZoom).GetNestedType("ItemActionDataZoom", System.Reflection.BindingFlags.NonPublic);
|
||||
//private static FieldInfo fldZoomInProgress = AccessTools.Field(zoomDataType, "bZoomInProgress");
|
||||
//private static FieldInfo fldTimeZoomStarted = AccessTools.Field(zoomDataType, "timeZoomStarted");
|
||||
//private static FieldInfo fldCurrentZoom = AccessTools.Field(zoomDataType, "CurrentZoom");
|
||||
//private static FieldInfo fldMaxZoomOut = AccessTools.Field(zoomDataType, "MaxZoomOut");
|
||||
//private static FieldInfo fldMaxZoomIn = AccessTools.Field(zoomDataType, "MaxZoomIn");
|
||||
//private static FieldInfo fldEndLerpFov = AccessTools.Field(typeof(EntityPlayerLocal), "lerpCameraEndFOV");
|
||||
//private static MethodInfo mtdUpdateCameraPosition = AccessTools.Method(typeof(EntityAlive), "updateCameraPosition");
|
||||
|
||||
public override bool CanExecute(MinEventTypes _eventType, MinEventParams _params)
|
||||
{
|
||||
if (!base.CanExecute(_eventType, _params))
|
||||
return false;
|
||||
|
||||
return _params.Self is EntityPlayerLocal player && player?.inventory != null && player.inventory.holdingItemData?.actionData[1] is ItemActionZoom.ItemActionDataZoom;
|
||||
}
|
||||
|
||||
public override void Execute(MinEventParams _params)
|
||||
{
|
||||
base.Execute(_params);
|
||||
var target = (EntityPlayerLocal)_params.Self;
|
||||
var zoomActionData = (ItemActionZoom.ItemActionDataZoom)target.inventory.holdingItemData.actionData[1];
|
||||
int targetFov = fov;
|
||||
int targetMax = fov;
|
||||
int targetMin = fov;
|
||||
//restore min max fov
|
||||
if (fov <= 0)
|
||||
{
|
||||
float fovSetting = (float)GamePrefs.GetInt(EnumGamePrefs.OptionsGfxFOV);
|
||||
ItemAction action = target.inventory.holdingItem.Actions[1];
|
||||
if (action.Properties != null && action.Properties.Values.ContainsKey("Zoom_max_out"))
|
||||
{
|
||||
targetMax = StringParsers.ParseSInt32(target.inventory.holdingItemData.itemValue.GetPropertyOverride("Zoom_max_out", action.Properties.Values["Zoom_max_out"]), 0, -1, NumberStyles.Integer);
|
||||
}
|
||||
else
|
||||
{
|
||||
targetMax = StringParsers.ParseSInt32(target.inventory.holdingItemData.itemValue.GetPropertyOverride("Zoom_max_out", fovSetting.ToString()), 0, -1, NumberStyles.Integer);
|
||||
}
|
||||
if (action.Properties != null && action.Properties.Values.ContainsKey("Zoom_max_in"))
|
||||
{
|
||||
targetMin = StringParsers.ParseSInt32(target.inventory.holdingItemData.itemValue.GetPropertyOverride("Zoom_max_in", action.Properties.Values["Zoom_max_in"]), 0, -1, NumberStyles.Integer);
|
||||
}
|
||||
else
|
||||
{
|
||||
targetMin = StringParsers.ParseSInt32(target.inventory.holdingItemData.itemValue.GetPropertyOverride("Zoom_max_in", fovSetting.ToString()), 0, -1, NumberStyles.Integer);
|
||||
}
|
||||
targetFov = targetMax;
|
||||
}
|
||||
|
||||
zoomActionData.MaxZoomIn = targetMin;
|
||||
zoomActionData.MaxZoomOut = targetMax;
|
||||
zoomActionData.CurrentZoom = targetFov;
|
||||
//Log.Out($"setting zoom override max {targetMax} min {targetMin} cur {targetFov}");
|
||||
//if is aiming, lerp towards the final result
|
||||
if (target.AimingGun)
|
||||
{
|
||||
//if lerp not in progress, start lerp
|
||||
if (!target.bLerpCameraFlag)
|
||||
{
|
||||
zoomActionData.bZoomInProgress = true;
|
||||
zoomActionData.timeZoomStarted = Time.time;
|
||||
target.updateCameraPosition(true);
|
||||
}
|
||||
//if already in progress, set end value
|
||||
else
|
||||
{
|
||||
target.lerpCameraEndFOV = targetFov;
|
||||
}
|
||||
|
||||
//Log.Out($"begin lerp camera");
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ParseXmlAttribute(XAttribute _attribute)
|
||||
{
|
||||
if(base.ParseXmlAttribute(_attribute))
|
||||
return true;
|
||||
|
||||
switch(_attribute.Name.LocalName)
|
||||
{
|
||||
case "value":
|
||||
fov = StringParsers.ParseSInt32(_attribute.Value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
31
Scripts/MinEventActions/MinEventActionRemoteHoldingBase.cs
Normal file
31
Scripts/MinEventActions/MinEventActionRemoteHoldingBase.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
//workaround for inventory sync
|
||||
//full toolbelt data is sent when holding item value changed or whatever, after a certain delay
|
||||
//causing remote players to update current holding item constantly
|
||||
//thus we need to handle some holding event for remote players on local player side
|
||||
using System.Xml.Linq;
|
||||
|
||||
public class MinEventActionRemoteHoldingBase : MinEventActionBase
|
||||
{
|
||||
protected bool isRemoteHolding = false;
|
||||
protected bool localOnly = true;
|
||||
|
||||
public override bool ParseXmlAttribute(XAttribute _attribute)
|
||||
{
|
||||
if (base.ParseXmlAttribute(_attribute))
|
||||
return true;
|
||||
|
||||
if (_attribute.Name == "local_only")
|
||||
{
|
||||
localOnly = bool.Parse(_attribute.Value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool CanExecute(MinEventTypes _eventType, MinEventParams _params)
|
||||
{
|
||||
isRemoteHolding = (_eventType == MinEventTypes.onSelfEquipStart && _params.Self.isEntityRemote);
|
||||
return (!localOnly || !_params.Self.isEntityRemote) && (!_params.Self.isEntityRemote || isRemoteHolding) && base.CanExecute(_eventType, _params);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
public class MinEventActionRemoveItemFromInventory : MinEventActionItemAccessBase
|
||||
{
|
||||
public override bool CanExecute(MinEventTypes _eventType, MinEventParams _params)
|
||||
{
|
||||
if (itemValueCache == null)
|
||||
itemValueCache = ItemClass.GetItem(itemName);
|
||||
return !_params.Self.isEntityRemote && base.CanExecute(_eventType, _params);
|
||||
}
|
||||
|
||||
public override void Execute(MinEventParams _params)
|
||||
{
|
||||
_params.Self.TryRemoveItem(GetCount(_params), itemValueCache);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
using KFCommonUtilityLib.Scripts.StaticManagers;
|
||||
using UnityEngine;
|
||||
|
||||
public class MinEventActionRemovePrefabFromHeldItem : MinEventActionRemovePrefabFromEntity
|
||||
{
|
||||
public override bool CanExecute(MinEventTypes _eventType, MinEventParams _params)
|
||||
{
|
||||
return base.CanExecute(_eventType, _params) && _params.Transform;
|
||||
}
|
||||
|
||||
public override void Execute(MinEventParams _params)
|
||||
{
|
||||
if (!_params.Self)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Transform parent = AnimationRiggingManager.GetAddPartTransformOverride(_params.Transform, parent_transform_path, false);
|
||||
if (parent)
|
||||
{
|
||||
Transform child = null;
|
||||
string prefabName = "tempPrefab_" + base.prefabName;
|
||||
if (_params.Transform.TryGetComponent<AnimationTargetsAbs>(out var targets))
|
||||
{
|
||||
GameObject prefab = targets.GetPrefab(prefabName);
|
||||
if (prefab)
|
||||
{
|
||||
child = prefab.transform;
|
||||
}
|
||||
}
|
||||
if (!child)
|
||||
{
|
||||
child = parent.Find(prefabName);
|
||||
}
|
||||
if (child)
|
||||
{
|
||||
if (child.TryGetComponent<AttachmentReferenceAppended>(out var reference))
|
||||
{
|
||||
reference.Remove();
|
||||
}
|
||||
child.parent = null;
|
||||
GameObject.Destroy(child.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
public class MinEventActionRemoveRoundsFromInventory : MinEventActionAmmoAccessBase
|
||||
{
|
||||
private ItemValue itemValueCache;
|
||||
|
||||
public override bool CanExecute(MinEventTypes _eventType, MinEventParams _params)
|
||||
{
|
||||
if (!base.CanExecute(_eventType, _params))
|
||||
return false;
|
||||
|
||||
var _ranged = _params.ItemValue.ItemClass.Actions[_params.ItemActionData.indexInEntityOfAction] as ItemActionRanged;
|
||||
string ammoName = _ranged.MagazineItemNames[_params.ItemValue.SelectedAmmoTypeIndex];
|
||||
return RoundsInInventory.TryGetValue(ammoName, out itemValueCache);
|
||||
}
|
||||
public override void Execute(MinEventParams _params)
|
||||
{
|
||||
_params.Self.TryRemoveItem(GetCount(_params), itemValueCache);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
using System.Xml.Linq;
|
||||
|
||||
public class MinEventActionSetAmmoOnWeaponLabel : MinEventActionRemoteHoldingBase
|
||||
{
|
||||
private int slot = 0;
|
||||
private bool maxAmmo = false;
|
||||
private bool useHoldingItemValue = false;
|
||||
private string[] wrap;
|
||||
private bool usePattern = false;
|
||||
public override bool ParseXmlAttribute(XAttribute _attribute)
|
||||
{
|
||||
bool flag = base.ParseXmlAttribute(_attribute);
|
||||
if (!flag)
|
||||
{
|
||||
flag = true;
|
||||
string name = _attribute.Name.LocalName;
|
||||
switch (name)
|
||||
{
|
||||
case "slot":
|
||||
slot = int.Parse(_attribute.Value);
|
||||
break;
|
||||
case "pattern":
|
||||
string str = _attribute.Value;
|
||||
wrap = str.Split(new string[] { "[ammo]" }, System.StringSplitOptions.None);
|
||||
usePattern = true;
|
||||
break;
|
||||
case "max_ammo":
|
||||
maxAmmo = bool.Parse(_attribute.Value);
|
||||
break;
|
||||
default:
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
public override bool CanExecute(MinEventTypes _eventType, MinEventParams _params)
|
||||
{
|
||||
//somehow when onSelfEquipStart is fired, holding item value is not successfully updated in MinEventParams
|
||||
useHoldingItemValue = _eventType == MinEventTypes.onSelfEquipStart;
|
||||
//consume_ammo = _eventType == MinEventTypes.onSelfRangedBurstShot;
|
||||
return base.CanExecute(_eventType, _params);
|
||||
}
|
||||
|
||||
public override void Execute(MinEventParams _params)
|
||||
{
|
||||
int meta;
|
||||
var inv = _params.Self.inventory;
|
||||
var value = useHoldingItemValue ? inv.holdingItemItemValue : _params.ItemValue;
|
||||
if (!maxAmmo)
|
||||
meta = value.Meta;
|
||||
else
|
||||
meta = (int)EffectManager.GetValue(PassiveEffects.MagazineSize, value, inv.GetHoldingGun().BulletsPerMagazine, _params.Self);
|
||||
string str = usePattern ? string.Join(meta.ToString(), wrap) : meta.ToString();
|
||||
//int num = consume_ammo ? meta - 1 : meta;
|
||||
if (isRemoteHolding || localOnly)
|
||||
NetPackageSyncWeaponLabelText.SetWeaponLabelText(_params.Self, slot, str);
|
||||
else if (!_params.Self.isEntityRemote)
|
||||
NetPackageSyncWeaponLabelText.NetSyncSetWeaponLabelText(_params.Self, slot, str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
using System.Xml.Linq;
|
||||
|
||||
public class MinEventActionSetMetadataOnWeaponLabel : MinEventActionRemoteHoldingBase
|
||||
{
|
||||
private int slot = 0;
|
||||
private bool useHoldingItemValue = false;
|
||||
private string[] wrap;
|
||||
private bool usePattern = false;
|
||||
private string metadata;
|
||||
|
||||
public override bool ParseXmlAttribute(XAttribute _attribute)
|
||||
{
|
||||
bool flag = base.ParseXmlAttribute(_attribute);
|
||||
if (!flag)
|
||||
{
|
||||
flag = true;
|
||||
string name = _attribute.Name.LocalName;
|
||||
switch (name)
|
||||
{
|
||||
case "slot":
|
||||
slot = int.Parse(_attribute.Value);
|
||||
break;
|
||||
case "pattern":
|
||||
string str = _attribute.Value;
|
||||
wrap = str.Split(new string[] { "[metadata]" }, System.StringSplitOptions.None);
|
||||
usePattern = true;
|
||||
break;
|
||||
case "metadata":
|
||||
metadata = _attribute.Value;
|
||||
break;
|
||||
default:
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
public override bool CanExecute(MinEventTypes _eventType, MinEventParams _params)
|
||||
{
|
||||
//somehow when onSelfEquipStart is fired, holding item value is not successfully updated in MinEventParams
|
||||
useHoldingItemValue = _eventType == MinEventTypes.onSelfEquipStart;
|
||||
//consume_ammo = _eventType == MinEventTypes.onSelfRangedBurstShot;
|
||||
return !string.IsNullOrEmpty(metadata) && base.CanExecute(_eventType, _params);
|
||||
}
|
||||
|
||||
public override void Execute(MinEventParams _params)
|
||||
{
|
||||
var inv = _params.Self.inventory;
|
||||
var value = useHoldingItemValue ? inv.holdingItemItemValue : _params.ItemValue;
|
||||
object obj = value.GetMetadata(metadata);
|
||||
if (obj is false || obj is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string meta = obj.ToString();
|
||||
string str = usePattern ? string.Join(meta.ToString(), wrap) : meta.ToString();
|
||||
if (isRemoteHolding || localOnly)
|
||||
NetPackageSyncWeaponLabelText.SetWeaponLabelText(_params.Self, slot, str);
|
||||
else if (!_params.Self.isEntityRemote)
|
||||
NetPackageSyncWeaponLabelText.NetSyncSetWeaponLabelText(_params.Self, slot, str);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using KFCommonUtilityLib.Scripts.StaticManagers;
|
||||
using System.Xml.Linq;
|
||||
|
||||
public class MinEventActionSetPassiveOnWeaponLabel : MinEventActionRemoteHoldingBase
|
||||
{
|
||||
private int slot = 0;
|
||||
private bool useHoldingItemValue = false;
|
||||
private string[] wrap;
|
||||
private bool usePattern = false;
|
||||
private PassiveEffects passive;
|
||||
private FastTags<TagGroup.Global> tags;
|
||||
|
||||
public override bool ParseXmlAttribute(XAttribute _attribute)
|
||||
{
|
||||
bool flag = base.ParseXmlAttribute(_attribute);
|
||||
if (!flag)
|
||||
{
|
||||
flag = true;
|
||||
string name = _attribute.Name.LocalName;
|
||||
switch (name)
|
||||
{
|
||||
case "slot":
|
||||
slot = int.Parse(_attribute.Value);
|
||||
break;
|
||||
case "pattern":
|
||||
string str = _attribute.Value;
|
||||
wrap = str.Split(new string[] { "[passive]" }, System.StringSplitOptions.None);
|
||||
usePattern = true;
|
||||
break;
|
||||
case "passive":
|
||||
passive = CustomEffectEnumManager.RegisterOrGetEnum<PassiveEffects>(_attribute.Value, true);
|
||||
break;
|
||||
case "tags":
|
||||
tags = FastTags<TagGroup.Global>.Parse(_attribute.Value);
|
||||
break;
|
||||
default:
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
public override bool CanExecute(MinEventTypes _eventType, MinEventParams _params)
|
||||
{
|
||||
//somehow when onSelfEquipStart is fired, holding item value is not successfully updated in MinEventParams
|
||||
useHoldingItemValue = _eventType == MinEventTypes.onSelfEquipStart;
|
||||
//consume_ammo = _eventType == MinEventTypes.onSelfRangedBurstShot;
|
||||
return base.CanExecute(_eventType, _params);
|
||||
}
|
||||
|
||||
public override void Execute(MinEventParams _params)
|
||||
{
|
||||
var inv = _params.Self.inventory;
|
||||
var value = useHoldingItemValue ? inv.holdingItemItemValue : _params.ItemValue;
|
||||
float res = EffectManager.GetValue(passive, value, 0, _params.Self, null, tags);
|
||||
string str = usePattern ? string.Join(res.ToString(), wrap) : res.ToString();
|
||||
if (isRemoteHolding || localOnly)
|
||||
NetPackageSyncWeaponLabelText.SetWeaponLabelText(_params.Self, slot, str);
|
||||
else if (!_params.Self.isEntityRemote)
|
||||
NetPackageSyncWeaponLabelText.NetSyncSetWeaponLabelText(_params.Self, slot, str);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using System.Xml.Linq;
|
||||
|
||||
public class MinEventActionSetStringOnWeaponLabel : MinEventActionRemoteHoldingBase
|
||||
{
|
||||
private int slot = 0;
|
||||
private string text;
|
||||
private bool isCvar = false;
|
||||
private bool isMetadata = false;
|
||||
|
||||
public override bool ParseXmlAttribute(XAttribute _attribute)
|
||||
{
|
||||
bool flag = base.ParseXmlAttribute(_attribute);
|
||||
if (!flag)
|
||||
{
|
||||
flag = true;
|
||||
string name = _attribute.Name.LocalName;
|
||||
switch (name)
|
||||
{
|
||||
case "slot":
|
||||
slot = int.Parse(_attribute.Value);
|
||||
break;
|
||||
case "text":
|
||||
text = _attribute.Value;
|
||||
break;
|
||||
case "cvar":
|
||||
text = _attribute.Value;
|
||||
isCvar = true;
|
||||
isMetadata = false;
|
||||
break;
|
||||
case "metadata":
|
||||
text = _attribute.Value;
|
||||
isMetadata = true;
|
||||
isCvar = false;
|
||||
break;
|
||||
default:
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
public override bool CanExecute(MinEventTypes _eventType, MinEventParams _params)
|
||||
{
|
||||
if (isMetadata && (_params.ItemValue == null || !_params.ItemValue.HasMetadata(text)))
|
||||
return false;
|
||||
return base.CanExecute(_eventType, _params);
|
||||
}
|
||||
|
||||
public override void Execute(MinEventParams _params)
|
||||
{
|
||||
if (isRemoteHolding || localOnly)
|
||||
NetPackageSyncWeaponLabelText.SetWeaponLabelText(_params.Self, slot, isCvar ? _params.Self.GetCVar(text).ToString() : (isMetadata ? _params.ItemValue.GetMetadata(text).ToString() : text));
|
||||
else if (!_params.Self.isEntityRemote)
|
||||
NetPackageSyncWeaponLabelText.NetSyncSetWeaponLabelText(_params.Self, slot, isCvar ? _params.Self.GetCVar(text).ToString() : (isMetadata ? _params.ItemValue.GetMetadata(text).ToString() : text));
|
||||
}
|
||||
}
|
||||
|
||||
51
Scripts/MinEventActions/MinEventActionSetWeaponLabelColor.cs
Normal file
51
Scripts/MinEventActions/MinEventActionSetWeaponLabelColor.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System.Xml.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class MinEventActionSetWeaponLabelColor : MinEventActionRemoteHoldingBase
|
||||
{
|
||||
private bool isText = true;
|
||||
private int slot0 = 0;
|
||||
private int slot1 = 0;
|
||||
private Color color;
|
||||
private int nameId;
|
||||
|
||||
public override bool ParseXmlAttribute(XAttribute _attribute)
|
||||
{
|
||||
bool flag = base.ParseXmlAttribute(_attribute);
|
||||
if (!flag)
|
||||
{
|
||||
string value = _attribute.Value;
|
||||
flag = true;
|
||||
switch (_attribute.Name.LocalName)
|
||||
{
|
||||
case "is_text":
|
||||
isText = bool.Parse(value);
|
||||
break;
|
||||
case "slot0":
|
||||
slot0 = int.Parse(value);
|
||||
break;
|
||||
case "slot1":
|
||||
slot1 = int.Parse(value);
|
||||
break;
|
||||
case "color":
|
||||
flag = ColorUtility.TryParseHtmlString(value, out color);
|
||||
break;
|
||||
case "name":
|
||||
nameId = Shader.PropertyToID(value);
|
||||
break;
|
||||
default:
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
public override void Execute(MinEventParams _params)
|
||||
{
|
||||
if (isRemoteHolding || localOnly)
|
||||
NetPackageSyncWeaponLabelColor.SetWeaponLabelColor(_params.Self, isText, slot0, color, slot1, nameId);
|
||||
else if (!_params.Self.isEntityRemote)
|
||||
NetPackageSyncWeaponLabelColor.NetSyncSetWeaponLabelColor(_params.Self, isText, slot0, color, slot1, nameId);
|
||||
}
|
||||
}
|
||||
|
||||
49
Scripts/MinEventActions/MinEventActionUpdateLocalCache.cs
Normal file
49
Scripts/MinEventActions/MinEventActionUpdateLocalCache.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using KFCommonUtilityLib;
|
||||
using KFCommonUtilityLib.Scripts.StaticManagers;
|
||||
using System;
|
||||
using System.Xml.Linq;
|
||||
|
||||
public class MinEventActionUpdateLocalCache : MinEventActionBase
|
||||
{
|
||||
private PassiveEffects passive;
|
||||
private FastTags<TagGroup.Global> tags;
|
||||
private int actionIndex = -1;
|
||||
private int saveAs;
|
||||
private string saveAsStr;
|
||||
public override bool CanExecute(MinEventTypes _eventType, MinEventParams _params)
|
||||
{
|
||||
return !_params.Self.isEntityRemote && (actionIndex < 0 ? _params.ItemActionData : _params.ItemActionData.invData.actionData[actionIndex]) is IModuleContainerFor<ActionModuleLocalPassiveCache.LocalPassiveCacheData> && base.CanExecute(_eventType, _params);
|
||||
}
|
||||
|
||||
public override void Execute(MinEventParams _params)
|
||||
{
|
||||
ActionModuleLocalPassiveCache.LocalPassiveCacheData _data = ((IModuleContainerFor<ActionModuleLocalPassiveCache.LocalPassiveCacheData>)(actionIndex < 0 ? _params.ItemActionData : _params.ItemActionData.invData.actionData[actionIndex])).Instance;
|
||||
|
||||
_data.CachePassive(passive, saveAs, saveAsStr, tags);
|
||||
}
|
||||
|
||||
public override bool ParseXmlAttribute(XAttribute _attribute)
|
||||
{
|
||||
if (base.ParseXmlAttribute(_attribute))
|
||||
return true;
|
||||
|
||||
switch (_attribute.Name.LocalName)
|
||||
{
|
||||
case "passive":
|
||||
passive = CustomEffectEnumManager.RegisterOrGetEnum<PassiveEffects>(_attribute.Value, true);
|
||||
return true;
|
||||
case "tags":
|
||||
tags = FastTags<TagGroup.Global>.Parse(_attribute.Value);
|
||||
return true;
|
||||
case "action_index":
|
||||
actionIndex = int.Parse(_attribute.Value);
|
||||
return true;
|
||||
case "as":
|
||||
saveAsStr = _attribute.Value;
|
||||
saveAs = _attribute.Value.GetHashCode();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user