using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class AffectingForcesManager : MonoBehaviour
{
	public enum Zone { NimbleZone, OutsideZone, UninitializedZone }
	private Dictionary<int, Vector3> impulseForces = new Dictionary<int, Vector3>();
	private Dictionary<int, Func<Vector3, Vector3>> currentGravity = new Dictionary<int, Func<Vector3, Vector3>>();
	private Dictionary<int, Zone> zoneInhabitants = new Dictionary<int, Zone>();

	public Zone GetZoneOfInstance(int id)
	{
		if (!zoneInhabitants.ContainsKey(id))
		{
			return Zone.UninitializedZone;
		}

		return zoneInhabitants[id];
	}

	public void IntroduceImpulseForce(int instanceID, Vector3 force)
	{
		if (!impulseForces.ContainsKey(instanceID))
		{
			impulseForces[instanceID] = force;
		}
		else
		{
			impulseForces[instanceID] += force;
		}
	}

	public void SetZoneForInstance(int instnaceID, Zone zone)
	{
		zoneInhabitants[instnaceID] = zone;
	}

	public void SetGravityForInstance(int instanceID, Func<Vector3, Vector3> gravityFunction)
	{
		currentGravity[instanceID] = gravityFunction;
	}

	public Vector3 GetImpulseForInstance(int instanceID)
	{
		if (impulseForces.ContainsKey(instanceID))
		{
			return impulseForces[instanceID];
		}
		return new Vector3();
	}

	public Func<Vector3, Vector3> GetGravityForInstance(int instanceID)
	{
		if (currentGravity.ContainsKey(instanceID))
		{
			return currentGravity[instanceID];
		}
		return new Func<Vector3, Vector3>(position => new Vector3());
	}
}
