Skip to content

Instantly share code, notes, and snippets.

@Zemnmez
Created March 31, 2021 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zemnmez/f1f787f3d42bd0d6ec1c7ccba47b68f8 to your computer and use it in GitHub Desktop.
Save Zemnmez/f1f787f3d42bd0d6ec1c7ccba47b68f8 to your computer and use it in GitHub Desktop.
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