private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.GetComponent <Interactable>() != null)
        {
            interactions.Add(other.gameObject.GetComponent <Interactable>());
        }

        if (other.GetComponentInParent <PistonController>() != null)
        {
            PistonController piston = other.GetComponentInParent <PistonController>();
            if (piston.activated)
            {
                Kill();
            }
        }
    }
Exemplo n.º 2
0
        public bool init()
        {
            IMyBlockGroup group = GridTerminalSystem.GetBlockGroupWithName(groupName_);

            if (group != null)
            {
                pistons_.Clear();
                drills_.Clear();

                group.GetBlocksOfType <IMyTerminalBlock>(null, (block) =>
                {
                    IMyPistonBase piston = block as IMyPistonBase;
                    if (piston != null)
                    {
                        PistonController controller = new PistonController(this, piston);
                        pistons_.Add(controller);
                        return(false);
                    }

                    IMyMotorStator stator = block as IMyMotorStator;
                    if (stator != null)
                    {
                        drillRotor_ = new RotorController(this, stator);
                        return(false);
                    }

                    IMyShipDrill drill = block as IMyShipDrill;
                    if (drill != null)
                    {
                        drills_.Add(drill);
                        return(false);
                    }

                    // production block
                    IMyProductionBlock pu = block as IMyProductionBlock;
                    if (pu != null)
                    {
                        production_ = new ProductionUnit(this, pu);
                        return(false);
                    }

                    IMyCargoContainer container = block as IMyCargoContainer;
                    if (container != null)
                    {
                        containers_.Add(container);
                        return(false);
                    }

                    return(false);
                });
            }
            else
            {
                addMessageLine("Error: Minig Group not found!");
                return(false);
            }

            // check drills
            if (drills_.Count == 0)
            {
                addMessageLine("Error: No drills found!");
                return(false);
            }

            // read config
            miningDepth_ = GetConfigMiningDepth();

            return(true);
        }