using AX.MessageSystem;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
///
/// 接受供水的设备,如水炮、暴风雪炮
///
public class WaterReceiver : MonoBehaviour
{
///
/// 是否连接水源
///
public bool hasSupplier;
private Vector3 connectPos;
public Transform connectPoint;
public List waterlinelist = new List();
private void Start()
{
connectPoint = transform.Find("ConnectPoint");
if (connectPoint != null)
{
connectPos = connectPoint.position;
}
else
{
connectPos = transform.position;
}
MessageDispatcher.AddListener("WaterSourceChanged", WaterLineChanged);
}
private void OnDestroy()
{
MessageDispatcher.RemoveListener("WaterSourceChanged", WaterLineChanged);
}
private void WaterLineChanged(IMessage obj)
{
var data = (WaterConnectionData)obj.Data;
if (data.receiverID == GetComponent().gameObjID)
{
if(data.connected == false && GetComponent())
{
GetComponent().enabled = true;
}
}
}
public Vector3 ConnectPos
{
get
{
if (connectPoint != null)
{
connectPos = connectPoint.position;
}
else
{
connectPos = transform.position;
}
return connectPos;
}
}
}