Created
March 31, 2021 02:58
-
-
Save Zemnmez/f1f787f3d42bd0d6ec1c7ccba47b68f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int iBlocks=-1; | |
void Main (string argument) { | |
string Prefix; | |
bool Attention=false; | |
Prefix = "[Security]"; /*This is prefix for timer, which will be triggered*/ | |
List<IMyTerminalBlock> Blocks = new List<IMyTerminalBlock>(); | |
GridTerminalSystem.GetBlocksOfType <IMyTerminalBlock> (Blocks); | |
iBlocks=(iBlocks==-1?Blocks.Count:iBlocks); | |
if (Blocks.Count<iBlocks) Attention = true; | |
for (int i = 0; i < Blocks.Count; i++) { | |
IMyTerminalBlock block = Blocks[i]; | |
if(IsBeingHacked (block) || IsBeingAttacked (block)) | |
Attention = true; | |
} | |
GridTerminalSystem.GetBlocksOfType<IMyTimerBlock>(Blocks); | |
if (Attention) { | |
for (int a = 0; a < Blocks.Count; a++) { | |
if(Blocks[a].CustomName.Contains(Prefix)) | |
Blocks[a].ApplyAction("TriggerNow"); | |
} | |
} | |
} | |
bool IsBeingHacked (IMyTerminalBlock _block) { | |
return _block.IsBeingHacked; | |
} | |
bool IsBeingAttacked (IMyTerminalBlock _block) { | |
IMySlimBlock _slimBlock = _block.CubeGrid.GetCubeBlock(_block.Position); | |
if(_slimBlock.DamageRatio > 1 || _slimBlock.CurrentDamage > _slimBlock.MaxIntegrity * 0.8f) { | |
return true; | |
} | |
else | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment