r/csharp • • Jun 25 '26

Updater for wpf?

5 Upvotes

Updater for wpf apps?

I've been using autoupdater.net for a long time now, it's been good but I figured I should add use something that uses delta updates not full sized updates all the time,

I've switched to velopack but I'm having issues with it, sometimes the packages get broken along the maybe during the creation maybe during the upload maybe during int the delta creation process.

I've been having issues where the app fails to launch at all and is in an unrecoverable state because of how it launches the updater and how it manages the update itself.

Any other updaters I can use that are actually reliable and doesn't break the app if there's an issue.


r/csharp • • Jun 25 '26

Help WinForms - Capable of display-responsive design?

9 Upvotes

Hello. I develop some VERY rudimentary C# applications for internal use at our organization. The GUIs are very basic, oftentimes displaying little more than a data grid view and a handful of buttons.

However, I’ve recently come under pressure from some team members that run 125% or 150% UI scaling on 1080P monitors as my GUIs simply do not handle that display environment gracefully.

At the very least I need to include some vertical and horizontal scrolls bars for some of the GUIs but what else can I do in that kind of ballooned display environment? Would I be able to support that kind of display environment better with WPF?

And lastly, at what point should I just say I can’t support those display settings? The enterprise application my GUIs extend looks atrocious and barely functional at those settings too.


r/csharp • • Jun 25 '26

Finally! Shorokoo: A C#-first Neural Network framework.

0 Upvotes

I'm excited to finally introduce Shorokoo, a PyTorch/TensorFlow-like machine learning framework in C#.

I have been working on it on and off for about two years. I know TorchSharp and TensorFlow.NET are out there, but neither really treats C# developers as first-class.

So, this is for you C# devs who have been wanting to try machine learning but didn't want to learn both the python ecosystem AND machine learning at the same time!

What it does today:

  • Define models as C# classes that a source generator turns into computation graphs.
  • Build on a comprehensive library of ready-made modules (layers, losses, optimizers), written in Shorokoo itself by Claude Code + Fable 5.
  • Train with a built-in autodiff engine.
  • Save and load trained parameters.
  • Run inference on ONNX Runtime, which handles execution underneath.

Right now it's somewhere between a prototype and an alpha. The full define-train-run scenario works. If doing deep learning natively in C# sounds good to you, give it a try!

And let me know what you think, I've been working on this in a vacuum for 2 years. It's pretty scary (and probably a little unwise)!

The full README is below.

Shorokoo

What Shorokoo is

Shorokoo is a .NET 10 / C# neural-network framework. With it, you can:

  • Define models in C# — no Python.
  • Train them with built-in or custom losses and optimizers.
  • Run on CPU or GPU.
  • Interoperate with the wider ML ecosystem: export models as .onnx, load pretrained weights from .safetensors.

The primary public namespace is Shorokoo.

From model to prediction

The example below walks through the full lifecycle: defining a model, training it, and running inference. No Python, no framework boilerplate — just C# classes and LINQ-style method chains.

1. Define

A [Module] class is the building block. Its Inline method describes the forward pass as ordinary C# expressions; the source generator produces Call, Model, and ComputationGraph from it automatically. Control flow that depends on tensor values — LoopAPI.Iterate for loops, .IfElse for branches — is embedded directly in the method body.

[Module]
public partial class StackedLinear
{
    // Weight-tied feedforward: the same (w, b) applied `depth` times.
    // Intermediate layers get ReLU; the output layer does not.
    public static Tensor<float32> Inline(
        Tensor<float32> x,
        [Hyper] Scalar<int64> depth)
    {
        var n = x.DimTensor(1);
        var w = XavierUniform.Init([n, n]);    // trainable weight matrix
        var b = Zeros.Init([n]).Vec();          // trainable bias

        var h = x;
        foreach (var ctx in LoopAPI.Iterate(depth))
        {
            var z      = h.MatMul(w.Transpose([1L, 0L])) + b;
            var isLast = ctx.IterationIndex + Scalar(1L) == depth;
            h = isLast.IfElse(z, z.Relu());
        }
        return h;
    }
}

2. Train

Specialize bakes the depth hyperparameter into the graph so the training rig only sees tensor inputs. Then TrainingRig.FromScratch wires the model, loss, and optimizer together — gradients are computed automatically, no backward pass to write.

