cleanup (tabs, whitespace, usings)

This commit is contained in:
Mister_Nebula 2021-07-07 09:02:23 +01:00
parent 78fd19430e
commit f267276ccf
16 changed files with 54 additions and 63 deletions

View File

@ -1,5 +1,5 @@
using QSB.WorldSync;
using QSB.Utility;
using QSB.Utility;
using QSB.WorldSync;
using UnityEngine;
namespace QSB.Animation.NPC.WorldObjects
@ -15,10 +15,10 @@ namespace QSB.Animation.NPC.WorldObjects
public abstract CharacterDialogueTree GetDialogueTree();
public virtual void StartConversation()
=> GetDialogueTree().RaiseEvent("OnStartConversation");
public virtual void StartConversation()
=> GetDialogueTree().RaiseEvent("OnStartConversation");
public virtual void EndConversation()
public virtual void EndConversation()
=> GetDialogueTree().RaiseEvent("OnEndConversation");
public abstract bool InConversation();

View File

@ -96,19 +96,19 @@ namespace QSB.Animation.Patches
else if (____leftFootGrounded && leftFootLift > 0.666f)
{
____leftFootGrounded = false;
__instance.RaiseEvent("OnLeftFootLift");
__instance.RaiseEvent("OnLeftFootLift");
}
var rightFootLift = ____animator.GetFloat("RightFootLift");
if (!____rightFootGrounded && rightFootLift < 0.333f)
{
____rightFootGrounded = true;
__instance.RaiseEvent("OnRightFootGrounded");
__instance.RaiseEvent("OnRightFootGrounded");
}
else if (____rightFootGrounded && rightFootLift > 0.666f)
{
____rightFootGrounded = false;
__instance.RaiseEvent("OnRightFootLift");
__instance.RaiseEvent("OnRightFootLift");
}
}

View File

@ -1,7 +1,7 @@
using QSB.Events;
using QSB.Patches;
using QSB.WorldSync;
using QSB.Utility;
using QSB.WorldSync;
using UnityEngine;
namespace QSB.OrbSync.Patches
@ -52,7 +52,7 @@ namespace QSB.OrbSync.Patches
{
QSBWorldSync.HandleSlotStateChange(__instance, orb, false);
____occupyingOrb = null;
__instance.RaiseEvent("OnSlotDeactivated", __instance);
__instance.RaiseEvent("OnSlotDeactivated", __instance);
__result = false;
return false;
}

View File

@ -1,7 +1,7 @@
using OWML.Utils;
using QSB.Events;
using QSB.WorldSync;
using QSB.Utility;
using QSB.WorldSync;
namespace QSB.OrbSync.WorldObjects
{
@ -38,7 +38,7 @@ namespace QSB.OrbSync.WorldObjects
var occOrb = state ? QSBWorldSync.OldOrbList[orbId] : null;
AttachedObject.SetValue("_occupyingOrb", occOrb);
var ev = state ? "OnSlotActivated" : "OnSlotDeactivated";
AttachedObject.RaiseEvent(ev, AttachedObject);
AttachedObject.RaiseEvent(ev, AttachedObject);
Activated = state;
}
}

View File

