当前位置: 首页>>代码示例>>C#>>正文


C# ZACommons.GetBlockGroupWithName方法代码示例

本文整理汇总了C#中ZACommons.GetBlockGroupWithName方法的典型用法代码示例。如果您正苦于以下问题:C# ZACommons.GetBlockGroupWithName方法的具体用法?C# ZACommons.GetBlockGroupWithName怎么用?C# ZACommons.GetBlockGroupWithName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ZACommons的用法示例。


在下文中一共展示了ZACommons.GetBlockGroupWithName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Prime

    public void Prime(ZACommons commons, EventDriver eventDriver)
    {
        // Wake up batteries
        var batteryGroup = commons.GetBlockGroupWithName(BATTERY_GROUP + MISSILE_GROUP_SUFFIX);
        if (batteryGroup == null)
        {
            throw new Exception("Group missing: " + BATTERY_GROUP + MISSILE_GROUP_SUFFIX);
        }
        var systemsGroup = commons.GetBlockGroupWithName(SYSTEMS_GROUP + MISSILE_GROUP_SUFFIX);
        if (systemsGroup == null)
        {
            throw new Exception("Group missing: " + SYSTEMS_GROUP + MISSILE_GROUP_SUFFIX);
        }

        var batteries = ZACommons.GetBlocksOfType<IMyBatteryBlock>(batteryGroup.Blocks);
        batteries.ForEach(battery =>
                {
                    battery.SetValue<bool>("OnOff", true);
                    battery.SetValue<bool>("Recharge", false);
                    battery.SetValue<bool>("Discharge", true);
                });

        // Activate flight systems
        ZACommons.EnableBlocks(systemsGroup.Blocks, true);

        eventDriver.Schedule(1.0, Release);
    }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:27,代码来源:missilelaunch.cs

示例2: AcquireTarget

    public void AcquireTarget(ZACommons commons)
    {
        // Find the sole text panel
        var panelGroup = commons.GetBlockGroupWithName("CM Target");
        if (panelGroup == null)
        {
            throw new Exception("Missing group: CM Target");
        }

        var panels = ZACommons.GetBlocksOfType<IMyTextPanel>(panelGroup.Blocks);
        if (panels.Count == 0)
        {
            throw new Exception("Expecting at least 1 text panel");
        }
        var panel = panels[0] as IMyTextPanel; // Just use the first one
        var targetString = panel.GetPublicText();

        // Parse target info
        var parts = targetString.Split(';');
        if (parts.Length != 3)
        {
            throw new Exception("Expecting exactly 3 parts to target info");
        }
        Target = new Vector3D();
        for (int i = 0; i < 3; i++)
        {
            Target.SetDim(i, double.Parse(parts[i]));
        }
    }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:29,代码来源:missileguidance.cs

示例3: AcquireTarget

    // Acquire target from CM Target text panel. If anything's wrong,
    // return null.
    private Vector3D? AcquireTarget(ZACommons commons)
    {
        // Find the sole text panel
        var panelGroup = commons.GetBlockGroupWithName("CM Target");
        if (panelGroup == null) return null;

        var panels = ZACommons.GetBlocksOfType<IMyTextPanel>(panelGroup.Blocks);
        if (panels.Count == 0) return null;
        var panel = panels[0] as IMyTextPanel; // Just use the first one
        var targetString = panel.GetPublicText();

        // Parse target info
        var parts = targetString.Split(';');
        if (parts.Length != 3) return null;

        var target = new Vector3D();
        for (int i = 0; i < 3; i++)
        {
            double coord;
            if (!double.TryParse(parts[i], out coord)) return null;
            target.SetDim(i, coord);
        }

        return target;
    }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:27,代码来源:smartshell.cs

示例4: GetSequenceBlocks

 private List<IMyTerminalBlock> GetSequenceBlocks(ZACommons commons,
                                                  string sequence)
 {
     var groupName = SEQUENCER_PREFIX + sequence;
     var group = commons.GetBlockGroupWithName(groupName);
     if (group == null || group.Blocks.Count == 0) return null;
     return group.Blocks;
 }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:8,代码来源:sequencer.cs