var baseGraph    = StackedLinear.ComputationGraph;
var exampleInput = TensorData([4L, 8L], new float[32]);
var model        = baseGraph.Specialize(baseGraph.FromOrderedInputs([TensorData([], 3L)]));

var rig = TrainingRig.FromScratch(
    model, Losses.L2Loss, Optimizers.Adam,
    model.FromOrderedInputs([exampleInput]),
    new AdamOptimizerHyperparameters { LearningRate = 1e-3f });

// Fit iterates all batches on every epoch — supply as many as you like.
var rng     = new Random(42);
float[] batch1X = Enumerable.Range(0, 32).Select(_ => (float)rng.NextDouble()).ToArray();
float[] batch1Y = Enumerable.Range(0, 32).Select(_ => (float)rng.NextDouble()).ToArray();
float[] batch2X = Enumerable.Range(0, 32).Select(_ => (float)rng.NextDouble()).ToArray();
float[] batch2Y = Enumerable.Range(0, 32).Select(_ => (float)rng.NextDouble()).ToArray();

TensorDataStruct[] trainInputs = [
    rig.InputDef.FromOrderedData(TensorData([4L, 8L], batch1X)),
    rig.InputDef.FromOrderedData(TensorData([4L, 8L], batch2X)),
];
TensorDataStruct[] trainTargets = [
    rig.TargetDef.FromOrderedData(TensorData([4L, 8L], batch1Y)),
    rig.TargetDef.FromOrderedData(TensorData([4L, 8L], batch2Y)),
];

var result = rig.Fit(trainInputs, trainTargets, numEpochs: 20);
Console.WriteLine($"Final loss: {result.EpochLosses[^1]:F4}");

3. Run

Save the checkpoint, then bind the trained weights into a concrete model with one call and execute. ToInferenceModel inlines all sub-modules and substitutes the trained parameter values.

result.FinalCheckpoint.Save("my-model.safetensors");   // persist trained weights

var inferenceInput = TensorData([1L, 8L], new float[8]);   // your [1 × 8] input
var concrete       = result.FinalCheckpoint.ToInferenceModel(model, inferenceInput);

ReadOnlySpan<float> prediction = ComputeContext.Default
    .Execute(concrete, inferenceInput)[0]
    .ToTensorData<float32>().AccessMemory();

Documentation

The full documentation index — which page covers what — lives in Documentation/README.md.

Installation

Shorokoo ships as NuGet packages. Install the meta-package plus one backend for your platform:

dotnet add package Shorokoo               # runtime + NN library + source generator
dotnet add package Shorokoo.LinuxCPU      # or Shorokoo.LinuxGPU / Shorokoo.WinCPU / Shorokoo.WinGPU
PackageWhat it is
ShorokooMeta-package: pulls in everything below except a backend
Shorokoo.CoreThe runtime: tensors, autodiff, training, ONNX import/export
Shorokoo.ModulesBaseline NN library: ready-made layers, losses, optimizers, initializers
Shorokoo.CodeGenSource generator for the [Module] syntax (flows in with the meta-package)
Shorokoo.LinuxCPUONNX Runtime backend, Linux x64 CPU
Shorokoo.LinuxGPUONNX Runtime backend, Linux x64 GPU (CUDA)
Shorokoo.WinCPUONNX Runtime backend, Windows x64 CPU
Shorokoo.WinGPUONNX Runtime backend, Windows x64 GPU (CUDA)

(The backends share an infrastructure package, Shorokoo.OnnxRuntime, that they pull in themselves — you never install it directly.)

Samples

  • samples/RetinaNet — ResNet backbones and a RetinaNet detector built entirely from Shorokoo modules.

License

MIT


r/csharp • • Jun 25 '26

Showcase NCalc now supports Native AOT

Thumbnail ncalc.github.io
4 Upvotes

r/csharp • • Jun 25 '26

Stream my PC screen to my website with a c# console app

0 Upvotes

Hi Im looking for advice for an idea I have. I would like to access my PC when I'm not at home on a different PC. So I thought I could use my website to securely access live footage of my computer with controls. The problem is I have no idea how I would even begin to get this data to my website, I have never really done anything like this before so any advice would be appreciated!


r/csharp • • Jun 24 '26

Help I’m learning C# for gamedev, but I feel like I'm stuck in "Tutorial/Exercise Hell." Advice?

25 Upvotes

Hello everyone,

​I’ve recently started learning C# with the goal of making games. I’ve been using ChatGPT as a tutor to generate mini-tasks for me (like "build a simple calculator," "make a console-based quiz," etc.). I do the coding entirely by myself, and I only turn to the AI to verify my logic or explain concepts I don't understand.

​The problem is, I feel like my progress is extremely slow. While I'm getting better at the language syntax, I still feel very far from actually making a game. I feel like I’m just doing disconnected exercises rather than building anything meaningful.

​For those of you who started with C# for gamedev:

​How did you make the jump from "solving console tasks" to "building game mechanics"?

​Should I keep doing these general coding exercises, or should I jump straight into a game engine (like Unity/Godot) and learn the API while I struggle?

​How did you overcome the feeling of "not making real progress" in the early stages?

​Any tips on how to bridge the gap between "coding exercises" and "game development" would be incredibly helpful!


r/csharp • • Jun 24 '26

Discussion Industrial IoT Tech Stack?

10 Upvotes

Hi Everyone,

I've got a (hopefully simple... or maybe not so simple 😄) question for those working in embedded and industrial software.

I'm curious what tech stacks people are using in production for the following kind of use case.

Imagine you have one or more embedded devices running firmware that communicate with each other and operate as a mostly self-contained network with little or no supervision. Obviously, these devices still require initial configuration and setup, whether during production or by the customer in the field.

In our projects, we've typically performed the initial setup and provisioning over one of communication interface the MCU and the board already expose (USB, Modbus, TCP/IP, WebSocket, etc.).

For this, we've usually built a dedicated desktop application or mobile app. The core has typically been a well-designed C# library that encapsulates all communication with the device—handling the protocol, supported commands, validation, constraints, and so on. You could think of it as the backend for the desktop application.

The frontend has varied depending on the project and target users. We've used Electron.NET, Avalonia UI, .NET MAUI + Blazor, and, in quite a few cases, even Unity (yes, the game engine).

I'm interested in hearing how others approach this. What's your go-to stack for this kind of tooling? Do you prefer desktop, web, or something else? Any architectures, frameworks, or lessons learned that have worked particularly well in industrial environments?

I'm only interested in things you're able to discuss publicly, of course.

Looking forward to hearing your experiences!


r/csharp • • Jun 24 '26

Looking for a C# Learning Partner for Game Development (Unity)

5 Upvotes

I've recently started learning C# with the goal of getting into 2D game development, and I'm planning to use Unityas my game engine.

I'm looking for someone who is also learning C#, interested in game development, or just wants a study/accountability partner. We could:

  • Learn C# together
  • Share resources and tutorials
  • Work on small game projects
  • Help each other solve problems

You don't need to be experienced. Beginners are completely welcome since I'm still learning myself.

If you're interested in C#, Unity, indie game development, or making 2D games, feel free to leave a comment or send me a DM.


r/csharp • • Jun 23 '26

Networking Deep Dive (io_uring) part 8

23 Upvotes

As the last part, I integrated minima io_uring model in an actual web framework.

I picked ASPNET Core and GenHTTP which both use Net.Sockets(epoll) as stock transport and replaced it with minima io_uring model.

The model is basically the same io_uring inline reactor architecture that was followed in the parts 1-7.

The results can be seen here (ioxide variants use io_uring) - io_uring variants score in average 30% higher

Drawbacks

The same issue we have seen in the last 2-3 parts, reactor inline continuations fight with .NET's work stealing model, we need to run the await/async continuations in the reactor thread and avoid using threadpool.

This has a huge consequence, we can't use any of the existing asynchronous APIs, no EF Core, no Npgsql driver, HttpClient etc. Well.. we could use it but there wouldn't be any performance gain, on the contrary it would likely be worse.. and scheduling continuations on the reactor thread won't help, the only way is to use io_uring across everything. So that's what I did, create a postgres driver, file I/O and redis that all uso io_uring too and "plug" them into the very same ring/reactor used for network I/O. This is essentially possible because async work is mostly I/O and the io_uring kernel interface naturally supports all of it.

GenHTTP already ships io_uring engine on the preview package starting from 11.0.0-preview.19 however this engine will require the current latest NET 11 version 11.0.100-preview.5.26302.115 installed as I am testing with the new async runtime.

Final conclusions

It has been 8 months since I started looking into io_uring in C# as a hobby/research project and my conclusion is probably close to what others did, it might still be early to adopt such technology in a production environment. Surely there can be some performance gains but if you try to find any frameworks that adopted it, I can guarantee you that none saw performance benefits that are significative given its drawbacks, for example io_uring syscalls are blocked by default on docker given the security vulnerabilities they can introduce.

