Skip to content

Commit

Permalink
Details Added v1.8
Browse files Browse the repository at this point in the history
- Added ability to adjust the maximum detail for cars
- Added ability to disable the killgrid rendering for every player online
- Updated Collision logic
- Added ability to adjust Outline Brightness
- Increased maximum timeout value
  • Loading branch information
Tribow committed Dec 2, 2023
1 parent 10c899e commit 8e6d0b8
Show file tree
Hide file tree
Showing 11 changed files with 190 additions and 9 deletions.
21 changes: 21 additions & 0 deletions Distance.OnlineAdditions/ConfigLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,29 @@ public bool DisableTimeout
set { Set("DisableTimeout", value); }
}

public bool DisableMultiKillGridRender
{
get { return Get<bool>("DisableMultiKillGridRender"); }
set { Set("DisableMultiKillGridRender", value); }
}

public int TimeLimitAmount
{
get { return Get<int>("TimeLimitAmount"); }
set { Set("TimeLimitAmount", value); }
}

public int MaxLevelOfDetail
{
get { return Get<int>("MaxLevelOfDetail"); }
set { Set("MaxLevelOfDetail", value); }
}

public float OutlineBrightness
{
get { return Get<float>("OutlineBrightness"); }
set { Set("OutlineBrightness", value); }
}
#endregion

internal Settings Config;
Expand All @@ -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();
}
Expand Down
5 changes: 5 additions & 0 deletions Distance.OnlineAdditions/Distance.OnlineAdditions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,21 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ConfigLogic.cs" />
<Compile Include="Harmony\Assembly-CSharp\RigidbodyStateTransceiver\FixedUpdate.cs" />
<Compile Include="Harmony\Assembly-CSharp\CarLevelOfDetail\IncrementLevel.cs" />
<Compile Include="Harmony\Assembly-CSharp\CarLevelOfDetail\SetLevelOfDetail.cs" />
<Compile Include="Harmony\Assembly-CSharp\ChatInputV2\CheckForServerCode.cs" />
<Compile Include="Harmony\Assembly-CSharp\ChatWindow\Update.cs" />
<Compile Include="Harmony\Assembly-CSharp\CheatMenu\TweakCheat.cs" />
<Compile Include="Harmony\Assembly-CSharp\CheatsManager\OnEventSceneLoadFinished.cs" />
<Compile Include="Harmony\Assembly-CSharp\ClientLogic\GetClientChatName.cs" />
<Compile Include="Harmony\Assembly-CSharp\ClientLogic\GetLocalChatName.cs" />
<Compile Include="Harmony\Assembly-CSharp\GameMode\UploadScoreAndReplay.cs" />
<Compile Include="Harmony\Assembly-CSharp\KillGrid\OnEventAddRemovePlayerData.cs" />
<Compile Include="Harmony\Assembly-CSharp\PlayerDataLocal\InitCarVirtual.cs" />
<Compile Include="Harmony\Assembly-CSharp\PlayerDataLocal\LocalOnPlayerEventFinished.cs" />
<Compile Include="Harmony\Assembly-CSharp\PlayerDataNet\InitCarVirtual.cs" />
<Compile Include="Harmony\Assembly-CSharp\PlayerDataNet\SetOutlineColor.cs" />
<Compile Include="Harmony\Assembly-CSharp\RigidbodyStateTransceiver\EaseTowards.cs" />
<Compile Include="Harmony\Assembly-CSharp\TimeBasedMode\AwakeVirtual.cs" />
<Compile Include="Harmony\Assembly-CSharp\TimeBasedMode\UpdateModeFinishedState.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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<UnityEngine.Renderer>();
__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<KillGrid.KillGridFollowerHelper>)(val => (UnityEngine.Object)val.player_ == (UnityEngine.Object)data.player_));
if (gridFollowerHelper == null)
return false;
gridFollowerHelper.Destroy();
__instance.helpers_.Remove(gridFollowerHelper);
}
return false;
}
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -21,6 +17,7 @@ System.Collections.IEnumerator ActivateCollidersAfterSeconds(float seconds)
{
__instance.SetAllColliderLayers(Layers.Default);
__instance.CarLOD_.rigidbody_.isKinematic = true;
__instance.CarLOD_.SetCarSimulationEnabled(true);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using HarmonyLib;
/*using HarmonyLib;
namespace Distance.OnlineAdditions.Harmony
{
Expand Down Expand Up @@ -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_));
Expand All @@ -48,4 +48,4 @@ internal static bool KinematicEaseTowards(RigidbodyStateTransceiver __instance)
}
}
}
}
}*/
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
28 changes: 27 additions & 1 deletion Distance.OnlineAdditions/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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<int>(MenuDisplayMode.Both, "settings:level_of_detail", "MAXIMUM CAR DETAIL")
.WithEntries(new System.Collections.Generic.Dictionary<string, int>()
{
{ "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");
Expand Down

0 comments on commit 8e6d0b8

Please sign in to comment.