示例5: Release

    public void Release(ZACommons commons, EventDriver eventDriver)
    {
        var relayRelease = commons.GetBlockGroupWithName(RELEASE_GROUP);
        if (relayRelease == null)
        {
            throw new Exception("Missing group: " + RELEASE_GROUP);
        }
        ZACommons.EnableBlocks(relayRelease.Blocks, false);

        eventDriver.Schedule(1.0, Burn);
    }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:11,代码来源:launchcontroller.cs

示例6: Prime

    public void Prime(ZACommons commons, EventDriver eventDriver)
    {
        var relayBatteries = commons.GetBlockGroupWithName(BATTERY_GROUP);
        if (relayBatteries == null)
        {
            throw new Exception("Missing group: " + BATTERY_GROUP);
        }
        var relaySystems = commons.GetBlockGroupWithName(SYSTEMS_GROUP);
        if (relaySystems == null)
        {
            throw new Exception("Missing group: " + SYSTEMS_GROUP);
        }

        // Wake up batteries
        var batteries = ZACommons.GetBlocksOfType<IMyBatteryBlock>(relayBatteries.Blocks);
        ZACommons.EnableBlocks(batteries, true);
        ZACommons.SetBatteryRecharge(batteries, false);
        // And activate flight systems
        ZACommons.EnableBlocks(relaySystems.Blocks, true);

        eventDriver.Schedule(1.0, Release);
    }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:22,代码来源:launchcontroller.cs

示例7: GetReference

 private IMyCubeBlock GetReference(ZACommons commons, string groupName)
 {
     var group = commons.GetBlockGroupWithName(groupName);
     if (group == null)
     {
         throw new Exception("Missing group: " + groupName);
     }
     var controllers = ZACommons.GetBlocksOfType<IMyShipController>(group.Blocks);
     if (controllers.Count == 0)
     {
         throw new Exception("Expecting at least 1 ship controller in " + groupName);
     }
     return controllers[0];
 }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:14,代码来源:rotorrangefinder.cs

示例8: GetRemoteControl

 private IMyRemoteControl GetRemoteControl(ZACommons commons)
 {
     var remoteGroup = commons.GetBlockGroupWithName(REMOTE_GROUP);
     if (remoteGroup == null)
     {
         throw new Exception("Missing group: " + REMOTE_GROUP);
     }
     var remotes = ZACommons.GetBlocksOfType<IMyRemoteControl>(remoteGroup.Blocks);
     if (remotes.Count != 1)
     {
         throw new Exception("Expecting exactly 1 remote control");
     }
     return (IMyRemoteControl)remotes[0];
 }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:14,代码来源:launchcontroller.cs

示例9: TargetAction

    private void TargetAction(ZACommons commons, Vector3D target)
    {
        var targetGroup = commons.GetBlockGroupWithName(RANGEFINDER_TARGET_GROUP);
        if (targetGroup != null)
        {
            var targetString = string.Format(RANGEFINDER_TARGET_FORMAT,
                                             target.GetDim(0),
                                             target.GetDim(1),
                                             target.GetDim(2));

            ZACommons.GetBlocksOfType<IMyTextPanel>(targetGroup.Blocks).ForEach(block => {
                    ((IMyTextPanel)block).WritePublicText(targetString);
                });
        }
    }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:15,代码来源:combatranger.cs

示例10: Release

    public void Release(ZACommons commons, EventDriver eventDriver)
    {
        var releaseGroup = commons.GetBlockGroupWithName(RELEASE_GROUP + MISSILE_GROUP_SUFFIX);
        if (releaseGroup == null)
        {
            throw new Exception("Group missing: " + RELEASE_GROUP + MISSILE_GROUP_SUFFIX);
        }

        // Unlock any landing gear
        ZACommons.ForEachBlockOfType<IMyLandingGear>(releaseGroup.Blocks,
                                                     gear => gear.ApplyAction("Unlock"));
        // And then turn everything off (connectors, merge blocks, etc)
        ZACommons.EnableBlocks(releaseGroup.Blocks, false);

        eventDriver.Schedule(1.0, Burn);
    }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:16,代码来源:missilelaunch.cs

示例11: Run

    public void Run(ZACommons commons, EventDriver eventDriver)
    {
        // Bleah, might be merged, so use a group
        var payloadGroup = commons.GetBlockGroupWithName(PAYLOAD_GROUP + MISSILE_GROUP_SUFFIX);
        if (payloadGroup == null) return;
        var containers = ZACommons.GetBlocksOfType<IMyCargoContainer>(payloadGroup.Blocks);
        if (containers.Count == 0) return;

        // Leisurely pace of one stack per container per frame
        bool moved = false;
        for (var e = containers.GetEnumerator(); e.MoveNext();)
        {
            var container = e.Current;
            if (SplitContainerContents(container)) moved = true;
        }

        if (moved) eventDriver.Schedule(1, Run);
    }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:18,代码来源:missilepayload.cs

示例12: Release

    public void Release(ZACommons commons, EventDriver eventDriver)
    {
        var releaseGroup = commons.GetBlockGroupWithName(RELEASE_GROUP);
        if (releaseGroup == null)
        {
            throw new Exception("Group missing: " + RELEASE_GROUP);
        }

        // Get one last reading from launcher and determine velocity
        var launcherDelta = ((ShipControlCommons)commons).ReferencePoint -
            InitialPosition;
        var deltaTime = (eventDriver.TimeSinceStart - InitialTime).TotalSeconds;
        LauncherVelocity = launcherDelta / deltaTime;

        // Turn release group off
        ZACommons.EnableBlocks(releaseGroup.Blocks, false);

        eventDriver.Schedule(1.0, Demass);
    }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:19,代码来源:dumbshell.cs

示例13: SetLauncherReference

 public IMyTerminalBlock SetLauncherReference(ZACommons commons, string groupName,
                                              Base6Directions.Direction direction = Base6Directions.Direction.Forward,
                                              Func<IMyTerminalBlock, bool> condition = null)
 {
     var group = commons.GetBlockGroupWithName(groupName);
     if (group != null)
     {
         for (var e = group.Blocks.GetEnumerator(); e.MoveNext();)
         {
             var block = e.Current;
             if (condition == null || condition(block))
             {
                 // Use first block that matches condition
                 SetLauncherReference(block, direction);
                 return block;
             }
         }
     }
     throw new Exception("Cannot set launcher reference from group: " + groupName);
 }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:20,代码来源:losguidance.cs

示例14: Run

    public void Run(ZACommons commons, EventDriver eventDriver)
    {
        if (!Triggered)
        {
            var turretGroup = commons.GetBlockGroupWithName(TURRET_DETECTOR_GROUP);
            if (turretGroup != null)
            {
                var turrets = ZACommons.GetBlocksOfType<IMyLargeTurretBase>(turretGroup.Blocks,
                                                                            block => block.CubeGrid == commons.Me.CubeGrid);
                for (var e = turrets.GetEnumerator(); e.MoveNext();)
                {
                    var turret = e.Current as IMyLargeTurretBase;
                    TurretInfo info;
                    if (turretInfos.TryGetValue(turret, out info))
                    {
                        if (turret.Elevation != info.LastElevation ||
                            turret.Azimuth != info.LastAzimuth)
                        {
                            // Trigger
                            ZACommons.StartTimerBlockWithName(commons.Blocks,
                                                              TURRET_DETECTOR_TRIGGER_TIMER_BLOCK_NAME);
                            // And don't trigger again until reset
                            Triggered = true;
                            break;
                        }
                    }
                    else
                    {
                        // Unknown turret
                        // FIXME shouldn't hold references...
                        turretInfos.Add(turret, new TurretInfo(turret));
                    }
                }
            }
        }

        eventDriver.Schedule(RunDelay, Run);
    }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:38,代码来源:turretdetector.cs

示例15: LaunchDecoy

 private void LaunchDecoy(ZACommons commons, EventDriver eventDriver,
                          string suffix)
 {
     var group = commons.GetBlockGroupWithName("SS Decoy Set" + suffix);
     // Activate decoys
     ZACommons.ForEachBlockOfType<IMyTerminalBlock>(group.Blocks,
                                                    block =>
             {
                 if (block.DefinitionDisplayNameText == "Decoy")
                 {
                     block.SetValue<bool>("OnOff", true);
                 }
             });
     eventDriver.Schedule(DecoyReleaseDelay, (c, e) => {
             var g = c.GetBlockGroupWithName("SS Decoy Set" + suffix);
             // Deactivate merge block
             ZACommons.ForEachBlockOfType<IMyShipMergeBlock>(g.Blocks,
                                                             merge =>
                     {
                         merge.SetValue<bool>("OnOff", false);
                     });
         });
 }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:23,代码来源:smartshell.cs


注:本文中的ZACommons.GetBlockGroupWithName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。