/// <summary> /// Akcje wywoływane podczas kolizji z wybuchającym obiektem /// </summary> /// <param name="explosive">Materiał wybuchowy</param> public virtual void HandleCollisionWithExplosive(Explosive explosive) { if (IsDestructable && State == EMachineState.Normal) { Game.CurrentLevel.Player.Points += _pointsForKill; State = EMachineState.Dying; } }
//------------------------------------------------------------------------ // States //------------------------------------------------------------------------ private void StateIdle() { DrawText("Machine is in idle state..."); if ((m_updateSource == UpdateType.Trigger) && (m_argument == "STARTWORK")) { DrawText("Machine going to work state..."); m_machineState = EMachineState.Work; } else { RetractPiston(); DrillOff(); } }
private void StateWork() { DrawText("Machine is in work state..."); DrawText("Checking inventory..."); bool bInventoryFull = false; for (int nIndex = 0; nIndex < m_listDrill.Count; nIndex++) { IMyShipDrill drill = m_listDrill[nIndex]; var inventory = drill.GetInventory(); float freeInventoryVolume = ( float )(inventory.MaxVolume - inventory.CurrentVolume); if (freeInventoryVolume < m_minFreeInventoryVolume) { bInventoryFull = true; break; } } //--------------------------------------------------------------------- if (bInventoryFull) { DrawText("Inventory is full, waiting..."); StopPiston(); DrillOff(); } else { DrawText("Mining some material..."); DrillOn(); if (ExtendPiston()) { DrawText("All pistons extended, going to idle state..."); m_machineState = EMachineState.Idle; } } }
//------------------------------------------------------------------------ public void Main(String argument, UpdateType updateSource) { if (Init()) { //------------------------------------------------------------------ // Environment //------------------------------------------------------------------ m_textPanel.WritePublicText(""); // Clear panel m_argument = argument; m_updateSource = updateSource; m_dateTimeNow = DateTime.Now; //------------------------------------------------------------------ DrawText("//----------------------------------------------"); DrawText("// Reffi BY VX TEK AUTOMATING SYSTEMS"); DrawText("//----------------------------------------------"); DrawText(""); DrawText("Date " + m_dateTimeNow.ToShortDateString() + " " + m_dateTimeNow.ToLongTimeString()); //------------------------------------------------------------------ // State machine //------------------------------------------------------------------ switch (m_machineState) { case EMachineState.Idle: { StateIdle(); } break; case EMachineState.Work: { StateWork(); } break; case EMachineState.Error: { StateError(); } break; } } else { m_machineState = EMachineState.Error; } }
//------------------------------------------------------------------------ public Program() { Runtime.UpdateFrequency = UpdateFrequency.Update10; m_machineState = EMachineState.Idle; }