This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Entitas; | |
using UnityEngine; | |
public class TimerSystem : IExecuteSystem, ICleanupSystem | |
{ | |
readonly IGroup<GameEntity> _timers; | |
readonly IGroup<GameEntity> _timerCompletes; | |
readonly GameContext _context; | |
public TimerSystem(Contexts contexts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Start() | |
{ | |
// ... | |
_contexts.game.OnEntityCreated += AddId; | |
_contexts.input.OnEntityCreated += AddId; | |
// ... | |
} | |
private void AddId(IContext context, IEntity entity) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Modified from Quill18's version | |
using UnityEngine; | |
using System.Collections.Generic; | |
public static class SimplePool | |
{ | |
// You can avoid resizing of the Stack's internal array by | |
// setting this to a number equal to or greater to what you | |
// expect most of your pool sizes to be. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class Graph | |
{ | |
public GraphNode[] Nodes; | |
public abstract void GenerateGraph(); | |
public abstract float HeuristicCostEstimate(GraphNode current, GraphNode target); | |
public bool Dirty; | |
} | |
// interface for graph nodes | |
public abstract class GraphNode : IHeapItem<GraphNode> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
public class Task | |
{ | |
public readonly string taskName; | |
public readonly float taskDuration; | |
public readonly float repeatDuration; | |
public readonly int minWorkers = 1; | |
public readonly int maxWorkers = 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using Entitas; | |
public class AssignGameViewSystem : ReactiveSystem<GameEntity> | |
{ | |
private readonly Contexts _contexts; | |
public AssignGameViewSystem(Contexts contexts) : base(contexts.game) | |
{ | |
_contexts = contexts; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ContextHelpers | |
{ | |
private static readonly Dictionary<string, IContext> _contextsLookup = new Dictionary<string, IContext>(); | |
public static IContext GetContextByName(this Contexts contexts, string name) | |
{ | |
if (_contextsLookup.Count == 0) SetContextsDictionary(contexts); | |
return _contextsLookup[name]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class FSMState<T_Data, T_Id> | |
{ | |
public abstract T_Id id { get; protected set; } | |
public virtual void OnEnter(T_Data data) { } | |
public virtual void OnUpdate(T_Data data) { } | |
public virtual void OnExit(T_Data data) { } | |
public delegate void TransitionEventHandler(T_Id id); | |
public event TransitionEventHandler TransitionEvent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using UnityEngine.SceneManagement; | |
public static class SceneHelpers | |
{ | |
public static string[] GetValidSceneNames() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Entitas; | |
using System.Collections.Generic; | |
public abstract class CollisionSystem : ReactiveSystem<InputEntity> | |
{ | |
protected Contexts _contexts; | |
public CollisionSystem(Contexts contexts) : base(contexts.input) | |
{ | |
_contexts = contexts; |
OlderNewer