Пример #1
0
    /// <summary>
    /// Remove any installed module from the provided Hardpoint, with the provided
    /// removal reason (Uninstalled or Destroyed).
    ///
    /// If there was a module installed,
    /// we try to return the prefab that the module was instantiated from.
    /// </summary>
    public GameObject RemoveModuleFrom(Hardpoint hardpoint,
                                       ActorModule.Change reason = ActorModule.Change.Uninstalled)
    {
        GameObject   prefab;
        ModuleResult result = hardpoints.RemoveModuleFrom(hardpoint, reason, out prefab);

        if (result == ModuleResult.InvalidHardpoint)
        {
            Debug.LogError("Trying to remove module from invalid hardpoint!");
        }
        return(prefab);
    }
    /// <summary>
    /// Try and remove the currently installed module from the provided Hardpoint.
    /// </summary>
    /// <param name="reason">The reason why the module was being removed.</param>
    /// <param name="prefab">Holds the prefab that was used to create the module, or null.</param>
    public ModuleResult RemoveModuleFrom(Hardpoint hardpoint, ActorModule.Change reason, out GameObject prefab)
    {
        ModuleResult result = DisableModuleIn(hardpoint);

        if (result != ModuleResult.Success && result != ModuleResult.AlreadyDisabled)
        {
            prefab = null;
            return(result);
        }

        ActorModule module = hardpoint.Module;

        Clear(hardpoint);

        if (onChange != null)
        {
            onChange(reason, module);
        }

        prefab = module.DestroyModule();
        return(ModuleResult.Success);
    }