Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am stipebosnjak on github.
  • I am stajp (https://keybase.io/stajp) on keybase.
  • I have a public key ASBO6IfKL31dlIU4LO48m1G9vLTWa-NJcbeVW_jRuriy5go

To claim this, I am signing this object:

@stipebosnjak
stipebosnjak / Puzzle6.cs
Last active December 6, 2018 17:03
Advent 6.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Aoc.Puzzles
@stipebosnjak
stipebosnjak / ObjectPooler.cs
Created November 2, 2018 02:16
Unity3D - Expandable Object Pooler
using System.Collections.Generic;
using UnityEngine;
namespace Utils
{
[System.Serializable]
public class ObjectPoolItem
{
public GameObject objectToPool;
public int amountToPool;
@stipebosnjak
stipebosnjak / Hangar.cs
Created November 2, 2018 02:06
Unity 3D boxgeneration algorithm - random bottom -> top
public void GenerateCrates(int crateCount)
{
var crateSize = Crate.GetComponent<BoxCollider>().size;
var bounds = SpawnBounds.bounds;
var maxCrates = bounds.size.x * bounds.size.z * bounds.size.y;
Assert.IsFalse(crateCount > maxCrates, "Cargo hold cant hold that much crates!");
var bottomMin = bounds.min + crateSize / 2;
@stipebosnjak
stipebosnjak / PlanetOrbitEditor.cs
Created November 2, 2018 02:01
PlanetOrbitEditor - Stash
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(PlanetOrbit))]
public class PlanetOrbitEditor : Editor
{
enum setupPlanet { Setup_Orbit, Setup_Rotation, Setup_Seasons }
public override void OnInspectorGUI()
{
@stipebosnjak
stipebosnjak / UnityConstantsGenerator.cs
Created November 2, 2018 02:00
UnityConstantsGenerator - Util - Generates constants from Layers Tags Axes
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEngine;
public static class UnityConstantsGenerator
{
[MenuItem("Edit/Generate UnityConstants.cs")]
public static void Generate()
@stipebosnjak
stipebosnjak / StellarObject.cs
Created November 2, 2018 01:40
StellarObject - Stash
using System.Collections.Generic;
using UnityEngine;
namespace Assets._Scripts
{
public class StellarObject : MonoBehaviour
{
public const float TICK_TIME = 5f;
private List<Factory> Factories;
@stipebosnjak
stipebosnjak / PlanetOrbit.cs
Last active November 2, 2018 01:37
Planet orbit - Stash
using System;
using UnityEngine;
public class PlanetOrbit : MonoBehaviour
{
public static float EARTH_DISTANCE = 4000f;
public static int TimeMultiplier = 200;
public enum Orbit
{
@stipebosnjak
stipebosnjak / Program.cs
Created September 3, 2018 10:18
Flatten an array of arbitrarily nested arrays of objects into a flat array of objects
using System;
using System.Collections.Generic;
namespace FlatNestedArray
{
class Program
{
static void Main(string[] args)
{
//[ [1, 2 , [3] ] ,4 ] -> [1,2,3,4]

Keybase proof

I hereby claim:

  • I am stipebosnjak on github.
  • I am ohanzee (https://keybase.io/ohanzee) on keybase.
  • I have a public key whose fingerprint is 5043 DB75 AD3A BBED 4C55 F12D DC5E 851C BE28 3EC4

To claim this, I am signing this object: