6 class SCR_MineDetectionData
14 protected ref set<RplId> m_aDetectedMines;
15 protected ref map<RplId, ref SCR_MineDetectionData> m_mMineDetection =
new map<RplId, ref SCR_MineDetectionData>();
21 PlayerController playerController =
GetGame().GetPlayerController();
22 if (!playerController)
32 void Detect(RplId
id,
bool instant =
false)
36 m_aDetectedMines.Insert(
id);
41 if (!m_mMineDetection.Contains(
id))
42 m_mMineDetection.Insert(
id,
new SCR_MineDetectionData);
46 WorldTimestamp currentTime = world.GetServerTimestamp();
47 SCR_MineDetectionData
data = m_mMineDetection.Get(
id);
48 if (
data.m_fLastTime == 0)
49 data.m_fLastTime = currentTime;
51 float sinceLastTime = currentTime.DiffMilliseconds(
data.m_fLastTime);
52 if (sinceLastTime < 1000)
53 data.m_fTimeElapsed += sinceLastTime;
55 data.m_fLastTime = currentTime;
57 if (
data.m_fTimeElapsed > 2000)
59 m_aDetectedMines.Insert(
id);
60 m_mMineDetection.Remove(
id);
68 bool IsDetected(IEntity entity)
70 RplComponent rplComponent = RplComponent.Cast(entity.FindComponent(RplComponent));
74 RplId
id = rplComponent.Id();
75 bool isDetected = m_aDetectedMines.Contains(
id);
84 override event protected void EOnInit(IEntity owner)
86 m_aDetectedMines =
new set<RplId>();
90 override event protected void OnPostInit(IEntity owner)
92 SetEventMask(
GetOwner(), EntityEvent.INIT);