diff --git a/Distance.OnlineAdditions/ConfigLogic.cs b/Distance.OnlineAdditions/ConfigLogic.cs index eddc0ba..e99b9df 100644 --- a/Distance.OnlineAdditions/ConfigLogic.cs +++ b/Distance.OnlineAdditions/ConfigLogic.cs @@ -43,11 +43,29 @@ public bool DisableTimeout set { Set("DisableTimeout", value); } } + public bool DisableMultiKillGridRender + { + get { return Get("DisableMultiKillGridRender"); } + set { Set("DisableMultiKillGridRender", value); } + } + public int TimeLimitAmount { get { return Get("TimeLimitAmount"); } set { Set("TimeLimitAmount", value); } } + + public int MaxLevelOfDetail + { + get { return Get("MaxLevelOfDetail"); } + set { Set("MaxLevelOfDetail", value); } + } + + public float OutlineBrightness + { + get { return Get("OutlineBrightness"); } + set { Set("OutlineBrightness", value); } + } #endregion internal Settings Config; @@ -70,7 +88,10 @@ public void Awake() Get("HidePlayerNames", false); Get("DisableCarAudio", false); Get("DisableTimeout", false); + Get("DisableMultiKillGridRender", false); Get("TimeLimitAmount", 60); + Get("MaxLevelOfDetail", 1); + Get("OutlineBrightness", 1); //Save settings to Config.json Save(); } diff --git a/Distance.OnlineAdditions/Distance.OnlineAdditions.csproj b/Distance.OnlineAdditions/Distance.OnlineAdditions.csproj index 169d714..01be68c 100644 --- a/Distance.OnlineAdditions/Distance.OnlineAdditions.csproj +++ b/Distance.OnlineAdditions/Distance.OnlineAdditions.csproj @@ -88,6 +88,9 @@ + + + @@ -95,9 +98,11 @@ + + diff --git a/Distance.OnlineAdditions/Harmony/Assembly-CSharp/CarLevelOfDetail/IncrementLevel.cs b/Distance.OnlineAdditions/Harmony/Assembly-CSharp/CarLevelOfDetail/IncrementLevel.cs new file mode 100644 index 0000000..db43a33 --- /dev/null +++ b/Distance.OnlineAdditions/Harmony/Assembly-CSharp/CarLevelOfDetail/IncrementLevel.cs @@ -0,0 +1,24 @@ +using HarmonyLib; + +namespace Distance.OnlineAdditions.Harmony +{ + [HarmonyPatch(typeof(CarLevelOfDetail), "IncrementLevel")] + internal class CarLevelOfDetail__IncrementLevel + { + [HarmonyPostfix] + internal static void MakeSureSimulationIsOn(CarLevelOfDetail __instance) + { + if (__instance.type_ == CarLevelOfDetail.Type.Networked && Mod.Instance.Config.EnableCollision) + { + __instance.SetCarSimulationEnabled(true); + } + else + { + if(__instance.rigidbody_.isKinematic) + { + __instance.rigidbody_.isKinematic = false; + } + } + } + } +} diff --git a/Distance.OnlineAdditions/Harmony/Assembly-CSharp/CarLevelOfDetail/SetLevelOfDetail.cs b/Distance.OnlineAdditions/Harmony/Assembly-CSharp/CarLevelOfDetail/SetLevelOfDetail.cs new file mode 100644 index 0000000..42acef1 --- /dev/null +++ b/Distance.OnlineAdditions/Harmony/Assembly-CSharp/CarLevelOfDetail/SetLevelOfDetail.cs @@ -0,0 +1,21 @@ +using HarmonyLib; + +namespace Distance.OnlineAdditions.Harmony +{ + [HarmonyPatch(typeof(CarLevelOfDetail), "SetLevelOfDetail", new System.Type[] { typeof(CarLevelOfDetail.Level) })] + internal class CarLevelOfDetail__SetLevelOfDetail + { + [HarmonyPrefix] + internal static bool MaxLevelDetail(CarLevelOfDetail __instance, CarLevelOfDetail.Level newLevel) + { + if(newLevel < (CarLevelOfDetail.Level)Mod.Instance.Config.MaxLevelOfDetail && G.Sys.NetworkingManager_.IsOnline_) + { + return false; + } + else + { + return true; + } + } + } +} diff --git a/Distance.OnlineAdditions/Harmony/Assembly-CSharp/KillGrid/OnEventAddRemovePlayerData.cs b/Distance.OnlineAdditions/Harmony/Assembly-CSharp/KillGrid/OnEventAddRemovePlayerData.cs new file mode 100644 index 0000000..8fb3b41 --- /dev/null +++ b/Distance.OnlineAdditions/Harmony/Assembly-CSharp/KillGrid/OnEventAddRemovePlayerData.cs @@ -0,0 +1,51 @@ +using HarmonyLib; +using Events.Player; + +namespace Distance.OnlineAdditions.Harmony +{ + [HarmonyPatch(typeof(KillGrid), "OnEventAddRemovePlayerData", new System.Type[] { typeof(AddRemovePlayerData.Data) })] + internal class OnEventAddRemovePlayerData + { + [HarmonyPrefix] + internal static bool KillGridRenderControl(KillGrid __instance, AddRemovePlayerData.Data data) + { + if(Mod.Instance.Config.DisableMultiKillGridRender) + { + if (data.added_) + { + if (!__instance.startCalled_) + Mod.Instance.Logger.Debug((object)"start wasn't called yet"); + if (__instance.isInvisible_) + return false; + if (data.type_ == AddRemovePlayerData.PDType.Replay) + { + PlayerDataReplay player = data.player_ as PlayerDataReplay; + if ((bool)(UnityEngine.Object)player && player.IsGhost_) + return false; + } + if (data.type_ == AddRemovePlayerData.PDType.Net) + { + //This should disable rendering for network cars on the killgrids. + Mod.Instance.Logger.Debug("No killgrids for network car!"); + return false; + } + UnityEngine.Renderer component = __instance.GetComponent(); + __instance.CreateParentIfNeeded(); + UnityEngine.GameObject followerObj = UnityEngine.Object.Instantiate(__instance.followerPrefab_); + followerObj.transform.SetParentKeepingLocalTransform(__instance.followerParent_); + __instance.helpers_.Add(new KillGrid.KillGridFollowerHelper(data.player_, followerObj, component.sharedMaterial.color, __instance.curvature_, new KillGrid.PositionFollowerFn(__instance.PositionFollower))); + } + else + { + KillGrid.KillGridFollowerHelper gridFollowerHelper = __instance.helpers_.Find((System.Predicate)(val => (UnityEngine.Object)val.player_ == (UnityEngine.Object)data.player_)); + if (gridFollowerHelper == null) + return false; + gridFollowerHelper.Destroy(); + __instance.helpers_.Remove(gridFollowerHelper); + } + return false; + } + return true; + } + } +} diff --git a/Distance.OnlineAdditions/Harmony/Assembly-CSharp/PlayerDataNet/InitCarVirtual.cs b/Distance.OnlineAdditions/Harmony/Assembly-CSharp/PlayerDataNet/InitCarVirtual.cs index c08d045..f2b381f 100644 --- a/Distance.OnlineAdditions/Harmony/Assembly-CSharp/PlayerDataNet/InitCarVirtual.cs +++ b/Distance.OnlineAdditions/Harmony/Assembly-CSharp/PlayerDataNet/InitCarVirtual.cs @@ -3,10 +3,6 @@ namespace Distance.OnlineAdditions.Harmony { //Enable to collider on network cars - - [HarmonyPatch(typeof(PlayerDataNet))] - - [HarmonyPatch(typeof(PlayerDataNet), "InitCarVirtual")] internal class PlayerDataNet__InitCarVirtual { @@ -21,6 +17,7 @@ System.Collections.IEnumerator ActivateCollidersAfterSeconds(float seconds) { __instance.SetAllColliderLayers(Layers.Default); __instance.CarLOD_.rigidbody_.isKinematic = true; + __instance.CarLOD_.SetCarSimulationEnabled(true); } } diff --git a/Distance.OnlineAdditions/Harmony/Assembly-CSharp/PlayerDataNet/SetOutlineColor.cs b/Distance.OnlineAdditions/Harmony/Assembly-CSharp/PlayerDataNet/SetOutlineColor.cs new file mode 100644 index 0000000..76822d3 --- /dev/null +++ b/Distance.OnlineAdditions/Harmony/Assembly-CSharp/PlayerDataNet/SetOutlineColor.cs @@ -0,0 +1,17 @@ +using HarmonyLib; + +namespace Distance.OnlineAdditions.Harmony +{ + [HarmonyPatch(typeof(PlayerDataNet), "SetOutlineColor")] + internal class PlayerDataNet__SetOutlineColor + { + [HarmonyPrefix] + internal static bool NetworkOutline(PlayerDataNet __instance) + { + if (!(bool)(UnityEngine.Object)__instance.outline_) + return false; + __instance.outline_.SetOutlineColorNoNorm(UnityEngine.Color.Lerp(UnityEngine.Color.black, __instance.GlowColor_.Normalized(), Mod.Instance.Config.OutlineBrightness)); + return false; + } + } +} diff --git a/Distance.OnlineAdditions/Harmony/Assembly-CSharp/RigidbodyStateTransceiver/EaseTowards.cs b/Distance.OnlineAdditions/Harmony/Assembly-CSharp/RigidbodyStateTransceiver/EaseTowards.cs index adfc4c4..d886b67 100644 --- a/Distance.OnlineAdditions/Harmony/Assembly-CSharp/RigidbodyStateTransceiver/EaseTowards.cs +++ b/Distance.OnlineAdditions/Harmony/Assembly-CSharp/RigidbodyStateTransceiver/EaseTowards.cs @@ -1,4 +1,4 @@ -using HarmonyLib; +/*using HarmonyLib; namespace Distance.OnlineAdditions.Harmony { @@ -27,7 +27,7 @@ internal static bool KinematicEaseTowards(RigidbodyStateTransceiver __instance) UnityEngine.Vector3 vector3_2 = RigidbodyStateTransceiver.posCorrectionSpringDamping_ * snapshot.vel; UnityEngine.Vector3 vector3_3 = 250f * snapshot.rot.ToVector3(); UnityEngine.Vector3 vector3_4 = RigidbodyStateTransceiver.rotCorrectionSpringDamping_ * snapshot.rotVel; - UnityEngine.Quaternion deltaRotation = UnityEngine.Quaternion.Euler(vector3_3 + vector3_4);*/ + UnityEngine.Quaternion deltaRotation = UnityEngine.Quaternion.Euler(vector3_3 + vector3_4);* RigidbodyStateTransceiver.Snapshot prevSnapshot = RigidbodyStateTransceiver.Snapshot.Difference(__instance.prevGoal_, new RigidbodyStateTransceiver.Snapshot(__instance.rigidbody_)); @@ -48,4 +48,4 @@ internal static bool KinematicEaseTowards(RigidbodyStateTransceiver __instance) } } } -} +}*/ diff --git a/Distance.OnlineAdditions/Harmony/Assembly-CSharp/RigidbodyStateTransceiver/FixedUpdate.cs b/Distance.OnlineAdditions/Harmony/Assembly-CSharp/RigidbodyStateTransceiver/FixedUpdate.cs new file mode 100644 index 0000000..8f77d8f --- /dev/null +++ b/Distance.OnlineAdditions/Harmony/Assembly-CSharp/RigidbodyStateTransceiver/FixedUpdate.cs @@ -0,0 +1,20 @@ +using HarmonyLib; + +namespace Distance.OnlineAdditions.Harmony +{ + [HarmonyPatch(typeof(RigidbodyStateTransceiver), "FixedUpdate")] + internal class RigidbodyStateTransceiver__FixedUpdate + { + [HarmonyPrefix] + internal static bool FixedTheFixedUpdate(RigidbodyStateTransceiver __instance) + { + if (!__instance.setCarOnFixedUpdate_) + return false; + __instance.rigidbody_.transform.position = __instance.posSpring_.Pos_ + __instance.setCarOnFixedUpdateCoef_ * 0.01f * __instance.velSpring_.Pos_; + __instance.rigidbody_.transform.rotation = __instance.rotSpring_.Pos_; + __instance.rigidbody_.velocity = __instance.velSpring_.Pos_; + __instance.rigidbody_.angularVelocity = __instance.rotSpring_.Vel_; + return false; + } + } +} diff --git a/Distance.OnlineAdditions/Harmony/Assembly-CSharp/TimeBasedMode/AwakeVirtual.cs b/Distance.OnlineAdditions/Harmony/Assembly-CSharp/TimeBasedMode/AwakeVirtual.cs index 9ca4212..dcac009 100644 --- a/Distance.OnlineAdditions/Harmony/Assembly-CSharp/TimeBasedMode/AwakeVirtual.cs +++ b/Distance.OnlineAdditions/Harmony/Assembly-CSharp/TimeBasedMode/AwakeVirtual.cs @@ -8,7 +8,6 @@ internal class TimeBasedMode__AwakeVirtual [HarmonyPostfix] internal static void VirtualedYourVirtual(TimeBasedMode __instance) { - Mod.Instance.Logger.Debug("SETTING BOOLS"); Mod.Instance.AmIHost = __instance.IsHost_; Mod.Instance.CountdownActive = false; Mod.Instance.AllPlayersFinished = false; diff --git a/Distance.OnlineAdditions/Mod.cs b/Distance.OnlineAdditions/Mod.cs index dc0ae92..ec93604 100644 --- a/Distance.OnlineAdditions/Mod.cs +++ b/Distance.OnlineAdditions/Mod.cs @@ -124,7 +124,7 @@ private void CreateSettingsMenu() new IntegerSlider(MenuDisplayMode.Both, "settings:timeout_amount", "ADJUST LENGTH OF TIMEOUT TIME") .WithDefaultValue(60) - .LimitedByRange(0, 180) + .LimitedByRange(0, 300) .WithGetter(() => Config.TimeLimitAmount) .WithSetter((x) => Config.TimeLimitAmount = x) .WithDescription("Adjust the amount of time is set when a time limit occurs"), @@ -133,6 +133,32 @@ private void CreateSettingsMenu() .WithGetter(() => Config.DisableTimeout) .WithSetter((x) => Config.DisableTimeout = x) .WithDescription("Completely disables the 60 seconds timeout when one player is left"), + + new CheckBox(MenuDisplayMode.Both, "setting:disable_killgrid", "DISABLE MULTI KILLGRIDS") + .WithGetter(() => Config.DisableMultiKillGridRender) + .WithSetter((x) => Config.DisableMultiKillGridRender = x) + .WithDescription("Disables the rendering of the kill grid for every player in multiplayer. The killgrid will only render for you!"), + + new FloatSlider(MenuDisplayMode.Both, "settings:outline_brightness", "ADJUST CAR OUTLINE BRIGHTNESS") + .WithDefaultValue(1) + .LimitedByRange(0, 1) + .WithGetter(() => Config.OutlineBrightness) + .WithSetter((x) => Config.OutlineBrightness = x) + .WithDescription("Adjust the brightness of the outlines on online player cars"), + + new ListBox(MenuDisplayMode.Both, "settings:level_of_detail", "MAXIMUM CAR DETAIL") + .WithEntries(new System.Collections.Generic.Dictionary() + { + { "Ultra", 1 }, + { "Very High", 2 }, + { "High", 3 }, + { "Medium", 4 }, + { "Low", 5 }, + { "Lowest", 6 } + }) + .WithGetter(() => Config.MaxLevelOfDetail) + .WithSetter((x) => Config.MaxLevelOfDetail = x) + .WithDescription("The maximum detail online cars can have. This will lower the visual quality other cars have online. Ultra is the usual default."), }; Menus.AddNew(MenuDisplayMode.Both, settingsMenu, "ONLINE ADDITIONS", "Settings for the Online Additions mod");