Skip to content

Commit

Permalink
Merge pull request #543 from misternebula/dev
Browse files Browse the repository at this point in the history
0.21.0
  • Loading branch information
misternebula authored Aug 18, 2022
2 parents 050fb5c + a8fb79b commit b1768e7
Show file tree
Hide file tree
Showing 147 changed files with 4,465 additions and 944 deletions.
2 changes: 1 addition & 1 deletion EpicOnlineTransport/EpicOnlineTransport.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="../Mirror/*.dll" />
<PackageReference Include="OuterWildsGameLibs" Version="1.1.12.168" IncludeAssets="compile" />
<PackageReference Include="OuterWildsGameLibs" Version="1.1.12.201" IncludeAssets="compile" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion EpicRerouter/EpicRerouter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="OuterWildsGameLibs" Version="1.1.12.168" IncludeAssets="compile" />
<PackageReference Include="OuterWildsGameLibs" Version="1.1.12.201" IncludeAssets="compile" />
<PackageReference Include="HarmonyX" Version="2.10.0" IncludeAssets="compile" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion MirrorWeaver/MirrorWeaver.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="OuterWildsGameLibs" Version="1.1.12.168" />
<PackageReference Include="OuterWildsGameLibs" Version="1.1.12.201" />
<PackageReference Include="OWML" Version="2.5.2" />
<PackageReference Include="HarmonyX" Version="2.10.0" />
<Reference Include="../Mirror/*.dll" />
Expand Down
9 changes: 0 additions & 9 deletions QSB.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,7 @@
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_LOCK/@EntryValue">Required</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_USING/@EntryValue">Required</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_WHILE/@EntryValue">Required</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/NAMESPACE_BODY/@EntryValue">FileScoped</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_BINARY_EXPRESSIONS_CHAIN/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGN_MULTILINE_STATEMENT_CONDITIONS/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ALIGNMENT_TAB_FILL_STYLE/@EntryValue">USE_TABS_ONLY</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/CASE_BLOCK_BRACES/@EntryValue">NEXT_LINE_SHIFTED_2</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/INDENT_STYLE/@EntryValue">Tab</s:String>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_CODE/@EntryValue">1</s:Int64>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue">1</s:Int64>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/LINE_FEED_AT_FILE_END/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LINES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
Expand Down
5 changes: 1 addition & 4 deletions QSB/Animation/NPC/CharacterAnimManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ internal class CharacterAnimManager : WorldObjectManager
{
public override WorldObjectScene WorldObjectScene => WorldObjectScene.Both;

public override async UniTask BuildWorldObjects(OWScene scene, CancellationToken ct)
{
QSBWorldSync.Init<QSBCharacterAnimController, CharacterAnimController>();
public override async UniTask BuildWorldObjects(OWScene scene, CancellationToken ct) =>
QSBWorldSync.Init<QSBSolanumAnimController, SolanumAnimController>();
}
}
19 changes: 0 additions & 19 deletions QSB/Animation/NPC/Patches/CharacterAnimationPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,4 @@ public static bool OnStartConversation(FacePlayerWhenTalking __instance)

return false;
}

[HarmonyPrefix]
[HarmonyPatch(typeof(KidRockController), nameof(KidRockController.Update))]
public static bool UpdateReplacement(KidRockController __instance)
{
if (!QSBWorldSync.AllObjectsReady)
{
return true;
}

var qsbObj = QSBWorldSync.GetWorldObjects<QSBCharacterAnimController>().First(x => x.GetDialogueTree() == __instance._dialogueTree);

if (!__instance._throwingRock && !qsbObj.InConversation() && Time.time > __instance._nextThrowTime)
{
__instance.StartRockThrow();
}

return false;
}
}
17 changes: 0 additions & 17 deletions QSB/Animation/NPC/WorldObjects/QSBCharacterAnimController.cs

This file was deleted.

2 changes: 0 additions & 2 deletions QSB/Animation/NPC/WorldObjects/QSBSolanumAnimController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ internal class QSBSolanumAnimController : WorldObject<SolanumAnimController>
{
private QSBSolanumTrigger _trigger;
public QSBSolanumTrigger Trigger => _trigger ??= QSBWorldSync.GetWorldObjects<QSBSolanumTrigger>().First();

public override void SendInitialState(uint to) { }
}
38 changes: 18 additions & 20 deletions QSB/Animation/Player/AnimationSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using QSB.Messaging;
using QSB.Player;
using QSB.Utility;
using QSB.WorldSync;
using System;
using UnityEngine;

Expand All @@ -17,8 +18,6 @@ public class AnimationSync : PlayerSyncObject
private AnimatorOverrideController _unsuitedAnimController;
private GameObject _suitedGraphics;
private GameObject _unsuitedGraphics;
private PlayerCharacterController _playerController;
private CrouchSync _crouchSync;

public AnimatorMirror Mirror { get; private set; }
public bool InSuitedUpState { get; set; }
Expand All @@ -31,28 +30,38 @@ protected void Awake()
InvisibleAnimator = gameObject.GetRequiredComponent<Animator>();
NetworkAnimator = gameObject.GetRequiredComponent<NetworkAnimator>();
NetworkAnimator.enabled = false;
RequestInitialStatesMessage.SendInitialState += SendInitialState;
}

protected void OnDestroy() => RequestInitialStatesMessage.SendInitialState -= SendInitialState;

/// <summary>
/// This wipes the NetworkAnimator's fields, so it assumes the parameters have changed.
/// Basically just forces it to set all its dirty flags.
/// </summary>
private void SendInitialState(uint to) => NetworkAnimator.Invoke("Awake");

public void Reset() => InSuitedUpState = false;

private void InitCommon(Transform modelRoot)
{
try
{

if (modelRoot == null)
{
DebugLog.ToConsole($"Error - Trying to InitCommon with null body!", MessageType.Error);
DebugLog.ToConsole("Error - Trying to InitCommon with null body!", MessageType.Error);
return;
}

VisibleAnimator = modelRoot.GetComponent<Animator>();
Mirror = modelRoot.gameObject.AddComponent<AnimatorMirror>();
if (isLocalPlayer)
{
Mirror.Init(VisibleAnimator, InvisibleAnimator);
Mirror.Init(VisibleAnimator, InvisibleAnimator, NetworkAnimator);
}
else
{
Mirror.Init(InvisibleAnimator, VisibleAnimator);
Mirror.Init(InvisibleAnimator, VisibleAnimator, null);
}

NetworkAnimator.enabled = true;
Expand All @@ -74,18 +83,13 @@ private void InitCommon(Transform modelRoot)
public void InitLocal(Transform body)
{
InitCommon(body);

_playerController = body.parent.GetComponent<PlayerCharacterController>();

InitCrouchSync();
InitAccelerationSync();
}

public void InitRemote(Transform body)
{
InitCommon(body);
SetSuitState(QSBSceneManager.CurrentScene == OWScene.EyeOfTheUniverse);
InitCrouchSync();
InitAccelerationSync();
ThrusterManager.CreateRemotePlayerVFX(Player);

Expand All @@ -100,12 +104,6 @@ private void InitAccelerationSync()
Player.JetpackAcceleration.Init(thrusterModel);
}

private void InitCrouchSync()
{
_crouchSync = this.GetRequiredComponent<CrouchSync>();
_crouchSync.Init(_playerController, VisibleAnimator);
}

public void SetSuitState(bool suitedUp)
{
if (!Player.IsReady)
Expand Down Expand Up @@ -176,12 +174,12 @@ public void SetSuitState(bool suitedUp)
// Avoids "jumping" when putting on suit
if (VisibleAnimator != null)
{
VisibleAnimator.SetTrigger("Grounded");
VisibleAnimator.SetBool("Grounded", true);
}

if (InvisibleAnimator != null)
{
InvisibleAnimator.SetTrigger("Grounded");
InvisibleAnimator.SetBool("Grounded", true);
}

if (NetworkAnimator == null)
Expand All @@ -196,4 +194,4 @@ public void SetSuitState(bool suitedUp)
Mirror.RebuildFloatParams();
NetworkAnimator.Invoke("Awake");
}
}
}
53 changes: 50 additions & 3 deletions QSB/Animation/Player/AnimatorMirror.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OWML.Common;
using Mirror;
using OWML.Common;
using QSB.Utility;
using System.Collections.Generic;
using System.Linq;
Expand All @@ -12,10 +13,17 @@ public class AnimatorMirror : MonoBehaviour

private Animator _from;
private Animator _to;
private NetworkAnimator _networkAnimator;

private readonly Dictionary<string, AnimFloatParam> _floatParams = new();

public void Init(Animator from, Animator to)
/// <summary>
/// Initializes the Animator Mirror
/// </summary>
/// <param name="from">The Animator to take the values from.</param>
/// <param name="to">The Animator to set the values on to.</param>
/// <param name="netAnimator">The NetworkAnimator to sync triggers through. Set only if you have auth over "<paramref name="from"/>", otherwise set to null.</param>
public void Init(Animator from, Animator to, NetworkAnimator netAnimator)
{
if (from == null)
{
Expand Down Expand Up @@ -44,6 +52,8 @@ public void Init(Animator from, Animator to)
_to.runtimeAnimatorController = _from.runtimeAnimatorController;
}

_networkAnimator = netAnimator;

RebuildFloatParams();
}

Expand All @@ -61,6 +71,7 @@ public void Update()
}

SyncParams();
SyncLayerWeights();
SmoothFloats();
}

Expand All @@ -74,13 +85,49 @@ private void SyncParams()
_floatParams[fromParam.name].Target = _from.GetFloat(fromParam.name);
break;

case AnimatorControllerParameterType.Int:
_to.SetInteger(fromParam.name, _from.GetInteger(fromParam.name));
break;

case AnimatorControllerParameterType.Bool:
_to.SetBool(fromParam.name, _from.GetBool(fromParam.name));
break;

case AnimatorControllerParameterType.Trigger:
if (_from.GetBool(fromParam.name) && !_to.GetBool(fromParam.name))
{
if (_networkAnimator != null)
{
_networkAnimator.SetTrigger(fromParam.name);
}

_to.SetTrigger(fromParam.name);
}

if (!_from.GetBool(fromParam.name) && _to.GetBool(fromParam.name))
{
if (_networkAnimator != null)
{
_networkAnimator.ResetTrigger(fromParam.name);
}

_to.ResetTrigger(fromParam.name);
}

break;
}
}
}

private void SyncLayerWeights()
{
for (var i = 0; i < _from.layerCount; i++)
{
var weight = _from.GetLayerWeight(i);
_to.SetLayerWeight(i, weight);
}
}

private void SmoothFloats()
{
foreach (var floatParam in _floatParams)
Expand All @@ -98,4 +145,4 @@ public void RebuildFloatParams()
_floatParams.Add(param.name, new AnimFloatParam());
}
}
}
}
59 changes: 0 additions & 59 deletions QSB/Animation/Player/CrouchSync.cs

This file was deleted.

Loading

0 comments on commit b1768e7

Please sign in to comment.