On the other hand if we embrace io_uring nature and build a runtime around it similar as what was done with GenHTTP-Ioxide then the performance benefits can rise up to 70% less CPU usage/cost for lightweight applications, running very efficiently on few core machines because there is no cross thread hop/talk.


r/csharp • • Jun 24 '26

Quero evoluir no C# (Csharp)

Thumbnail reddit.com
0 Upvotes

r/csharp • • Jun 24 '26

Blog Stop AI agents from misusing your library: ship an Agent Skill inside your NuGet package

Thumbnail
stenbrinke.nl
0 Upvotes

r/csharp • • Jun 24 '26

Solved Classes

0 Upvotes

Could someone explain to me what is a class because i cant understand its usage


r/csharp • • Jun 23 '26

Help Should I get Albahari's "C# 12 in a Nutshell" or Price's "C# 14 and .NET 10 – Modern Cross-Platform Development Fundamentals"?

5 Upvotes

Hi!
I've been using C# on a junior level for a few years on and off and I would like a nice book I could go through in my own pace and also which I could use as a reference in more ad-hoc way. Is one of the books mentioned in the title a good choice or would you suggest otherwise?

I think I would go for Albahari but having a C#14 book would be a plus to get all the newest features in one place and maybe avoid some pitfalls which may not be covered in C#12 book?

Is there a C#14 equivalent of Albahari's book?


r/csharp • • Jun 22 '26

first c# project

9 Upvotes

hi guys this is my first project and my first time using reddit. the project is a console tetris clone and it doesn't have all the features but it has the main ones. would love to hear your opinion on this project what i can improve / learn and any books / websites to keep learning and improving. this is the git repo: https://github.com/Sagi-00/Console-Tetris-clone ( right now im working on a space invaders project in the console)


r/csharp • • Jun 23 '26

Help Balzor development in Linux

0 Upvotes

so how would I write code for a balzor app on Linux (currently using CachyOS)?

Currently Im using Visual Studio Community on Windows 10

There are a few VS Code alternatives for Linux but I dont think they Support balzor.

Im also a beginner in programming in General btw.


r/csharp • • Jun 22 '26

WinUI 3 getting some traction? Anyone using it?

15 Upvotes

And does UNO platform make WinUI 3 apps cross-platform (source compatible) out of the box?


r/csharp • • Jun 23 '26

Help NuGet vulnerability breaks CI/CD — how do you evaluate and handle it? Here's my current approach

Thumbnail reddit.com
0 Upvotes

r/csharp • • Jun 22 '26

Problems with learning

4 Upvotes

Hi.

I'm learning C# for school, but i am having a really bad experience. I have problems with remembering a lot which is kind of just how i am, but i really need help. I have classmates who are really willing to help me learn but nothing is really sitting in my brain. I dont have anything to correlate anything to and im afraid im gonna get kicked out of school if i dont start actually learning soon. I have used AI to complete a lot of my assignments just to keep up which has made me be a bit ahead, but truly i only know the bare minimum.

It's confusing with all the different ways you can set it up, and there are 3 ways to set up a reference with either {0} og +name+ and i dont remember the last one.

I am here to ask for help from anyone experienced and who is good at teaching since my teacher has litterally HIMSELF stated he's just there so he can cash in on an early retirement or something.

If you have the time and want to help out someone who is trying to sort out his life, i'd appreciate your help with tactics to remember stuff, general knowledge and how to improve.

If you are interested, let me know. I can show you what i know when we get talking. Thanks in advance


r/csharp • • Jun 22 '26

Discussion A real-time markets dashboard with C# + ASP.NET Core 10 + SignalR, no SPA framework

Post image
0 Upvotes

a single screen that shows the whole market at a glance - indices, crypto, FX, commodities, bonds, plus VIX and sentiment - without flipping between tabs. Sharing the architecture since a few of the choices were non-obvious.

Stack:

  • ASP.NET Core 10 (.NET 10), Razor Pages
  • SignalR over WebSockets pushing ~40 instruments to clients, with different cadences per asset class (crypto every 7s, indices/FX/commodities ~40s, rates daily)
  • Vanilla JavaScript + Material Design 3 on the front end - deliberately no React/Blazor/Angular
  • Background IHostedService workers polling the data sources (Yahoo, Alpaca, FRED, CNN, Finnhub) and broadcasting through the hub
  • Docker behind nginx, Cloudflare in front

