using HutongGames.PlayMaker;
using System;
using System.Collections.Generic;
using UnityEngine;
namespace Floodlight
{
public class LightbulbBoxBehaviour : MonoBehaviour
{
public static readonly Vector3 TeimoBuyPos = new Vector3(-1551.1f, 4.8f, 1182.8f);
public List<GameObject> ShopList;
private bool _bought;
private bool _buying;
private FsmBool _guiBuy;
private FsmString _guiText;
public static float Price
{
get
{
return 300f;
}
}
public void Activate()
{
((Component) this).get_transform().set_parent((Transform) null);
((Object) ((Component) this).get_gameObject()).set_name("lightbulb(Clone)");
((Component) this).get_gameObject().set_layer(LayerMask.NameToLayer("Parts"));
((Component) this).get_gameObject().set_tag("PART");
((Rigidbody) ((Component) this).get_gameObject().GetComponent<Rigidbody>()).set_isKinematic(false);
}
public void SetBought()
{
this._bought = true;
}
private void _buy()
{
M0 component = GameObject.Find("STORE/StoreCashRegister/Register").GetComponent<PlayMakerFSM>();
FsmFloat fsmFloat = ((PlayMakerFSM) component).get_FsmVariables().GetFsmFloat("PriceTotal");
fsmFloat.set_Value(fsmFloat.get_Value() + LightbulbBoxBehaviour.Price);
((PlayMakerFSM) component).SendEvent("PURCHASE");
this._buying = true;
((Component) this).get_gameObject().SetActive(false);
}
private void _pay()
{
if (!this._buying)
return;
((Component) this).get_gameObject().SetActive(true);
((Component) this).get_transform().set_position(LightbulbBoxBehaviour.TeimoBuyPos);
this.Activate();
this.ShopList.Remove(((Component) this).get_gameObject());
this._buying = false;
this._bought = true;
}
private void Awake()
{
Material material = new Material(Shader.Find("Standard"));
material.set_mainTexture(((Renderer) ((Component) this).get_gameObject().GetComponent<Renderer>()).get_material().get_mainTexture());
((Renderer) ((Component) this).get_gameObject().GetComponent<Renderer>()).set_material(material);
this._guiBuy = PlayMakerGlobals.get_Instance().get_Variables().FindFsmBool("GUIbuy");
this._guiText = PlayMakerGlobals.get_Instance().get_Variables().FindFsmString("GUIinteraction");
GameHook.InjectStateHook(GameObject.Find("STORE/StoreCashRegister/Register"), "Purchase", (Action) (() => this._pay()));
}
private void Update()
{
bool keyDown = Input.GetKeyDown((KeyCode) 323);
RaycastHit raycastHit;
Physics.Raycast(Camera.get_main().ScreenPointToRay(Input.get_mousePosition()), ref raycastHit, 1f);
if (!Object.op_Equality((Object) ((Component) ((RaycastHit) ref raycastHit).get_collider()).get_gameObject(), (Object) ((Component) this).get_gameObject()) || this._bought)
return;
this._guiBuy.set_Value(true);
this._guiText.set_Value(string.Format("lightbulb ({0} mk)", (object) LightbulbBoxBehaviour.Price));
if (!keyDown)
return;
this._buy();
}
public LightbulbBoxBehaviour()
{
base.\u002Ector();
}
}
}