public virtual void Awake() { VisibleAnimator = Instantiate(visibleAnimatorPrefab, transform).GetComponent <VisibleAnimator>(); VisibleAnimator.TargetMaterial = targetMaterial; VisibleAnimator.VisibleSpeed = visibleSpeed; VisibleAnimator.InvisibleSpeed = invisibleSpeed; }
private void InitCommon(Transform modelRoot) { try { if (modelRoot == null) { 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); } else { Mirror.Init(InvisibleAnimator, VisibleAnimator); } NetworkAnimator.enabled = true; NetworkAnimator.Invoke("Awake"); _suitedAnimController = Instantiate(QSBCore.NetworkAssetBundle.LoadAsset <RuntimeAnimatorController>("Assets/GameAssets/AnimatorController/Player.controller")); _unsuitedAnimController = Instantiate(QSBCore.NetworkAssetBundle.LoadAsset <AnimatorOverrideController>("Assets/GameAssets/AnimatorOverrideController/PlayerUnsuitedOverride.overrideController")); _suitedGraphics = modelRoot.GetChild(1).gameObject; _unsuitedGraphics = modelRoot.GetChild(0).gameObject; VisibleAnimator.SetLayerWeight(2, 1f); } catch (Exception ex) { DebugLog.ToConsole($"Exception thrown when running InitCommon on {(modelRoot != null ? modelRoot.name : "NULL BODY")}. {ex.Message} Stacktrace: {ex.StackTrace}", MessageType.Error); } }
public void SetSuitState(bool suitedUp) { if (!Player.IsReady) { return; } if (Player == QSBPlayerManager.LocalPlayer) { new PlayerSuitMessage(suitedUp).Send(); } if (InSuitedUpState == suitedUp) { return; } InSuitedUpState = suitedUp; if (_unsuitedAnimController == null) { DebugLog.ToConsole($"Error - Unsuited controller is null. ({PlayerId})", MessageType.Error); } if (_suitedAnimController == null) { DebugLog.ToConsole($"Error - Suited controller is null. ({PlayerId})", MessageType.Error); } if (_unsuitedGraphics == null) { DebugLog.ToConsole($"Warning - _unsuitedGraphics is null! ({PlayerId})", MessageType.Warning); } if (_suitedGraphics == null) { DebugLog.ToConsole($"Warning - _suitedGraphics is null! ({PlayerId})", MessageType.Warning); } var controller = suitedUp ? _suitedAnimController : _unsuitedAnimController; if (_unsuitedGraphics != null) { _unsuitedGraphics?.SetActive(!suitedUp); } if (_suitedGraphics != null) { _suitedGraphics?.SetActive(suitedUp); } if (InvisibleAnimator == null) { DebugLog.ToConsole($"Error - InvisibleAnimator is null. ({PlayerId})", MessageType.Error); } else { InvisibleAnimator.runtimeAnimatorController = controller; } if (VisibleAnimator == null) { DebugLog.ToConsole($"Error - VisibleAnimator is null. ({PlayerId})", MessageType.Error); } else { VisibleAnimator.runtimeAnimatorController = controller; } // Avoids "jumping" when putting on suit if (VisibleAnimator != null) { VisibleAnimator.SetTrigger("Grounded"); } if (InvisibleAnimator != null) { InvisibleAnimator.SetTrigger("Grounded"); } if (NetworkAnimator == null) { DebugLog.ToConsole($"Error - NetworkAnimator is null. ({PlayerId})", MessageType.Error); } else if (Mirror == null) { DebugLog.ToConsole($"Error - Mirror is null. ({PlayerId})", MessageType.Error); } Mirror.RebuildFloatParams(); NetworkAnimator.Invoke("Awake"); }