Skip to content

Instantly share code, notes, and snippets.

@redxdev
redxdev / DungeonGenerator.cs
Last active September 11, 2022 06:23
2d Dungeon Layout Generator
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
// NOTE: Some of the classes here (namely the primitives like Vector2d and Rect2d) are not provided,
// but most should be fairly easy to implement yourself or replace with similar
// classes from other libraries.
// The exception is the Delaunay triangulation - that takes quite a bit more effort to implement. That said,
@redxdev
redxdev / Heuristics.cs
Last active February 4, 2018 23:01
Old C# pathfinder
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Navier_Boats.Engine.Level;
namespace Navier_Boats.Engine.Pathfinding
{
public static class Heuristics
@redxdev
redxdev / MonoGameTemplates.md
Last active April 1, 2023 22:54
How to get MonoGame Templates for your IDE

Visual Studio 2017

MonoGame already supports installing templates from the official installer

dotnet Command Line

This works for all IDEs that support .net core (which is pretty much anything up to date nowadays). Use this if you can't get any other methods to work.

Install the latest .net core sdk. Run the following command:

@redxdev
redxdev / AudioBank.cs
Created April 19, 2020 22:05
Simple FMOD wrapper
using System;
using Flame.Engine.Assets;
using FMOD.Studio;
namespace Flame.Engine.Audio
{
public sealed class AudioBank : IDisposable, IEquatable<AudioBank>
{
private readonly Bank bank;
@redxdev
redxdev / FlameSmartNavLinkComponent.cpp
Created April 27, 2021 22:21
Blueprint spawnable smart nav link component
#include "FlameSmartNavLinkComponent.h"
#include "Navigation/PathFollowingComponent.h"
UFlameSmartNavLinkComponent::UFlameSmartNavLinkComponent()
{
SetMoveReachedLink(this, &ThisClass::NotifySmartLinkReached);
}
void UFlameSmartNavLinkComponent::ResumePathFollowing(AActor* Agent)
@redxdev
redxdev / SaveGameEditorUtilities.cpp
Created January 17, 2022 20:13
Editor functions that allow exporting save games to json and then importing them again. Meant to be used in an editor module that depends on Json and JsonUtilities. Use it from an editor utility widget.
#include "SaveGameEditorUtilities.h"
#include "GameFramework/SaveGame.h"
#include "DesktopPlatformModule.h"
#include "JsonObjectConverter.h"
#include "Kismet/GameplayStatics.h"
#include "Logging/MessageLog.h"
#include "Misc/FileHelper.h"
#define LOCTEXT_NAMESPACE "SaveGameEditorUtilities"
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
IAssetRegistry& AssetRegistry = AssetRegistryModule.Get();
// Optional
TArray<FString> ContentPaths;
ContentPaths.Add(TEXT("/Game/My/Folder"));
AssetRegistry.ScanPathsSynchronous(ContentPaths);
// End Optional
TSet<FName> DerivedNames;