@ -36,26 +36,26 @@ namespace QSB.Player.Events
return;
}
// TODO : CLEAN. THIS. SHIT.
QSBWorldSync.DialogueConditions.ForEach(condition => QSBEventManager.FireEvent(EventNames.DialogueCondition, condition.Key, condition.Value));
// TODO : CLEAN. THIS. SHIT.
QSBWorldSync.DialogueConditions.ForEach(condition => QSBEventManager.FireEvent(EventNames.DialogueCondition, condition.Key, condition.Value));
QSBWorldSync.ShipLogFacts.ForEach(fact => QSBEventManager.FireEvent(EventNames.QSBRevealFact, fact.Id, fact.SaveGame, false));
//We could add a nested ForEach here, but, in my opinion, it would reduce readbility in this case - ShoosGun(Locochoco)
QSBWorldSync.ShipLogFacts.ForEach(fact => QSBEventManager.FireEvent(EventNames.QSBRevealFact, fact.Id, fact.SaveGame, false));
//We could add a nested ForEach here, but, in my opinion, it would reduce readbility in this case - ShoosGun(Locochoco)
foreach (var wallText in QSBWorldSync.GetWorldObjects<QSBWallText>().Where(x => x.AttachedObject.GetValue<bool>("_initialized") && x.AttachedObject.GetNumTextBlocks() > 0))
wallText.GetTranslatedIds().ForEach(id => QSBEventManager.FireEvent(EventNames.QSBTextTranslated, NomaiTextType.WallText, wallText.ObjectId, id));
wallText.GetTranslatedIds().ForEach(id => QSBEventManager.FireEvent(EventNames.QSBTextTranslated, NomaiTextType.WallText, wallText.ObjectId, id));
foreach (var computer in QSBWorldSync.GetWorldObjects<QSBComputer>().Where(x => x.AttachedObject.GetValue<bool>("_initialized") && x.AttachedObject.GetNumTextBlocks() > 0))
computer.GetTranslatedIds().ForEach(id => QSBEventManager.FireEvent(EventNames.QSBTextTranslated, NomaiTextType.Computer, computer.ObjectId, id));
computer.GetTranslatedIds().ForEach(id => QSBEventManager.FireEvent(EventNames.QSBTextTranslated, NomaiTextType.Computer, computer.ObjectId, id));
foreach (var vesselComputer in QSBWorldSync.GetWorldObjects<QSBVesselComputer>().Where(x => x.AttachedObject.GetValue<bool>("_initialized") && x.AttachedObject.GetNumTextBlocks() > 0))
vesselComputer.GetTranslatedIds().ForEach(id => QSBEventManager.FireEvent(EventNames.QSBTextTranslated, NomaiTextType.VesselComputer, vesselComputer.ObjectId, id));
vesselComputer.GetTranslatedIds().ForEach(id => QSBEventManager.FireEvent(EventNames.QSBTextTranslated, NomaiTextType.VesselComputer, vesselComputer.ObjectId, id));
var list = QSBWorldSync.GetWorldObjects<IQSBQuantumObject>().ToList();
for (var i = 0; i < list.Count; i++)
QSBEventManager.FireEvent(EventNames.QSBQuantumAuthority, i, list[i].ControllingPlayer);
QSBWorldSync.GetWorldObjects<QSBCampfire>().ForEach(campfire => QSBEventManager.FireEvent(EventNames.QSBCampfireState, campfire.ObjectId, campfire.GetState()));
QSBWorldSync.GetWorldObjects<QSBCampfire>().ForEach(campfire => QSBEventManager.FireEvent(EventNames.QSBCampfireState, campfire.ObjectId, campfire.GetState()));
}
}
}

View File

@ -8,10 +8,10 @@ namespace QSB.ProbeSync.Events
{
public override EventType Type => EventType.ProbeEvent;
public override void SetupListener()
public override void SetupListener()
=> GlobalMessenger<ProbeEvent>.AddListener(EventNames.QSBProbeEvent, Handler);
public override void CloseListener()
public override void CloseListener()
=> GlobalMessenger<ProbeEvent>.RemoveListener(EventNames.QSBProbeEvent, Handler);
private void Handler(ProbeEvent probeEvent) => SendEvent(CreateMessage(probeEvent));

View File

@ -8,10 +8,10 @@ namespace QSB.ProbeSync.Events
{
public override EventType Type => EventType.ProbeStartRetrieve;
public override void SetupListener()
public override void SetupListener()
=> GlobalMessenger<float>.AddListener(EventNames.QSBProbeStartRetrieve, Handler);
public override void CloseListener()
public override void CloseListener()
=> GlobalMessenger<float>.RemoveListener(EventNames.QSBProbeStartRetrieve, Handler);
private void Handler(float duration) => SendEvent(CreateMessage(duration));

View File

@ -59,10 +59,10 @@ namespace QSB.ProbeSync
Deactivate();
}
public bool IsRetrieving()
public bool IsRetrieving()
=> IsLaunched() && _isRetrieving;
public bool IsLaunched()
public bool IsLaunched()
=> gameObject.activeSelf;
public void HandleEvent(ProbeEvent probeEvent)

View File

@ -21,8 +21,8 @@ namespace QSB.QuantumSync.Patches
Postfix(nameof(Shape_OnDisable));
}
public static void Shape_OnEnable(Shape __instance)
=> __instance.RaiseEvent("OnShapeActivated", __instance);
public static void Shape_OnEnable(Shape __instance)
=> __instance.RaiseEvent("OnShapeActivated", __instance);
public static void Shape_OnDisable(Shape __instance)
=> __instance.RaiseEvent("OnShapeDeactivated", __instance);

