Skip to content

Instantly share code, notes, and snippets.

View AldeRoberge's full-sized avatar
💛
.

Alexandre D. Roberge AldeRoberge

💛
.
View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Jeux - S.T.A.R.S</title>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
<style>
.game-canvas {
@AldeRoberge
AldeRoberge / Ticking.cs
Created January 6, 2021 04:21
Ticking logic for world
public void TickLoop()
{
Log.Info("Logic loop started.");
int loopTime = 0;
Stopwatch watch = Stopwatch.StartNew();
RealmTime t = new RealmTime();
using LiteNetLib.Utils;
namespace AG_LNL_Shared.Networking.World.Packets.DataObjects.Base.Utils
{
/// <summary>
/// Utils to serialize and deserialize arrays.
/// </summary>
public static class NetworkArray
{
public static T[] Deserialize<T>(NetDataReader rdr) where T : DataObject, new()
@AldeRoberge
AldeRoberge / MapReset.cs
Created September 9, 2021 00:58
Resets an Unity tilemap
using UnityEngine;
namespace Scripts
{
public class MapReset : MonoBehaviour
{
public Terrain terrain;
private float[,] originalHeights;
private void OnApplicationQuit() {
@AldeRoberge
AldeRoberge / GetTextureAverageColor.cs
Created September 9, 2021 03:09
Returns the average color of a texture.
/// <summary>
/// Get the average color of a texture. The more samplePoints, the more accurate is the average color but also takes more performance.
/// </summary>
/// <param name="sprite"></param>
/// <param name="_samplePoints"></param>
/// <returns></returns>
public static Color GetTextureAverageColor(Sprite sprite, int _samplePoints)
{
Color sampleColor = new Color();
float r = 0;
@AldeRoberge
AldeRoberge / VariousTilemapTools.cs
Created September 9, 2021 03:15
Unity Tilemap tools.
public static class Tools
{
/// <summary>
/// Get the average color of a texture. The more samplePoints, the more accurate is the average color but also takes more performance.
/// </summary>
/// <param name="sprite"></param>
/// <param name="_samplePoints"></param>
/// <returns></returns>
public static Color GetTextureAverageColor(Sprite sprite, int _samplePoints)
{
@AldeRoberge
AldeRoberge / DialogueUnit.cs
Last active November 1, 2021 17:09
Coroutine version of custom Bolt Unit
using System.Collections;
using System.Collections.Generic;
using Bolt;
using UnityEngine;
using System;
using DefaultNamespace;
using Ludiq;
[UnitTitle("Dialogue")]
[UnitShortTitle("Dialogue")]
// Uses Odin's Button and the following package to take a 360 capture
// https://assetstore.unity.com/packages/tools/camera/360-screenshot-capture-112864
public class Take360Screenshot : MonoBehaviour
{
public int imageWidth = 2048;
private bool saveAsJPEG = false;
[Button]
void TakePicture()
@AldeRoberge
AldeRoberge / QualityCommand.cs
Last active February 12, 2022 17:02
Uses InGameDebugConsole's command system to dynamically change the quality of the game during runtime.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Humanizer;
using IngameDebugConsole;
using UnityEngine;
using UnityEngine.Rendering;
using VirtualRamen.Utils;
@AldeRoberge
AldeRoberge / Vector3Ext.cs
Created January 22, 2022 19:17
Allows to clone a Vector3 using an extension method.
using UnityEngine;
namespace MV_Archetype_Utils
{
public static class Vector3Ext
{
// Clone a Vector3
public static Vector3 Clone(this Vector3 v)
{
return new Vector3(v.x, v.y, v.z);