Merge pull request #353 from misternebula/c#9

C# 9
This commit is contained in:
_nebula 2021-11-20 21:23:25 +00:00 committed by GitHub
commit 1a3a364906
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
128 changed files with 248 additions and 337 deletions

View File

@ -19,7 +19,7 @@ namespace QSB.Anglerfish.Events
private void Handler(QSBAngler qsbAngler) => SendEvent(CreateMessage(qsbAngler));
private AnglerChangeStateMessage CreateMessage(QSBAngler qsbAngler) => new AnglerChangeStateMessage
private AnglerChangeStateMessage CreateMessage(QSBAngler qsbAngler) => new()
{
ObjectId = qsbAngler.ObjectId,
EnumValue = qsbAngler.AttachedObject._currentState,

View File

@ -228,7 +228,7 @@ namespace QSB.Anglerfish.Patches
}
}
__instance._targetPos = qsbAngler.TargetTransform.position + normalized * num2;
__instance._targetPos = qsbAngler.TargetTransform.position + (normalized * num2);
__instance.RotateTowardsTarget(__instance._targetPos, __instance._turnSpeed, __instance._quickTurnSpeed);
if (__instance._turningInPlace)
{
@ -287,8 +287,8 @@ namespace QSB.Anglerfish.Patches
return false;
}
if (__instance._currentState == AnglerfishController.AnglerState.Consuming
|| __instance._currentState == AnglerfishController.AnglerState.Stunned)
if (__instance._currentState is AnglerfishController.AnglerState.Consuming
or AnglerfishController.AnglerState.Stunned)
{
return false;
}
@ -311,8 +311,8 @@ namespace QSB.Anglerfish.Patches
}
else
{
if (__instance._currentState != AnglerfishController.AnglerState.Lurking
&& __instance._currentState != AnglerfishController.AnglerState.Investigating)
if (__instance._currentState is not AnglerfishController.AnglerState.Lurking
and not AnglerfishController.AnglerState.Investigating)
{
return false;
}

View File

@ -13,7 +13,7 @@ namespace QSB.Anglerfish.TransformSync
public override bool UseInterpolation => false;
private QSBAngler _qsbAngler;
private static readonly List<AnglerTransformSync> _instances = new List<AnglerTransformSync>();
private static readonly List<AnglerTransformSync> _instances = new();
protected override OWRigidbody GetRigidbody()
=> _qsbAngler.AttachedObject._anglerBody;

View File

@ -13,7 +13,7 @@ namespace QSB.Animation.NPC.Events
private void Handler(AnimationEvent animEvent, int index) => SendEvent(CreateMessage(animEvent, index));
private NpcAnimationMessage CreateMessage(AnimationEvent animEvent, int index) => new NpcAnimationMessage
private NpcAnimationMessage CreateMessage(AnimationEvent animEvent, int index) => new()
{
AboutId = LocalPlayerId,
AnimationEvent = animEvent,

View File

@ -6,7 +6,7 @@ namespace QSB.Animation.NPC.WorldObjects
{
internal class QSBCharacterAnimController : NpcAnimController<CharacterAnimController>
{
private readonly List<PlayerInfo> _playersInHeadZone = new List<PlayerInfo>();
private readonly List<PlayerInfo> _playersInHeadZone = new();
public List<PlayerInfo> GetPlayersInHeadZone()
=> _playersInHeadZone;

View File

@ -6,7 +6,7 @@ namespace QSB.Animation.NPC.WorldObjects
{
internal class QSBSolanumAnimController : WorldObject<SolanumAnimController>
{
private readonly List<PlayerInfo> _playersInHeadZone = new List<PlayerInfo>();
private readonly List<PlayerInfo> _playersInHeadZone = new();
public override void Init(SolanumAnimController controller, int id)
{

View File

@ -225,7 +225,7 @@ namespace QSB.Animation.Player
InvisibleAnimator.runtimeAnimatorController = controller;
VisibleAnimator.runtimeAnimatorController = controller;
if (type != AnimationType.PlayerSuited && type != AnimationType.PlayerUnsuited)
if (type is not AnimationType.PlayerSuited and not AnimationType.PlayerUnsuited)
{
VisibleAnimator.SetTrigger("Playing");
InvisibleAnimator.SetTrigger("Playing");

View File

@ -13,7 +13,7 @@ namespace QSB.Animation.Player
private Animator _from;
private Animator _to;
private readonly Dictionary<string, AnimFloatParam> _floatParams = new Dictionary<string, AnimFloatParam>();
private readonly Dictionary<string, AnimFloatParam> _floatParams = new();
public void Init(Animator from, Animator to)
{

View File

@ -12,7 +12,7 @@ namespace QSB.Animation.Player.Events
private void Handler(uint attachedNetId, string name) => SendEvent(CreateMessage(attachedNetId, name));
private AnimationTriggerMessage CreateMessage(uint attachedNetId, string name) => new AnimationTriggerMessage
private AnimationTriggerMessage CreateMessage(uint attachedNetId, string name) => new()
{
AboutId = LocalPlayerId,
AttachedNetId = attachedNetId,

View File

@ -14,7 +14,7 @@ namespace QSB.Animation.Player.Events
private void Handler(uint player, AnimationType type) => SendEvent(CreateMessage(player, type));
private EnumMessage<AnimationType> CreateMessage(uint player, AnimationType type) => new EnumMessage<AnimationType>
private EnumMessage<AnimationType> CreateMessage(uint player, AnimationType type) => new()
{
AboutId = player,
EnumValue = type

View File

@ -23,7 +23,7 @@ namespace QSB.Animation.Player.Events
private void HandleSuitUp() => SendEvent(CreateMessage(true));
private void HandleSuitDown() => SendEvent(CreateMessage(false));
private ToggleMessage CreateMessage(bool value) => new ToggleMessage
private ToggleMessage CreateMessage(bool value) => new()
{
AboutId = LocalPlayerId,
ToggleValue = value

View File

@ -8,7 +8,7 @@ namespace QSB.Animation.Player.Thrusters
private Thruster _thruster;
private Light _light;
private AnimationCurve _scaleByThrust = AnimationCurve.Linear(0f, 0f, 1f, 1f);
private DampedSpring _scaleSpring = new DampedSpring();
private DampedSpring _scaleSpring = new();
private float _belowMaxThrustScalar = 1f;
private MeshRenderer _thrusterRenderer;
private Vector3 _thrusterFilter;

View File

@ -47,23 +47,12 @@ namespace QSB.Animation.Player.Thrusters
var gameObject = controller.gameObject;
var oldThruster = controller.GetValue<Thruster>("_thruster");
var oldLight = controller.GetValue<Light>("_light");
// pain
Vector3 localPos;
switch (oldThruster)
var localPos = oldThruster switch
{
case Thruster.Up_RightThruster:
case Thruster.Up_LeftThruster:
localPos = new Vector3(0, 0, 3);
break;
case Thruster.Down_RightThruster:
case Thruster.Down_LeftThruster:
localPos = new Vector3(0, 0, 7);
break;
default:
localPos = new Vector3(0, 0, 5);
break;
}
Thruster.Up_RightThruster or Thruster.Up_LeftThruster => new Vector3(0, 0, 3),
Thruster.Down_RightThruster or Thruster.Down_LeftThruster => new Vector3(0, 0, 7),
_ => new Vector3(0, 0, 5),
};
oldLight.transform.localPosition = localPos;
var oldAnimCurve = controller.GetValue<AnimationCurve>("_scaleByThrust");

View File

@ -14,7 +14,7 @@ namespace QSB.CampfireSync.Events
private void Handler(int objId, Campfire.State state) => SendEvent(CreateMessage(objId, state));
private EnumWorldObjectMessage<Campfire.State> CreateMessage(int objId, Campfire.State state) => new EnumWorldObjectMessage<Campfire.State>
private EnumWorldObjectMessage<Campfire.State> CreateMessage(int objId, Campfire.State state) => new()
{
AboutId = LocalPlayerId,
ObjectId = objId,

View File

@ -17,7 +17,7 @@ namespace QSB.ClientServerStateSync.Events
private void Handler(ClientState state) => SendEvent(CreateMessage(state));
private EnumMessage<ClientState> CreateMessage(ClientState state) => new EnumMessage<ClientState>
private EnumMessage<ClientState> CreateMessage(ClientState state) => new()
{
AboutId = LocalPlayerId,
EnumValue = state

View File

@ -15,7 +15,7 @@ namespace QSB.ClientServerStateSync.Events
private void Handler(ServerState state) => SendEvent(CreateMessage(state));
private EnumMessage<ServerState> CreateMessage(ServerState state) => new EnumMessage<ServerState>
private EnumMessage<ServerState> CreateMessage(ServerState state) => new()
{
AboutId = LocalPlayerId,
EnumValue = state

View File

@ -133,9 +133,9 @@ namespace QSB.ClientServerStateSync
if (_currentState == ServerState.WaitingForAllPlayersToReady)
{
if (QSBPlayerManager.PlayerList.All(x
=> x.State == ClientState.WaitingForOthersToReadyInSolarSystem
|| x.State == ClientState.AliveInSolarSystem
|| x.State == ClientState.AliveInEye))
=> x.State is ClientState.WaitingForOthersToReadyInSolarSystem
or ClientState.AliveInSolarSystem
or ClientState.AliveInEye))
{
DebugLog.DebugWrite($"All ready!!");
QSBEventManager.FireEvent(EventNames.QSBStartLoop);

View File

@ -14,7 +14,7 @@ namespace QSB.ConversationSync.Events
private void Handler(uint id, string message, ConversationType type) => SendEvent(CreateMessage(id, message, type));
private ConversationMessage CreateMessage(uint id, string message, ConversationType type) => new ConversationMessage
private ConversationMessage CreateMessage(uint id, string message, ConversationType type) => new()
{
AboutId = LocalPlayerId,
ObjectId = (int)id,

View File

@ -15,7 +15,7 @@ namespace QSB.ConversationSync.Events
private void Handler(int objId, uint playerId, bool state) => SendEvent(CreateMessage(objId, playerId, state));
private ConversationStartEndMessage CreateMessage(int objId, uint playerId, bool state) => new ConversationStartEndMessage
private ConversationStartEndMessage CreateMessage(int objId, uint playerId, bool state) => new()
{
AboutId = LocalPlayerId,
TreeId = objId,

View File

@ -12,7 +12,7 @@ namespace QSB.ConversationSync.Events
private void Handler(string name, bool state) => SendEvent(CreateMessage(name, state));
private DialogueConditionMessage CreateMessage(string name, bool state) => new DialogueConditionMessage
private DialogueConditionMessage CreateMessage(string name, bool state) => new()
{
AboutId = LocalPlayerId,
ConditionName = name,

View File

@ -15,7 +15,7 @@ namespace QSB.DeathSync.Events
private void Handler(EndLoopReason type) => SendEvent(CreateMessage(type));
private EnumMessage<EndLoopReason> CreateMessage(EndLoopReason type) => new EnumMessage<EndLoopReason>
private EnumMessage<EndLoopReason> CreateMessage(EndLoopReason type) => new()
{
AboutId = LocalPlayerId,
EnumValue = type

View File

@ -15,7 +15,7 @@ namespace QSB.DeathSync.Events
private void Handler(DeathType type) => SendEvent(CreateMessage(type));
private PlayerDeathMessage CreateMessage(DeathType type) => new PlayerDeathMessage
private PlayerDeathMessage CreateMessage(DeathType type) => new()
{
AboutId = LocalPlayerId,
EnumValue = type,

View File

@ -14,7 +14,7 @@ namespace QSB.DeathSync.Events
private void Handler() => SendEvent(CreateMessage());
private PlayerMessage CreateMessage() => new PlayerMessage
private PlayerMessage CreateMessage() => new()
{
AboutId = LocalPlayerId
};

View File

@ -5,7 +5,7 @@ namespace QSB.DeathSync
{
public static class Necronomicon
{
private static readonly Dictionary<DeathType, string[]> Darkhold = new Dictionary<DeathType, string[]>
private static readonly Dictionary<DeathType, string[]> Darkhold = new()
{
{ DeathType.Default, new[] // Running out of health
{

View File

@ -14,7 +14,7 @@ namespace QSB.ElevatorSync.Events
private void Handler(int id, bool isGoingUp) => SendEvent(CreateMessage(id, isGoingUp));
private BoolWorldObjectMessage CreateMessage(int id, bool isGoingUp) => new BoolWorldObjectMessage
private BoolWorldObjectMessage CreateMessage(int id, bool isGoingUp) => new()
{
State = isGoingUp,
ObjectId = id

View File

@ -39,7 +39,7 @@ namespace QSB.Events
{
public static bool Ready { get; private set; }
private static List<IQSBEvent> _eventList = new List<IQSBEvent>();
private static List<IQSBEvent> _eventList = new();
public static void Init()
{

View File

@ -13,7 +13,7 @@ namespace QSB.FrequencySync.Events
private void Handler(SignalFrequency frequency) => SendEvent(CreateMessage(frequency));
private EnumMessage<SignalFrequency> CreateMessage(SignalFrequency frequency) => new EnumMessage<SignalFrequency>
private EnumMessage<SignalFrequency> CreateMessage(SignalFrequency frequency) => new()
{
AboutId = QSBPlayerManager.LocalPlayerId,
EnumValue = frequency

View File

@ -13,7 +13,7 @@ namespace QSB.FrequencySync.Events
private void Handler(SignalName name) => SendEvent(CreateMessage(name));
private EnumMessage<SignalName> CreateMessage(SignalName name) => new EnumMessage<SignalName>
private EnumMessage<SignalName> CreateMessage(SignalName name) => new()
{
AboutId = QSBPlayerManager.LocalPlayerId,
EnumValue = name

View File

@ -14,7 +14,7 @@ namespace QSB.GeyserSync.Events
private void Handler(int id, bool state) => SendEvent(CreateMessage(id, state));
private BoolWorldObjectMessage CreateMessage(int id, bool state) => new BoolWorldObjectMessage
private BoolWorldObjectMessage CreateMessage(int id, bool state) => new()
{
AboutId = LocalPlayerId,
ObjectId = id,

View File

@ -20,7 +20,7 @@ namespace QSB.ItemSync.Events
private void Handler(int objectId, Vector3 position, Vector3 normal, Sector sector)
=> SendEvent(CreateMessage(objectId, position, normal, sector));
private DropItemMessage CreateMessage(int objectId, Vector3 position, Vector3 normal, Sector sector) => new DropItemMessage
private DropItemMessage CreateMessage(int objectId, Vector3 position, Vector3 normal, Sector sector) => new()
{
ObjectId = objectId,
Position = position,

View File

@ -20,7 +20,7 @@ namespace QSB.ItemSync.Events
private void Handler(int itemId)
=> SendEvent(CreateMessage(itemId));
private WorldObjectMessage CreateMessage(int itemid) => new WorldObjectMessage
private WorldObjectMessage CreateMessage(int itemid) => new()
{
AboutId = QSBPlayerManager.LocalPlayerId,
ObjectId = itemid
@ -33,39 +33,19 @@ namespace QSB.ItemSync.Events
var itemType = itemObject.GetItemType();
player.HeldItem = itemObject;
Transform itemSocket = null;
switch (itemType)
var itemSocket = itemType switch
{
case ItemType.Scroll:
itemSocket = player.ScrollSocket;
break;
case ItemType.SharedStone:
itemSocket = player.SharedStoneSocket;
break;
case ItemType.WarpCore:
itemSocket = ((QSBWarpCoreItem)itemObject).IsVesselCoreType()
? player.VesselCoreSocket
: player.WarpCoreSocket;
break;
case ItemType.Lantern:
itemSocket = player.SimpleLanternSocket;
break;
case ItemType.DreamLantern:
itemSocket = player.DreamLanternSocket;
break;
case ItemType.SlideReel:
itemSocket = player.SlideReelSocket;
break;
case ItemType.VisionTorch:
itemSocket = player.VisionTorchSocket;
break;
default:
itemSocket = player.ItemSocket;
break;
}
ItemType.Scroll => player.ScrollSocket,
ItemType.SharedStone => player.SharedStoneSocket,
ItemType.WarpCore => ((QSBWarpCoreItem)itemObject).IsVesselCoreType()
? player.VesselCoreSocket
: player.WarpCoreSocket,
ItemType.Lantern => player.SimpleLanternSocket,
ItemType.DreamLantern => player.DreamLanternSocket,
ItemType.SlideReel => player.SlideReelSocket,
ItemType.VisionTorch => player.VisionTorchSocket,
_ => player.ItemSocket,
};
itemObject.PickUpItem(itemSocket, message.AboutId);
}
}

View File

@ -20,7 +20,7 @@ namespace QSB.ItemSync.Events
private void Handler(int socketId, int itemId, SocketEventType type)
=> SendEvent(CreateMessage(socketId, itemId, type));
private SocketItemMessage CreateMessage(int socketId, int itemId, SocketEventType type) => new SocketItemMessage
private SocketItemMessage CreateMessage(int socketId, int itemId, SocketEventType type) => new()
{
AboutId = QSBPlayerManager.LocalPlayerId,
SocketId = socketId,

View File

@ -12,7 +12,7 @@ namespace QSB.LogSync.Events
private void Handler(string id, bool saveGame, bool showNotification) => SendEvent(CreateMessage(id, saveGame, showNotification));
private RevealFactMessage CreateMessage(string id, bool saveGame, bool showNotification) => new RevealFactMessage
private RevealFactMessage CreateMessage(string id, bool saveGame, bool showNotification) => new()
{
AboutId = LocalPlayerId,
FactId = id,

View File

@ -196,26 +196,14 @@ namespace QSB.Menus
public void OnKicked(KickReason reason)
{
string text;
switch (reason)
var text = reason switch
{
case KickReason.QSBVersionNotMatching:
text = "Server refused connection as QSB version does not match.";
break;
case KickReason.GameVersionNotMatching:
text = "Server refused connection as Outer Wilds version does not match.";
break;
case KickReason.GamePlatformNotMatching:
text = "Server refused connection as Outer Wilds platform does not match. (Steam/Epic)";
break;
case KickReason.None:
text = "Kicked from server. No reason given.";
break;
default:
text = $"Kicked from server. KickReason:{reason}";
break;
}
KickReason.QSBVersionNotMatching => "Server refused connection as QSB version does not match.",
KickReason.GameVersionNotMatching => "Server refused connection as Outer Wilds version does not match.",
KickReason.GamePlatformNotMatching => "Server refused connection as Outer Wilds platform does not match. (Steam/Epic)",
KickReason.None => "Kicked from server. No reason given.",
_ => $"Kicked from server. KickReason:{reason}",
};
OpenInfoPopup(text, "OK");
DisconnectButton.gameObject.SetActive(false);
@ -230,17 +218,11 @@ namespace QSB.Menus
return;
}
string text;
switch (error)
var text = error switch
{
case NetworkError.Timeout:
text = "Client disconnected with error!\r\nConnection timed out.";
break;
default:
text = $"Client disconnected with error!\r\nNetworkError:{error}";
break;
}
NetworkError.Timeout => "Client disconnected with error!\r\nConnection timed out.",
_ => $"Client disconnected with error!\r\nNetworkError:{error}",
};
OpenInfoPopup(text, "OK");
DisconnectButton.gameObject.SetActive(false);

View File

@ -17,7 +17,7 @@ namespace QSB.MeteorSync.Events
private void Handler(QSBFragment qsbFragment, float damage) =>
SendEvent(CreateMessage(qsbFragment, damage));
private FragmentDamageMessage CreateMessage(QSBFragment qsbFragment, float damage) => new FragmentDamageMessage
private FragmentDamageMessage CreateMessage(QSBFragment qsbFragment, float damage) => new()
{
ObjectId = qsbFragment.ObjectId,
Damage = damage

View File

@ -73,11 +73,11 @@ namespace QSB.MeteorSync.Events
var whiteHoleVolume = MeteorManager.WhiteHoleVolume;
var attachedFluidDetector = body.GetAttachedFluidDetector();
var attachedForceDetector = body.GetAttachedForceDetector();
if (attachedFluidDetector != null && attachedFluidDetector is ConstantFluidDetector constantFluidDetector)
if (attachedFluidDetector is not null and ConstantFluidDetector constantFluidDetector)
{
constantFluidDetector.SetDetectableFluid(whiteHoleVolume._fluidVolume);
}
if (attachedForceDetector != null && attachedForceDetector is ConstantForceDetector constantForceDetector)
if (attachedForceDetector is not null and ConstantForceDetector constantForceDetector)
{
constantForceDetector.ClearAllFields();
}

View File

@ -17,7 +17,7 @@ namespace QSB.MeteorSync.Events
private void Handler(QSBMeteorLauncher qsbMeteorLauncher) =>
SendEvent(CreateMessage(qsbMeteorLauncher));
private MeteorLaunchMessage CreateMessage(QSBMeteorLauncher qsbMeteorLauncher) => new MeteorLaunchMessage
private MeteorLaunchMessage CreateMessage(QSBMeteorLauncher qsbMeteorLauncher) => new()
{
ObjectId = qsbMeteorLauncher.ObjectId,
MeteorId = qsbMeteorLauncher.MeteorId,

View File

@ -17,7 +17,7 @@ namespace QSB.MeteorSync.Events
private void Handler(QSBMeteorLauncher qsbMeteorLauncher) => SendEvent(CreateMessage(qsbMeteorLauncher));
private WorldObjectMessage CreateMessage(QSBMeteorLauncher qsbMeteorLauncher) => new WorldObjectMessage
private WorldObjectMessage CreateMessage(QSBMeteorLauncher qsbMeteorLauncher) => new()
{
ObjectId = qsbMeteorLauncher.ObjectId
};

View File

@ -17,7 +17,7 @@ namespace QSB.MeteorSync.Events
private void Handler(QSBMeteor qsbMeteor) => SendEvent(CreateMessage(qsbMeteor));
private WorldObjectMessage CreateMessage(QSBMeteor qsbMeteor) => new WorldObjectMessage
private WorldObjectMessage CreateMessage(QSBMeteor qsbMeteor) => new()
{
ObjectId = qsbMeteor.ObjectId
};

View File

@ -52,7 +52,7 @@ namespace QSB.MeteorSync.Patches
}
if (meteorController != null)
{
var linearVelocity = __instance._parentBody.GetPointVelocity(__instance.transform.position) + __instance.transform.TransformDirection(__instance._launchDirection) * qsbMeteorLauncher.LaunchSpeed;
var linearVelocity = __instance._parentBody.GetPointVelocity(__instance.transform.position) + (__instance.transform.TransformDirection(__instance._launchDirection) * qsbMeteorLauncher.LaunchSpeed);
var angularVelocity = __instance.transform.forward * 2f;
meteorController.Launch(null, __instance.transform.position, __instance.transform.rotation, linearVelocity, angularVelocity);
if (__instance._audioSector.ContainsOccupant(DynamicOccupant.Player))
@ -134,7 +134,7 @@ namespace QSB.MeteorSync.Patches
{
var vector = __instance._attachedBody.GetPosition() - __instance._anchorBody.GetPosition();
var d = Mathf.Min(distance, qsbFragment.LeashLength - vector.magnitude);
__instance._attachedBody.SetPosition(__instance._anchorBody.GetPosition() + vector.normalized * d);
__instance._attachedBody.SetPosition(__instance._anchorBody.GetPosition() + (vector.normalized * d));
}
return false;

View File

@ -118,7 +118,7 @@ namespace QSB.MeteorSync.Patches
qsbMeteorLauncher.MeteorId = qsbMeteor.ObjectId;
qsbMeteorLauncher.LaunchSpeed = Random.Range(__instance._minLaunchSpeed, __instance._maxLaunchSpeed);
var linearVelocity = __instance._parentBody.GetPointVelocity(__instance.transform.position) + __instance.transform.TransformDirection(__instance._launchDirection) * qsbMeteorLauncher.LaunchSpeed;
var linearVelocity = __instance._parentBody.GetPointVelocity(__instance.transform.position) + (__instance.transform.TransformDirection(__instance._launchDirection) * qsbMeteorLauncher.LaunchSpeed);
var angularVelocity = __instance.transform.forward * 2f;
meteorController.Launch(null, __instance.transform.position, __instance.transform.rotation, linearVelocity, angularVelocity);
if (__instance._audioSector.ContainsOccupant(DynamicOccupant.Player))
@ -184,7 +184,7 @@ namespace QSB.MeteorSync.Patches
{
var vector = __instance._attachedBody.GetPosition() - __instance._anchorBody.GetPosition();
var d = Mathf.Min(distance, qsbFragment.LeashLength - vector.magnitude);
__instance._attachedBody.SetPosition(__instance._anchorBody.GetPosition() + vector.normalized * d);
__instance._attachedBody.SetPosition(__instance._anchorBody.GetPosition() + (vector.normalized * d));
}
return false;

View File

@ -36,8 +36,6 @@ namespace QSB.MeteorSync.WorldObjects
public float LeashLength;
public void AddDamage(float damage)
{
AttachedObject.AddDamage(damage);
}
=> AttachedObject.AddDamage(damage);
}
}

View File

@ -13,7 +13,7 @@ namespace QSB.OrbSync.Events
private void Handler(int slotId, int orbId, bool slotState) => SendEvent(CreateMessage(slotId, orbId, slotState));
private OrbSlotMessage CreateMessage(int slotId, int orbId, bool slotState) => new OrbSlotMessage
private OrbSlotMessage CreateMessage(int slotId, int orbId, bool slotState) => new()
{
AboutId = LocalPlayerId,
SlotId = slotId,

View File

@ -19,7 +19,7 @@ namespace QSB.OrbSync.Events
private void Handler(int id) => SendEvent(CreateMessage(id));
private WorldObjectMessage CreateMessage(int id) => new WorldObjectMessage
private WorldObjectMessage CreateMessage(int id) => new()
{
AboutId = LocalPlayerId,
ObjectId = id

View File

@ -12,7 +12,7 @@ namespace QSB.OrbSync
{
public class OrbManager : WorldObjectManager
{
private List<GameObject> _orbs = new List<GameObject>();
private List<GameObject> _orbs = new();
protected override void RebuildWorldObjects(OWScene scene)
{

View File

@ -9,7 +9,7 @@ namespace QSB.OrbSync.TransformSync
{
internal class NomaiOrbTransformSync : UnsectoredTransformSync
{
public static List<NomaiOrbTransformSync> OrbTransformSyncs = new List<NomaiOrbTransformSync>();
public static List<NomaiOrbTransformSync> OrbTransformSyncs = new();
private int _index => OrbTransformSyncs.IndexOf(this);

View File

@ -37,10 +37,10 @@ namespace QSB.Patches
public static event Action<QSBPatchTypes> OnPatchType;
public static event Action<QSBPatchTypes> OnUnpatchType;
private static List<QSBPatch> _patchList = new List<QSBPatch>();
private static List<QSBPatchTypes> _patchedTypes = new List<QSBPatchTypes>();
private static List<QSBPatch> _patchList = new();
private static List<QSBPatchTypes> _patchedTypes = new();
public static Dictionary<QSBPatchTypes, Harmony> TypeToInstance = new Dictionary<QSBPatchTypes, Harmony>();
public static Dictionary<QSBPatchTypes, Harmony> TypeToInstance = new();
public static void Init()
{

View File

@ -44,7 +44,7 @@ namespace QSB.Player.Events
private void Handler(EnterLeaveType type, int objectId = -1) => SendEvent(CreateMessage(type, objectId));
private EnumWorldObjectMessage<EnterLeaveType> CreateMessage(EnterLeaveType type, int objectId) => new EnumWorldObjectMessage<EnterLeaveType>
private EnumWorldObjectMessage<EnterLeaveType> CreateMessage(EnterLeaveType type, int objectId) => new()
{
AboutId = LocalPlayerId,
EnumValue = type,

View File

@ -14,7 +14,7 @@ namespace QSB.Player.Events
private void Handler(int id) => SendEvent(CreateMessage(id));
private WorldObjectMessage CreateMessage(int id) => new WorldObjectMessage
private WorldObjectMessage CreateMessage(int id) => new()
{
AboutId = LocalPlayerId,
ObjectId = id

View File

@ -13,7 +13,7 @@ namespace QSB.Player.Events
private void Handler() => SendEvent(CreateMessage(QSBPlayerManager.LocalPlayer));
private PlayerInformationMessage CreateMessage(PlayerInfo player) => new PlayerInformationMessage
private PlayerInformationMessage CreateMessage(PlayerInfo player) => new()
{
AboutId = player.PlayerId,
PlayerName = player.Name,

View File

@ -13,7 +13,7 @@ namespace QSB.Player.Events
private void Handler(string name) => SendEvent(CreateMessage(name));
private PlayerJoinMessage CreateMessage(string name) => new PlayerJoinMessage
private PlayerJoinMessage CreateMessage(string name) => new()
{
AboutId = LocalPlayerId,
PlayerName = name,

View File

@ -16,7 +16,7 @@ namespace QSB.Player.Events
private void Handler(uint player, KickReason reason) => SendEvent(CreateMessage(player, reason));
private EnumMessage<KickReason> CreateMessage(uint player, KickReason reason) => new EnumMessage<KickReason>
private EnumMessage<KickReason> CreateMessage(uint player, KickReason reason) => new()
{
AboutId = player,
EnumValue = reason

View File

@ -14,7 +14,7 @@ namespace QSB.Player.Events
private void Handler(bool ready) => SendEvent(CreateMessage(ready));
private ToggleMessage CreateMessage(bool ready) => new ToggleMessage
private ToggleMessage CreateMessage(bool ready) => new()
{
AboutId = LocalPlayerId,
ToggleValue = ready

View File

@ -23,7 +23,7 @@ namespace QSB.Player.Events
private void Handler() => SendEvent(CreateMessage());
private PlayerMessage CreateMessage() => new PlayerMessage
private PlayerMessage CreateMessage() => new()
{
AboutId = LocalPlayerId
};

View File

@ -56,6 +56,7 @@ namespace QSB.Player
{
DebugLog.ToConsole($"Warning - {PlayerId}.Body is null!", MessageType.Warning);
}
return _body;
}
set
@ -64,6 +65,7 @@ namespace QSB.Player
{
DebugLog.ToConsole($"Warning - Setting {PlayerId}.Body to null.", MessageType.Warning);
}
_body = value;
}
}
@ -75,18 +77,7 @@ namespace QSB.Player
// Tools
public GameObject ProbeBody { get; set; }
public QSBProbe Probe { get; set; }
public QSBFlashlight FlashLight
{
get
{
if (CameraBody == null)
{
return null;
}
return CameraBody.GetComponentInChildren<QSBFlashlight>();
}
}
public QSBFlashlight FlashLight => CameraBody?.GetComponentInChildren<QSBFlashlight>();
public QSBTool Signalscope => GetToolByType(ToolType.Signalscope);
public QSBTool Translator => GetToolByType(ToolType.Translator);
public QSBProbeLauncherTool ProbeLauncher => (QSBProbeLauncherTool)GetToolByType(ToolType.ProbeLauncher);
@ -109,8 +100,8 @@ namespace QSB.Player
// Animation
public AnimationSync AnimationSync => QSBPlayerManager.GetSyncObject<AnimationSync>(PlayerId);
public bool PlayingInstrument => AnimationSync.CurrentType != AnimationType.PlayerSuited
&& AnimationSync.CurrentType != AnimationType.PlayerUnsuited;
public bool PlayingInstrument => AnimationSync.CurrentType is not AnimationType.PlayerSuited
and not AnimationType.PlayerUnsuited;
public JetpackAccelerationSync JetpackAcceleration { get; set; }
// Misc

View File

@ -41,11 +41,11 @@ namespace QSB.Player
public static PlayerInfo LocalPlayer => GetPlayer(LocalPlayerId);
public static List<PlayerInfo> PlayerList { get; } = new List<PlayerInfo>();
private static readonly List<PlayerSyncObject> PlayerSyncObjects = new List<PlayerSyncObject>();
private static readonly List<PlayerSyncObject> PlayerSyncObjects = new();
public static PlayerInfo GetPlayer(uint id)
{
if (id == uint.MaxValue || id == 0U)
if (id is uint.MaxValue or 0U)
{
return default;
}
@ -129,7 +129,7 @@ namespace QSB.Player
}
public static Tuple<Flashlight, IEnumerable<QSBFlashlight>> GetPlayerFlashlights()
=> new Tuple<Flashlight, IEnumerable<QSBFlashlight>>(Locator.GetFlashlight(), PlayerList.Where(x => x.FlashLight != null).Select(x => x.FlashLight));
=> new(Locator.GetFlashlight(), PlayerList.Where(x => x.FlashLight != null).Select(x => x.FlashLight));
public static void ShowAllPlayers()
=> PlayerList.Where(x => x != LocalPlayer).ToList().ForEach(x => ChangePlayerVisibility(x.PlayerId, true));

View File

@ -55,7 +55,7 @@ namespace QSB.PoolSync
private bool _anyoneStillOnPlatform;
private bool _wasLocalInBounds;
private CameraState _cameraState;
private readonly Dictionary<PlayerInfo, GameObject> _playerToHologram = new Dictionary<PlayerInfo, GameObject>();
private readonly Dictionary<PlayerInfo, GameObject> _playerToHologram = new();
private void Awake()
{
@ -129,7 +129,7 @@ namespace QSB.PoolSync
CustomPlatformList.Remove(this);
}
if (_cameraState == CameraState.Connected || _cameraState == CameraState.Connecting_FadeIn || _cameraState == CameraState.Connecting_FadeOut)
if (_cameraState is CameraState.Connected or CameraState.Connecting_FadeIn or CameraState.Connecting_FadeOut)
{
DisconnectCamera();
SwitchToPlayerCamera();
@ -231,7 +231,7 @@ namespace QSB.PoolSync
_slavePlatform.UpdatePoolRenderer();
if (_slavePlatform._transitionFade == 1f)
{
_slavePlatform._poolT = ((!(_slavePlatform._sharedStone == null)) ? 1f : 0f);
_slavePlatform._poolT = (!(_slavePlatform._sharedStone == null)) ? 1f : 0f;
_slavePlatform._showPlayerRipples = false;
_slavePlatform._activePlayerHolo = null;
_slavePlatform.UpdatePoolRenderer();
@ -550,7 +550,7 @@ namespace QSB.PoolSync
}
var cameraState = _cameraState;
if (cameraState != CameraState.Disconnected && cameraState != CameraState.Disconnecting_FadeOut)
if (cameraState is not CameraState.Disconnected and not CameraState.Disconnecting_FadeOut)
{
if (cameraState == CameraState.Disconnecting_FadeIn)
{
@ -574,7 +574,7 @@ namespace QSB.PoolSync
}
var cameraState = _cameraState;
if (cameraState != CameraState.Connected && cameraState != CameraState.Connecting_FadeOut)
if (cameraState is not CameraState.Connected and not CameraState.Connecting_FadeOut)
{
if (cameraState == CameraState.Connecting_FadeIn)
{

View File

@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<LangVersion>9</LangVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -88,6 +91,7 @@
<Compile Include="ConversationSync\ConversationManager.cs" />
<Compile Include="DeathSync\EndLoopReason.cs" />
<Compile Include="DeathSync\Events\EndLoopEvent.cs" />
<Compile Include="Player\PlayerState.cs" />
<Compile Include="RespawnSync\Events\PlayerRespawnEvent.cs" />
<Compile Include="DeathSync\Events\StartLoopEvent.cs" />
<Compile Include="DeathSync\Patches\MapPatches.cs" />
@ -147,7 +151,6 @@
<Compile Include="Player\Events\RequestStateResyncEvent.cs" />
<Compile Include="Player\GamePlatform.cs" />
<Compile Include="Player\Patches\PlayerPatches.cs" />
<Compile Include="Player\PlayerState.cs" />
<Compile Include="PoolSync\CustomNomaiRemoteCameraPlatform.cs" />
<Compile Include="PoolSync\CustomNomaiRemoteCameraStreaming.cs" />
<Compile Include="ItemSync\Events\DropItemEvent.cs" />

View File

@ -38,6 +38,6 @@ namespace QSB
}
private static bool InUniverse(OWScene scene) =>
scene == OWScene.SolarSystem || scene == OWScene.EyeOfTheUniverse;
scene is OWScene.SolarSystem or OWScene.EyeOfTheUniverse;
}
}

View File

@ -15,7 +15,7 @@ namespace QSB.QuantumSync.Events
private void Handler(int stateIndex, Vector3 onUnitSphere, int orbitAngle) => SendEvent(CreateMessage(stateIndex, onUnitSphere, orbitAngle));
private MoonStateChangeMessage CreateMessage(int stateIndex, Vector3 onUnitSphere, int orbitAngle) => new MoonStateChangeMessage
private MoonStateChangeMessage CreateMessage(int stateIndex, Vector3 onUnitSphere, int orbitAngle) => new()
{
AboutId = LocalPlayerId,
StateIndex = stateIndex,

View File

@ -15,7 +15,7 @@ namespace QSB.QuantumSync.Events
private void Handler(int objid, int stateIndex) => SendEvent(CreateMessage(objid, stateIndex));
private MultiStateChangeMessage CreateMessage(int objid, int stateIndex) => new MultiStateChangeMessage
private MultiStateChangeMessage CreateMessage(int objid, int stateIndex) => new()
{
AboutId = LocalPlayerId,
ObjectId = objid,

View File

@ -13,7 +13,7 @@ namespace QSB.QuantumSync.Events
private void Handler(int objId, uint authorityOwner) => SendEvent(CreateMessage(objId, authorityOwner));
private QuantumAuthorityMessage CreateMessage(int objId, uint authorityOwner) => new QuantumAuthorityMessage
private QuantumAuthorityMessage CreateMessage(int objId, uint authorityOwner) => new()
{
AboutId = LocalPlayerId,
ObjectId = objId,

View File

@ -13,7 +13,7 @@ namespace QSB.QuantumSync.Events
private void Handler(int objid, int[] indexArray) => SendEvent(CreateMessage(objid, indexArray));
private QuantumShuffleMessage CreateMessage(int objid, int[] indexArray) => new QuantumShuffleMessage
private QuantumShuffleMessage CreateMessage(int objid, int[] indexArray) => new()
{
AboutId = LocalPlayerId,
ObjectId = objid,

View File

@ -16,7 +16,7 @@ namespace QSB.QuantumSync.Events
private void Handler(int objid, int socketid, Quaternion localRotation) => SendEvent(CreateMessage(objid, socketid, localRotation));
private SocketStateChangeMessage CreateMessage(int objid, int socketid, Quaternion localRotation) => new SocketStateChangeMessage
private SocketStateChangeMessage CreateMessage(int objid, int socketid, Quaternion localRotation) => new()
{
AboutId = LocalPlayerId,
ObjectId = objid,

View File

@ -17,7 +17,7 @@ namespace QSB.RespawnSync.Events
private void Handler(uint playerId) => SendEvent(CreateMessage(playerId));
private PlayerMessage CreateMessage(uint playerId) => new PlayerMessage
private PlayerMessage CreateMessage(uint playerId) => new()
{
AboutId = playerId
};

View File

@ -16,7 +16,7 @@ namespace QSB.RespawnSync
public bool RespawnNeeded => _playersPendingRespawn.Count != 0;
private List<PlayerInfo> _playersPendingRespawn = new List<PlayerInfo>();
private List<PlayerInfo> _playersPendingRespawn = new();
private NotificationData _previousNotification;
private GameObject _owRecoveryPoint;
private GameObject _qsbRecoveryPoint;

View File

@ -35,7 +35,7 @@ namespace QSB.RoastingSync.Events
SendEvent(CreateMessage(qsbObj.ObjectId, roasting));
}
private BoolWorldObjectMessage CreateMessage(int objectId, bool roasting) => new BoolWorldObjectMessage
private BoolWorldObjectMessage CreateMessage(int objectId, bool roasting) => new()
{
AboutId = LocalPlayerId,
State = roasting,
@ -57,14 +57,9 @@ namespace QSB.RoastingSync.Events
var player = QSBPlayerManager.GetPlayer(message.AboutId);
player.RoastingStick.SetActive(message.State);
if (message.State)
{
player.Campfire = QSBWorldSync.GetWorldFromId<QSBCampfire>(message.ObjectId);
}
else
{
player.Campfire = null;
}
player.Campfire = message.State
? QSBWorldSync.GetWorldFromId<QSBCampfire>(message.ObjectId)
: null;
}
}
}

View File

@ -18,7 +18,7 @@ namespace QSB.RoastingSync.Events
private void Handler(MarshmallowEventType type) => SendEvent(CreateMessage(type));
private EnumMessage<MarshmallowEventType> CreateMessage(MarshmallowEventType type) => new EnumMessage<MarshmallowEventType>
private EnumMessage<MarshmallowEventType> CreateMessage(MarshmallowEventType type) => new()
{
AboutId = LocalPlayerId,
EnumValue = type

View File

@ -21,7 +21,7 @@ namespace QSB.SatelliteSync.Events
private void Handler(bool usingProjector) => SendEvent(CreateMessage(usingProjector));
private BoolMessage CreateMessage(bool usingProjector) => new BoolMessage
private BoolMessage CreateMessage(bool usingProjector) => new()
{
AboutId = LocalPlayerId,
Value = usingProjector

View File

@ -13,7 +13,7 @@ namespace QSB.SatelliteSync.Events
private void Handler(bool forward) => SendEvent(CreateMessage(forward));
private BoolMessage CreateMessage(bool forward) => new BoolMessage
private BoolMessage CreateMessage(bool forward) => new()
{
AboutId = LocalPlayerId,
Value = forward

View File

@ -13,12 +13,12 @@ namespace QSB.SectorSync
{
public static QSBSectorManager Instance { get; private set; }
public bool IsReady { get; private set; }
public List<QSBSector> FakeSectors = new List<QSBSector>();
public List<QSBSector> FakeSectors = new();
private void OnEnable() => RepeatingManager.Repeatings.Add(this);
private void OnDisable() => RepeatingManager.Repeatings.Remove(this);
public List<BaseSectoredSync> SectoredSyncs = new List<BaseSectoredSync>();
public List<BaseSectoredSync> SectoredSyncs = new();
public void Invoke()
{

View File

@ -13,7 +13,7 @@ namespace QSB.SectorSync
public class SectorSync : MonoBehaviour
{
public bool IsReady { get; private set; }
public List<QSBSector> SectorList = new List<QSBSector>();
public List<QSBSector> SectorList = new();
private OWRigidbody _attachedOWRigidbody;
private SectorDetector _sectorDetector;

View File

@ -63,7 +63,7 @@ namespace QSB.SectorSync.WorldObjects
return false;
}
if (AttachedObject.name == "Sector_Shuttle" || AttachedObject.name == "Sector_NomaiShuttleInterior")
if (AttachedObject.name is "Sector_Shuttle" or "Sector_NomaiShuttleInterior")
{
if (QSBSceneManager.CurrentScene == OWScene.SolarSystem)
{

View File

@ -28,7 +28,7 @@ namespace QSB.ShipSync.Events
private void Handler(bool flying) => SendEvent(CreateMessage(flying));
private BoolMessage CreateMessage(bool flying) => new BoolMessage
private BoolMessage CreateMessage(bool flying) => new()
{
AboutId = LocalPlayerId,
Value = flying

View File

@ -15,7 +15,7 @@ namespace QSB.ShipSync.Events
private void Handler() => SendEvent(CreateMessage());
private PlayerMessage CreateMessage() => new PlayerMessage
private PlayerMessage CreateMessage() => new()
{
AboutId = LocalPlayerId
};

View File

@ -16,7 +16,7 @@ namespace QSB.ShipSync.Events
private void Handler(bool open) => SendEvent(CreateMessage(open));
private BoolMessage CreateMessage(bool open) => new BoolMessage
private BoolMessage CreateMessage(bool open) => new()
{
AboutId = LocalPlayerId,
Value = open

View File

@ -224,7 +224,7 @@ namespace QSB.ShipSync.Patches
return false;
}
____integrity = Mathf.Min(____integrity + Time.deltaTime / ____repairTime, 1f);
____integrity = Mathf.Min(____integrity + (Time.deltaTime / ____repairTime), 1f);
QSBEventManager.FireEvent(EventNames.QSBHullRepairTick, __instance, ____integrity);
if (____integrity >= 1f)

View File

@ -37,7 +37,7 @@ namespace QSB.ShipSync
}
}
private List<PlayerInfo> _playersInShip = new List<PlayerInfo>();
private List<PlayerInfo> _playersInShip = new();
private uint _currentFlyer = uint.MaxValue;

View File

@ -17,7 +17,7 @@ namespace QSB.StatueSync.Events
private void Handler(Vector3 position, Quaternion rotation, float degrees)
=> SendEvent(CreateMessage(position, rotation, degrees));
private StartStatueMessage CreateMessage(Vector3 position, Quaternion rotation, float degrees) => new StartStatueMessage
private StartStatueMessage CreateMessage(Vector3 position, Quaternion rotation, float degrees) => new()
{
AboutId = LocalPlayerId,
PlayerPosition = position,

View File

@ -18,7 +18,7 @@ namespace QSB.Syncs
public abstract class SyncBase : QNetworkTransform
{
private static readonly Dictionary<uint, Dictionary<Type, SyncBase>> _storedTransformSyncs = new Dictionary<uint, Dictionary<Type, SyncBase>>();
private static readonly Dictionary<uint, Dictionary<Type, SyncBase>> _storedTransformSyncs = new();
public static T GetPlayers<T>(PlayerInfo player)
where T : SyncBase

View File

@ -11,7 +11,7 @@ namespace QSB.TimeSync.Events
private void Handler(float time, int count) => SendEvent(CreateMessage(time, count));
private ServerTimeMessage CreateMessage(float time, int count) => new ServerTimeMessage
private ServerTimeMessage CreateMessage(float time, int count) => new()
{
AboutId = LocalPlayerId,
ServerTime = time,

View File

@ -324,7 +324,7 @@ namespace QSB.TimeSync
// Checks to pause/fastforward
if (clientState == ClientState.NotLoaded || clientState == ClientState.InTitleScreen)
if (clientState is ClientState.NotLoaded or ClientState.InTitleScreen)
{
return;
}
@ -400,7 +400,7 @@ namespace QSB.TimeSync
{
var diff = GetTimeDifference();
if (diff > PauseOrFastForwardThreshold || diff < -PauseOrFastForwardThreshold)
if (diff is > PauseOrFastForwardThreshold or < (-PauseOrFastForwardThreshold))
{
WakeUpOrSleep();
return;

View File

@ -23,7 +23,7 @@ namespace QSB.Tools.FlashlightTool.Events
private void HandleTurnOn() => SendEvent(CreateMessage(true));
private void HandleTurnOff() => SendEvent(CreateMessage(false));
private ToggleMessage CreateMessage(bool value) => new ToggleMessage
private ToggleMessage CreateMessage(bool value) => new()
{
AboutId = LocalPlayerId,
ToggleValue = value

View File

@ -4,7 +4,7 @@ namespace QSB.Tools.FlashlightTool
{
internal static class FlashlightCreator
{
private static readonly Vector3 FlashlightOffset = new Vector3(0.7196316f, -0.2697681f, 0.3769455f);
private static readonly Vector3 FlashlightOffset = new(0.7196316f, -0.2697681f, 0.3769455f);
internal static void CreateFlashlight(Transform cameraBody)
{

View File

@ -57,7 +57,7 @@ namespace QSB.Tools.ProbeLauncherTool.Events
SendEvent(CreateMessage(false));
}
private ToggleMessage CreateMessage(bool value) => new ToggleMessage
private ToggleMessage CreateMessage(bool value) => new()
{
AboutId = LocalPlayerId,
ToggleValue = value

View File

@ -17,7 +17,7 @@ namespace QSB.Tools.ProbeLauncherTool.Events
private void Handler(QSBProbeLauncher launcher) => SendEvent(CreateMessage(launcher));
private BoolWorldObjectMessage CreateMessage(QSBProbeLauncher launcher) => new BoolWorldObjectMessage
private BoolWorldObjectMessage CreateMessage(QSBProbeLauncher launcher) => new()
{
AboutId = LocalPlayerId,
ObjectId = launcher.ObjectId

View File

@ -16,7 +16,7 @@ namespace QSB.Tools.ProbeLauncherTool.Events
private void Handler() => SendEvent(CreateMessage());
private PlayerMessage CreateMessage() => new PlayerMessage
private PlayerMessage CreateMessage() => new()
{
AboutId = LocalPlayerId
};

View File

@ -16,7 +16,7 @@ namespace QSB.Tools.ProbeLauncherTool.Events
private void Handler(bool playEffects) => SendEvent(CreateMessage(playEffects));
private BoolMessage CreateMessage(bool playEffects) => new BoolMessage
private BoolMessage CreateMessage(bool playEffects) => new()
{
AboutId = LocalPlayerId,
Value = playEffects

View File

@ -17,7 +17,7 @@ namespace QSB.Tools.ProbeLauncherTool.Events
private void Handler(QSBProbeLauncher launcher, bool playEffects) => SendEvent(CreateMessage(launcher, playEffects));
private BoolWorldObjectMessage CreateMessage(QSBProbeLauncher launcher, bool playEffects) => new BoolWorldObjectMessage
private BoolWorldObjectMessage CreateMessage(QSBProbeLauncher launcher, bool playEffects) => new()
{
AboutId = LocalPlayerId,
ObjectId = launcher.ObjectId,

View File

@ -4,7 +4,7 @@ namespace QSB.Tools.ProbeLauncherTool
{
internal static class ProbeLauncherCreator
{
private static readonly Vector3 ProbeLauncherOffset = new Vector3(0.5745087f, -0.26f, 0.4453125f);
private static readonly Vector3 ProbeLauncherOffset = new(0.5745087f, -0.26f, 0.4453125f);
internal static void CreateProbeLauncher(Transform cameraBody)
{

View File

@ -16,7 +16,7 @@ namespace QSB.Tools.ProbeTool.Events
private void Handler(ProbeEvent probeEvent) => SendEvent(CreateMessage(probeEvent));
private EnumMessage<ProbeEvent> CreateMessage(ProbeEvent probeEvent) => new EnumMessage<ProbeEvent>
private EnumMessage<ProbeEvent> CreateMessage(ProbeEvent probeEvent) => new()
{
AboutId = LocalPlayerId,
EnumValue = probeEvent

View File

@ -16,7 +16,7 @@ namespace QSB.Tools.ProbeTool.Events
private void Handler(float duration) => SendEvent(CreateMessage(duration));
private FloatMessage CreateMessage(float duration) => new FloatMessage
private FloatMessage CreateMessage(float duration) => new()
{
AboutId = LocalPlayerId,
Value = duration

View File

@ -23,7 +23,7 @@ namespace QSB.Tools.SignalscopeTool.Events
private void HandleEquip(Signalscope var) => SendEvent(CreateMessage(true));
private void HandleUnequip() => SendEvent(CreateMessage(false));
private ToggleMessage CreateMessage(bool value) => new ToggleMessage
private ToggleMessage CreateMessage(bool value) => new()
{
AboutId = LocalPlayerId,
ToggleValue = value

View File

@ -4,7 +4,7 @@ namespace QSB.Tools.SignalscopeTool
{
internal static class SignalscopeCreator
{
private static readonly Vector3 SignalscopeScale = new Vector3(1.5f, 1.5f, 1.5f);
private static readonly Vector3 SignalscopeScale = new(1.5f, 1.5f, 1.5f);
internal static void CreateSignalscope(Transform cameraBody)
{

View File

@ -23,7 +23,7 @@ namespace QSB.Tools.TranslatorTool.Events
private void HandleEquip() => SendEvent(CreateMessage(true));
private void HandleUnequip() => SendEvent(CreateMessage(false));
private ToggleMessage CreateMessage(bool value) => new ToggleMessage
private ToggleMessage CreateMessage(bool value) => new()
{
AboutId = LocalPlayerId,
ToggleValue = value

View File

@ -25,9 +25,7 @@ namespace QSB.Tools.TranslatorTool
}
public override void OnDisable()
{
_translatorProp.OnFinishUnequipAnimation();
}
=> _translatorProp.OnFinishUnequipAnimation();
public override void EquipTool()
{
@ -72,7 +70,7 @@ namespace QSB.Tools.TranslatorTool
if (_currentNomaiText != null)
{
tooCloseToTarget = (num < _currentNomaiText.GetMinimumReadableDistance());
tooCloseToTarget = num < _currentNomaiText.GetMinimumReadableDistance();
if (_currentNomaiText is NomaiWallText)
{
@ -83,7 +81,7 @@ namespace QSB.Tools.TranslatorTool
if (distToCenter > _lastLineDist + 0.1f)
{
_lastHighlightedTextLine = nomaiTextLine;
_lastLineWasTranslated = (nomaiTextLine != null && nomaiTextLine.IsTranslated());
_lastLineWasTranslated = nomaiTextLine != null && nomaiTextLine.IsTranslated();
_lastLineLocked = false;
}
else
@ -105,7 +103,7 @@ namespace QSB.Tools.TranslatorTool
else
{
_lastHighlightedTextLine = nomaiTextLine;
_lastLineWasTranslated = (nomaiTextLine != null && nomaiTextLine.IsTranslated());
_lastLineWasTranslated = nomaiTextLine != null && nomaiTextLine.IsTranslated();
}
if (nomaiTextLine && !nomaiTextLine.IsHidden() && nomaiTextLine.IsActive())

View File

@ -15,8 +15,8 @@ namespace QSB.Tools.TranslatorTool
const float _fadeLength = 0.66f;
public float _scanSpeed = 1f;
public readonly Color _baseProjectorColor = new Color(0.3545942f, 2.206932f, 4.594794f, 1f);
public readonly Color _baseLightColor = new Color(0.1301365f, 0.2158605f, 0.6239606f, 1f);
public readonly Color _baseProjectorColor = new(0.3545942f, 2.206932f, 4.594794f, 1f);
public readonly Color _baseLightColor = new(0.1301365f, 0.2158605f, 0.6239606f, 1f);
public Quaternion _baseRotation;
private bool _tooCloseToTarget;
@ -92,7 +92,7 @@ namespace QSB.Tools.TranslatorTool
_switchTime = Mathf.MoveTowards(_switchTime, 1f, Time.deltaTime / _switchLength);
var smoothedSwitchTime = Mathf.SmoothStep(0f, 1f, _switchTime);
_scanTime += Time.deltaTime * _scanSpeed;
var num = Mathf.Cos(_scanTime + _scanOffset) * 0.5f + 0.5f;
var num = (Mathf.Cos(_scanTime + _scanOffset) * 0.5f) + 0.5f;
var pointAlongLine = _nomaiTextLine.GetPointAlongLine(num);
var rhs = _nomaiTextLine.GetPointAlongLine(num + 0.1f) - _nomaiTextLine.GetPointAlongLine(num - 0.1f);
var vector = pointAlongLine - transform.position;
@ -108,7 +108,7 @@ namespace QSB.Tools.TranslatorTool
_switchTime = Mathf.MoveTowards(_switchTime, 1f, Time.deltaTime / _switchLength);
var t2 = Mathf.SmoothStep(0f, 1f, _switchTime);
_scanTime += Time.deltaTime * _scanSpeed;
var t3 = Mathf.Cos(_scanTime + _scanOffset) * 0.5f + 0.5f;
var t3 = (Mathf.Cos(_scanTime + _scanOffset) * 0.5f) + 0.5f;
t3 = Mathf.Lerp(0.25f, 0.75f, t3);
var pointOnRing = _nomaiComputerRing.GetPointOnRing(t3, transform.position);
var forward = pointOnRing - transform.position;
@ -125,7 +125,7 @@ namespace QSB.Tools.TranslatorTool
var smoothedSwitchTime = Mathf.SmoothStep(0f, 1f, _switchTime);
_scanTime += Time.deltaTime * _scanSpeed;
var t5 = Mathf.Cos(_scanTime + _scanOffset) * 0.5f + 0.5f;
var t5 = (Mathf.Cos(_scanTime + _scanOffset) * 0.5f) + 0.5f;
t5 = Mathf.Lerp(0.25f, 0.75f, t5);
var pointOnRing2 = _nomaiVesselComputerRing.GetPointOnRing(t5, transform.position);
var forward2 = pointOnRing2 - transform.position;

View File

@ -5,7 +5,7 @@ namespace QSB.Tools.TranslatorTool
{
internal static class TranslatorCreator
{
private static readonly Vector3 TranslatorScale = new Vector3(0.75f, 0.75f, 0.75f);
private static readonly Vector3 TranslatorScale = new(0.75f, 0.75f, 0.75f);
internal static void CreateTranslator(Transform cameraBody)
{

View File

@ -13,7 +13,7 @@ namespace QSB.TranslationSync.Events
private void Handler(NomaiTextType type, int objId, int textId) => SendEvent(CreateMessage(type, objId, textId));
private SetAsTranslatedMessage CreateMessage(NomaiTextType type, int objId, int textId) => new SetAsTranslatedMessage
private SetAsTranslatedMessage CreateMessage(NomaiTextType type, int objId, int textId) => new()
{
AboutId = LocalPlayerId,
ObjectId = objId,

View File

@ -24,7 +24,7 @@ namespace QSB.Utility
private const float Column4 = Column3 + FixedWidth;
private float column4Offset = 10f;
private GUIStyle guiStyle = new GUIStyle()
private GUIStyle guiStyle = new()
{
fontSize = 9
};

Some files were not shown because too many files have changed in this diff Show More