Skip to content

Instantly share code, notes, and snippets.

@Zemnmez
Created Mar 31, 2021
Embed
What would you like to do?
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