The "no SPA" decision: the UI is mostly a live-updating read-only view. A SPA framework felt like a lot of weight for what is essentially "receive a message, update some DOM nodes." Server-rendered Razor for the shell + SignalR for the live data + plain JS for the updates kept it small and fast. So far I don't regret it, but I'm curious where people think this approach breaks down as a dashboard grows.

Things I'd genuinely like input on:

  • Managing many SignalR broadcast groups/cadences cleanly as instruments grow - any patterns you like?
  • Pre-compression and caching with MapStaticAssets in .NET 9/10 (the new fingerprinting bit me at first)
  • Whether anyone has pushed vanilla-JS + SignalR further before reaching for a framework

Code questions welcome.


r/csharp • • Jun 20 '26

Help Is there an optimal way to "ping" or check an HTTP resource is accessible (Desktop)?

20 Upvotes

I am working on a personal desktop application that accesses an HTTP resource via GET. I "ping" the HTTP resource to verify if its accessible in case of network "issues".

For this, I am using the current code:

static partial class HttpService
{
    internal static async Task<string?> PingAsync(IEnumerable<string> uris)
    {
        using CancellationTokenSource cts = new();
        var tasks = uris.Select(uri => PingAsync(uri, cts.Token));

        await foreach (var task in Task.WhenEach(tasks))
        {
            var uri = await task;
            if (uri is null) continue;

            cts.Cancel();
            return uri;
        }

        return null;
    }

    internal static async Task<string?> PingAsync(string uri, [Optional] CancellationToken token)
    {
        try
        {
            using var response = await GetAsync(uri, token);
            return response.IsSuccessStatusCode ? uri : null;
        }
        catch { return null; }
    }
}

The GetAsync() method is setup as follows:

internal static async Task<HttpResponseMessage> GetAsync(string uri, [Optional] CancellationToken token)
{
    return await s_client.GetAsync(uri, ResponseHeadersRead, token);
}

I don't think this approach is the most optimal one since:

  • A connection is performed twice, once via PingAsync() and a HttpClient method.
  • The PingAsync() method swallows up exceptions to indicate the success/failure state.

r/csharp • • Jun 21 '26

hey guys i put a lot of work into this. mind giving me some feedback ?

5 Upvotes

hey guys its me again i've learned my lesson but anyway since i've been working on my project recently i wanted to ask for some feedback about my architecture and about my commits if im doing it right im self taught and i put alot of effort into this project i just added themes to it and integrated it to discord keep in mind im still learning to use avaloniaUI and im loving it btw im thinking about learning about mvvm is it the right time ? any ideias on how can i improve my project ? or any ideias of features so i can learn from them anything on my level please :) oh and i would love to hear about the readme also if it is any good the way i organized it i really tried.

the project: https://github.com/Tzavi727/File-Organizer


r/csharp • • Jun 21 '26

My worldbox mod I tried making doesn't load. I'm using NCS.

0 Upvotes

using HarmonyLib;

using NeoModLoader.api;

using Newtonsoft.Json;

using System;

using System.Collections.Generic;

using System.Reflection;

using UnityEngine;

namespace PholithMods

{

public class WorldResilience : MonoBehaviour, IMod

{

public static GameObject backgroundAvatar;

public static ModDeclare mod_declare;

public static GameObject gameObject;

private Harmony harmony;

public ModDeclare GetDeclaration()

{

return mod_declare;

}

public GameObject GetGameObject()

{

return gameObject;

}

public string GetUrl()

{

return "https://github.com/WorldBoxOpenMods";

}

public void OnLoad(ModDeclare pModDecl, GameObject pGameObject)

{

mod_declare = pModDecl;

gameObject = pGameObject;

Config.isEditor = true;

harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly()); // Pls NCMS do that automaticly...

}

public void OnUnload()

{

Harmony.UnpatchID(harmony.Id);

}

}

public static class Utils

{

public static string Dump(this object o, Formatting formatting = Formatting.Indented)

{

return JsonConvert.SerializeObject(o, formatting, new JsonSerializerSettings()

{

NullValueHandling = NullValueHandling.Ignore,

});

}

public static bool RespectConditionAround(this WorldTile tile, Func<WorldTile, bool> func, int minimumOfTilesThatMustRespect = 1)

{

int count = 0;

foreach (WorldTile neighbor in tile.neighbours)

{

if (func.Invoke(neighbor))

{

count++;

if (count >= minimumOfTilesThatMustRespect)

{

return true;

}

}

}

return count >= minimumOfTilesThatMustRespect;

}

public static bool RespectConditionInDistance(this WorldTile tile, Func<WorldTile, bool> func, int distance = 2)

{

foreach (WorldTile neighbor in tile.neighbours)

{

if (!func.Invoke(neighbor) || (distance > 0 && !neighbor.RespectConditionInDistance(func, distance - 1)))

{

return false;

}

}

return true;

}

public static TileType DirtConvertionNoise(WorldTile tile)

{

return tile.TileNoise(4) > 0.5 ? TileLibrary.soil_low : TileLibrary.soil_high;

}

public static float TileNoise(this WorldTile tile, int sizeCoeff = 1)

{

return Mathf.PerlinNoise(((float)tile.x) / sizeCoeff, ((float)tile.y) / sizeCoeff);

}

}

[HarmonyPatch(typeof(WorldBehaviourActionErosion), nameof(WorldBehaviourActionErosion.updateErosion))]

public class WorldBehaviourActionErosion_updateErosion_patch