View File

@ -2,7 +2,6 @@
using QSB.Events;
using QSB.Patches;
using QSB.Utility;
using QSB.WorldSync;
using UnityEngine;
namespace QSB.ShipSync.Patches

View File

@ -21,7 +21,7 @@ namespace QSB.Syncs.TransformSync
private readonly static Dictionary<PlayerInfo, Dictionary<Type, BaseTransformSync>> _storedTransformSyncs = new Dictionary<PlayerInfo, Dictionary<Type, BaseTransformSync>>();
public static T GetPlayers<T>(PlayerInfo player)
where T : BaseTransformSync
where T : BaseTransformSync
{
var dictOfOwnedSyncs = _storedTransformSyncs[player];
var wantedSync = dictOfOwnedSyncs[typeof(T)];

View File

@ -1,10 +1,8 @@
using OWML.Utils;
using QSB.SectorSync;
using QSB.SectorSync;
using QSB.SectorSync.WorldObjects;
using QSB.Utility;
using QSB.WorldSync;
using QuantumUNET.Transport;
using System.Linq;
using UnityEngine;
namespace QSB.Syncs.TransformSync

View File

@ -1,12 +1,7 @@
using QSB.Player;
using QSB.Player.TransformSync;
using QSB.ProbeSync.TransformSync;
using QSB.QuantumSync;
using QSB.ShipSync;
using QSB.ShipSync.TransformSync;
using QSB.Syncs.TransformSync;
using QSB.TimeSync;
using QSB.WorldSync;
using System.Linq;
using UnityEngine;

View File

@ -91,31 +91,31 @@ namespace QSB.Utility
public static float Map(this float value, float inputFrom, float inputTo, float outputFrom, float outputTo)
=> ((value - inputFrom) / (inputTo - inputFrom) * (outputTo - outputFrom)) + outputFrom;
public static void ForEach<T>(this System.Collections.Generic.IEnumerable<T> enumerable, Action<T> action)
{
foreach (var item in enumerable)
action(item);
}
public static void ForEach<T>(this System.Collections.Generic.IEnumerable<T> enumerable, Action<T> action)
{
foreach (var item in enumerable)
action(item);
}
private const BindingFlags Flags = BindingFlags.Instance
| BindingFlags.Static
| BindingFlags.Public
| BindingFlags.NonPublic
| BindingFlags.DeclaredOnly;
private const BindingFlags Flags = BindingFlags.Instance
| BindingFlags.Static
| BindingFlags.Public
| BindingFlags.NonPublic
| BindingFlags.DeclaredOnly;
public static void RaiseEvent<T>(this T instance, string eventName, params object[] args) // TODO : move this to qsb.utility
{
if (!(typeof(T)
.GetField(eventName, Flags)?
.GetValue(instance) is MulticastDelegate multiDelegate))
{
return;
}
public static void RaiseEvent<T>(this T instance, string eventName, params object[] args) // TODO : move this to qsb.utility
{
if (!(typeof(T)
.GetField(eventName, Flags)?
.GetValue(instance) is MulticastDelegate multiDelegate))
{
return;
}
multiDelegate.GetInvocationList().ToList().ForEach(dl => dl.DynamicInvoke(args));
}
multiDelegate.GetInvocationList().ToList().ForEach(dl => dl.DynamicInvoke(args));
}
public static void CallBase<ThisType, BaseType>(this ThisType obj, string methodName)
where ThisType : BaseType
{

View File

@ -6,7 +6,6 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using UnityEngine;
namespace QSB.WorldSync
@ -119,7 +118,7 @@ namespace QSB.WorldSync
WorldObjects.Add(worldObject);
return worldObject;
}
public static void HandleSlotStateChange(NomaiInterfaceSlot slot, NomaiInterfaceOrb affectingOrb, bool state)
{
var slotList = GetWorldObjects<QSBOrbSlot>().ToList();

View File

@ -215,7 +215,7 @@ namespace QuantumUNET.Components
_targetSyncPosition = reader.ReadVector3();
_targetSyncRotation3D = QNetworkTransform.DeserializeRotation(reader);
}
}
}
private bool HasMoved()
{