Skip to content

Commit 3753fd6

Browse files
committed
Improve Grid World template generation
Adds fixes for Yellow-Dog-Man/Resonite-Issues#2754 and Yellow-Dog-Man/Resonite-Issues#3829
1 parent 66b0025 commit 3753fd6

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using Elements.Core;
2+
using FrooxEngine;
3+
using HarmonyLib;
4+
using MonkeyLoader.Resonite;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Text;
8+
9+
namespace CommunityBugFixCollection
10+
{
11+
[HarmonyPatchCategory(nameof(BetterGridWorldPreset))]
12+
[HarmonyPatch(typeof(WorldPresets), nameof(WorldPresets.Grid))]
13+
internal sealed class BetterGridWorldPreset : ResoniteMonkey<BetterGridWorldPreset>
14+
{
15+
public override IEnumerable<string> Authors => Contributors.Banane9;
16+
17+
public override bool CanBeDisabled => true;
18+
19+
private static bool Prefix(World w)
20+
{
21+
if (!Enabled)
22+
return true;
23+
24+
WorldPresets.BlankWorld(w);
25+
26+
var ground = w.AddSlot("Ground");
27+
ground.LocalRotation = floatQ.Euler(90, 0, 0);
28+
29+
var attachedModel = ground.AttachMesh<GridMesh, PBS_Metallic>();
30+
attachedModel.mesh.Size.Value = 1000 * float2.One;
31+
attachedModel.mesh.Points.Value = 20 * int2.One;
32+
33+
var gridTexture = ground.AttachComponent<GridTexture>();
34+
gridTexture.BackgroundColor.Value = new colorX(0.07f, 0.08f, 0.11f);
35+
gridTexture.FilterMode.Value = TextureFilterMode.Anisotropic;
36+
gridTexture.Size.Value = 256 * int2.One;
37+
gridTexture.Mipmaps.Value = true;
38+
gridTexture.Grids.Clear();
39+
40+
var minorGrid = gridTexture.Grids.Add();
41+
minorGrid.LineColor.Value = new colorX(0.17f, 0.18f, 0.21f);
42+
minorGrid.Spacing.Value = 85 * int2.One;
43+
minorGrid.Width.Value = 2 * int2.One;
44+
minorGrid.Offset.Value = int2.Zero;
45+
46+
var majorGrid = gridTexture.Grids.Add();
47+
majorGrid.LineColor.Value = new colorX(0.88f);
48+
majorGrid.Spacing.Value = 256 * int2.One;
49+
majorGrid.Width.Value = 2 * int2.One;
50+
majorGrid.Offset.Value = int2.Zero;
51+
52+
attachedModel.material.AlbedoTexture.Target = gridTexture;
53+
attachedModel.material.TextureScale.DriveFrom(attachedModel.mesh.Size);
54+
attachedModel.material.Smoothness.Value = 0f;
55+
56+
var boxCollider = ground.AttachComponent<BoxCollider>();
57+
boxCollider.Size.DriveFrom(attachedModel.mesh.Size);
58+
boxCollider.SetCharacterCollider();
59+
60+
return false;
61+
}
62+
}
63+
}

CommunityBugFixCollection/Locale/de.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
"CommunityBugFixCollection.CopyToClipboard": "In Zwischenablage kopieren",
99

10+
"CommunityBugFixCollection.BetterGridWorldPreset.Description": "Verbessert das Grid Welt Preset indem das zittern des Bodens verhindert und das Grid zentriert wird.",
1011
"CommunityBugFixCollection.BreakDragAndDropCopiedComponentDrives.Description": "Sorgt dafür, dass Drives beim Kopieren von Komponenten mittels Drag-und-Drop nicht kaputt gehen.",
1112
"CommunityBugFixCollection.BreakDuplicatedComponentDrives.Description": "Sorgt dafür, dass Drives beim Duplizieren von Komponenten nicht kaputt gehen.",
1213
"CommunityBugFixCollection.CaseInsensitiveCustomGenerics.Description": "Macht das Auswählen von eigenen generischen Typparametern unabhängig von Groß- und Kleinschreibung.",

CommunityBugFixCollection/Locale/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
"CommunityBugFixCollection.CopyToClipboard": "Copy to Clipboard",
99

10+
"CommunityBugFixCollection.BetterGridWorldPreset.Description": "Improves the Grid World Preset by preventing the shaking ground and centering the grid.",
1011
"CommunityBugFixCollection.BreakDragAndDropCopiedComponentDrives.Description": "Fixes copying components using drag-and-drop breaking drives.",
1112
"CommunityBugFixCollection.BreakDuplicatedComponentDrives.Description": "Fixes duplicating components breaking drives.",
1213
"CommunityBugFixCollection.CaseInsensitiveCustomGenerics.Description": "Makes picking custom generic type parameters case-insensitive.",

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ just disable them in the settings in the meantime.
4545
* URLs to text files or Resonite Packages failing to import instead of appearing as a hyperlink (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/785)
4646
* References in multiple duplicated or transferred-between-worlds items breaking (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/984)
4747
* UserInspectors not listing existing users in the session for non-host users (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/1964)
48+
* Grid World grid being off-center (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/2754)
4849
* Animators updating all associated fields every frame while enabled but not playing (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/3480)
4950
* Direct cursor size becoming very large when snapped to an object much closer than the true cursor (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/3654)
51+
* Grid World floor shaking on AMD and Intel GPUs (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/3829)
5052
* DuplicateSlot ProtoFlux node crashes game when if OverrideParent is identical to Template (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/3950)
5153

5254
Fixes with no issue (that could be found).

0 commit comments

Comments
 (0)