Skip to content

Instantly share code, notes, and snippets.

@LordNed
LordNed / JustCause3TaskSaveEdit.cs
Created October 23, 2018 03:54
This is a super quick exploration into the Just Cause 3 "Task" save file. This is the state of things discovered on your map (such as Settlements, Wingsuit Challenges, etc.).
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tasks
{
class Program
// ToDo: This fixes the OoB issue when an animation doesn't have a key on the final frame,
// but this isn't totally correct as the time calculation below doesn't take the shifted
// t value into account.
int i = 1;
while (keys[i].Time < t)
{
i++;
if (i >= keys.Count)
{
i = 1;
@LordNed
LordNed / Types.md
Created November 22, 2017 08:23
Unreal Shader and Pipeline Types

LogTemp: FShaderType: FARKitCameraOverlayPS /Engine/Private/PostProcessMaterialShaders.usf LogTemp: FShaderType: FARKitCameraOverlayVS /Engine/Private/PostProcessMaterialShaders.usf LogTemp: FShaderType: TSlateElementPSLineSegmenttruetrueA /Engine/Private/SlateElementPixelShader.usf LogTemp: FShaderType: TSlateElementPSFonttruetrueA /Engine/Private/SlateElementPixelShader.usf LogTemp: FShaderType: TSlateElementPSLineSegmentfalsetrueA /Engine/Private/SlateElementPixelShader.usf LogTemp: FShaderType: TSlateElementPSFontfalsetrueA /Engine/Private/SlateElementPixelShader.usf LogTemp: FShaderType: TSlateElementPSBordertruefalseA /Engine/Private/SlateElementPixelShader.usf LogTemp: FShaderType: TSlateElementPSDefaulttruefalseA /Engine/Private/SlateElementPixelShader.usf LogTemp: FShaderType: TSlateElementPSBorderfalsefalseA /Engine/Private/SlateElementPixelShader.usf LogTemp: FShaderType: TSlateElementPSDefaultfalsefalseA /Engine/Private/SlateElementPixelShader.usf

@LordNed
LordNed / MEHUD.cpp
Created October 18, 2017 03:45
Unreal Engine 4 C++ UMG Crossover
// Fill out your copyright notice in the Description page of Project Settings.
#include "MEHUD.h"
void AMEHUD::BeginPlay()
{
ResourceDisplayWidget = CreateWidget<UUserWidget>(PlayerOwner, ResourceDisplayClass);
ResourceDisplayWidget->AddToViewport();
}

What is Garbage Collection?

Garbage Collection is a form of automatic memory management. It is a feature of many modern languages that you may have already used (C#, Python, Javascript, etc.) so you may already be using it without even knowing! In a garbage collected environment objects are automatically removed from memory after you stop using them. This means you can create a new object, use it for a while, and when you are done using it you set the variable that points to it as null and that's the end of your worries. Behind the scene the garbage collector ("GC") is keeping track of what objects are still being used. When an object is no longer being used the garbage collector automatically frees up the memory.

Lower level languages such as C and C++ do not provide a garbage collector out of the box. This means you have to manually keep track of what memory is being used and free it when you no longer wish to use it. This can be bug prone and is harder for a programmer to manage so Unreal Engine 4 has c

using UnityEditor;
using UnityEngine;
[InitializeOnLoad]
public class EditorEvents
{
// InitializeOnLoad causes this to get called when the editor starts up
static EditorEvents()
{
#include "Sandbox.h"
#include "SandboxStatics.h"
USandboxStatics::USandboxStatics(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
void USandboxStatics::GetStringHeightAndWidth(const UFont *Font, const FString & InString, int32& Height, int32& Width)
{
@LordNed
LordNed / UIBaseOverlay.cs
Created November 10, 2015 04:59
Simple UI panel manager for use in bringing a more state-like approach to the UI. Only one panel can be active at a time, but multiple overlays can be active. To use, derive a class from either UIBasePanel, or UIBaseOverlay and put them on an object in the scene. Also put an instance of UIPanelManager, preferably on the root of your UI.
using UnityEngine;
using System.Collections;
public class UIBaseOverlay : MonoBehaviour
{
public virtual IEnumerator OnOverlayActivated()
{
yield break;
}
@LordNed
LordNed / ConsoleEntry.prefab
Created October 16, 2015 19:55
HTC Vive in-vr Console Viewer. Add the ConsoleLogger script to a gameobject in your scene, and then the UIConsoleViewer to the controller or object you want the console to track. It has a somewhat complicated prefab setup so the prefabs have been attached at the end. I have no idea if you can distribute prefabs this way, so someone gets to find …
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &121470
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 224: {fileID: 22423080}
@LordNed
LordNed / ReactiveGrassSway.cs
Last active April 13, 2022 21:17
A 2D grass that sways and springs back when you walk through it or land on it. Place onto a 2D quad.
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(BoxCollider2D))]
public class ReactiveGrassSway : MonoBehaviour
{
[SerializeField] private float m_bendForceOnExit = -0.1f;
[SerializeField] private bool m_windIsEnabled;
[SerializeField] private float m_baseWindForce = 0f;
[SerializeField] private float m_windPeriod = 0f;