Skip to content

Instantly share code, notes, and snippets.

View gamemachine's full-sized avatar

Chris Ochs gamemachine

View GitHub Profile
// For the new DOTS animation. Although you need to use DrawMeshInstanced yourself, Hybrid renderer does not support instanced
// props for builtin.
Shader "Custom/VertexSkinning"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
@gamemachine
gamemachine / ItemCatalog.cs
Created September 12, 2015 23:43
Scriptablable object as protobuf message container
using UnityEngine;
using io.gamemachine.messages;
namespace GameMachine {
namespace ItemManagement {
[CreateAssetMenu(menuName =@"ItemCatalog")]
public class ItemCatalog : ScriptableProtobuf<PlayerItems> {
}
}
@gamemachine
gamemachine / SpatialHash.cs
Created May 29, 2021 20:10
Spatial Hash
using Unity.Mathematics;
namespace GameCommon.Spatial
{
public struct SpatialHash
{
public const int Goffset = 10000;
public const int Max = 20480;
public int CellSize;
pub struct Broadcast<T: Clone> {
senders: ArrayQueue<Vec<crossbeam::channel::Sender<T>>>,
pending_senders: ArrayQueue<crossbeam::channel::Sender<T>>,
pending_signal: Arc<AtomicBool>
}
impl<T: Clone> Broadcast<T> {
pub fn new() -> Arc<Self> {
let senders: ArrayQueue<Vec<crossbeam::channel::Sender<T>>> = ArrayQueue::new(1);
use glam::DVec2;
use rustc_hash::{FxHashMap};
#[derive(Clone, Copy, Debug)]
pub struct SpatialHash {
cell_size: u32,
conv_factor: f32,
use std::num::Wrapping;
use bincode::{Encode, Decode};
// Time is monotonic time (OS ticks) not clock time. The difference is precision vs accuracy.
// clock time can have huge variances, be different by over 100ms even when queried within a few ms of each other. Accurate but not precise.
// OS ticks are very precise over short intervals. But can drift very quickly over longer periods.
// We consume snapshots in sequence order, possibly skipping missing sequences.
// The interpolation state time represents our progression through the server timeline. Our server timeline is based on received snapshots. We advance through this timeline using local delta time.
using Unity.Collections;
using UnityEngine;
[ExecuteAlways]
public class TempAllocTest : MonoBehaviour
{
private NativeHashMap<int, int> Map;
private void OnEnable()
using ClientServer.Shared;
using Unity.Burst;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Jobs;
using Unity.Mathematics;
using Unity.Physics;
using UnityEngine;
namespace CombatServer
@gamemachine
gamemachine / TerrainMod.cs
Last active December 12, 2021 20:19
TerrainMod
using GameCommon.Models;
using ProtoBuf;
using System;
using System.Collections.Generic;
using Unity.Mathematics;
namespace GameCommon.Features.Land
{
[Serializable]
[ProtoContract]
namespace ClientServerShared
{
public class BinaryAsset
{
public static BinaryAssetFolder AssetFolder(string path1, string path2 = null)
{
return new BinaryAssetFolder(FolderType.Asset, path1, path2);
}
public static BinaryAssetFolder PersistentFolder(string path1, string path2 = null)