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


C# EventDriver.Schedule方法代码示例

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


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

示例1: HandleCommand

 public void HandleCommand(ZACommons commons, EventDriver eventDriver,
                           string argument)
 {
     var command = argument.Trim().ToLower();
     switch (command)
     {
         case "reactors":
             {
                 // Turn on all reactors
                 GetAllReactors(commons).ForEach(block => block.SetValue<bool>("OnOff", true));
                 eventDriver.Schedule(1.0, (c,ed) => {
                         // Turn off all local batteries
                         GetBatteries(c).ForEach(block => block.SetValue<bool>("OnOff", false));
                     });
                 break;
             }
         case "batteries":
             {
                 // Turn on all local batteries
                 // and disable recharge/discharge
                 GetBatteries(commons).ForEach(block =>
                         {
                             block.SetValue<bool>("OnOff", true);
                             block.SetValue<bool>("Recharge", false);
                             block.SetValue<bool>("Discharge", false);
                         });
                 eventDriver.Schedule(1.0, (c,ed) => {
                         // Turn off all reactors
                         GetAllReactors(c).ForEach(block => block.SetValue<bool>("OnOff", false));
                     });
                 break;
             }
     }
 }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:34,代码来源:reactormanager.cs

示例2: Init

    public void Init(ZACommons commons, EventDriver eventDriver)
    {
        IsControlled = null;

        ResetAbandonment(eventDriver);

        IsDocked = false;
        eventDriver.Schedule(0.0, Fast);
        eventDriver.Schedule(0.0, Slow);
    }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:10,代码来源:safemode.cs

示例3: Run

    public void Run(ZACommons commons, EventDriver eventDriver)
    {
        if (!AutopilotEngaged)
        {
            Reset(commons);
            return;
        }

        var shipControl = (ShipControlCommons)commons;

        var targetVector = AutopilotTarget - shipControl.ReferencePoint;
        var distance = targetVector.Normalize();

        double yawError, pitchError;
        var gyroControl = seeker.Seek(shipControl, targetVector,
                                      out yawError, out pitchError);

        var targetSpeed = Math.Min(distance / AUTOPILOT_TTT_BUFFER,
                                   AutopilotSpeed);
        targetSpeed = Math.Max(targetSpeed, AUTOPILOT_MIN_SPEED); // Avoid Zeno's paradox...

        cruiser.Cruise(shipControl, eventDriver, targetSpeed);

        if (distance < AUTOPILOT_DISENGAGE_DISTANCE)
        {
            Reset(commons);
            if (DoneAction != null) DoneAction(commons, eventDriver);
        }
        else
        {
            eventDriver.Schedule(FramesPerRun, Run);
        }
    }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:33,代码来源:yawpitchauto.cs

示例4: Run

    public void Run(ZACommons commons, EventDriver eventDriver)
    {
        var groups = commons.GetBlockGroupsWithPrefix(DOOR_AUTO_CLOSER_PREFIX);
        if (groups.Count > 0)
        {
            groups.ForEach(group => {
                    // Determine open duration
                    var parts = group.Name.Split(new char[] { DURATION_DELIMITER }, 2);
                    var duration = DEFAULT_DOOR_OPEN_DURATION;
                    if (parts.Length == 2)
                    {
                        if (!double.TryParse(parts[1], out duration))
                        {
                            duration = DEFAULT_DOOR_OPEN_DURATION;
                        }
                    }

                    var doors = ZACommons.GetBlocksOfType<IMyDoor>(group.Blocks,
                                                                   block => block.IsFunctional);
                    CloseDoors(commons, eventDriver, doors, duration);
                });
        }
        else
        {
            // Default behavior (all doors except vanilla Airtight Hangar Doors and tagged doors)
            var doors = ZACommons
                .GetBlocksOfType<IMyDoor>(commons.Blocks,
                                          block => block.IsFunctional &&
                                          block.CustomName.IndexOf("[Excluded]", ZACommons.IGNORE_CASE) < 0 &&
                                          block.DefinitionDisplayNameText != "Airtight Hangar Door");
            CloseDoors(commons, eventDriver, doors, DEFAULT_DOOR_OPEN_DURATION);
        }
        eventDriver.Schedule(RunDelay, Run);
    }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:34,代码来源:doorautocloser.cs

示例5: Run

    public void Run(ZACommons commons, EventDriver eventDriver)
    {
        var groups = commons.GetBlockGroupsWithPrefix(SIMPLE_AIRLOCK_GROUP_PREFIX);
        for (var e = groups.GetEnumerator(); e.MoveNext();)
        {
            var doors = ZACommons.GetBlocksOfType<IMyDoor>(e.Current.Blocks,
                                                           door => door.CubeGrid == commons.Me.CubeGrid &&
                                                           door.IsFunctional);

            var opened = IsAnyDoorOpen(doors);
            for (var f = doors.GetEnumerator(); f.MoveNext();)
            {
                var door = (IMyDoor)f.Current;
                if (door.OpenRatio == 0.0f && opened)
                {
                    // This door is not open and some other door in the group is, lock it down
                    if (door.Enabled) door.SetValue<bool>("OnOff", false);
                }
                else
                {
                    if (!door.Enabled) door.SetValue<bool>("OnOff", true);
                }
            }
        }

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

示例6: Run

    public void Run(ZACommons commons, EventDriver eventDriver)
    {
        if (Indexes.Count == 0) return;

        var newIndexes = new Dictionary<string, int>();

        for (var e = Indexes.GetEnumerator(); e.MoveNext();)
        {
            var kv = e.Current;
            var sequence = kv.Key;
            var index = kv.Value;

            var blocks = GetSequenceBlocks(commons, sequence);
            if (blocks == null) continue;
            ZACommons.EnableBlocks(blocks, false);

            // TODO sort?
            index++;
            index %= blocks.Count;

            blocks[index].SetValue<bool>("OnOff", true);

            newIndexes.Add(sequence, index);
        }

        Indexes = newIndexes;

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

示例7: Demass

    public void Demass(ZACommons commons, EventDriver eventDriver)
    {
        var shipControl = (ShipControlCommons)commons;

        var deltaTime = (eventDriver.TimeSinceStart - InitialTime).TotalSeconds;
        var launcherDelta = LauncherVelocity * deltaTime;
        var distanceFromLauncher = (shipControl.ReferencePoint -
                                    (InitialPosition + launcherDelta)).LengthSquared();

        if (distanceFromLauncher < DemassDistance * DemassDistance)
        {
            // Not yet
            eventDriver.Schedule(TicksPerRun, Demass);
            return;
        }

        // Disable mass
        var group = commons.GetBlockGroupWithName(MASS_GROUP);
        if (group != null)  ZACommons.EnableBlocks(group.Blocks, false);

        // Start roll
        shipControl.GyroControl.EnableOverride(true);
        shipControl.GyroControl.SetAxisVelocity(GyroControl.Roll,
                                                MathHelper.Pi);

        // All done
        if (PostLaunch != null) PostLaunch(commons, eventDriver);
    }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:28,代码来源:dumbshell.cs

示例8: HandleCommand

    public void HandleCommand(ZACommons commons, EventDriver eventDriver,
                              string argument)
    {
        argument = argument.Trim().ToLower();
        var parts = argument.Split(new char[] { ' ' }, 3);
        if (parts.Length < 3 || parts[0] != "sequence") return;
        var command = parts[1];
        var sequence = parts[2];

        if (command == "start")
        {
            var blocks = GetSequenceBlocks(commons, sequence);
            if (blocks == null) return;

            ZACommons.EnableBlocks(blocks, false);
            blocks[0].SetValue<bool>("OnOff", true);

            var first = Indexes.Count == 0;
            if (!Indexes.ContainsKey(sequence)) Indexes.Add(sequence, 0);
            if (first)
            {
                eventDriver.Schedule(SEQUENCER_FRAMES_PER_RUN, Run);
            }
        }
        else if (command == "stop")
        {
            var blocks = GetSequenceBlocks(commons, sequence);
            if (blocks != null) ZACommons.EnableBlocks(blocks, true);

            Indexes.Remove(sequence);
        }
    }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:32,代码来源:sequencer.cs

示例9: Start

 private void Start(ZACommons commons, EventDriver eventDriver, bool auto)
 {
     Show(commons);
     if (Mode == IDLE) eventDriver.Schedule(RunDelay, Run);
     Mode = auto ? AUTO : ACTIVE;
     SaveMode(commons);
 }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:7,代码来源:damagecontrol.cs

示例10: 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

示例11: Run

    public void Run(ZACommons commons, EventDriver eventDriver)
    {
        var vents = ZACommons.GetBlocksOfType<IMyAirVent>(commons.AllBlocks,
                                                          vent => vent.IsFunctional &&
                                                          vent.CustomName.IndexOf("[Excluded]", ZACommons.IGNORE_CASE) < 0 &&
                                                          vent.CustomName.IndexOf("[Intake]", ZACommons.IGNORE_CASE) < 0);

        vents.ForEach(block =>
                {
                    var vent = (IMyAirVent)block;
                    var level = vent.GetOxygenLevel();
                    if (vent.IsDepressurizing && !vent.Enabled && level > 0.0f)
                    {
                        vent.SetValue<bool>("OnOff", true);
                    }
                    else if (!vent.IsDepressurizing)
                    {
                        if (level < MIN_AIR_VENT_PRESSURE && !vent.Enabled)
                        {
                            vent.SetValue<bool>("OnOff", true);
                        }
                        else if (level > MAX_AIR_VENT_PRESSURE && vent.Enabled)
                        {
                            vent.SetValue<bool>("OnOff", false);
                        }
                    }
                });

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

示例12: Init

    public void Init(ZACommons commons, EventDriver eventDriver,
                     double maxError,
                     Base6Directions.Direction thrusterDirection = Base6Directions.Direction.Forward)
    {
        MaxError = maxError;
        ThrusterDirection = thrusterDirection;
        
        var shipControl = (ShipControlCommons)commons;

        var forward = shipControl.ShipBlockOrientation.TransformDirection(ThrusterDirection);
        // Don't really care about "up," just pick a perpindicular direction
        seeker.Init(shipControl,
                    shipUp: Base6Directions.GetPerpendicular(forward),
                    shipForward: forward);

        var gyroControl = shipControl.GyroControl;
        gyroControl.Reset();
        gyroControl.EnableOverride(true);

        LastPosition = shipControl.ReferencePoint;

        Enabled = true;

        shipControl.ThrustControl.Enable(false);

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

示例13: Run

    public void Run(ZACommons commons, EventDriver eventDriver)
    {
        var myConnectors = ZACommons.GetBlocksOfType<IMyShipConnector>(commons.Blocks,
                                                                       block => block.DefinitionDisplayNameText == "Connector" &&
                                                                       ((IMyShipConnector)block).IsLocked &&
                                                                       ((IMyShipConnector)block).IsConnected);
        var currentConnectorCount = myConnectors.Count;
        if (currentConnectorCount > ConnectorCount)
        {
            // New connection, force re-evaluation
            State = null;
        }
        ConnectorCount = currentConnectorCount;

        var myReactors = ZACommons.GetBlocksOfType<IMyReactor>(commons.Blocks,
                                                               block => block.IsWorking);
        var currentState = myReactors.Count > 0;

        // Only on state change
        if (State == null || currentState != (bool)State)
        {
            State = currentState;

            if (!(bool)State)
            {
                // Disable reactors on all connected grids
                var reactors = ZACommons.GetBlocksOfType<IMyReactor>(commons.AllBlocks,
                                                                     block => block.CubeGrid != commons.Me.CubeGrid);
                reactors.ForEach(block => block.SetValue<bool>("OnOff", false));
            }
        }

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

示例14: Run

    public void Run(ZACommons commons, EventDriver eventDriver)
    {
        if (IsDocked) return;

        RunInternal(commons, eventDriver);

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

示例15: Init

 public void Init(ZACommons commons, EventDriver eventDriver)
 {
     Active = true;
     SaveActive(commons);
     MaxPowers.Clear();
     TotalPower = 0.0f;
     eventDriver.Schedule(0.0, Run);
 }
开发者ID:ZerothAngel,项目名称:SEScripts,代码行数:8,代码来源:solarrotorcontroller.cs


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