Esempio n. 1
0
        public override void GridInitialising(IMyCubeGrid grid)
        {
            if (!grid.IsStatic)
            {
                return;
            }

            var slimBlocks = new List <IMySlimBlock>();

            grid.GetBlocks(slimBlocks, b => b.FatBlock is IMyRemoteControl);

            foreach (var slim in slimBlocks)
            {
                var remoteControl = slim.FatBlock as IMyRemoteControl;

                if (remoteControl.CustomName.Contains("RC_FURNACE") && remoteControl.IsOwnedByFaction("MIKI"))
                {
                    grid.SetAllSubgridsInvulnerable(true);
                    var mikiScrap = new MikiScrap(grid, remoteControl,
                                                  grid.GetContainerInventoryOfName("MIKISCRAP_INPUT"),
                                                  grid.GetContainerInventoryOfName("MIKISCRAP_OUTPUT"),
                                                  grid.GetTerminalBlockMatchingName <IMyDoor>("FURNACE_DOOR"),
                                                  grid.GetTerminalBlockMatchingName <IMySoundBlock>("MIKISCRAP_SPEAKER"),
                                                  grid.GetTerminalBlocksOfType <IMyTextPanel>("FURNACE_LCD"),
                                                  grid.GetTerminalBlocksOfType <IMyReflectorLight>("FURNACE_SPOTLIGHT"),
                                                  grid.GetContainerInventoryOfName("FURNACE_OUTPUT"),
                                                  audioSystem);

                    MikiScrapSaveData saveData;
                    if (restoredMikiScrapSavaData.TryGetValue(grid.EntityId, out saveData))
                    {
                        mikiScrap.RestoreSavedData(saveData);
                    }
                    ApplyBackFixes(grid);
                    mikiScraps.Add(mikiScrap);
                    return;
                }
            }
        }