Upload from upload_mods.ps1
This commit is contained in:
175
Scripts/ConsoleCmd/ConsoleCmdCalibrateWeapon.cs
Normal file
175
Scripts/ConsoleCmd/ConsoleCmdCalibrateWeapon.cs
Normal file
@@ -0,0 +1,175 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ConsoleCmdCalibrateWeapon : ConsoleCmdAbstract
|
||||
{
|
||||
public override void Execute(List<string> _params, CommandSenderInfo _senderInfo)
|
||||
{
|
||||
if (!_senderInfo.IsLocalGame || _params.Count < 2)
|
||||
{
|
||||
Log.Error("too few params: expecting 2 at least");
|
||||
return;
|
||||
}
|
||||
|
||||
bool flag = Enum.TryParse<CalibrateType>(_params[0], out var calType);
|
||||
if (!flag)
|
||||
{
|
||||
Log.Error("Only following commands are valid: " + string.Join(",", Enum.GetNames(typeof(CalibrateType))));
|
||||
return;
|
||||
}
|
||||
|
||||
flag = Enum.TryParse<TweakType>(_params[1], out var tweakType);
|
||||
if (!flag)
|
||||
{
|
||||
Log.Error("Only following tweak type are valid: " + String.Join(",", Enum.GetNames(typeof(TweakType))));
|
||||
return;
|
||||
}
|
||||
|
||||
Transform targetTrans = null;
|
||||
var inv = GameManager.Instance.World.GetPrimaryPlayer().inventory;
|
||||
if (calType != CalibrateType.offset)
|
||||
{
|
||||
var weaponTrans = inv.GetHoldingItemTransform();
|
||||
if (weaponTrans == null)
|
||||
{
|
||||
Log.Error("player is not holding anything!");
|
||||
return;
|
||||
}
|
||||
|
||||
targetTrans = weaponTrans.Find(_params[2]);
|
||||
if (targetTrans == null)
|
||||
{
|
||||
Log.Error("transform not found on weapon!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 param = Vector3.zero;
|
||||
if (tweakType != TweakType.log)
|
||||
{
|
||||
int parseIndex;
|
||||
if (calType != CalibrateType.offset)
|
||||
{
|
||||
parseIndex = 3;
|
||||
if (_params.Count < 4)
|
||||
{
|
||||
Log.Error("relative or absolute value is required to calibrate!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
parseIndex = 2;
|
||||
if (_params.Count < 3)
|
||||
{
|
||||
Log.Error("offset value is required to calibrate!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (_params.Count < parseIndex + 2)
|
||||
param = StringParsers.ParseVector3(_params[parseIndex]);
|
||||
else if (_params.Count == parseIndex + 2)
|
||||
{
|
||||
flag = float.TryParse(_params[parseIndex + 1], out float value);
|
||||
if (!flag)
|
||||
{
|
||||
Log.Error("offset value is NAN!");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (_params[parseIndex])
|
||||
{
|
||||
case "x":
|
||||
param.x = value;
|
||||
break;
|
||||
case "y":
|
||||
param.y = value;
|
||||
break;
|
||||
case "z":
|
||||
param.z = value;
|
||||
break;
|
||||
default:
|
||||
Log.Error("must specify x/y/z axis!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error("too many params!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch (calType)
|
||||
{
|
||||
case CalibrateType.pos:
|
||||
targetTrans.localPosition = DoCalibrate(tweakType, targetTrans.localPosition, param);
|
||||
break;
|
||||
case CalibrateType.rot:
|
||||
targetTrans.localEulerAngles = DoCalibrate(tweakType, targetTrans.localEulerAngles, param);
|
||||
break;
|
||||
case CalibrateType.scale:
|
||||
targetTrans.localScale = DoCalibrate(tweakType, targetTrans.localScale, param);
|
||||
break;
|
||||
case CalibrateType.offset:
|
||||
//var zoomAction = Convert.ChangeType(inv.holdingItemData.actionData[1], typeof(ItemActionZoom).GetNestedType("ItemActionDataZoom", System.Reflection.BindingFlags.NonPublic));
|
||||
if (!(inv.holdingItemData.actionData[1] is ItemActionZoom.ItemActionDataZoom zoomAction))
|
||||
{
|
||||
Log.Error("holding item can not aim!");
|
||||
return;
|
||||
}
|
||||
zoomAction.ScopeCameraOffset = DoCalibrate(tweakType, zoomAction.ScopeCameraOffset, param);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3 DoCalibrate(TweakType type, Vector3 origin, Vector3 param)
|
||||
{
|
||||
Vector3 res = origin;
|
||||
switch (type)
|
||||
{
|
||||
case TweakType.abs:
|
||||
res = param;
|
||||
break;
|
||||
case TweakType.rel:
|
||||
res = origin + param;
|
||||
break;
|
||||
case TweakType.log:
|
||||
Log.Out(res.ToString("F6"));
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public override string[] getCommands()
|
||||
{
|
||||
return new string[] { "calibrate", "calib" };
|
||||
}
|
||||
|
||||
public override string getDescription()
|
||||
{
|
||||
return "adjust weapon transform rotation, position, scale, scope offset in game and print current value for xml editing purpose.";
|
||||
}
|
||||
|
||||
public override bool IsExecuteOnClient => true;
|
||||
|
||||
public override int DefaultPermissionLevel => 1000;
|
||||
|
||||
private enum CalibrateType
|
||||
{
|
||||
pos,
|
||||
rot,
|
||||
scale,
|
||||
offset
|
||||
}
|
||||
|
||||
private enum TweakType
|
||||
{
|
||||
abs,
|
||||
rel,
|
||||
log
|
||||
}
|
||||
}
|
||||
|
||||
57
Scripts/ConsoleCmd/ConsoleCmdListParticleScripts.cs
Normal file
57
Scripts/ConsoleCmd/ConsoleCmdListParticleScripts.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class ConsoleCmdListParticleScripts : ConsoleCmdAbstract
|
||||
{
|
||||
public override bool IsExecuteOnClient => true;
|
||||
|
||||
public override bool AllowedInMainMenu => false;
|
||||
|
||||
public override void Execute(List<string> _params, CommandSenderInfo _senderInfo)
|
||||
{
|
||||
if(_params.Count > 1)
|
||||
{
|
||||
Log.Error("Invalid param count: expecting 0 or 1!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_params.Count == 0)
|
||||
{
|
||||
HashSet<string> typeNames = new HashSet<string>();
|
||||
foreach (var pe in ParticleEffect.loadedTs.Values)
|
||||
{
|
||||
foreach (var script in pe.GetComponentsInChildren<MonoBehaviour>())
|
||||
{
|
||||
typeNames.Add(script.GetType().AssemblyQualifiedName);
|
||||
}
|
||||
}
|
||||
string print = string.Join("\n", typeNames.ToList().OrderBy(s => s));
|
||||
Log.Out($"Listing all scripts...\n{print}\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
int id = ParticleEffect.ToId(_params[0]);
|
||||
var pe = ParticleEffect.GetDynamicTransform(id);
|
||||
if (pe)
|
||||
{
|
||||
string print = "";
|
||||
foreach (var script in pe.GetComponentsInChildren<MonoBehaviour>())
|
||||
{
|
||||
print += $"{(script.transform.parent != null ? pe.GetChildPath(script.transform) : script.transform.name)} - {script.GetType().AssemblyQualifiedName}\n";
|
||||
}
|
||||
Log.Out($"{_params[0]} has following scripts attached:\n{print}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string[] getCommands()
|
||||
{
|
||||
return new[] { "listpes" };
|
||||
}
|
||||
|
||||
public override string getDescription()
|
||||
{
|
||||
return "list monobehaviour on all the particle effects that are currently loaded, or the specified one only.";
|
||||
}
|
||||
}
|
||||
59
Scripts/ConsoleCmd/ConsoleCmdMultiActionItemValueDebug.cs
Normal file
59
Scripts/ConsoleCmd/ConsoleCmdMultiActionItemValueDebug.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using HarmonyLib;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace KFCommonUtilityLib.Scripts.ConsoleCmd
|
||||
{
|
||||
public class ConsoleCmdMultiActionItemValueDebug : ConsoleCmdAbstract
|
||||
{
|
||||
public override bool IsExecuteOnClient => true;
|
||||
|
||||
public override int DefaultPermissionLevel => base.DefaultPermissionLevel;
|
||||
|
||||
public override bool AllowedInMainMenu => false;
|
||||
|
||||
public override void Execute(List<string> _params, CommandSenderInfo _senderInfo)
|
||||
{
|
||||
EntityPlayerLocal player = GameManager.Instance.World?.GetPrimaryPlayer();
|
||||
if (player)
|
||||
{
|
||||
ItemValue itemValue = player.inventory.holdingItemItemValue;
|
||||
LogMeta(itemValue);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LogMeta(ItemValue itemValue)
|
||||
{
|
||||
if (itemValue != null && itemValue.ItemClass != null)
|
||||
{
|
||||
var metadata = itemValue.Metadata;
|
||||
if (metadata != null)
|
||||
{
|
||||
Log.Out("Logging metadata...");
|
||||
foreach (var pair in metadata)
|
||||
{
|
||||
if (pair.Value != null)
|
||||
{
|
||||
Log.Out($"key: {pair.Key}, type: {pair.Value.typeTag.ToString()}, value: {pair.Value.GetValue()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Out("Metadata is null!");
|
||||
}
|
||||
Log.Out($"meta: {itemValue.Meta}, ammo index: {itemValue.SelectedAmmoTypeIndex}");
|
||||
}
|
||||
}
|
||||
|
||||
public override string[] getCommands()
|
||||
{
|
||||
return new string[] { "maivd" };
|
||||
}
|
||||
|
||||
public override string getDescription()
|
||||
{
|
||||
return "Debug ItemValue metadata and stuff.";
|
||||
}
|
||||
}
|
||||
}
|
||||
59
Scripts/ConsoleCmd/ConsoleCmdPlayerDebugInfo.cs
Normal file
59
Scripts/ConsoleCmd/ConsoleCmdPlayerDebugInfo.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace KFCommonUtilityLib.Scripts.ConsoleCmd
|
||||
{
|
||||
public class ConsoleCmdPlayerDebugInfo : ConsoleCmdAbstract
|
||||
{
|
||||
public override bool IsExecuteOnClient => true;
|
||||
|
||||
public override void Execute(List<string> _params, CommandSenderInfo _senderInfo)
|
||||
{
|
||||
EntityPlayerLocal player = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
RenderTexture playerCamRT = player.playerCamera.targetTexture;
|
||||
if (playerCamRT != null)
|
||||
SaveTextureToFileUtility.SaveTextureToFile(playerCamRT, Application.dataPath + playerCamRT.name, playerCamRT.width, playerCamRT.height, SaveTextureToFileUtility.SaveTextureFileFormat.PNG, 95, true, (bool res) => Log.Out(res ? $"player camera rendertexture saved to {Application.dataPath}" : "failed to save player camera render texture!"));
|
||||
RenderTexture finalCamRT = player.finalCamera.targetTexture;
|
||||
if (finalCamRT != null)
|
||||
SaveTextureToFileUtility.SaveTextureToFile(finalCamRT, Application.dataPath + finalCamRT.name, finalCamRT.width, finalCamRT.height, SaveTextureToFileUtility.SaveTextureFileFormat.PNG, 95, true, (bool res) => Log.Out(res ? $"final camera rendertexture saved to {Application.dataPath}" : "failed to save final camera render texture!"));
|
||||
Renderer[] renderers = player.gameObject.GetComponentsInChildren<Renderer>();
|
||||
Log.Out($"renderers layers: \n{string.Join("\n", renderers.Select(r => r.gameObject.name + " layer:" + r.gameObject.layer))})");
|
||||
Log.Out($"player transform values: {player.transform.name} {player.transform.position}/{player.transform.eulerAngles}");
|
||||
Log.Out($"player camera transform values: {player.playerCamera.transform.parent.name}/{player.playerCamera.gameObject.name} {player.playerCamera.transform.localPosition}/{player.playerCamera.transform.localEulerAngles} viewport {player.playerCamera.rect} render layers {player.playerCamera.cullingMask} fov {player.playerCamera.fieldOfView}");
|
||||
Log.Out($"final camera transform values: {player.finalCamera.transform.parent.name}/{player.finalCamera.gameObject.name} {player.finalCamera.transform.localPosition}/{player.finalCamera.transform.localEulerAngles} viewport {player.finalCamera.rect} render layers {player.finalCamera.cullingMask} fov {player.finalCamera.fieldOfView}");
|
||||
Log.Out($"vp components list:\n{string.Join("\n", player.RootTransform.GetComponentsInChildren<vp_Component>().Select(c => c.GetType().Name + " on " + c.transform.name))}");
|
||||
foreach (var animator in player.RootTransform.GetComponentsInChildren<Animator>())
|
||||
{
|
||||
Log.Out($"animator transform {animator.name} values: {animator.transform.localPosition}/{animator.transform.localEulerAngles}");
|
||||
}
|
||||
Log.Out("PRINTING PLAYER HIERARCHY:");
|
||||
Log.Out(PrintTransform(player.RootTransform));
|
||||
|
||||
Transform fpsArm = ((AvatarLocalPlayerController)player.emodel.avatarController).FPSArms.animator.transform;
|
||||
Log.Out($"FPS ARM:\nparent {fpsArm.parent.name}\n{PrintTransform(fpsArm)}");
|
||||
}
|
||||
|
||||
private static string PrintTransform(Transform parent, string str = "", int indent = 0)
|
||||
{
|
||||
str += "".PadLeft(indent * 4) + $"{parent.name}/pos:{parent.transform.localPosition}/rot:{parent.localEulerAngles}" + "\n";
|
||||
indent++;
|
||||
foreach (Transform child in parent)
|
||||
{
|
||||
str = PrintTransform(child, str, indent);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public override string[] getCommands()
|
||||
{
|
||||
return new string[] { "printpinfo" };
|
||||
}
|
||||
|
||||
public override string getDescription()
|
||||
{
|
||||
return "print player debug info.";
|
||||
}
|
||||
}
|
||||
}
|
||||
41
Scripts/ConsoleCmd/ConsoleCmdPrintLocalCache.cs
Normal file
41
Scripts/ConsoleCmd/ConsoleCmdPrintLocalCache.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace KFCommonUtilityLib.Scripts.ConsoleCmd
|
||||
{
|
||||
public class ConsoleCmdPrintLocalCache : ConsoleCmdAbstract
|
||||
{
|
||||
public override bool IsExecuteOnClient => true;
|
||||
|
||||
public override bool AllowedInMainMenu => false;
|
||||
|
||||
public override int DefaultPermissionLevel => 1000;
|
||||
|
||||
public override void Execute(List<string> _params, CommandSenderInfo _senderInfo)
|
||||
{
|
||||
if (_params.Count != 1)
|
||||
return;
|
||||
int index = int.Parse(_params[0]);
|
||||
var player = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
if (player != null && player.inventory.holdingItemData.actionData[index] is IModuleContainerFor<ActionModuleLocalPassiveCache.LocalPassiveCacheData> module)
|
||||
{
|
||||
ActionModuleLocalPassiveCache.LocalPassiveCacheData instance = module.Instance;
|
||||
foreach (int hash in instance)
|
||||
{
|
||||
Log.Out($"cache {instance.GetCachedName(hash)} value {instance.GetCachedValue(hash)}");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override string[] getCommands()
|
||||
{
|
||||
return new[] { "plc" };
|
||||
}
|
||||
|
||||
public override string getDescription()
|
||||
{
|
||||
return "Show local cache for current holding item.";
|
||||
}
|
||||
}
|
||||
}
|
||||
28
Scripts/ConsoleCmd/ConsoleCmdReloadLog.cs
Normal file
28
Scripts/ConsoleCmd/ConsoleCmdReloadLog.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class ConsoleCmdReloadLog : ConsoleCmdAbstract
|
||||
{
|
||||
public static bool LogInfo { get; private set; } = false;
|
||||
|
||||
public override bool IsExecuteOnClient => true;
|
||||
|
||||
public override bool AllowedInMainMenu => false;
|
||||
|
||||
public override int DefaultPermissionLevel => 1000;
|
||||
|
||||
public override void Execute(List<string> _params, CommandSenderInfo _senderInfo)
|
||||
{
|
||||
LogInfo = !LogInfo;
|
||||
Log.Out($"Log Reload Info: {LogInfo}");
|
||||
}
|
||||
|
||||
public override string[] getCommands()
|
||||
{
|
||||
return new string[] { "reloadlog", "rlog" };
|
||||
}
|
||||
|
||||
public override string getDescription()
|
||||
{
|
||||
return "Print reload animation length and multiplier.";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user