Entities / Netcode for Entities
Introduction
Getting Started
using StatusEffects.Entities;
using Unity.Entities;
using System;
using UnityEngine;
// Note that there is a UnityEngine.Hash128
// which we do not want to use here.
using Hash128 = Unity.Entities.Hash128;
public class ExamplePlayerAuthoring : MonoBehaviour, IEntityStatus
{
public Hash128 ComponentId => m_ComponentId;
private Hash128 m_ComponentId = new Hash128(Guid.NewGuid().ToString("N"));
public void OnBake(Entity entity, StatusManagerBaker baker)
{
baker.DependsOn(this);
baker.AppendToBuffer(entity, new StatusFloats(ComponentId, StatusMaxHealth));
baker.AppendToBuffer(entity, new StatusFloats(ComponentId, StatusSpeed));
baker.AppendToBuffer(entity, new StatusInts(ComponentId, StatusCoinMultiplier));
baker.AppendToBuffer(entity, new StatusBools(ComponentId, StatusStunned));
}
// Example variables
public StatusFloat StatusMaxHealth = new StatusFloat(100, true);
public StatusFloat StatusSpeed = new StatusFloat(5, true);
public StatusInt StatusCoinMultiplier = new StatusInt(1, true);
public StatusBool StatusStunned = new StatusBool(false);
}Additional Info
Last updated