Skip to content

Instantly share code, notes, and snippets.

View manbeardgames's full-sized avatar

Christopher Whitley manbeardgames

View GitHub Profile
@manbeardgames
manbeardgames / AboutModule.cs
Created March 4, 2021 20:14
Discord Bot Group Not Working
using System.Threading.Tasks;
using Discord.Commands;
namespace Rena.Modules
{
public class AboutModule : BaseModule
{
[Command("about")]
public async Task AboutAsync()
{
@manbeardgames
manbeardgames / monogame_extended_json_importing.md
Last active November 25, 2025 15:12
How to use the MonoGame.Extended Json Import for any custom class

MonoGame.Extended JSON Importing

How to use

Overview

MonoGame.Extended provideds a generic JSON importer as part of the MonoGame.Extended.Content.Pipeline.dll. Taking advantage of this and how it's setup for a generic type <T> can allow you to load content through the MGCB Editor that can be deserialized to any custom class type in you code.

Prerequsites

  • This gist assumes you are using MonoGame 3.8. The steps should be similar for MonoGame 3.7, however, no guarentees are made
  • The steps outlined here are going to be using Visual Studio 2019. You can also do this from Visual Studio Code, however steps will assume Visual Studio 2019.
@manbeardgames
manbeardgames / ByteArrayDictionaryKey.cs
Last active December 13, 2019 17:12
C# Using Byte Array As Dictionary Key
using System;
using System.Collections;
using System.Collections.Generic;
public class Program
{
/*
* When using collections such as Dictionary or HashSet, in which the key
* will be an array of some type, key collisions do not work properly
* if two keys have equal value sequences stored in them as you would expect.
@manbeardgames
manbeardgames / dynamic-gulp-tasks.js
Created October 17, 2019 02:12
A gulpfile that dynamically creates clean and build tasks based on a preconfigured object.
const del = require('del');
const gulp = require('gulp');
/*
* Libs
* Each property in the libs object pertains to one client-side
* library that needs to have files and/or directories from
* node_modules copied into wwwroot. Each property is an array
* of objects that contain a src and dest property. The src property
* is the source path glob that will be used for the gulp task and the dest
@manbeardgames
manbeardgames / DateTimeExtensions.cs
Created August 6, 2019 17:40
A quick example of showing how to add a Deconstruct method using Extensions for existing built-in types
/// <summary>
/// Extension class for DateTime objects that adds a Deconstruct method for DateTime
/// </summary>
public static class DateTimeExtensions
{
/// <summary>
/// Deconstructs a DateTime instance into day, month, and year ints.
/// </summary>
/// <param name="dateTime">The DateTime instance</param>
/// <param name="day">The day</param>
@manbeardgames
manbeardgames / FooBar.cs
Created August 6, 2019 17:28
A quick example showing the use of multiple Deconstruct method overloads as well as deconstruction while deconstructing.
/// <summary>
/// Simple class used to demonstrate the use of multiple Deconstruct overloads
/// and Deconstructception.
/// </summary>
public class FooBar
{
public string Foo { get; set; }
public int Bar { get; set; }
public FooBar(string foo, int bar)
@manbeardgames
manbeardgames / FooBar.cs
Last active August 6, 2019 17:20
A quick example showing the use of a Deconstruct method
/// <summary>
/// Simple class used to demonstrate the use of a Deconstruct method.
/// </summary>
public class FooBar
{
public string Foo { get; set; }
public int Bar { get; set; }
public FooBar(string foo, int bar)
{