You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
2.7 KiB
88 lines
2.7 KiB
3 years ago
|
using AX.MessageSystem;
|
||
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class StorageTankSystem : MonoBehaviour
|
||
|
{
|
||
|
public OutFireSystem outFireSystem;
|
||
|
public bool Switch;
|
||
|
|
||
|
void Start()
|
||
|
{
|
||
|
MessageDispatcher.AddListener("ReplayEvent", ReplayAgent);
|
||
|
MessageDispatcher.AddListener("ReplayFrame", ReplayFrame);
|
||
|
MessageDispatcher.AddListener("StorageTankSystemSwitch", StorageTankSystemSwitch);
|
||
|
MessageDispatcher.AddListener("ClearObject", Clear);
|
||
|
}
|
||
|
private void OnDestroy()
|
||
|
{
|
||
|
MessageDispatcher.RemoveListener("ReplayEvent", ReplayAgent);
|
||
|
MessageDispatcher.RemoveListener("ReplayFrame", ReplayFrame);
|
||
|
MessageDispatcher.RemoveListener("StorageTankSystemSwitch", StorageTankSystemSwitch);
|
||
|
MessageDispatcher.RemoveListener("ClearObject", Clear);
|
||
|
}
|
||
|
private void Clear(IMessage obj)
|
||
|
{
|
||
|
Control(false);
|
||
|
}
|
||
|
private void StorageTankSystemSwitch(IMessage obj)
|
||
|
{
|
||
|
var data = (StorageTankSystemRecordData)obj.Data;
|
||
|
if (data.OutFireSystem == outFireSystem)
|
||
|
if (data.Switch != Switch)
|
||
|
{
|
||
|
Control(data.Switch);
|
||
|
RecordEvent.AddEventData(CloneObjType.StorageTankSystem, RecordEventType.StorageTankSystem, JsonUtility.ToJson(
|
||
|
new StorageTankSystemRecordData()
|
||
|
{
|
||
|
OutFireSystem = outFireSystem,
|
||
|
Switch = Switch
|
||
|
}));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void ReplayFrame(IMessage obj)
|
||
|
{
|
||
|
var objectData = (ObjectData)obj.Data;
|
||
|
if (objectData.cloneObjType == CloneObjType.StorageTankSystem)
|
||
|
{
|
||
|
StorageTankSystemRecordData data = JsonUtility.FromJson<StorageTankSystemRecordData>(objectData.json);
|
||
|
if (data.OutFireSystem == outFireSystem)
|
||
|
Control(data.Switch);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void ReplayAgent(IMessage obj)
|
||
|
{
|
||
|
var eventData = (EventData)obj.Data;
|
||
|
if (eventData.eventType == RecordEventType.StorageTankSystem)
|
||
|
{
|
||
|
var data = JsonUtility.FromJson<StorageTankSystemRecordData>(eventData.json);
|
||
|
if (data.OutFireSystem == outFireSystem)
|
||
|
Control(data.Switch);
|
||
|
}
|
||
|
}
|
||
|
public void Control(bool flag)
|
||
|
{
|
||
|
Switch = flag;
|
||
|
foreach (Transform item in transform)
|
||
|
{
|
||
|
item.GetChild(0).gameObject.SetActive(flag);
|
||
|
}
|
||
|
}
|
||
|
public StorageTankSystemRecordData AddRecordFrameData()
|
||
|
{
|
||
|
return new StorageTankSystemRecordData()
|
||
|
{
|
||
|
OutFireSystem = outFireSystem,
|
||
|
Switch = Switch
|
||
|
};
|
||
|
}
|
||
|
}
|
||
|
public enum OutFireSystem
|
||
|
{
|
||
|
FrothGenerator,
|
||
|
WaterSpraySystem
|
||
|
}
|