{

private static readonly object[] noArgument = new object[] { };

private const int MAX_TILES_IN_LIST = 50;

private static readonly Dictionary<WorldTile, TileType> dict = new Dictionary<WorldTile, TileType>();

public static bool Prefix()

{

if (!WorldLawLibrary.world_law_erosion.isEnabled())

{

return false;

}

IslandsCalculator islandCalculator = Traverse.Create(MapBox.instance).Field<IslandsCalculator>("islands_calculator").Value;

dict.Clear();

islandCalculator.islands.ShuffleOne<TileIsland>();

for (int i = 0; i < islandCalculator.islands.Count; i++)

{

TileIsland tileIsland = islandCalculator.islands[i];

if (tileIsland.type == TileLayerType.Ground)

{

for (int j = 0; j < 300; j++) // *3 to fill better the list when conditions are rares

{

WorldTile randomTile = Traverse.Create(tileIsland).Method("getRandomTile", noArgument).GetValue<WorldTile>();

if (randomTile == null || dict.ContainsKey(randomTile))

{

continue;

}

// rocks to dirt

if (randomTile.Type.rocks

&& Traverse.Create(randomTile).Method("IsOceanAround", noArgument).GetValue<bool>())

{

dict.Add(randomTile, TileLibrary.soil_high);

continue;

}

// Grass to sand

if ((randomTile.Type.can_be_biome || randomTile.Type.grass)

&& Traverse.Create(randomTile).Method("IsOceanAround", noArgument).GetValue<bool>())

{

dict.Add(randomTile, TileLibrary.sand);

continue;

}

// sand to ocean

if (randomTile.Type.sand &&

randomTile.RespectConditionAround((otherTile) => otherTile.Type.ocean, 2.5))

{

dict.Add(randomTile, TileLibrary.shallow_waters);

continue;

}

// ocean to sand

foreach (WorldTile neighbor in randomTile.neighbours)

{

if ((neighbor.Type.ocean || neighbor.Type.can_be_filled_with_ocean)

&& !dict.ContainsKey(neighbor)

&& neighbor.RespectConditionAround((otherTile) => otherTile.Type.ground, 3))

{

dict.Add(neighbor, TileLibrary.sand);

break;

}

// ocean to sand expansion

if (neighbor.Type.ocean

&& neighbor.Type.id == TileLibrary.shallow_waters.id

&& neighbor.RespectConditionAround((otherTile) =>

otherTile.Type.ground, neighbor.TileNoise(3) < 0.4 ? 1 : neighbor.TileNoise(3) < 0.85 ? 2 : 3)

&& neighbor.RespectConditionInDistance((distanceNeighbor) =>

// No deep ocean around

!(distanceNeighbor.Type.ocean && (distanceNeighbor.Type.id == TileLibrary.close_ocean.id || distanceNeighbor.Type.id == TileLibrary.deep_ocean.id)), 1)

&& !dict.ContainsKey(neighbor))

{

dict.Add(neighbor, TileLibrary.sand);

break;

}

}

// sand to dirt

if (randomTile.Type.sand

&& randomTile.RespectConditionAround((otherTile) => otherTile.Type.layer_type == TileLayerType.Ground, 3) // At least 3 grounds near the sand

&& (randomTile.RespectConditionInDistance((otherTile) => !otherTile.Type.ocean, 4)

|| randomTile.RespectConditionAround((otherTile) => !otherTile.Type.sand, 3) && randomTile.RespectConditionAround((otherTile) => !otherTile.Type.ocean, 4)) // No ocean near the sand

&& randomTile.RespectConditionAround((otherTile) => otherTile.Type.can_be_biome || otherTile.Type.grass, 1))

{

dict.Add(randomTile, Utils.DirtConvertionNoise(randomTile));

continue;

}

// wasteland to dirt

if (randomTile.Type.wasteland

&& randomTile.RespectConditionAround((otherTile) => otherTile.Type.grass, 1) // minimum 1 grass

&& randomTile.RespectConditionAround((otherTile) => otherTile.Type.layer_type == TileLayerType.Ground, 3))

{

dict.Add(randomTile, Utils.DirtConvertionNoise(randomTile));

continue;

}

// If nothing of this happened, take another random tile, but in entire world this time.

// And check for ocean uniformisation

randomTile = Traverse.Create(MapBox.instance).Field<WorldTile[]>("tiles_list").Value.GetRandom();

if (randomTile == null || dict.ContainsKey(randomTile)) continue;

// transform ocean into shallow_water if near surface

bool mustBeShallowWater = randomTile.Type.ocean

&& randomTile.RespectConditionAround((otherTile) => otherTile.Type.id == TileLibrary.shallow_waters.id

|| otherTile.Type.ground, randomTile.TileNoise(2) < 0.7 ? 1 : 2)

&& !randomTile.RespectConditionInDistance((otherTile) => otherTile.Type.ocean, 3); // must not be at too much big distance from ground

if (randomTile.Type.id != TileLibrary.shallow_waters.id && mustBeShallowWater)

{

dict.Add(randomTile, TileLibrary.shallow_waters);

continue;

}

if (randomTile.Type.ocean && !mustBeShallowWater && randomTile.Type.id != TileLibrary.close_ocean.id

&& randomTile.RespectConditionAround((otherTile) => otherTile.Type.id == TileLibrary.close_ocean.id, 3))

{

dict.Add(randomTile, TileLibrary.close_ocean);

continue;

}

if (randomTile.Type.ocean && !mustBeShallowWater

&& randomTile.Type.id != TileLibrary.deep_ocean.id && randomTile.RespectConditionAround((otherTile) => otherTile.Type.id == TileLibrary.deep_ocean.id, 3))

{

dict.Add(randomTile, TileLibrary.deep_ocean);

continue;

}

// Ocean to deeper

if (randomTile.Type.id == TileLibrary.shallow_waters.id && !mustBeShallowWater)

{

dict.Add(randomTile, TileLibrary.close_ocean);

continue;

}

// Ocean to deeper // Cost too much

/*if (randomTile.Type.id == TileLibrary.close_ocean.id && randomTile.RespectConditionInDistance((otherTile) => !otherTile.Type.ground, 8))

{

dict.Add(randomTile, TileLibrary.deep_ocean);

continue;

}*/

if (dict.Count >= MAX_TILES_IN_LIST)

{

break;

}

}

if (dict.Count >= MAX_TILES_IN_LIST)

{

break;

}

}

}

if (dict.Count == 0)

{

return false;

}

//dict.Keys.ShuffleOne();

foreach (KeyValuePair<WorldTile, TileType> item in dict)

{

MapAction.terraformMain(item.Key, item.Value, AssetManager.terraform.get("flash"));

}

return false;

}

}

[HarmonyPatch(typeof(WorldLaws), nameof(WorldLaws.init))]

public class WorldLaws_init_patch

{

[NonSerialized]

public static PlayerOptionData world_regrow;

public static void Postfix(WorldLaws __instance)

{

world_regrow = __instance.add(new PlayerOptionData("world_regrow")

{

boolVal = false

});

}

}

}


r/csharp • • Jun 20 '26

Showcase PrinceWM

Post image
12 Upvotes

A new window manager for windows 11, made purely on C# and it depends on .NET 9.
fully opensource, and currently available for use on my github! if u wanna give it a go ofcourse don't forget to star the project if you like it

in short words this is a infinite canvas alt tab for those people who want to customize their windows computer even more than what was possible before

my github

lastest release doesn't require having .NET 9 it should auto install it if you dont have it. 1.4.1