Skip to content

Instantly share code, notes, and snippets.

@tenpn
Created November 22, 2017 10:33
Show Gist options
  • Save tenpn/46dd4edc1acba410f046f2a6a0878cbc to your computer and use it in GitHub Desktop.
Save tenpn/46dd4edc1acba410f046f2a6a0878cbc to your computer and use it in GitHub Desktop.
fixed CustomSingleContextFactory
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TenPN.DecisionFlex;
using System;
public class CustomSingleContextFactory : SingleContextFactory
{
public override IContext SingleContext(Logging loggingSetting)
{
ContextDictionary masterContext = new ContextDictionary();
float distToPlayer = Player.DistanceTo(transform.root.position);
masterContext.SetContext("PlayerPosition", Player.position);
masterContext.SetContext("DistanceToPlayer", distToPlayer);
if(loggingSetting == Logging.Enabled)
{
//Debug.Log("My distance to the player: " + distToPlayer);
}
return masterContext;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment